/* ==========================================================================
   CortexQuant — Six-Layer Architecture
   Design direction: dark market terminal. Monospaced data readouts,
   layered stack diagram, amber/green signal accents on near-black glass.
   ========================================================================== */

:root {
  --void: #080a0d;
  --panel: #101419;
  --panel-2: #161c24;
  --rule: #212a35;
  --rule-soft: #1a2129;
  --ink: #dce4ee;
  --ink-dim: #8c99ab;
  --ink-faint: #5d6779;
  --amber: #f2b544;
  --green: #34d399;
  --red: #ff6b5e;
  --cyan: #4fd6e0;

  --step--1: clamp(0.78rem, 0.76rem + 0.1vw, 0.85rem);
  --step-0: clamp(0.95rem, 0.92rem + 0.15vw, 1.02rem);
  --step-1: clamp(1.15rem, 1.05rem + 0.4vw, 1.4rem);
  --step-2: clamp(1.5rem, 1.3rem + 0.9vw, 2.1rem);
  --step-3: clamp(2rem, 1.5rem + 2.2vw, 3.4rem);

  --gutter: clamp(1.1rem, 4vw, 4rem);
  --measure: 68ch;
}

*,
*::before,
*::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

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

body {
  margin: 0;
  background-color: var(--void);
  /* Non-flat surface: layered radial glow + fine grain */
  background-image:
    radial-gradient(900px 520px at 78% -8%, rgba(79, 214, 224, 0.09), transparent 65%),
    radial-gradient(700px 480px at 4% 12%, rgba(242, 181, 68, 0.07), transparent 62%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='0.035'/%3E%3C/svg%3E");
  background-attachment: fixed;
  color: var(--ink);
  font-family: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: var(--step-0);
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

img { max-width: 100%; height: auto; display: block; }

a {
  color: var(--cyan);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

a:focus-visible,
button:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 3px;
  border-radius: 2px;
}

h1, h2, h3, h4 {
  font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.02em;
  text-wrap: balance;
  margin: 0;
}

p { margin: 0 0 1.15em; }
p:last-child { margin-bottom: 0; }

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--amber);
  color: var(--void);
  padding: 0.75rem 1.1rem;
  font-weight: 700;
  z-index: 100;
}
.skip-link:focus { left: 0.5rem; top: 0.5rem; }

/* ---------- shell ---------------------------------------------------- */

.shell {
  max-width: 1240px;
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.rail {
  position: sticky;
  top: 0;
  z-index: 40;
  backdrop-filter: blur(14px);
  background: rgba(8, 10, 13, 0.82);
  border-bottom: 1px solid var(--rule);
}
.rail__inner {
  max-width: 1240px;
  margin-inline: auto;
  padding: 0.85rem var(--gutter);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.rail__mark {
  font-family: "IBM Plex Mono", monospace;
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  color: var(--ink);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.55rem;
}
.rail__mark span { color: var(--amber); }
.rail__tick {
  width: 8px; height: 8px;
  background: var(--green);
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.18);
  animation: pulse 2.6s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}
.rail__nav {
  display: flex;
  gap: 1.35rem;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.rail__nav a {
  color: var(--ink-dim);
  text-decoration: none;
  transition: color 0.22s cubic-bezier(0.22, 1, 0.36, 1);
  min-height: 44px;
  display: flex;
  align-items: center;
}
.rail__nav a:hover { color: var(--amber); }
@media (max-width: 780px) { .rail__nav { display: none; } }

/* ---------- hero ----------------------------------------------------- */

.hero {
  position: relative;
  padding: clamp(3rem, 9vw, 6.5rem) 0 clamp(2.5rem, 6vw, 4rem);
  border-bottom: 1px solid var(--rule);
}
.hero__grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 0.9fr);
  gap: clamp(1.5rem, 4vw, 3.5rem);
  align-items: end;
}
@media (max-width: 900px) { .hero__grid { grid-template-columns: minmax(0, 1fr); } }

