/* ===== ADHD Capital ===== */

:root {
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --font-serif: 'Newsreader', Georgia, 'Times New Roman', Times, serif;

  /* dark (default) — logo palette: black + cyan neon glow */
  --bg: #04070b;
  --fg: #bfe6f7;
  --fg-strong: #eaf8ff;
  --fg-muted: #6f93a4;
  --fg-faint: #41606e;
  --accent: #8fe6ff;
  --line: rgba(127, 220, 255, 0.14);
  --glow: rgba(120, 210, 255, 0.55);
  --halo: rgba(86, 176, 232, 0.12);
}

html.light {
  --bg: #eef5fa;
  --fg: #0d2a36;
  --fg-strong: #04141d;
  --fg-muted: #5a7d8c;
  --fg-faint: #9bb6c2;
  --accent: #0a86b8;
  --line: rgba(12, 70, 100, 0.16);
  --glow: rgba(40, 150, 200, 0.30);
  --halo: rgba(120, 185, 225, 0.20);
}

* { box-sizing: border-box; }
html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;   /* no surprise font inflation on iOS rotation */
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  overflow: hidden;
  background-color: var(--bg);
  background-image: radial-gradient(60rem 44rem at 50% 50%, var(--halo), transparent 70%);
  background-repeat: no-repeat;
  background-attachment: fixed;
  color: var(--fg);
  font-family: var(--font-mono);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color .35s ease, color .35s ease;
}

/* ===== Top bar ===== */
.topbar {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  /* clear the notch / rounded corners on phones */
  padding: max(1.4rem, env(safe-area-inset-top)) max(1.6rem, env(safe-area-inset-right)) 1.4rem max(1.6rem, env(safe-area-inset-left));
}
@media (min-width: 768px) {
  .topbar { padding: max(1.8rem, env(safe-area-inset-top)) max(2.2rem, env(safe-area-inset-right)) 1.8rem max(2.2rem, env(safe-area-inset-left)); }
}

/* Wordmark: logo mark + serif name, top-left — sized in proportion (Paradigm-style) */
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;           /* logo sits close to the text */
  text-decoration: none;
  color: var(--fg-strong);
}
.brandmark {
  width: 40px;
  height: 40px;
  flex: none;
  display: block;
  margin: -5px 0;         /* glow overflows the bar without enlarging its row */
  transform: translateY(-3px);   /* nudge up so the D sits level with the wordmark */
  /* mark.png is cropped tight to the D and transparent — scales cleanly, no edge */
}
.brand-name {
  font-family: var(--font-serif);
  font-size: clamp(19px, 1.9vw, 25px);   /* matched to the logo height, modest like Paradigm */
  font-weight: 500;
  letter-spacing: 0.005em;
  line-height: 1;
}
@media (max-width: 420px) {
  .brandmark { width: 34px; height: 34px; }
  .brand-name { font-size: 18px; }
}

.controls { display: flex; align-items: center; gap: 1.2rem; }

/* ===== Language box (dropdown) ===== */
.lang { position: relative; }

.lang-trigger {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 6px 11px;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--fg-muted);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  cursor: pointer;
  transition: border-color .2s ease, color .2s ease, box-shadow .2s ease;
}
@media (min-width: 768px) { .lang-trigger { font-size: 12px; } }
.lang-trigger:hover, .lang.open .lang-trigger {
  border-color: var(--accent);
  color: var(--fg-strong);
  box-shadow: 0 0 10px rgba(143, 230, 255, 0.12);
}
.lang-caret { font-size: 9px; transition: transform .2s ease; color: var(--fg-faint); }
.lang.open .lang-caret { transform: rotate(180deg); color: var(--accent); }

.lang-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 150px;
  margin: 0;
  padding: 5px;
  list-style: none;
  background: var(--bg);
  border: 1px solid var(--line);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.55);
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 1px;
  animation: menuIn .16s ease-out both;
}
.lang-menu[hidden] { display: none; }
@keyframes menuIn { from { opacity: 0; transform: translateY(-5px); } to { opacity: 1; transform: none; } }

