/* ==========================================================================
   Glaucoma Simulator -- stylesheet
   Design tokens copied verbatim from the learnabouteyes.com design system
   (same tokens as the sibling IOL Vision Simulator's stylesheet). Diagram
   INTERIORS deliberately do NOT use these brand colours -- see js/disc.js,
   js/tsnit.js, js/gcl.js, js/vf.js for the medical-convention palettes
   (fundus tones, red/yellow/green normative bands, true grayscale). Brand
   teal/orange are UI chrome only: header, card titles, buttons, sliders,
   and the single sector-highlight ring on the disc diagram.
   ========================================================================== */

:root {
  --primary: #5F9EAD;
  --primary-dark: #4A8A99;
  --primary-light: #EDF5F7;

  --accent: #F7A828;
  --accent-dark: #D4891A;

  --neutral-900: #1A1F2B;
  --neutral-700: #374151;
  --neutral-400: #9CA3AF;
  --neutral-200: #E5E7EB;
  --neutral-100: #F8FAFB;
  --white: #FFFFFF;
  --success: #10B981;

  --radius: 12px;
  --radius-sm: 8px;

  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);

  --bg: var(--neutral-100);
  --surface: var(--white);
  --surface-alt: var(--primary-light);
  --border: var(--neutral-200);
  --text: var(--neutral-900);
  --text-muted: var(--neutral-700);
  --text-faint: var(--neutral-400);

  --warning-bg: #FDF1DE;
  --warning-border: var(--accent);
  --warning-text: #7A4E0C;

  --focus-ring: var(--primary);

  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-width: 0;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { line-height: 1.25; font-weight: 700; color: var(--neutral-900); }
p { margin: 0 0 0.6em; }
a { color: var(--primary); }
a:hover { color: var(--primary-dark); }
:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 2px; }

.container { max-width: 1280px; margin: 0 auto; padding: 0 24px; }

/* --------------------------------------------------------------------------
   Nav / page intro (shared visual language with the sibling IOL simulator)
   -------------------------------------------------------------------------- */

.nav { background: var(--neutral-900); position: sticky; top: 0; z-index: 20; box-shadow: var(--shadow-md); }
.nav-inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding-top: 0.85rem; padding-bottom: 0.85rem; flex-wrap: wrap; }
.nav-logo { display: inline-flex; align-items: center; gap: 0.6rem; text-decoration: none; color: var(--white); }
.nav-logo:hover { color: var(--white); opacity: 0.9; }
.logo-img { width: 36px; height: 36px; border-radius: 50%; display: block; }
.logo-text { font-weight: 700; font-size: 1.05rem; color: var(--white); letter-spacing: -0.01em; }
.nav-tool-label { font-size: 0.85rem; font-weight: 600; color: var(--primary-light); background: rgba(95,158,173,0.25); border: 1px solid rgba(95,158,173,0.5); padding: 0.3rem 0.75rem; border-radius: var(--radius-sm); }

.page-intro { background: var(--primary-light); border-bottom: 1px solid var(--border); padding: 2.25rem 0 1.75rem; }
.page-intro h1 { margin: 0 0 0.4rem; font-size: clamp(1.5rem, 1.1rem + 1.6vw, 2.1rem); color: var(--neutral-900); letter-spacing: -0.01em; }
.page-intro .subtitle { margin: 0 0 0.75rem; font-size: 1.05rem; max-width: 70ch; color: var(--text-muted); }
.page-intro .disclaimer { margin: 0; font-size: 0.8rem; max-width: 75ch; color: var(--text-faint); }

/* --------------------------------------------------------------------------
   Layout
   -------------------------------------------------------------------------- */

.layout { padding-top: 1.75rem; padding-bottom: 1.75rem; display: flex; flex-direction: column; gap: 1.5rem; }

.controls-panel {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.4rem;
  box-shadow: var(--shadow);
}

@media (min-width: 900px) {
  .controls-panel {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    column-gap: 2rem;
    row-gap: 1.5rem;
    align-items: start;
  }
}

.control-section { padding-bottom: 1.15rem; border-bottom: 1px solid var(--border); }
.control-section:last-of-type { border-bottom: none; padding-bottom: 0; }
.control-section h2 { margin: 0 0 0.75rem; font-size: 0.9rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); }