.eyebrow {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--amber);
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin-bottom: 1.4rem;
}
.eyebrow::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--rule), transparent);
  max-width: 180px;
}

.hero h1 {
  font-size: var(--step-3);
  margin-bottom: 1.3rem;
}
.hero h1 em {
  font-style: normal;
  color: var(--amber);
}
.hero__lede {
  font-size: var(--step-1);
  line-height: 1.6;
  color: var(--ink-dim);
  max-width: 46ch;
}

.hero__figures {
  display: grid;
  gap: 1px;
  background: var(--rule);
  border: 1px solid var(--rule);
  border-radius: 3px;
  overflow: hidden;
}
.figure-row {
  background: var(--panel);
  padding: 0.95rem 1.15rem;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}
.figure-row dt {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-faint);
}
.figure-row dd {
  margin: 0;
  font-family: "IBM Plex Mono", monospace;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--green);
}

.hero__media {
  margin-top: clamp(2rem, 5vw, 3.5rem);
  border: 1px solid var(--rule);
  border-radius: 3px;
  overflow: hidden;
  position: relative;
}
.hero__media img {
  width: 100%;
  aspect-ratio: 21 / 9;
  object-fit: cover;
  filter: saturate(0.72) contrast(1.05);
}
.hero__media figcaption {
  position: absolute;
  left: 0;
  bottom: 0;
  right: 0;
  padding: 0.7rem 1rem;
  background: linear-gradient(0deg, rgba(8, 10, 13, 0.94), transparent);
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  color: var(--ink-dim);
}

/* ---------- body layout ---------------------------------------------- */

.dossier {
  display: grid;
  grid-template-columns: minmax(0, 210px) minmax(0, 1fr);
  gap: clamp(1.75rem, 4vw, 3.5rem);
  /* padding-block, not the shorthand — the shorthand would wipe .shell's inline gutter */
  padding-block: clamp(2.5rem, 6vw, 4.5rem);
  align-items: start;
}
.dossier > * { min-width: 0; }
@media (max-width: 1000px) { .dossier { grid-template-columns: minmax(0, 1fr); } }

.toc {
  position: sticky;
  top: 5rem;
  border-left: 1px solid var(--rule);
  padding-left: 1.1rem;
}
@media (max-width: 1000px) {
  .toc { position: static; border-left: 0; border-top: 1px solid var(--rule); padding: 1.25rem 0 0; }
}
.toc__title {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-faint);
  margin-bottom: 0.9rem;
}
.toc ol { list-style: none; margin: 0; padding: 0; counter-reset: toc; }
.toc li { counter-increment: toc; }
.toc a {
  display: block;
  padding: 0.42rem 0;
  color: var(--ink-dim);
  text-decoration: none;
  font-size: 0.9rem;
  line-height: 1.35;
  transition: color 0.2s cubic-bezier(0.22, 1, 0.36, 1), padding-left 0.2s cubic-bezier(0.22, 1, 0.36, 1);
}
.toc a::before {
  content: counter(toc, decimal-leading-zero) "  ";
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.7rem;
  color: var(--ink-faint);
}
.toc a:hover { color: var(--amber); padding-left: 4px; }

.prose { max-width: var(--measure); }
.prose > * + * { margin-top: 1.5rem; }

.prose h2 {
  font-size: var(--step-2);
  padding-top: 1.2rem;
  border-top: 1px solid var(--rule);
  scroll-margin-top: 5rem;
}
.prose h3 {
  font-size: var(--step-1);
  color: var(--amber);
  margin-top: 2rem;
}
.prose h4 {
  font-size: 1rem;
  color: var(--cyan);
  margin-top: 1.5rem;
  letter-spacing: 0.01em;
}

.lede {
  font-size: var(--step-1);
  line-height: 1.62;
  color: var(--ink-dim);
  border-left: 2px solid var(--amber);
  padding-left: 1.25rem;
}

/* ---------- layer stack ---------------------------------------------- */

.stack { display: grid; gap: 0.6rem; margin: 2.25rem 0; }