.lang-item {
  appearance: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  padding: 8px 9px;
  background: none;
  border: 0;
  cursor: pointer;
  text-align: left;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--fg-muted);
  transition: color .15s ease, background-color .15s ease;
}
.lang-item:hover { color: var(--fg-strong); background-color: rgba(143, 230, 255, 0.06); }
.lang-item[aria-selected="true"] { color: var(--accent); }
.lang-item .code { font-size: 10px; letter-spacing: 0.16em; color: var(--fg-faint); }
.lang-item[aria-selected="true"] .code { color: var(--accent); }

/* ===== Hero ===== */
.hero {
  position: relative;
  z-index: 10;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem max(1rem, env(safe-area-inset-right)) 4rem max(1rem, env(safe-area-inset-left));
}

.field-wrap {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
}

/* the morphing square→circle field */
.ascii-field,
.spark-field {
  grid-area: 1 / 1;
  margin: 0;
  font-family: var(--font-mono);
  white-space: pre;
  line-height: 1.05;
  letter-spacing: 0;
  user-select: none;
  -webkit-user-select: none;
  pointer-events: none;
}
.ascii-field {
  color: var(--fg-strong);
  text-shadow: 0 0 6px var(--glow), 0 0 16px var(--glow);
  cursor: crosshair;
  pointer-events: auto;
  animation: fieldFadeIn 1.1s ease-out both;
}
.spark-field {
  color: #ffffff;
  text-shadow: 0 0 6px var(--accent), 0 0 16px var(--glow);
}
@keyframes fieldFadeIn { 0% { opacity: 0; } 100% { opacity: 1; } }

/* ===== Tagline (Paradigm-style serif prose) — caption below the figure ===== */
.tagline {
  position: absolute;
  left: 50%;
  bottom: clamp(1.4rem, 5vh, 3rem);
  transform: translateX(-50%);
  z-index: 4;
  margin: 0;
  width: max-content;
  max-width: 90vw;
  font-family: var(--font-serif);
  font-size: clamp(17px, 2vw, 23px);
  font-style: italic;
  font-weight: 400;
  letter-spacing: 0.01em;
  color: var(--fg);
  text-align: center;
}

/* ===== Access nodes + connector wires (Paradigm-style) ===== */
.wires {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  pointer-events: none;
  overflow: visible;
}
.wires line {
  stroke: var(--wire-stroke, var(--line));   /* idle colour fed by a var so ID rules don't beat state rules */
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
  opacity: 0.7;
  transition: stroke .25s ease, opacity .25s ease;
}
/* the always-live wire reads brighter at idle — set the var, NOT stroke directly,
   so .active / .dashed (plain class rules) still win over this ID selector */
#wire-join { --wire-stroke: rgba(127, 220, 255, 0.22); }
.wires line.active {
  stroke: var(--accent);
  opacity: 1;
  filter: drop-shadow(0 0 4px var(--glow));
}

/* a faint cyan glint streams inward along each wire — same calm clock as the hero */
.wire-glint {
  stroke: var(--accent);
  stroke-width: 1.4;
  vector-effect: non-scaling-stroke;
  opacity: 0.8;
  stroke-dasharray: 4 96;          /* one short lit segment per normalised 100u line */
  filter: drop-shadow(0 0 3px var(--glow));
  animation: wireGlint 8.5s linear infinite;
}
@keyframes wireGlint { from { stroke-dashoffset: 0; } to { stroke-dashoffset: 100; } }

/* when a node is hovered, bright dashes stream OUT of the hub to the other two
   modules — a moving "data transmission" (the wires run centre→node, so a
   negative dashoffset animation travels outward, away from the hub). */
.wires line.dashed {
  stroke: var(--accent);
  opacity: 1;
  stroke-width: 2;
  stroke-dasharray: 4 12;          /* fewer, fatter pulses → the transmission reads clearly */
  stroke-linecap: round;           /* each dash glows like a travelling packet */
  filter: drop-shadow(0 0 5px var(--glow));
  animation: wireTx 0.7s linear infinite;
}
@keyframes wireTx { from { stroke-dashoffset: 0; } to { stroke-dashoffset: -16; } }

