/* ============================================================
   Shared Styles — All views use these.

   Color palette, typography, layout grid, panel components,
   button styles, slider styles. View-specific overrides go
   in /css/views/<view>.css.
   ============================================================ */

:root {
  --bg:           #0c141f;
  --bg-main:      #0c141f;
  --bg-panel:     #0f1922;
  --bg-card:      #162029;
  --bg-highlight: #1a2d3d;
  --border:       #3d6d85;
  --text:         #b8c5d6;
  --text-main:    #e0e7ef;
  --text-dim:     #9fb3c8;
  --cyan:         #18d6e0;
  --accent:       #18d6e0;
  --magenta:      #c4b5fd;
  --orange:       #df740c;
  --green:        #34d399;
  --gold:         #fde68a;
  --red:          #f87171;
  --violet:       #a78bfa;
  --focus-ring:   #18d6e0;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
}

/* --- Layout: canvas + sidebar --- */

.layout {
  display: grid;
  grid-template-columns: 1fr 360px;
  height: 100vh;
}

.canvas-area {
  position: relative;
  background: var(--bg);
  overflow: hidden;
}

canvas#graph-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* --- Overlay (step counter, mode label) --- */

.overlay {
  position: absolute;
  top: 1rem;
  left: 1.2rem;
  pointer-events: none;
}

.overlay .step-count {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--cyan);
}

.overlay .mode-label {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-top: 0.15rem;
}

/* --- Sidebar --- */

.sidebar {
  background: var(--bg-panel);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  padding: 0.9rem;
}

.sidebar h1 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.15rem;
}

.sidebar .subtitle {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-bottom: 0.9rem;
  letter-spacing: 2px;
  text-transform: uppercase;
}

/* --- Panels --- */

.panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  margin-bottom: 0.6rem;
  overflow: hidden;
}

.panel-header {
  padding: 0.4rem 0.55rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--cyan);
  background: rgba(24, 214, 224, 0.04);
  border-bottom: 1px solid var(--border);
}

.panel-header.ontology {
  color: var(--gold);
  background: rgba(253, 230, 138, 0.04);
}

.panel-body {
  padding: 0.5rem;
}

/* --- Stat rows --- */

.stat-row {
  display: flex;
  justify-content: space-between;
  padding: 0.22rem 0;
  font-size: 0.8rem;
  border-bottom: 1px solid rgba(61, 109, 133, 0.4);
}

.stat-row:last-child { border-bottom: none; }
.stat-label { color: var(--text-dim); }
.stat-value { color: var(--text); font-weight: 500; }
.stat-value.hl { color: var(--orange); }

/* --- Buttons --- */

button {
  padding: 0.35rem 0.6rem;
  font-family: inherit;
  font-size: 0.8rem;
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 3px;
  cursor: pointer;
  transition: all 0.15s;
}

button:hover { border-color: var(--cyan); color: var(--cyan); }
button.active { background: var(--cyan); color: var(--bg); border-color: var(--cyan); }

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

/* --- Sliders --- */

.speed-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.4rem;
  font-size: 0.8rem;
}

.speed-row input[type="range"] { flex: 1; accent-color: var(--cyan); }

/* --- Toggles --- */

.toggle-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.4rem;
  font-size: 0.8rem;
}

.toggle-row label { cursor: pointer; display: flex; align-items: center; gap: 0.3rem; }
.toggle-row input[type="checkbox"] { accent-color: var(--cyan); }

/* --- Notes --- */

.note {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-top: 0.3rem;
  line-height: 1.5;
}

/* --- Chart --- */

canvas.chart-canvas {
  width: 100%;
  height: 110px;
  display: block;
}

.legend {
  display: flex;
  gap: 0.7rem;
  font-size: 0.75rem;
  margin-top: 0.3rem;
}

.legend-item { display: flex; align-items: center; gap: 0.25rem; }
.legend-dot { width: 9px; height: 9px; border-radius: 50%; }

/* --- Gate code display --- */

.gate-code {
  font-size: 0.8rem;
  line-height: 1.55;
  color: var(--text);
  white-space: pre;
  overflow-x: auto;
}

.gate-code .c { color: var(--text-dim); }
.gate-code .k { color: var(--cyan); }
.gate-code .h { color: var(--gold); font-weight: 700; }

/* --- Method labels --- */

.method-label {
  font-size: 0.7rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-top: 0.4rem;
}

/* --- Responsive --- */

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; grid-template-rows: 55vh auto; }
  .sidebar { border-left: none; border-top: 1px solid var(--border); }
}

/* Library entries */
.lib-entry { padding: 0.35rem 0; border-bottom: 1px solid var(--border); cursor: pointer; }
.lib-entry:hover { background: rgba(255,255,255,0.03); }
.lib-entry:last-child { border-bottom: none; }
.lib-row { display: flex; justify-content: space-between; align-items: center; }
.lib-title { font-size: 0.75rem; color: var(--text-main); }
.lib-meta { font-size: 0.75rem; color: var(--text-dim); margin-top: 0.1rem; }
.lib-del { font-size: 0.75rem; padding: 0.15rem 0.35rem; background: none; border: 1px solid var(--border); color: var(--text-dim); cursor: pointer; border-radius: 2px; min-width: 1.5rem; min-height: 1.5rem; display: inline-flex; align-items: center; justify-content: center; }
.lib-del:hover { color: #f87171; border-color: #f87171; }

/* Nav bar */
.nav-bar { position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  background: rgba(12, 20, 31, 0.95); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 0.8rem; height: 2.75rem;
  backdrop-filter: blur(8px); gap: 0.15rem; overflow-x: auto; }
.nav-bar a { font-size: 0.85rem; padding: 0.35rem 0.6rem; color: var(--text-dim);
  text-decoration: none; border-radius: 3px; white-space: nowrap;
  min-height: 2rem; display: inline-flex; align-items: center; }
.nav-bar a:hover { color: var(--accent); background: rgba(24,214,224,0.08); }
.nav-bar a.active { color: var(--accent); background: rgba(24,214,224,0.12); }
.nav-logo { font-size: 1rem; font-weight: bold; color: var(--text-main);
  margin-right: 0.5rem; letter-spacing: 0.05em; }
.nav-logo:hover { color: var(--accent); background: none; }
.nav-sep { color: var(--border); margin: 0 0.1rem; font-size: 0.6rem; user-select: none; }
.layout { margin-top: 2.75rem; }

/* Site footer */
.site-footer { position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  background: rgba(12, 20, 31, 0.9); border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center; gap: 0.4rem;
  padding: 0.35rem 0.8rem; height: 1.75rem;
  font-size: 0.75rem; color: var(--text-dim); backdrop-filter: blur(8px); }
.footer-sep { color: var(--border); }

/* ============================================================
   WCAG 2.1 AA — Accessibility
   ============================================================ */

/* Skip link — visible on focus only */
.skip-link { position: absolute; top: -100px; left: 0; z-index: 200;
  background: var(--accent); color: #0c141f; padding: 0.5rem 1rem;
  font-size: 0.85rem; font-weight: bold; text-decoration: none; border-radius: 0 0 4px 0; }
.skip-link:focus { top: 0; outline: none; }

/* Focus indicators — 2.4.7 Focus Visible */
:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 2px; }
button:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 2px; }
a:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 2px; }
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--focus-ring); outline-offset: 1px; }

/* Remove default outline on non-keyboard focus */
:focus:not(:focus-visible) { outline: none; }

/* Canvas accessibility — keyboard-focusable */
canvas[role="img"] { outline: none; }
canvas[role="img"]:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 2px; }

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important; }
}
