/* ==========================================================================
   Qlyse — Neumorphic design system
   --------------------------------------------------------------------------
   Every shadow in this file derives from four tokens: --shadow-dark,
   --shadow-light, --distance and --blur. Changing the surface colour changes
   the entire system, which is why light and dark are a variable swap rather
   than a duplicated stylesheet.

   Rule of the system: nothing is flat and nothing has a border. An element is
   either extruded from the surface or pressed into it. Edges are defined by
   light, never by a stroke.
   ========================================================================== */

:root {
  /* Surface — cool clay. Everything is moulded from this one colour. */
  --bg: #e0e5ec;
  --surface: #e0e5ec;

  --fg: #3d4852;          /* 7.5:1 on --bg  (AAA) */
  --fg-muted: #6b7280;    /* 4.6:1 on --bg  (AA)  */
  --fg-faint: #8b95a5;    /* decorative only — never body text */

  --accent: #6c63ff;
  --accent-light: #8b84ff;
  --accent-ink: #ffffff;

  /* Semantic colours. Each is paired with an icon or label so colour is
     never the sole carrier of meaning (WCAG 1.4.1). */
  --classical: #2b6cb0;   /* classical estimator */
  --quantum: #6c63ff;     /* quantum estimator   */
  --success: #2f855a;
  --warning: #975a16;
  --danger: #9b2c2c;
  --info: #2c7a7b;

  --shadow-dark: rgba(163, 177, 198, 0.62);
  --shadow-light: rgba(255, 255, 255, 0.55);
  --shadow-dark-strong: rgba(163, 177, 198, 0.72);
  --shadow-light-strong: rgba(255, 255, 255, 0.65);

  --r-container: 32px;
  --r-base: 16px;
  --r-inner: 12px;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --dur: 300ms;

  --font-display: "Plus Jakarta Sans", ui-sans-serif, system-ui, sans-serif;
  --font-body: "DM Sans", ui-sans-serif, system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", monospace;
}

[data-theme="dark"] {
  --bg: #2a2e35;
  --surface: #2a2e35;
  --fg: #e2e8f0;
  --fg-muted: #a0aec0;
  --fg-faint: #718096;
  --accent: #8b84ff;
  --accent-light: #a89fff;
  --classical: #63b3ed;
  --quantum: #a89fff;
  --success: #68d391;
  --warning: #f6c177;
  --danger: #fc8181;
  --info: #4fd1c5;
  --shadow-dark: rgba(0, 0, 0, 0.55);
  --shadow-light: rgba(255, 255, 255, 0.055);
  --shadow-dark-strong: rgba(0, 0, 0, 0.65);
  --shadow-light-strong: rgba(255, 255, 255, 0.075);
}

/* ---- Shadow physics ---------------------------------------------------- */

.neu {
  box-shadow: 9px 9px 16px var(--shadow-dark), -9px -9px 16px var(--shadow-light);
}
.neu-sm {
  box-shadow: 5px 5px 10px var(--shadow-dark), -5px -5px 10px var(--shadow-light);
}
.neu-lg {
  box-shadow: 12px 12px 22px var(--shadow-dark-strong),
              -12px -12px 22px var(--shadow-light-strong);
}
.neu-in {
  box-shadow: inset 6px 6px 10px var(--shadow-dark),
              inset -6px -6px 10px var(--shadow-light);
}
.neu-in-sm {
  box-shadow: inset 3px 3px 6px var(--shadow-dark),
              inset -3px -3px 6px var(--shadow-light);
}
.neu-in-deep {
  box-shadow: inset 10px 10px 20px var(--shadow-dark-strong),
              inset -10px -10px 20px var(--shadow-light-strong);
}

/* ---- Base -------------------------------------------------------------- */

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

h1, h2, h3, h4, .display {
  font-family: var(--font-display);
  letter-spacing: -0.025em;
  margin: 0;
  color: var(--fg);
}
h1 { font-weight: 800; }
h2, h3, h4 { font-weight: 700; }

a { color: inherit; text-decoration: none; }
code, .mono { font-family: var(--font-mono); font-size: 0.86em; }

::placeholder { color: var(--fg-faint); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: var(--r-inner);
}

/* ---- Surfaces ---------------------------------------------------------- */