/* the always-on idle glint would fight the transmission — mute it while engaged */
.wires.engaged .wire-glint { opacity: 0; }

/* ===== Central hub where the three wires converge ===== */
.hub {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  z-index: 3;
  width: 18px; height: 18px;
  display: grid;
  place-items: center;
  border: 1px solid var(--fg-faint);
  background: var(--bg);
  pointer-events: none;
  transition: border-color .25s ease, box-shadow .25s ease;
}
.hub-core {
  width: 5px; height: 5px;
  background: rgba(143, 230, 255, 0.22);
  box-shadow: none;
  transition: width .25s ease, height .25s ease, background-color .25s ease, box-shadow .25s ease;
}
.hub.lit { border-color: var(--accent); box-shadow: 0 0 12px var(--glow); }
.hub.lit .hub-core { width: 9px; height: 9px; background: var(--accent); box-shadow: 0 0 8px var(--glow); }

.nodes { position: absolute; inset: 0; z-index: 3; pointer-events: none; }

/* the whole button (box + label + padding) is one large hit target;
   it's anchored by the box edge that meets the wire. */
.node {
  position: absolute;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  background: none;
  border: 0;
  font-family: var(--font-mono);
  cursor: pointer;
  pointer-events: auto;
}
.node--right { flex-direction: row; }       /* [box][label] — box on the inner side */
.node--left  { flex-direction: row-reverse; }
.node:focus-visible { outline: none; }

.node-box {
  flex: none;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  background: var(--bg);
  border: 1px dashed var(--fg-faint);
  color: var(--fg-muted);
  transition: border-color .2s ease, color .2s ease, box-shadow .2s ease;
}
.node:hover .node-box, .node:focus-visible .node-box { border-color: var(--accent); color: var(--fg-strong); }

.node-q { font-size: 16px; line-height: 1; }
/* active boxes hold a faint dormant square that grows + brightens on hover/focus */
.node-fill {
  width: 7px; height: 7px;
  background: rgba(143, 230, 255, 0.22);
  box-shadow: none;
  transition: width .25s ease, height .25s ease, background-color .25s ease, box-shadow .25s ease;
}
.node--join:hover .node-fill, .node--join:focus-visible .node-fill, .node--join.is-hot .node-fill,
.node--manifest:hover .node-fill, .node--manifest:focus-visible .node-fill, .node--manifest.is-hot .node-fill {
  width: 13px; height: 13px;
  background: var(--accent);
  box-shadow: 0 0 9px var(--glow);
}

.node-info {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  white-space: nowrap;
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  opacity: 0.62;
  transition: opacity .2s ease;
}
.node:hover .node-info, .node:focus-visible .node-info { opacity: 1; }

.node-label { color: var(--fg-strong); }
.node-state { color: var(--fg-muted); font-size: 11px; }
.node--locked .node-state { letter-spacing: 0.2em; }

.node--join .node-box { border-style: solid; border-color: var(--accent); }
.node--join .node-arrow { color: var(--accent); font-size: 15px; transition: transform .2s ease; }
.node--join:hover .node-box { box-shadow: 0 0 12px var(--glow); }
.node--join:hover .node-arrow { transform: translateX(3px); }

/* ===== Manifest node (active, with teaser text below) ===== */
.node--manifest { align-items: flex-start; }
.node--manifest .node-box { border-style: solid; border-color: var(--accent); }
.node--manifest .node-arrow { color: var(--accent); font-size: 15px; transition: transform .2s ease; }
.node--manifest:hover .node-box { box-shadow: 0 0 12px var(--glow); }
.node--manifest:hover .node-arrow { transform: translateX(3px); }

