/* ═══════════════════════════════════════════════════════════════
   Infokit.io — terminal/Lombardi theme
   palette:  paper  #f2ecdd  (cream/beige)
             ink    #23241f  (anthracite, metallic black)
             accent #8a6d3b  (pencil ochre, used sparingly)
             faint  #a89f8a  (muted lines)
   adapt:    change the custom properties below, everything follows
   ═══════════════════════════════════════════════════════════════ */
:root {
  --paper:        #f4eede;   /* Lombardi's cream paper */
  --paper-dim:    #ece4cf;
  --ink:          #3d3c37;   /* graphite pencil */
  --ink-soft:     #5c5a50;
  --faint:        #b8b09a;
  --accent:       #8a6d3b;
  --evidence:     #9e3b2c;   /* the "red layer" */
  --cue-h:        clamp(3rem, 7dvh, 6rem);  /* scroll-strip height; also the
                                               graph overlay margin unit */
  --cli-min-h:    4.4rem;   /* CLI one-liner height (bar + input) */
  --font:         "Ubuntu", "Ubuntu Sans", -apple-system, "Segoe UI",
                  Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono:         "Ubuntu Mono", "JetBrains Mono", "Fira Code", ui-monospace,
                  "Cascadia Code", Menlo, Consolas, monospace;
  --chrome-h:     3.25rem;
  --border:       1.5px solid var(--ink);
}

* { box-sizing: border-box; }

/* ── global type scale ────────────────────────────────────────────
   ONE lever for all rem-based sizes. 150% = every font size, padding
   and rem dimension ×1.5. The hero headline is compensated below to
   keep its absolute size (per "everything except the headline").
   Set to 100% to revert, or e.g. 115% for a gentler bump. */
html { font-size: 150%; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 0.9375rem;           /* 15px × 1.5 */
  line-height: 1.55;
}

::selection { background: var(--ink); color: var(--paper); }

/* ── fixed chrome (corner buttons) ─────────────────────────────── */
.chrome {
  position: fixed;
  left: 0; right: 0;
  top: 0;
  height: var(--chrome-h);        /* fixed height → border sits exactly on
                                     the graph's top edge */
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 1rem;
  z-index: 100;
  background: var(--paper);
  border-bottom: 1px solid var(--faint);
  pointer-events: none;           /* only the buttons are clickable */
}
.chrome--top { top: 0; }

.chrome__btn {
  pointer-events: auto;
  font-family: var(--font);
  font-size: 0.8rem;
  background: var(--paper);
  color: var(--ink);
  border: var(--border);
  border-radius: 2px;
  padding: 0.3rem 0.65rem;
  cursor: pointer;
  text-decoration: none;
  letter-spacing: 0.02em;
  box-shadow: 3px 3px 0 rgba(61, 60, 55, 0.25);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}
.chrome__btn:hover { transform: translate(1px, 1px); box-shadow: 1px 1px 0 rgba(35,36,31,.35); }
.chrome__btn:active { transform: translate(3px, 3px); box-shadow: none; }
.chrome__btn--accent { background: var(--ink); color: var(--paper); }
/* expanded terminal: underline accent marking the active state */
.chrome__btn--expanded {
  box-shadow: 3px 3px 0 rgba(61, 60, 55, 0.25), inset 0 -3px 0 var(--accent);
}
.chrome__nav { display: flex; gap: 0.5rem; flex-wrap: wrap; justify-content: flex-end; }

/* brand group: blinking headline + mission slug */
.chrome__brand {
  display: flex;
  align-items: baseline;          /* slug's bottom line sits on the
                                     headline's baseline */
  gap: 0.35rem;
  pointer-events: none;           /* buttons inside re-enable */
}
.chrome__name {
  pointer-events: auto;
  font-family: var(--font);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
}
.chrome__brand-name { margin: 0; font-size: inherit; font-weight: inherit; }
.chrome__name:hover { color: var(--accent); }
.chrome__slug {
  font-family: var(--font);
  font-size: 0.78rem;
  color: var(--ink);              /* brighter: full graphite, not soft */
  letter-spacing: 0.02em;
  white-space: nowrap;
}

/* ── hero: full-viewport graph ─────────────────────────────────── */
.hero {
  /* exactly one viewport; the CLI overlays its lower third */
  height: 100vh;
  height: 100dvh;                 /* mobile: excludes collapsing URL bar */
  position: relative;
  border-bottom: var(--border);
}