.card {
  background: var(--surface);
  border-radius: var(--r-container);
  padding: 2rem;
  box-shadow: 9px 9px 16px var(--shadow-dark), -9px -9px 16px var(--shadow-light);
  transition: box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.card-hover:hover {
  transform: translateY(-2px);
  box-shadow: 12px 12px 22px var(--shadow-dark-strong),
              -12px -12px 22px var(--shadow-light-strong);
}
.card-sm { border-radius: 24px; padding: 1.25rem; }

.well {
  background: var(--surface);
  border-radius: var(--r-base);
  padding: 1.25rem;
  box-shadow: inset 6px 6px 10px var(--shadow-dark),
              inset -6px -6px 10px var(--shadow-light);
}
.well-deep {
  box-shadow: inset 10px 10px 20px var(--shadow-dark-strong),
              inset -10px -10px 20px var(--shadow-light-strong);
}

/* Icon wells look drilled into the card. Nesting depth is the signature. */
.icon-well {
  display: inline-grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: var(--r-base);
  background: var(--surface);
  box-shadow: inset 10px 10px 20px var(--shadow-dark-strong),
              inset -10px -10px 20px var(--shadow-light-strong);
  color: var(--accent);
  flex: none;
  transition: transform 500ms var(--ease);
}
.icon-well-sm { width: 38px; height: 38px; border-radius: var(--r-inner); }
.card-hover:hover .icon-well { transform: scale(1.05); }

/* ---- Controls ---------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  min-height: 44px;                    /* touch target floor */
  padding: 0.7rem 1.4rem;
  border: none;
  border-radius: var(--r-base);
  background: var(--surface);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 0.94rem;
  font-weight: 500;
  cursor: pointer;
  box-shadow: 5px 5px 10px var(--shadow-dark), -5px -5px 10px var(--shadow-light);
  transition: box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 8px 8px 14px var(--shadow-dark-strong),
              -8px -8px 14px var(--shadow-light-strong);
}
.btn:active:not(:disabled) {
  transform: translateY(0.5px);
  box-shadow: inset 3px 3px 6px var(--shadow-dark),
              inset -3px -3px 6px var(--shadow-light);
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}
.btn-primary:active:not(:disabled) {
  box-shadow: inset 3px 3px 7px rgba(0, 0, 0, 0.28),
              inset -3px -3px 7px rgba(255, 255, 255, 0.18);
}
.btn-sm { min-height: 38px; padding: 0.45rem 0.95rem; font-size: 0.85rem; }
.btn-danger { color: var(--danger); }

.input, .select, textarea.input {
  width: 100%;
  min-height: 46px;
  padding: 0.7rem 1rem;
  border: none;
  border-radius: var(--r-base);
  background: var(--surface);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 0.94rem;
  box-shadow: inset 6px 6px 10px var(--shadow-dark),
              inset -6px -6px 10px var(--shadow-light);
  transition: box-shadow var(--dur) var(--ease);
}
.input:focus, .select:focus, textarea.input:focus {
  outline: none;
  box-shadow: inset 10px 10px 20px var(--shadow-dark-strong),
              inset -10px -10px 20px var(--shadow-light-strong),
              0 0 0 2px var(--bg), 0 0 0 4px var(--accent);
}
.select {
  appearance: none;
  padding-right: 2.5rem;
  background-image: linear-gradient(45deg, transparent 50%, var(--fg-muted) 50%),
                    linear-gradient(135deg, var(--fg-muted) 50%, transparent 50%);
  background-position: calc(100% - 20px) 21px, calc(100% - 14px) 21px;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}
textarea.input { min-height: 92px; resize: vertical; }

.label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg-muted);
  margin-bottom: 0.5rem;
}
.hint { font-size: 0.8rem; color: var(--fg-muted); line-height: 1.5; }