.manifest-teaser {
  position: absolute;
  top: calc(100% + 12px);
  right: 0;                       /* hangs under the marker, opening into the left margin */
  width: min(280px, 22vw);        /* stays inside the left margin at any width */
  text-align: left;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  pointer-events: auto;
}
.manifest-text {
  display: block;
  font-family: var(--font-serif);
  font-size: 14px;
  line-height: 1.5;
  color: var(--fg-muted);
  transition: color .2s ease;
}
.manifest-teaser:hover .manifest-text,
.manifest-teaser:focus-visible .manifest-text { color: var(--fg); }
.manifest-more {
  display: inline-block;
  margin-top: 0.7rem;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
  opacity: 0;
  transform: translateY(-3px);
  transition: opacity .22s ease, transform .22s ease;
}
.manifest-teaser:hover .manifest-more,
.manifest-teaser:focus-visible .manifest-more { opacity: 1; transform: none; }

/* ambient life: locked boxes breathe (dormant-but-powered), join box has a heartbeat */
.node--locked .node-box { animation: boxBreath 8.5s ease-in-out infinite; }
.node--right.node--locked .node-box { animation-delay: -4.25s; }
@keyframes boxBreath {
  0%, 100% { border-color: var(--fg-faint); box-shadow: 0 0 0 0 transparent; }
  50%      { border-color: color-mix(in srgb, var(--fg-faint) 55%, var(--accent));
             box-shadow: 0 0 7px -1px var(--glow); }
}
.node--locked .node-q { animation: qBreath 8.5s ease-in-out infinite; }
.node--right.node--locked .node-q { animation-delay: -4.25s; }
@keyframes qBreath { 0%, 100% { opacity: 0.55; } 50% { opacity: 0.85; } }

/* on hover/focus, stop the ambient loops so the crisp hover state wins cleanly */
.node:hover .node-box, .node:focus-visible .node-box,
.node:hover .node-q,   .node:focus-visible .node-q { animation: none; }

/* ===== Phones & portrait tablets: the absolute "wire" layout needs a wide, short
   viewport, so below 900px we drop it and stack the figure → tagline → nodes,
   and let the page scroll instead of clipping. ===== */
@media (max-width: 900px) {
  body { overflow-x: hidden; overflow-y: auto; }   /* allow scroll; nothing gets clipped */

  .wires, .hub { display: none; }                  /* hover-wire choreography is desktop-only */

  .hero {
    min-height: 100svh;                            /* stable against mobile URL-bar resize */
    justify-content: center;
    padding: clamp(5.5rem, 14vh, 7rem) max(1.1rem, env(safe-area-inset-right))
             clamp(2.5rem, 7vh, 3.5rem) max(1.1rem, env(safe-area-inset-left));
  }

  .field-wrap { width: 100%; }

  .tagline {
    position: static;
    transform: none;
    width: auto;                                   /* override base max-content → wrap to fit */
    margin: 1.5rem auto 0;
    max-width: min(30ch, 90vw);                    /* vw bound guarantees no horizontal clip */
    font-size: clamp(16px, 4.4vw, 21px);
  }

  /* nodes become a centred, full-width tappable column */
  .nodes {
    position: static;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 1.1rem;
    width: min(360px, 90vw);                       /* vw bound, not % of a maybe-wider parent */
    margin: 1.8rem auto 0;
    z-index: 4;
  }
  .node {
    position: static;
    transform: none;
    width: 100%;
    max-width: 100%;
    padding: 12px 10px;                            /* ≥44px tall touch target */
  }
  .node--left, .node--right { flex-direction: row; }
  .node-info { opacity: 1; min-width: 0; }         /* no hover on touch → keep labels legible */

  /* manifest: [box][label] on the first row, teaser paragraph wraps beneath it */
  .node--manifest { flex-wrap: wrap; align-items: center; }
  .manifest-teaser {
    position: static;
    order: 3;
    flex-basis: 100%;
    min-width: 0;                                  /* let the flex item shrink below content */
    width: auto;
    max-width: 100%;
    margin-top: 0.6rem;
  }
  .manifest-text { overflow-wrap: anywhere; }
  .manifest-more { opacity: 1; transform: none; }

  /* roomier tap area for the language switch */
  .lang-trigger { padding: 9px 12px; }
}

/* Landscape phones / very short viewports: trim the vertical rhythm so less scroll */
@media (max-width: 900px) and (max-height: 560px) {
  .hero { padding-top: clamp(4.5rem, 18vh, 5.5rem); padding-bottom: 2rem; }
  .tagline { margin-top: 1rem; }
  .nodes { margin-top: 1.1rem; }
}