.hero__graph {
  position: absolute;
  top: var(--chrome-h);           /* reserve space for the fixed menu bar —
                                     no more pass-through hover/drag cursor */
  right: 0;
  bottom: 0;
  left: 0;
  min-height: 0;                  /* allow shrinking below content size */
  width: 100%;
  overflow: hidden;
  background:
    radial-gradient(circle at 1px 1px, rgba(35,36,31,.10) 1px, transparent 0);
  background-size: 22px 22px;     /* faint dot grid, like drafting paper */
}

#graph-svg {
  display: block;
  position: absolute;             /* fill container, immune to SVG sizing quirks */
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: grab;
}
#graph-svg:active { cursor: grabbing; }
#graph-svg text { font-family: var(--font); }   /* Ubuntu for node/edge labels */

.hero__cursor {
  animation: blink 1.1s steps(1) infinite;
  color: var(--accent);
  margin-left: 0.15em;
}
@keyframes blink { 50% { opacity: 0; } }

/* ── CLI panel: fixed bottom window, overlays all content ──────── */
.hero__cli {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 200;
  display: flex;
  flex-direction: column;
  border-top: var(--border);
  background: var(--paper-dim);
  font-family: var(--mono);       /* the terminal stays monospace */
  font-size: 0.85rem;
  box-shadow: 0 -8px 22px rgba(61, 60, 55, 0.18);
  transition: height 0.18s ease;
}

/* window states */
.hero__cli.cli--hidden   { display: none; }   /* closed entirely */
.hero__cli.cli--restored { height: 33vh; height: 33dvh; }
.hero__cli.cli--expanded { height: 100vh; height: 100dvh; }
.hero__cli.cli--minimized { height: var(--cli-min-h); }
.hero__cli.cli--minimized .cli__scroll { display: none; }

/* ── scroll cue strip: sits directly above the CLI top bar ──────
   wheel events here are NOT captured by d3.zoom (that's on the svg
   only), so they fall through to the document → the page scrolls */
.scroll-cue {
  position: fixed;
  left: 0; right: 0;
  bottom: 33vh;                   /* rest on top of the restored window */
  bottom: 33dvh;
  height: var(--cue-h);           /* proportional, see --cue-h */
  z-index: 150;                   /* above content, below the CLI (200) */
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
  background: transparent;        /* theme-neutral: no gradient */
  border-top: 1px dashed var(--faint);
  cursor: pointer;
  transition: opacity 0.3s ease, bottom 0.18s ease;
}
.scroll-cue__arrow {
  display: inline-block;
  animation: cue-bounce 1.6s ease-in-out infinite;
}
@keyframes cue-bounce {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(4px); }
}
.scroll-cue:hover { color: var(--ink); }

/* follow the CLI window state (cue is a sibling AFTER #cli) */
.hero__cli.cli--hidden    ~ .scroll-cue { bottom: 0; }
.hero__cli.cli--minimized ~ .scroll-cue { bottom: var(--cli-min-h); }
.hero__cli.cli--expanded  ~ .scroll-cue { display: none; }

/* fade out once the hero has been scrolled past */
.scroll-cue.scroll-cue--hidden { opacity: 0; pointer-events: none; }

.cli__bar {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.75rem;
  border-bottom: 1px solid var(--faint);
  background: var(--paper);
}
.cli__dot {
  width: 9px; height: 9px;
  border: 1px solid var(--ink);
  border-radius: 50%;
  background: transparent;
}
.cli__dot:first-child { background: var(--ink); }
.cli__title { margin-left: 0.5rem; color: var(--ink-soft); font-size: 0.75rem; }

.cli__winbtns {
  margin-left: auto;
  display: flex;
  gap: 0.3rem;
}
.cli__winbtn {
  font-family: var(--mono);
  font-size: 0.85rem;
  line-height: 1;
  width: 1.7rem; height: 1.4rem;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--ink);
  border-radius: 2px;
  cursor: pointer;
  padding: 0;
}
.cli__winbtn:hover { background: var(--ink); color: var(--paper); }

.cli__scroll {
  flex: 1;
  overflow-y: auto;
  padding: 0.6rem 0.9rem;
  min-height: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--faint) transparent;
}