.layer {
  display: grid;
  grid-template-columns: 3.4rem minmax(0, 1fr) auto;
  align-items: center;
  gap: 1rem;
  background: linear-gradient(100deg, var(--panel-2), var(--panel));
  border: 1px solid var(--rule);
  border-left: 3px solid var(--layer-color, var(--cyan));
  border-radius: 3px;
  padding: 1rem 1.15rem;
  transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1), border-color 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}
.layer:hover {
  transform: translateX(6px);
  border-color: var(--layer-color);
}
.layer__idx {
  font-family: "IBM Plex Mono", monospace;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--layer-color, var(--cyan));
  line-height: 1;
}
.layer__name {
  font-family: "IBM Plex Mono", monospace;
  font-weight: 600;
  font-size: 1rem;
  color: var(--ink);
}
.layer__desc {
  grid-column: 2;
  font-size: 0.9rem;
  color: var(--ink-dim);
  line-height: 1.55;
  margin-top: -0.4rem;
}
.layer__tag {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--layer-color, var(--cyan));
  border: 1px solid currentColor;
  border-radius: 2px;
  padding: 0.22rem 0.5rem;
  white-space: nowrap;
  opacity: 0.8;
}
@media (max-width: 620px) {
  .layer { grid-template-columns: 2.4rem minmax(0, 1fr); }
  .layer__tag { grid-column: 2; justify-self: start; }
  .layer__desc { grid-column: 1 / -1; margin-top: 0; }
}

/* ---------- signal table --------------------------------------------- */

.signal-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  margin: 1.75rem 0;
  border: 1px solid var(--rule);
}
.signal-table caption {
  caption-side: top;
  text-align: left;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-faint);
  padding-bottom: 0.7rem;
}
.signal-table th,
.signal-table td {
  padding: 0.75rem 0.95rem;
  text-align: left;
  border-bottom: 1px solid var(--rule-soft);
  vertical-align: top;
}
.signal-table thead th {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-faint);
  background: var(--panel-2);
  border-bottom-color: var(--rule);
}
.signal-table tbody tr { background: var(--panel); }
.signal-table tbody tr:hover { background: var(--panel-2); }
.signal-table td:first-child {
  font-family: "IBM Plex Mono", monospace;
  font-weight: 600;
  white-space: nowrap;
}
.dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 0.5rem;
  vertical-align: middle;
}
.dot--pos { background: var(--green); }
.dot--watch { background: var(--amber); }
.dot--neutral { background: var(--ink-faint); }
.dot--risk { background: var(--red); }
.table-scroll { overflow-x: auto; min-width: 0; max-width: 100%; }

/* ---------- callout -------------------------------------------------- */

.callout {
  background: var(--panel);
  border: 1px solid var(--rule);
  border-top: 2px solid var(--amber);
  border-radius: 3px;
  padding: 1.35rem 1.5rem;
  margin: 2rem 0;
}
.callout__label {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--amber);
  margin-bottom: 0.7rem;
  display: block;
}
.callout p { color: var(--ink-dim); }
.callout strong { color: var(--ink); }

/* ---------- figure --------------------------------------------------- */

figure.inline-fig { margin: 2.25rem 0; }
figure.inline-fig img {
  width: 100%;
  border: 1px solid var(--rule);
  border-radius: 3px;
  filter: saturate(0.8);
}
figure.inline-fig figcaption {
  font-size: 0.8rem;
  color: var(--ink-faint);
  margin-top: 0.7rem;
  padding-left: 0.9rem;
  border-left: 2px solid var(--rule);
}

/* ---------- faq ------------------------------------------------------ */