/* ===== Apply modal ===== */
.modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 1rem; }
.modal[hidden] { display: none; }
.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(2, 6, 10, 0.72);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}
html.light .modal-backdrop { background: rgba(40, 70, 90, 0.30); }

.modal-panel {
  position: relative;
  width: min(440px, 92vw);
  max-height: min(88vh, 88dvh);
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 2.2rem 2rem 2rem;
  background: var(--bg);
  border: 1px solid var(--line);
  box-shadow: 0 0 0 1px rgba(143, 230, 255, 0.06), 0 24px 60px rgba(0, 0, 0, 0.5);
  animation: modalIn .25s ease-out both;
}
@keyframes modalIn { 0% { opacity: 0; transform: translateY(8px); } 100% { opacity: 1; transform: none; } }

.modal-x {
  position: absolute; top: 0.4rem; right: 0.5rem;
  width: 40px; height: 40px;             /* comfortable touch target */
  display: grid; place-items: center;
  background: none; border: 0; cursor: pointer;
  color: var(--fg-muted); font-size: 24px; line-height: 1;
  transition: color .18s ease;
}
.modal-x:hover { color: var(--fg-strong); }

.modal-title {
  margin: 0 0 0.5rem;
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: 28px;
  color: var(--fg-strong);
}
.modal-intro {
  margin: 0 0 1.4rem;
  font-size: 13px;
  line-height: 1.5;
  color: var(--fg-muted);
}

/* manifest (reading) modal */
.modal-panel--read { width: min(560px, 92vw); padding: 2.6rem 2.4rem 2.4rem; }
.modal-panel--read .modal-title { margin-bottom: 1.1rem; font-size: 30px; }
.manifest-body { display: flex; flex-direction: column; gap: 1rem; }
.manifest-body p {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 16px;
  line-height: 1.62;
  color: var(--fg);
}
.manifest-body .manifest-sign {
  margin-top: 0.5rem;
  font-style: italic;
  color: var(--fg-strong);
}

.apply-form { display: flex; flex-direction: column; gap: 0.9rem; }
.apply-form label {
  display: flex; flex-direction: column; gap: 0.4rem;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-muted);
}
.apply-form input, .apply-form textarea {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--fg-strong);
  background: transparent;
  border: 1px solid var(--line);
  padding: 0.6rem 0.7rem;
  border-radius: 0;
  outline: none;
  transition: border-color .18s ease, box-shadow .18s ease;
  resize: vertical;
}
.apply-form input:focus, .apply-form textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), 0 0 10px var(--glow);
}
.apply-submit {
  margin-top: 0.4rem;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--bg);
  background: var(--accent);
  border: 0;
  padding: 0.75rem 1rem;
  cursor: pointer;
  transition: filter .18s ease, box-shadow .18s ease;
}
.apply-submit:hover { filter: brightness(1.08); box-shadow: 0 0 14px var(--glow); }

.apply-thanks {
  margin: 0.4rem 0 0;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 18px;
  color: var(--fg-strong);
  text-align: center;
}

@media (prefers-reduced-motion: reduce) {
  .ascii-field { animation: none; }
  .modal-panel { animation: none; }
  /* the reduce block above only kills transitions — explicitly stop the ambient loops too */
  .node--locked .node-box, .node--locked .node-q,
  .wires line.dashed { animation: none !important; }
  .wire-glint { display: none !important; }
  * { transition: none !important; }
}

/* ===== Modal on small screens (kept last so it wins over the base modal/form rules) ===== */
@media (max-width: 560px) {
  .modal-panel { width: 100%; padding: 2rem 1.4rem 1.6rem; }
  .modal-panel--read { padding: 2.2rem 1.4rem 1.8rem; }
  .modal-title { font-size: 24px; }
  .modal-panel--read .modal-title { font-size: 26px; }
  .manifest-body p { font-size: 15px; line-height: 1.58; }
  /* 16px inputs stop iOS from auto-zooming the page on focus */
  .apply-form input, .apply-form textarea { font-size: 16px; }
}