.cli__output .line { white-space: pre-wrap; word-break: break-word; }
.cli__output .line--cmd  { color: var(--ink); font-weight: 600; }
.cli__output .line--sys  { color: var(--ink-soft); }
.cli__output .line--ok   { color: var(--accent); }
.cli__output .line--err  { color: #8a3b2e; }
.cli__output a { color: var(--accent); }

.cli__inputline {
  display: flex;
  gap: 0.6rem;
  align-items: baseline;
  padding: 0.5rem 0.9rem 0.55rem;
  border-top: 1px dashed var(--faint);
}
.cli__prompt { color: var(--accent); white-space: nowrap; }
.cli__inputwrap {
  position: relative;
  flex: 1;
  display: flex;
}
.cli__input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--ink);
  font-family: var(--mono);
  font-size: inherit;
  padding: 0;
  caret-color: var(--accent);
}
/* inline suggestion ("ghost") after the typed prefix */
.cli__ghost {
  position: absolute;
  top: 0; left: 0;
  color: var(--faint);            /* lighter grey */
  pointer-events: none;
  user-select: none;
  white-space: pre;
  font-family: var(--mono);
  font-size: inherit;
  line-height: inherit;
}

/* ── content panels below the fold ─────────────────────────────── */
.content {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.5rem 4rem;
  /* keep the last section scrollable clear of the fixed CLI window */
  padding-bottom: calc(33vh + 3.5rem);
  padding-bottom: calc(33dvh + 3.5rem);
}
/* CLI closed → the page doesn't need to reserve its space */
body.cli-hidden .content { padding-bottom: 3.5rem; }

.panel { padding: 4.5rem 0 2.5rem; }
.panel + .panel { border-top: 1px dashed var(--faint); }

.panel__head {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 1.8rem;
}
.panel__index { color: var(--accent); font-size: 0.9rem; }
.panel__title {
  margin: 0;
  font-size: 1.6rem;
  letter-spacing: 0.04em;
}
.panel__title::before { content: "~/"; color: var(--faint); }
.panel__meta { color: var(--ink-soft); font-size: 0.8rem; }

.panel__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.2rem;
}

.card {
  border: var(--border);
  border-radius: 3px;
  padding: 1.1rem 1.2rem;
  background: var(--paper);
  box-shadow: 4px 4px 0 rgba(61, 60, 55, 0.14);
}
.card h3 { margin: 0 0 0.6rem; font-size: 1rem; }
.card p  { margin: 0; font-size: 0.88rem; color: var(--ink-soft); }
.card__tag {
  color: var(--accent) !important;
  font-size: 0.75rem !important;
  margin-bottom: 0.5rem !important;
  text-transform: lowercase;
}
.card--accent { background: var(--paper-dim); }

.panel__body { max-width: 46rem; }
.panel__body p { font-size: 0.95rem; }

.contact-block {
  background: var(--paper-dim);
  border: 1px dashed var(--faint);
  padding: 1rem 1.2rem;
  font-family: var(--mono);
  font-size: 0.85rem;
  overflow-x: auto;
}
.contact-block a { color: var(--accent); text-decoration: underline; }
.contact-block a:hover { color: var(--ink); }
.muted { color: var(--faint); }

.footer {
  margin-top: 4rem;
  padding-top: 1.2rem;
  border-top: 1px dashed var(--faint);
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  font-size: 0.78rem;
  color: var(--ink-soft);
}
.footer a { color: var(--accent); text-decoration: none; }
.footer a:hover { text-decoration: underline; }

/* highlight ring d3 puts on matched nodes via JS */
.node--hit circle { stroke: var(--accent); stroke-width: 3; }
.node--hit text  { fill: var(--accent) !important; }

/* selection state (click on a node or edge) */
.node--selected circle { stroke: var(--accent) !important; stroke-width: 3 !important; }
.node--selected text   { fill: var(--accent) !important; }
.link--selected .link-line { stroke: var(--accent) !important; stroke-width: 2.6 !important; }
.link-hit { cursor: pointer; }

