/* ============================================================
   RES Explorer – Dark Mode CSS
   All colours driven by CSS custom properties.
   No !important except where overriding D3 axis output.
   ============================================================ */

/* ── Fonts ──────────────────────────────────────────────── */
@font-face {
  font-family: 'AkkuratLL-Light';
  src: url('fonts/AkkuratLL-Light.woff2') format('woff2');
  font-style: normal;
}
@font-face {
  font-family: 'AkkuratLL-Regular';
  src: url('fonts/AkkuratLL-Regular.woff2') format('woff2');
  font-style: normal;
}
@font-face {
  font-family: 'AkkuratLL-Bold';
  src: url('fonts/AkkuratLL-Bold.woff2') format('woff2');
  font-style: normal;
}

/* ── Variables ──────────────────────────────────────────── */
:root {
  --bg:             #0a0a0a;
  --text:           #ffffff;
  --text-muted:     rgba(255, 255, 255, 0.55);
  --color-onshore:  #4997ab;
  --color-offshore: #92c0cc;
  --color-solar:    #f1a649;
  --arrow-color:    #0a0a0a;
  --range-line:     #999999;
  --grid-line:      #474747;
  --panel-bg:       #333333;
  --border:         rgba(255, 255, 255, 0.12);
}

/* ── Reset / Base ───────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
}

html {
  height: 100%;
  overflow-y: auto;
  margin: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: auto;
}

body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "AkkuratLL-Light";
  overflow-x: hidden;
}

/* ── Typography scale ───────────────────────────────────── */
h1 { font-size: 1.75rem; font-family: "AkkuratLL-Bold"; margin: 0; }
h2 { font-size: 1rem; font-family: "AkkuratLL-Light"; font-weight: normal; line-height: 1.3; margin: 0; }

/* ── Layout wrapper ─────────────────────────────────────── */
#app {
  max-width: 900px;
  margin: 0 auto;
  position: relative;
}

.res-wrapper {
  padding: 1rem;
  color: var(--text);
  width: 100%;
  position: relative;
  min-height: 100vh;
  overflow-x: hidden;  /* clip panel when slid off right edge */
}

/* ── Header ─────────────────────────────────────────────── */
.res-header {
  margin-bottom: 0.5rem;
}

/* ── Controls (dropdowns) ───────────────────────────────── */
.res-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  column-gap: 2.5rem;
  row-gap: 1rem;
  padding: 0.4rem 0 0;
}

.control-group {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 1rem;
}

.control-label {
  white-space: nowrap;
  font-size: 1rem;
  font-family: "AkkuratLL-Regular";
}

.res-select {
  appearance: none;
  -webkit-appearance: none;
  background: #0a0a0a;
  color: #edf85f;
  border: 1px solid #575e63;
  border-radius: 4px;
  padding: 0.3rem 2rem 0.3rem 0.5rem;
  font-family: "AkkuratLL-Regular";
  font-size: 0.9rem;
  cursor: pointer;
  height: 2rem;
  width: 160px;
  /* custom chevron */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpolyline points='1,1 5,5 9,1' fill='none' stroke='%23575e63' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.5rem center;
  background-size: 8px;
}

.res-select option {
  background: #0a0a0a;
  color: #edf85f;
  font-family: "AkkuratLL-Regular";
}

.res-select:focus {
  outline: none;
  border-color: rgba(255, 255, 255, 0.35);
}

/* ── Legend ─────────────────────────────────────────────── */
.res-legend {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  font-size: 1rem;
  color: var(--text-muted);
  margin-top: 1.2rem;
  padding-right: 20px;
}

.legend-bracket {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  white-space: nowrap;
}

.legend-gap {
  display: inline-block;
  width: 2rem;
}

@media (max-width: 640px) {
  .legend-gap { width: 0.75rem; }
}

/* ── Fixed X-axis ───────────────────────────────────────── */
.xaxis-container {
  overflow: hidden;
  margin-top: 0.6rem;
}

.xaxis-svg {
  display: block;
}

/* ── Chart area ─────────────────────────────────────────── */
.chart-container {
  position: relative;
  width: 100%;
  overflow-y: hidden;  /* clips drop animation above SVG, not horizontal */
}

.chart-svg {
  display: block;
  overflow: visible;
}

/* ── D3 axis styles ─────────────────────────────────────── */
.axis path,
.axis line {
  stroke: none;
}

.axis text {
  fill: var(--text);
  font-family: "AkkuratLL-Light";
  font-size: 1rem;
}

/* Grid lines (vertical) */
.axis-grid line {
  stroke: var(--grid-line);
  stroke-width: 1;
}