/* Checkbox rendered as a pressed well that fills when checked. */
.check {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-height: 44px;
  padding: 0.55rem 0.9rem;
  border-radius: var(--r-base);
  cursor: pointer;
  transition: box-shadow var(--dur) var(--ease);
  box-shadow: 5px 5px 10px var(--shadow-dark), -5px -5px 10px var(--shadow-light);
}
.check input { position: absolute; opacity: 0; pointer-events: none; }
.check .box {
  width: 22px; height: 22px; flex: none;
  border-radius: 7px;
  background: var(--surface);
  display: grid; place-items: center;
  box-shadow: inset 3px 3px 6px var(--shadow-dark),
              inset -3px -3px 6px var(--shadow-light);
  transition: background var(--dur) var(--ease);
}
.check .box::after {
  content: ""; width: 9px; height: 9px; border-radius: 3px;
  background: transparent; transition: background var(--dur) var(--ease);
}
.check input:checked ~ .box::after { background: var(--accent); }
.check:has(input:checked) {
  box-shadow: inset 3px 3px 6px var(--shadow-dark),
              inset -3px -3px 6px var(--shadow-light);
}
.check input:focus-visible ~ .box { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Range slider on a carved track. */
.range { width: 100%; appearance: none; background: transparent; height: 28px; }
.range::-webkit-slider-runnable-track {
  height: 10px; border-radius: 999px; background: var(--surface);
  box-shadow: inset 3px 3px 6px var(--shadow-dark),
              inset -3px -3px 6px var(--shadow-light);
}
.range::-moz-range-track {
  height: 10px; border-radius: 999px; background: var(--surface);
  box-shadow: inset 3px 3px 6px var(--shadow-dark),
              inset -3px -3px 6px var(--shadow-light);
}
.range::-webkit-slider-thumb {
  appearance: none; width: 22px; height: 22px; margin-top: -6px;
  border-radius: 50%; background: var(--surface); cursor: pointer;
  box-shadow: 3px 3px 7px var(--shadow-dark), -3px -3px 7px var(--shadow-light);
}
.range::-moz-range-thumb {
  width: 22px; height: 22px; border: none;
  border-radius: 50%; background: var(--surface); cursor: pointer;
  box-shadow: 3px 3px 7px var(--shadow-dark), -3px -3px 7px var(--shadow-light);
}

/* ---- Pills, badges, status -------------------------------------------- */

.pill {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.3rem 0.8rem;
  border-radius: 999px;
  font-size: 0.76rem; font-weight: 600;
  letter-spacing: 0.02em;
  background: var(--surface);
  color: var(--fg-muted);
  box-shadow: inset 3px 3px 6px var(--shadow-dark),
              inset -3px -3px 6px var(--shadow-light);
}
.pill-raised {
  box-shadow: 4px 4px 8px var(--shadow-dark), -4px -4px 8px var(--shadow-light);
}
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }

.pill-classical { color: var(--classical); }
.pill-quantum { color: var(--quantum); }
.pill-success { color: var(--success); }
.pill-warning { color: var(--warning); }
.pill-danger { color: var(--danger); }
.pill-info { color: var(--info); }

/* "Not evaluated" is styled as deliberately as a real value. It is a
   first-class state, not an absence. */
.not-evaluated {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--fg-muted);
  font-style: italic;
  letter-spacing: 0.01em;
}

/* ---- Tables ------------------------------------------------------------ */

.table-wrap {
  border-radius: var(--r-base);
  padding: 0.5rem;
  background: var(--surface);
  box-shadow: inset 6px 6px 10px var(--shadow-dark),
              inset -6px -6px 10px var(--shadow-light);
  overflow-x: auto;
}
table.neu-table { width: 100%; border-collapse: separate; border-spacing: 0 6px; font-size: 0.88rem; }
.neu-table th {
  text-align: left;
  font-size: 0.72rem; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--fg-muted);
  padding: 0.5rem 0.9rem;
  white-space: nowrap;
}
.neu-table td { padding: 0.85rem 0.9rem; background: var(--surface); vertical-align: middle; }
.neu-table tbody tr td:first-child { border-radius: var(--r-inner) 0 0 var(--r-inner); }
.neu-table tbody tr td:last-child { border-radius: 0 var(--r-inner) var(--r-inner) 0; }
.neu-table tbody tr {
  box-shadow: 4px 4px 9px var(--shadow-dark), -4px -4px 9px var(--shadow-light);
  transition: box-shadow var(--dur) var(--ease);
}
.neu-table tbody tr:hover {
  box-shadow: 7px 7px 13px var(--shadow-dark-strong),
              -7px -7px 13px var(--shadow-light-strong);
}
.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---- Navigation -------------------------------------------------------- */

.topbar {
  position: sticky; top: 0; z-index: 40;
  background: var(--bg);
  padding: 0.9rem 0;
  box-shadow: 0 8px 18px -10px var(--shadow-dark);
}
.nav-link {
  display: inline-flex; align-items: center; gap: 0.5rem;
  min-height: 42px; padding: 0.5rem 1rem;
  border-radius: var(--r-base);
  font-size: 0.9rem; font-weight: 500;
  color: var(--fg-muted);
  transition: box-shadow var(--dur) var(--ease), color var(--dur) var(--ease);
}
.nav-link:hover { color: var(--fg); box-shadow: 4px 4px 9px var(--shadow-dark), -4px -4px 9px var(--shadow-light); }
.nav-link.active {
  color: var(--accent); font-weight: 600;
  box-shadow: inset 4px 4px 8px var(--shadow-dark), inset -4px -4px 8px var(--shadow-light);
}