/* ── detail window: overlays the graph, top-right ──────────────── */
.detail {
  position: absolute;
  /* positioned within .hero__graph, which already starts below the
     menu bar — margin from the graph's top edge = scroll-strip height */
  top: var(--cue-h);
  right: var(--cue-h);
  width: min(22rem, calc(100vw - 2 * var(--cue-h)));
  max-height: min(70dvh, 32rem);
  overflow-y: auto;
  background: #ffffff;            /* fully white, per spec */
  border: var(--border);
  box-shadow: 6px 6px 0 rgba(61, 60, 55, 0.2);
  z-index: 60;
  padding: 1.1rem 1.2rem 1.2rem;
  scrollbar-width: thin;
  scrollbar-color: var(--faint) transparent;
}
.detail__head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.6rem;
  border-bottom: 1px dashed var(--faint);
  padding-bottom: 0.55rem;
  margin-bottom: 0.75rem;
}
.detail__title {
  margin: 0;
  font-size: 1.25rem;
  line-height: 1.3;
  white-space: pre-line;          /* render \n in node labels */
}
.detail__close {
  font-family: var(--mono);
  font-size: 1.1rem;
  line-height: 1;
  width: 1.7rem; height: 1.7rem;
  flex: 0 0 auto;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--ink);
  border-radius: 2px;
  cursor: pointer;
  padding: 0;
}
.detail__close:hover { background: var(--ink); color: var(--paper); }
.detail__body p { margin: 0 0 0.6rem; font-size: 0.88rem; }
.detail__body p:last-child { margin-bottom: 0; }
.detail__meta {
  color: var(--ink-soft);
  font-size: 0.8rem;
  border-top: 1px dashed var(--faint);
  padding-top: 0.6rem;
  margin-top: 0.4rem;
}

/* ── graph semantics section ───────────────────────────────────── */
.panel__body h3 {
  font-size: 1rem;
  margin: 2.2rem 0 0.9rem;
}
.panel__body h3::before { content: ""; }

.sem-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  margin: 0 0 1rem;
}
.sem-table th, .sem-table td {
  border: 1px dashed var(--faint);
  padding: 0.5rem 0.7rem;
  text-align: left;
  vertical-align: top;
}
.sem-table th {
  background: var(--paper-dim);
  font-weight: 600;
  border-bottom-style: solid;
}
.sem-table td:first-child {
  white-space: nowrap;
  font-weight: 600;
  letter-spacing: 0.05em;
}
.red { color: var(--evidence); }

.sem-list, .src-list {
  padding-left: 1.2rem;
  font-size: 0.9rem;
}
.sem-list li, .src-list li { margin-bottom: 0.45rem; }
.src-list a { color: var(--accent); }
.note {
  font-size: 0.82rem;
  border-left: 2px solid var(--faint);
  padding-left: 0.7rem;
}

/* ── mobile / small screens ──────────────────────────────────────
   levers: root type scale down (see html{font-size} above), chrome
   becomes two rows (brand / nav), detail window goes edge-to-edge,
   CLI restored state gets more room for touch input.             */
@media (max-width: 720px) {
  html { font-size: 125%; }              /* type-scale lever: 150% → 125% */

  /* chrome: brand on row 1, nav on row 2 — --chrome-h override keeps
     the graph's top edge and the border in sync (single source)     */
  :root { --chrome-h: 6.1rem; }
  .chrome {
    height: var(--chrome-h);
    flex-wrap: wrap;
    align-content: center;
    row-gap: 0.35rem;
    padding: 0.4rem 0.7rem;
  }
  .chrome__brand { width: 100%; }
  .chrome__nav {
    width: 100%;
    justify-content: flex-start;
    gap: 0.35rem;
  }
  .chrome__btn {
    font-size: 0.7rem;
    padding: 0.24rem 0.45rem;
    box-shadow: 2px 2px 0 rgba(61, 60, 55, 0.25);
  }
  .chrome__slug { display: none; }

  /* CLI: taller restored state — thumb typing needs the room,
     and the minimized one-liner gets a bit more touch target */
  .hero__cli { font-size: 0.8rem; }
  .hero__cli.cli--restored { height: 45vh; height: 45dvh; }
  .scroll-cue { bottom: 45vh; bottom: 45dvh; }
  .cli__winbtn { width: 2.1rem; height: 1.7rem; }

  /* detail window: edge-to-edge card over the graph */
  .detail {
    top: 0.75rem;
    right: 0.75rem;
    left: 0.75rem;
    width: auto;
    max-height: 62dvh;
  }

  /* content: tighter rhythm, single-column cards, stacked footer */
  .content { padding: 0 1rem 4rem; padding-bottom: calc(45dvh + 3rem); }
  body.cli-hidden .content { padding-bottom: 3rem; }
  .panel { padding: 3rem 0 2rem; }
  .panel__head { flex-wrap: wrap; row-gap: 0.2rem; }
  .panel__grid { grid-template-columns: 1fr; }
  .footer { flex-direction: column; gap: 0.35rem; }
}

/* very narrow phones: shrink the nav a touch more so it fits one row */
@media (max-width: 420px) {
  .chrome__btn { font-size: 0.62rem; padding: 0.2rem 0.32rem; letter-spacing: 0; }
}