.axis-grid path {
  stroke: none;
}

/* Zero line highlight when domain includes negatives */
.axis-grid .zero-line line {
  stroke: #787878;
  stroke-width: 2;
}

/* Chart row animations are handled imperatively by D3 in Row.jsx.
   No CSS keyframes needed here — D3 transitions y/cy/opacity directly. */

/* ── Panel (slide-in overlay on entire viz) ─────────────── */
/* .res-wrapper already has position: relative — panel is anchored to it */

.panel-outer {
  position: absolute;
  top: 0;
  right: 0;
  width: 400px;
  height: 100vh;
  pointer-events: none;
  z-index: 100;
}

.panel-inner {
  width: 100%;
  min-height: 100%;    /* at least full wrapper height */
  background: var(--panel-bg);
  pointer-events: none;
  transform: translateX(100%);
  transition: transform 0.25s ease-out;
  box-sizing: border-box;
  /* NO overflow-y: auto — the page scrolls, not the panel */
}

.panel-inner.open {
  transform: translateX(0);
  pointer-events: all;
}

.panel-content {
  padding: 1rem;
}

/* Panel header: icon + name side by side */
.panel-header {
  display: flex;
}

.panel-icon {
  width: 50px;
  height: 50px;
  margin-right: 10px;
  flex-shrink: 0;
}

.panel-name-group {
  display: flex;
  flex-direction: column;
}

.panel-title {
  font-size: 1.125rem;
  font-family: "AkkuratLL-Bold";
  margin-top: 6px;
}

.panel-type {
  font-size: 0.875rem;
  font-family: "AkkuratLL-Light";
  color: #ffffff;
  margin-top: 4px;
}

/* Price + metric */
.panel-price-group {
  margin-top: 1rem;
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.panel-price {
  font-size: 1.75rem;
  font-family: "AkkuratLL-Bold";
  color: #ffffff;
}

.panel-metric {
  font-size: 1rem;
  font-family: "AkkuratLL-Regular";
  color: #ffffff;
}

/* 2×2 metric grid */
.panel-grid {
  display: grid;
  grid-template-columns: 170px 170px;
  column-gap: 0.875rem;
  row-gap: 10px;
  margin-top: 0.5rem;
}

.panel-grid-item {
  padding: 8px;
  background: #0a0a0a;
  border-radius: 4px;
}

.panel-grid-heading {
  font-size: 0.875rem;
  font-family: "AkkuratLL-Light";
  color: #ffffff;
}

.panel-grid-value {
  font-size: 1.25rem;
  font-family: "AkkuratLL-Regular";
  color: #ffffff;
  margin-top: 8px;
}

/* Panel chart heading */
.panel-chart-title {
  margin: 1rem 0 .5rem;
}

.panel-chart-label {
  font-size: 1rem;
  font-family: "AkkuratLL-Bold";
}

.panel-chart-metric {
  font-size: 1rem;
  font-family: "AkkuratLL-Light";
}

/* Panel mini line chart */
.panel-chart-wrap {
  width: 100%;
}

.panel-chart-svg {
  display: block;
  width: 100%;
  height: auto;
}

.panel-chart-source {
  margin-top: 0.5rem;
  font-size: 0.75rem;
  color: rgba(255,255,255);
}

.panel-chart-axis-label {
  fill: var(--text);
  font-family: "AkkuratLL-Light";
  font-size: 0.85rem;
}

.panel-chart-grid-line {
  stroke: var(--grid-line);
  stroke-width: 1;
  fill: none;
}

.panel-chart-line {
  fill: none;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Panel close button */
.panel-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 1.5rem;
  height: 1.5rem;
  cursor: pointer;
  opacity: 0.8;
  transition: opacity 0.15s;
}

.panel-close:hover {
  opacity: 1;
}

/* Panel shadow (left edge) */
.panel-shadow {
  pointer-events: none;
  position: absolute;
  top: 0;
  left: -3rem;
  width: 3rem;
  height: 100%;
  overflow: hidden;
}

.panel-shadow::before {
  content: '';
  display: block;
  position: absolute;
  width: 1.5rem;
  height: 100%;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.5);
  top: 0;
  right: -50%;
  filter: blur(15px);
}

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 640px) {
  .res-controls {
    flex-direction: column;
    align-items: flex-start;
  }
  .control-label {
    min-width: 128px;
    text-align: right;
  }
  .panel-outer { width: 100%; }
}

@media (min-width: 641px) {
  .res-controls { flex-wrap: nowrap; }
}