.logo-mark {
  width: 42px; height: 42px; border-radius: 13px; flex: none;
  display: grid; place-items: center;
  background: var(--surface);
  box-shadow: 5px 5px 10px var(--shadow-dark), -5px -5px 10px var(--shadow-light);
}

/* ---- Alerts ------------------------------------------------------------ */

.alert {
  display: flex; gap: 0.9rem; align-items: flex-start;
  padding: 1rem 1.25rem;
  border-radius: var(--r-base);
  font-size: 0.88rem;
  background: var(--surface);
  box-shadow: inset 5px 5px 9px var(--shadow-dark),
              inset -5px -5px 9px var(--shadow-light);
}
.alert .bar { width: 4px; align-self: stretch; border-radius: 999px; flex: none; }
.alert-error .bar { background: var(--danger); }
.alert-warning .bar { background: var(--warning); }
.alert-success .bar { background: var(--success); }
.alert-info .bar { background: var(--info); }

/* ---- Progress / meters ------------------------------------------------- */

.meter {
  height: 10px; border-radius: 999px; background: var(--surface);
  box-shadow: inset 3px 3px 6px var(--shadow-dark), inset -3px -3px 6px var(--shadow-light);
  overflow: hidden;
}
.meter > span {
  display: block; height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-light));
  transition: width 600ms var(--ease);
}

/* ---- Decorative concentric depth -------------------------------------- */

.depth-ring {
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface);
  transition: transform 500ms var(--ease);
}
.depth-ring.out { box-shadow: 12px 12px 22px var(--shadow-dark), -12px -12px 22px var(--shadow-light); }
.depth-ring.in {
  box-shadow: inset 10px 10px 20px var(--shadow-dark-strong),
              inset -10px -10px 20px var(--shadow-light-strong);
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}
.floating { animation: float 4s ease-in-out infinite; }

@keyframes pulse-soft {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}
.pulsing { animation: pulse-soft 1.8s ease-in-out infinite; }

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

.shell { max-width: 1240px; margin: 0 auto; padding: 0 1.25rem; }
.stack > * + * { margin-top: 1.5rem; }
.grid { display: grid; gap: 1.5rem; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.row { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.between { justify-content: space-between; }
.muted { color: var(--fg-muted); }
.tiny { font-size: 0.78rem; }
.mt0 { margin-top: 0; }

.stat-value {
  font-family: var(--font-display);
  font-weight: 800; font-size: 2rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.stat-label {
  font-size: 0.72rem; font-weight: 600;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--fg-muted);
}

.section-title { font-size: 1.05rem; font-weight: 700; letter-spacing: -0.01em; }
.eyebrow {
  font-size: 0.72rem; font-weight: 700;
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--accent);
}

hr.neu-rule {
  border: none; height: 2px; margin: 1.75rem 0; border-radius: 999px;
  background: var(--surface);
  box-shadow: inset 2px 2px 4px var(--shadow-dark), inset -2px -2px 4px var(--shadow-light);
}

/* ---- Reaction graph ---------------------------------------------------- */

#graph-canvas { width: 100%; height: 560px; border-radius: var(--r-base); }
.graph-node circle { cursor: pointer; transition: r 200ms var(--ease); }
.graph-link { stroke: var(--fg-faint); stroke-opacity: 0.55; fill: none; }
.graph-label {
  font-family: var(--font-mono); font-size: 9.5px;
  fill: var(--fg); pointer-events: none;
}

/* ---- Responsive -------------------------------------------------------- */

@media (max-width: 1024px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  body { font-size: 14.5px; }
  .card { padding: 1.4rem; border-radius: 26px; }
  .g2, .g3, .g4 { grid-template-columns: minmax(0, 1fr); }
  .stat-value { font-size: 1.6rem; }
  #graph-canvas { height: 420px; }
  .desktop-nav { display: none !important; }
}
@media (min-width: 721px) {
  .mobile-only { display: none !important; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

@media print {
  .topbar, .no-print { display: none !important; }
  .card, .well { box-shadow: none !important; border: 1px solid #ccc; }
  body { background: #fff; }
}
