/* Chartwell Pies font for donut chart */
@font-face {
  font-family: 'Chartwell Pies';
  src: url('/fonts/chartwell/Chartwell-Pies.woff2') format('woff2');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

* {
  box-sizing: border-box;
}

:root {
  /* DGW brand tokens mapped to Web Awesome */
  --wa-color-primary-600: #FA008A;
  --wa-color-primary-500: #D60076;
  --wa-color-success-600: #00E5E5;
  --wa-color-warning-600: #FFDD00;
  --wa-color-danger-600: #FF7043;
  --wa-font-sans: system-ui, sans-serif;

  /* Fuel type colours (from DGW prototypes) */
  --fuel-wind: #9bdb5e;
  --fuel-solar: #eedc30;
  --fuel-nuclear: #189aca;
  --fuel-gas: #ec994d;
  --fuel-coal: #000000;
  --fuel-biomass: #8b4513;
  --fuel-hydro: #0066cc;
  --fuel-imports: #555555;
  --fuel-other: #cccccc;

  /* App tokens */
  --color-text: #f1f5f9;
  --color-text-muted: #94a3b8;
  --color-primary: #3b82f6;
  --color-success: #22c55e;
  --color-warning: #f59e0b;
  --color-danger: #ef4444;
  --radius: 8px;
}

body {
  font-family: system-ui, -apple-system, sans-serif;
  margin: 0;
  padding: 0;
  min-height: 100vh;
  line-height: 1.5;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1rem;
}

/* Tab badges */
wa-tab wa-badge {
  margin-inline-start: var(--wa-space-xs);
}

/* Fuel bars */
.fuel-bars {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.fuel-row {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.fuel-row wa-flank {
  font-size: 0.875rem;
}

.fuel-label {
  text-transform: capitalize;
  font-weight: 500;
}

.fuel-perc {
  color: var(--color-text-muted);
}

/* Grid-aware status bar */
.grid-aware-bar {
  margin-bottom: 1rem;
}

/* Intensity badge variants */
.intensity-low { --wa-badge-background: var(--color-success); }
.intensity-moderate { --wa-badge-background: var(--color-warning); color: #000; }
.intensity-high { --wa-badge-background: var(--color-danger); }
.intensity-very-high { --wa-badge-background: #dc2626; }

/* DGW custom elements */
dgw-gaw-info-bar {
  display: block;
  margin-bottom: 1rem;
}

.carbon-intensity-bar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
}

.carbon-intensity-bar[data-level="low"] {
  background: rgba(34, 197, 94, 0.15);
  border: 1px solid rgba(34, 197, 94, 0.3);
}

.carbon-intensity-bar[data-level="moderate"] {
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.carbon-intensity-bar[data-level="high"] {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.carbon-intensity-content {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.carbon-intensity-level {
  text-transform: capitalize;
}

/* Power mix donut (DGW Chartwell) */
dgw-gaw-power-mix {
  display: block;
  text-align: center;
}

.power-mix-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.dgwltd-chart {
  font-family: 'Chartwell Pies', sans-serif;
  font-size: 8rem;
  line-height: 1;
  letter-spacing: 0;
  -webkit-font-feature-settings: "dlig";
  font-feature-settings: "dlig";
}

.chart-ring {
  color: var(--wa-card-background-color, var(--wa-color-surface-base, #1e293b));
}

.renewable-percentage {
  font-weight: 600;
  color: var(--fuel-wind);
}

.mix-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  justify-content: center;
  margin-top: 0.5rem;
}

.mix-legend-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  color: var(--color-text-muted);
  text-transform: capitalize;
}

.mix-legend-swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

/* Grid-aware CSS layers */
[data-grid-aware="moderate"] * {
  animation-duration: 0s !important;
}

[data-grid-aware="high"] .decorative,
[data-grid-aware="high"] wa-skeleton[effect] {
  display: none;
}

[data-grid-aware="very-high"] * {
  animation: none !important;
  transition: none !important;
}

[data-grid-aware="very-high"] img:not([data-essential]),
[data-grid-aware="very-high"] .decorative {
  display: none;
}

/* Feed list */
.feed-list {
  display: flex;
  flex-direction: column;
}

.feed-item {
  border-bottom: 1px solid var(--wa-color-surface-border, rgba(255, 255, 255, 0.08));
}

.feed-item:last-child {
  border-bottom: none;
}

.feed-item__link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0.25rem;
  text-decoration: none;
  color: inherit;
  transition: background 0.15s;
}

.feed-item__link:hover {
  background: rgba(255, 255, 255, 0.04);
}

.feed-item__favicon {
  flex-shrink: 0;
  border-radius: 2px;
}

.feed-item__source {
  flex-shrink: 0;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-text-muted);
  min-width: 6rem;
}

.feed-item__green {
  flex-shrink: 0;
  color: var(--wa-color-success-600);
  font-size: 0.75rem;
}

.feed-item__title {
  flex: 1;
  font-size: 0.875rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.feed-item__date {
  flex-shrink: 0;
  font-size: 0.75rem;
  color: var(--color-text-muted);
  min-width: 4rem;
  text-align: right;
}

@media (max-width: 640px) {
  .feed-item__link {
    flex-wrap: wrap;
  }

  .feed-item__source {
    min-width: auto;
  }

  .feed-item__date {
    min-width: auto;
    text-align: left;
  }

  .feed-item__title {
    flex-basis: 100%;
    white-space: normal;
  }
}

/* Ramp chart */
.ramp-chart {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.ramp-chart__header {
  display: grid;
  grid-template-columns: 8rem repeat(6, 1fr);
  gap: 0.25rem;
  text-align: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-text-muted);
}

.ramp-chart__row {
  display: grid;
  grid-template-columns: 8rem repeat(6, 1fr);
  gap: 0.25rem;
  align-items: end;
  height: 6rem;
}

.ramp-chart__label {
  font-size: 0.75rem;
  font-weight: 500;
  align-self: center;
}

.ramp-chart__cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
}

.ramp-chart__bar {
  width: 70%;
  min-height: 2px;
  border-radius: 2px 2px 0 0;
  transition: height 0.3s;
}

.ramp-chart__val {
  font-size: 0.65rem;
  color: var(--color-text-muted);
  margin-top: 0.15rem;
}

@media (max-width: 640px) {
  .ramp-chart__header,
  .ramp-chart__row {
    grid-template-columns: 5rem repeat(6, 1fr);
  }

  .ramp-chart__label {
    font-size: 0.65rem;
  }
}

/* Hidden utility */
.hidden {
  display: none !important;
}

/* Footer */
footer {
  text-align: center;
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--wa-color-surface-border);
  color: var(--color-text-muted);
  font-size: 0.875rem;
}

footer a {
  color: var(--color-primary);
  text-decoration: none;
}

footer a:hover {
  text-decoration: underline;
}

.build-info {
  font-size: 0.75rem;
  margin-top: 0.5rem;
}

/* Responsive */
@media (max-width: 640px) {
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