@media (min-width: 900px) {
  .control-section { border-bottom: none; padding-bottom: 0; background: var(--surface-alt); border-radius: var(--radius-sm); padding: 1.1rem 1.25rem; }
}

/* Segmented eye toggle ---------------------------------------------------- */

.segmented { display: inline-flex; border: 1px solid var(--primary); border-radius: var(--radius-sm); overflow: hidden; }
.segmented button {
  font-family: inherit; font-size: 0.9rem; font-weight: 600; padding: 0.5rem 1.1rem;
  background: var(--surface); color: var(--primary); border: none; cursor: pointer; transition: all 0.15s ease;
}
.segmented button + button { border-left: 1px solid var(--primary); }
.segmented button.is-active { background: var(--primary); color: var(--white); }
.segmented button:hover:not(.is-active) { background: var(--primary-light); }

/* Preset buttons ----------------------------------------------------------- */

.preset-list { display: flex; flex-direction: column; gap: 0.5rem; }
.preset-btn {
  display: block; width: 100%; text-align: left; font-family: inherit;
  padding: 0.6rem 0.8rem; font-size: 0.86rem; font-weight: 600; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  cursor: pointer; transition: border-color 0.15s ease, background-color 0.15s ease;
}
.preset-btn:hover { border-color: var(--primary); }
.preset-btn.is-active { border-color: var(--primary); background: var(--primary-light); color: var(--primary-dark); }

#preset-description { margin-top: 0.75rem; padding: 0.7rem 0.85rem; font-size: 0.83rem; color: var(--text-muted); background: var(--surface); border: 1px dashed var(--primary); border-radius: var(--radius-sm); min-height: 2.4em; }

/* Sliders ------------------------------------------------------------------ */

#slider-panel.is-disabled { opacity: 0.45; pointer-events: none; }
.slider-field { margin-bottom: 0.9rem; }
.slider-field:last-child { margin-bottom: 0; }
.slider-field label { display: flex; justify-content: space-between; font-size: 0.82rem; font-weight: 600; color: var(--text-muted); margin-bottom: 0.35rem; }
.slider-field .slider-value { color: var(--primary-dark); font-variant-numeric: tabular-nums; }
.slider-field input[type="range"] { width: 100%; accent-color: var(--primary); }
.slider-help { margin: 0.3rem 0 0; font-size: 0.75rem; color: var(--text-faint); line-height: 1.4; }
.spillover-warning {
  margin: 0.9rem 0 0; padding: 0.6rem 0.75rem; font-size: 0.76rem; line-height: 1.4; font-weight: 600;
  color: #8A6D0B; background: rgba(217,164,6,0.12); border: 1px solid rgba(217,164,6,0.35); border-radius: var(--radius-sm);
}
.spillover-warning[hidden] { display: none; }

/* Sector table --------------------------------------------------------------- */