.faq { margin-top: 1.75rem; border-top: 1px solid var(--rule); }
.faq details {
  border-bottom: 1px solid var(--rule-soft);
}
.faq summary {
  cursor: pointer;
  padding: 1.05rem 2rem 1.05rem 0;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.98rem;
  font-weight: 500;
  color: var(--ink);
  list-style: none;
  position: relative;
  transition: color 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
  content: "+";
  position: absolute;
  right: 0.3rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--amber);
  font-size: 1.3rem;
  line-height: 1;
}
.faq details[open] summary::after { content: "−"; }
.faq summary:hover { color: var(--amber); }
.faq .faq__body {
  padding: 0 0 1.25rem;
  color: var(--ink-dim);
  max-width: 62ch;
}

/* ---------- related -------------------------------------------------- */

.related {
  margin-top: 1.75rem;
  display: grid;
  gap: 1px;
  background: var(--rule);
  border: 1px solid var(--rule);
  border-radius: 3px;
  overflow: hidden;
}
@media (min-width: 720px) { .related { grid-template-columns: repeat(3, 1fr); } }
.related a {
  background: var(--panel);
  padding: 1.1rem 1.2rem;
  text-decoration: none;
  display: block;
  transition: background 0.24s cubic-bezier(0.22, 1, 0.36, 1);
}
.related a:hover { background: var(--panel-2); }
.related__kicker {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--cyan);
  display: block;
  margin-bottom: 0.45rem;
}
.related__title {
  color: var(--ink);
  font-weight: 600;
  font-size: 0.95rem;
  line-height: 1.4;
}

/* ---------- footer --------------------------------------------------- */

.foot {
  border-top: 1px solid var(--rule);
  margin-top: clamp(2.5rem, 6vw, 4rem);
  padding: clamp(2.5rem, 5vw, 3.5rem) 0 2rem;
  background: linear-gradient(180deg, transparent, rgba(16, 20, 25, 0.6));
}
.foot__brand {
  font-family: "IBM Plex Mono", monospace;
  font-weight: 700;
  font-size: 1.05rem;
  margin-bottom: 0.5rem;
}
.foot__blurb {
  color: var(--ink-dim);
  font-size: 0.9rem;
  max-width: 52ch;
  margin-bottom: 2rem;
}
.foot__net-title {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-faint);
  margin-bottom: 0.9rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule-soft);
}
.linknet {
  display: grid;
  gap: 0.35rem 1.5rem;
  grid-template-columns: repeat(auto-fill, minmax(215px, 1fr));
  list-style: none;
  margin: 0 0 2rem;
  padding: 0;
}
.linknet a {
  color: var(--ink-dim);
  text-decoration: none;
  font-size: 0.87rem;
  display: block;
  padding: 0.35rem 0;
  transition: color 0.2s cubic-bezier(0.22, 1, 0.36, 1);
}
.linknet a:hover { color: var(--amber); }
.linknet span { color: var(--ink-faint); font-family: "IBM Plex Mono", monospace; font-size: 0.75rem; }

.foot__legal {
  border-top: 1px solid var(--rule-soft);
  padding-top: 1.5rem;
  font-size: 0.78rem;
  color: var(--ink-faint);
  line-height: 1.7;
}
.foot__legal p { margin-bottom: 0.6rem; }

/* ---------- reveal --------------------------------------------------- */

.reveal {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.7s cubic-bezier(0.22, 1, 0.36, 1), transform 0.7s cubic-bezier(0.22, 1, 0.36, 1);
}
.reveal.is-in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; }
}

/* ---------- brand logo ---------- */
/* Sized relative to the adjacent wordmark (em) with an absolute cap, so each
   site's own type scale governs the mark instead of one fixed pixel height. */
.brand-logo {
  display: inline-block;
  height: min(1.1em, 18px);
  width: auto;
  margin-right: 0.45em;
  vertical-align: -0.22em;
}
.foot__brand .brand-logo,
.foot__wordmark .brand-logo,
.foot__logo .brand-logo {
  height: min(1.3em, 26px);
  margin-right: 0.45em;
  vertical-align: -0.24em;
}
@media (max-width: 640px) {
  .brand-logo { height: min(1.05em, 16px); margin-right: 0.35em; }
  .foot__brand .brand-logo,
  .foot__wordmark .brand-logo { height: min(1.2em, 22px); }
}