.sector-table { width: 100%; border-collapse: collapse; font-size: 0.78rem; }
.sector-table th, .sector-table td { padding: 0.35rem 0.5rem; text-align: left; border-bottom: 1px solid var(--border); }
.sector-table th { color: var(--text-faint); font-weight: 600; text-transform: uppercase; font-size: 0.68rem; letter-spacing: 0.03em; }
.sector-table tr.is-lesioned td { font-weight: 600; background: rgba(247,168,40,0.08); }
.sector-table td.dev-borderline { color: #8A6D0B; font-weight: 600; }
.sector-table td.dev-abnormal { color: #B91C1C; font-weight: 600; }
.sector-table td.dev-severe { color: #7F1D1D; font-weight: 700; }

/* --------------------------------------------------------------------------
   Visualisation grid
   -------------------------------------------------------------------------- */

.viz-grid { display: grid; grid-template-columns: 1fr; gap: 1.25rem; }
@media (min-width: 900px) { .viz-grid { grid-template-columns: 1fr 1fr; } }

.viz-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1rem 1.1rem 1.2rem; box-shadow: var(--shadow); transition: transform 0.15s ease, box-shadow 0.15s ease;
  display: flex; flex-direction: column; gap: 0.6rem;
}
.viz-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.viz-card h3 { margin: 0; font-size: 0.95rem; color: var(--primary-dark); display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.viz-card .viz-hint { margin: 0; font-size: 0.76rem; color: var(--text-faint); }
.vf-global-indices {
  margin: 0; font-size: 0.82rem; font-weight: 700; letter-spacing: 0.02em; color: var(--primary-dark);
  font-variant-numeric: tabular-nums; text-align: center;
}

.viz-canvas-host { width: 100%; aspect-ratio: 1 / 1; max-width: 460px; margin: 0 auto; background: #0F1216; border-radius: var(--radius-sm); overflow: hidden; }
.viz-canvas-host.is-light { background: var(--surface); }
/* Runde 19: js/vf.js zeichnet auf ein 520x460-Canvas (Octopus 24-2-Raster
   ist nasal breiter als temporal, daher kein Quadrat) -- die geteilte 1:1
   Aspect-Ratio von .viz-canvas-host quetschte dieses Raster sichtbar
   nicht-uniform. Eigenes Seitenverhaeltnis nur fuer den VF-Host. */
.viz-canvas-host.is-vf { aspect-ratio: 520 / 460; max-width: 520px; }
.viz-canvas-host canvas, .viz-canvas-host svg { display: block; width: 100%; height: 100%; }

#disc-container { width: 100%; aspect-ratio: 1 / 1; max-width: 420px; margin: 0 auto; border-radius: var(--radius-sm); overflow: hidden; }
#disc-container svg { cursor: pointer; }
#tsnit-container { width: 100%; aspect-ratio: 640 / 280; }

.vf-mode-tabs { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.vf-mode-tabs button {
  font-family: inherit; font-size: 0.76rem; font-weight: 600; padding: 0.35rem 0.7rem;
  background: var(--surface-alt); color: var(--primary-dark); border: 1px solid var(--border); border-radius: 999px; cursor: pointer;
}
.vf-mode-tabs button.is-active { background: var(--primary); color: var(--white); border-color: var(--primary); }

/* --------------------------------------------------------------------------
   Selftest badge
   -------------------------------------------------------------------------- */

#selftest-badge {
  display: inline-block; font-size: 0.75rem; font-weight: 600; padding: 0.3rem 0.7rem;
  border-radius: 999px; background: rgba(16,185,129,0.12); color: #067A55; border: 1px solid rgba(16,185,129,0.35);
}
#selftest-badge.is-fail { background: rgba(220,38,38,0.12); color: #B91C1C; border-color: rgba(220,38,38,0.35); }

/* --------------------------------------------------------------------------
   How it works / footer (shared with sibling app)
   -------------------------------------------------------------------------- */

.how-it-works { background: var(--surface); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.how-it-works-inner { max-width: 900px; padding: 2rem 24px; }
.how-it-works h2 { margin: 0 0 0.75rem; font-size: 1.15rem; }
.how-it-works p { margin: 0 0 0.75rem; color: var(--text-muted); font-size: 0.95rem; max-width: 72ch; }
.how-it-works p:last-child { margin-bottom: 0; }

.footer { background: var(--neutral-900); color: var(--neutral-400); padding: 2.5rem 0 1.5rem; margin-top: 1rem; }
.footer-grid { display: grid; grid-template-columns: 1fr; gap: 2rem; padding-bottom: 1.5rem; }
@media (min-width: 640px) { .footer-grid { grid-template-columns: 1.2fr 1fr; } }
.footer-brand { display: flex; flex-direction: column; align-items: flex-start; gap: 0.5rem; }
.footer-brand .logo-text { color: var(--white); }
.footer-logo-img { width: 40px; height: 40px; border-radius: 50%; }
.footer-brand p { margin: 0; font-size: 0.85rem; color: var(--neutral-400); max-width: 40ch; }
.footer-about h3 { margin: 0 0 0.6rem; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--white); }
.footer-about .disclaimer { font-size: 0.8rem; color: var(--neutral-400); max-width: 55ch; }
.footer-about a { color: var(--primary-light); font-size: 0.85rem; }
.footer-about a:hover { color: var(--white); }
.footer-bottom { border-top: 1px solid rgba(255,255,255,0.1); padding-top: 1.25rem; }
.footer-bottom p { margin: 0; font-size: 0.78rem; color: var(--neutral-400); }
