/*
 * THE CAR-BAR — coming soon.
 * Tokens mirror src/app/globals.css: white and green only, no dark theme.
 */

@font-face {
  font-family: "Bricolage Grotesque";
  src: url("assets/fonts/bricolage-grotesque-latin.woff2") format("woff2");
  font-weight: 200 800;
  font-display: swap;
}

@font-face {
  font-family: "Instrument Sans";
  src: url("assets/fonts/instrument-sans-latin.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
}

@font-face {
  font-family: "Geist Mono";
  src: url("assets/fonts/geist-mono-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

/* Metric-matched fallbacks (the same overrides next/font generates), so the swap does not shift the layout. */
@font-face {
  font-family: "Bricolage Grotesque Fallback";
  src: local("Arial");
  ascent-override: 88.21%;
  descent-override: 25.61%;
  line-gap-override: 0%;
  size-adjust: 105.43%;
}

@font-face {
  font-family: "Instrument Sans Fallback";
  src: local("Arial");
  ascent-override: 94.42%;
  descent-override: 24.33%;
  line-gap-override: 0%;
  size-adjust: 102.74%;
}

@font-face {
  font-family: "Geist Mono Fallback";
  src: local("Arial");
  ascent-override: 74.67%;
  descent-override: 21.92%;
  line-gap-override: 0%;
  size-adjust: 134.59%;
}

:root {
  --paper: #ffffff;
  --paper-2: #f5f8f2;
  --ink: #0e1b09;
  --ink-soft: #47563f;
  --ink-faint: #5f6c58;

  --green: #45a117; /* fills and marks — fails AA as text */
  --green-deep: #2f7510; /* green text on light (5.72:1) */
  --green-dark: #1d4c0a;
  --green-soft: #e9f4e2;
  --green-line: #cfe4c2;
  --line: #e2e8dd;

  --font-display: "Bricolage Grotesque", "Bricolage Grotesque Fallback", "Arial Black", system-ui, sans-serif;
  --font-sans: "Instrument Sans", "Instrument Sans Fallback", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "Geist Mono", "Geist Mono Fallback", ui-monospace, "SF Mono", Menlo, monospace;

  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --gutter: clamp(1.15rem, 4.5vw, 4.5rem);
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background: var(--paper);
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  font-synthesis-weight: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* clip, not hidden: nothing here should ever scroll sideways */
  overflow-x: clip;
}

p {
  margin: 0;
  text-wrap: pretty;
}

img,
svg {
  display: block;
}

a {
  color: inherit;
  -webkit-tap-highlight-color: transparent;
}

:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 3px;
  border-radius: 6px;
}

/* Ink on brand green passes AA (5.40:1); white on it does not. */
::selection {
  background: var(--green);
  color: var(--ink);
}

.skip {
  position: absolute;
  left: 1rem;
  top: -4rem;
  z-index: 10;
  padding: 0.75rem 1.25rem;
  border-radius: 999px;
  background: var(--green);
  color: var(--ink);
  font: 600 0.875rem/1 var(--font-sans);
  text-decoration: none;
}

.skip:focus {
  top: 1rem;
}

/* ---------- Page frame ---------- */

.page {
  position: relative;
  isolation: isolate;
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

/* One soft wash behind the stage gives the white page depth without a dark ground. */
.page::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: radial-gradient(80% 34% at 50% 70%, var(--green-soft) 0%, rgba(233, 244, 226, 0) 72%);
}

.top,
.main,
.foot {
  width: 100%;
  max-width: 88rem;
  margin-inline: auto;
  padding-inline: var(--gutter);
}

/* ---------- Header ---------- */

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-block: clamp(1rem, 2.4vw, 1.6rem);
}

.brand {
  width: auto;
  height: clamp(2.5rem, 3.6vw, 3.25rem);
}

.follow {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  min-height: 44px;
  padding: 0 1rem 0 0.85rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-decoration: none;
  white-space: nowrap;
  transition:
    border-color 0.3s,
    background-color 0.3s;
}

.follow:hover {
  border-color: var(--green-line);
  background: var(--green-soft);
}

.follow img {
  width: 18px;
  height: 18px;
}

/* ---------- Main ---------- */

.main {
  display: flex;
  flex-direction: column;
}

.hero {
  flex: 1;
  display: grid;
  align-items: center;
  align-content: center;
  gap: clamp(3rem, 9vw, 4rem);
  padding-block: clamp(1.5rem, 4vw, 2rem) clamp(2.5rem, 6vw, 3rem);
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--green-deep);
}

/* The live dot: the business is open even though the website is not. */
.beacon {
  position: relative;
  flex: none;
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: var(--green);
}

.beacon::after {
  content: "";
  position: absolute;
  inset: -0.35rem;
  border-radius: 50%;
  border: 1.5px solid var(--green);
  opacity: 0;
}

.title {
  margin: 1.15rem 0 0;
  font-family: var(--font-display);
  font-size: clamp(2.5rem, 12.4vw, 5.25rem);
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.034em;
  text-transform: uppercase;
  color: var(--ink);
}

/* Each line climbs out of its own box; the padding keeps descenders unclipped. */
.ln {
  display: block;
  overflow: hidden;
  padding-bottom: 0.08em;
  margin-bottom: -0.08em;
}

.ln > span {
  display: block;
}

.ln-accent {
  color: var(--green-deep);
}

.lead {
  margin-top: 1.35rem;
  max-width: 34rem;
  font-size: clamp(1.04rem, 1.25vw, 1.16rem);
  line-height: 1.62;
  letter-spacing: -0.003em;
  color: var(--ink-soft);
}

.actions {
  margin-top: 1.9rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.7rem;
  min-height: 54px;
  padding: 0.9rem 1.55rem;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-decoration: none;
  white-space: nowrap;
  transition:
    background-color 0.3s,
    color 0.3s,
    border-color 0.3s;
}

.btn svg {
  flex: none;
}

/* Brand-green fill takes ink, deepening to green-deep + white on hover (both pass AA). */
.btn-primary {
  background: var(--green);
  color: var(--ink);
  box-shadow:
    0 1px 2px rgba(14, 27, 9, 0.05),
    0 16px 34px -18px rgba(47, 117, 16, 0.6);
}

.btn-primary:hover {
  background: var(--green-deep);
  color: #ffffff;
}

.btn-ghost {
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  letter-spacing: 0.08em;
}

.btn-ghost:hover {
  border-color: var(--green-line);
  background: var(--green-soft);
  color: var(--green-dark);
}

.btn-ghost svg {
  color: var(--green-deep);
}

.btn-arrow {
  transition: transform 0.3s var(--ease-out);
}

.btn:hover .btn-arrow {
  transform: translateX(3px);
}

.fineprint {
  margin-top: 1.3rem;
  max-width: 30rem;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  line-height: 1.7;
  letter-spacing: 0.04em;
  color: var(--ink-faint);
}

/* ---------- Stage ---------- */

/* Full column width when stacked, so its edges line up with the copy above it. */
.stage {
  position: relative;
  width: 100%;
}

.stage-bar {
  display: flex;
  align-items: center;
  min-height: 1.5rem;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.status {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
}

.status-dot {
  flex: none;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
}

.status-k {
  flex: none;
  color: var(--green-deep);
}

.status-k::after {
  content: "—";
  margin-left: 0.6rem;
  color: var(--ink-faint);
}

.status-v {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink);
}

.status-k,
.status-v {
  display: inline-block;
}

.stage-canvas {
  position: relative;
  margin-top: 0.85rem;
}

.net {
  width: 100%;
  height: auto;
  overflow: visible;
  -webkit-user-select: none;
  user-select: none;
}

.fallback {
  width: min(100%, 24rem);
  height: auto;
  margin-inline: auto;
}

.js .fallback {
  display: none;
}

/* Under the drawing when stacked; beside the status on desktop. Never where the handle reaches. */
.hint {
  margin-top: 0.6rem;
  text-align: right;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-faint);
  pointer-events: none;
  transition: opacity 0.6s var(--ease-out);
}

.hint:empty,
.stage.is-touched .hint {
  opacity: 0;
}

/* The lens follows the pointer here, so the cursor reads as a sight. */
.stage.is-interactive .stage-canvas {
  cursor: crosshair;
}

/* ---- Network drawing (SVG built by main.js) ---- */

.net text {
  font-family: var(--font-mono);
  font-weight: 500;
  text-transform: uppercase;
}

.d-spine,
.d-branch {
  fill: none;
  stroke: #c5d2bb;
  stroke-width: 1.15;
}

.node-ring {
  fill: #ffffff;
  stroke: #b4c2a9;
  stroke-width: 1.25;
}

.node-core {
  fill: #6c7a64;
}

.node-halo {
  fill: var(--green);
  opacity: 0.16;
}

.node-ring-lit {
  fill: #ffffff;
  stroke: var(--green);
  stroke-width: 1.7;
}

.node-core-lit {
  fill: var(--green);
}

/*
 * White knockout stroke keeps connector lines clear of the lettering.
 * --label is set by main.js from the stage's rendered scale, so labels stay
 * legible when the drawing is shrunk to fit.
 */
.node-label,
.anchor-label {
  font-size: var(--label, 10.5px);
  letter-spacing: 0.13em;
  fill: var(--ink-soft);
  paint-order: stroke;
  stroke: #ffffff;
  stroke-width: 4px;
  stroke-linejoin: round;
}

.anchor-label--hub {
  font-size: calc(var(--label, 10.5px) * 1.1);
  font-weight: 600;
  fill: var(--ink);
}

.you-dot {
  fill: var(--ink-soft);
}

.hub-glow {
  fill: var(--green);
  opacity: 0.12;
}

.hub-ring {
  fill: #ffffff;
  stroke: var(--green);
  stroke-width: 1.8;
}

.hub-core {
  fill: var(--green);
}

.hub-echo,
.lens-lock {
  fill: none;
  stroke: var(--green);
  stroke-width: 1.5;
}

.req-pulse,
.conn-head {
  fill: var(--green);
}

.conn {
  fill: none;
  stroke: var(--green);
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* The same drawing, lit: what the glass shows, magnified. */
.net-lit .d-spine,
.net-lit .d-branch {
  stroke: var(--green);
  stroke-width: 1.1;
  opacity: 0.8;
}

.net-lit .node-ring {
  stroke: var(--green);
  stroke-width: 1.7;
}

.net-lit .node-core,
.net-lit .you-dot {
  fill: var(--green);
}

.net-lit .node-label,
.net-lit .anchor-label {
  fill: var(--green-deep);
}

.find-pill {
  fill: rgba(255, 255, 255, 0.94);
  stroke: var(--green-line);
  stroke-width: 0.8;
}

.find-name {
  font-size: 7.6px;
  letter-spacing: 0.1em;
  fill: var(--ink-soft);
  text-anchor: middle;
}

/* ---------- Process rail ---------- */

.rail {
  list-style: none;
  margin: 0;
  padding: 0 0 clamp(1.25rem, 3vw, 1.75rem);
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(0.85rem, 2.6vw, 2.5rem);
}

.rail-step {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding-top: 0.95rem;
  font-family: var(--font-mono);
  font-size: 0.66rem;
  font-weight: 500;
  line-height: 1.5;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.rail-step::before,
.rail-step::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
}

.rail-step::before {
  height: 1px;
  background: var(--line);
}

/* Fills across the step while that beat of the search is playing. */
.rail-step::after {
  top: -0.5px;
  height: 2px;
  border-radius: 2px;
  background: var(--green);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 0.45s var(--ease-out);
}

.rail-step.is-active::after {
  transform: scaleX(1);
  transition: transform var(--dur, 0.6s) linear;
}

.rail-step.is-done::after {
  transform: scaleX(1);
}

.rail-n {
  color: var(--green-deep);
}

.rail-t {
  transition: color 0.4s;
}

.rail-step.is-active .rail-t,
.rail-step.is-done .rail-t {
  color: var(--ink);
}

/* ---------- Footer ---------- */

.foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem 2rem;
  padding-block: 0.5rem max(1.25rem, env(safe-area-inset-bottom));
  font-family: var(--font-mono);
  font-size: 0.66rem;
  line-height: 1.6;
  letter-spacing: 0.06em;
  color: var(--ink-faint);
}

/* ---------- Breakpoints ---------- */

@media (max-width: 479px) {
  .follow-verb {
    display: none;
  }
}

@media (max-width: 559px) {
  .actions {
    flex-direction: column;
  }

  .btn {
    width: 100%;
  }
}

@media (min-width: 640px) {
  .rail-step {
    flex-direction: row;
    gap: 0.65rem;
    font-size: 0.68rem;
    letter-spacing: 0.12em;
  }
}

@media (min-width: 1024px) {
  .page::before {
    background: radial-gradient(48% 70% at 74% 48%, var(--green-soft) 0%, rgba(233, 244, 226, 0) 72%);
  }

  /* Columns share a top line, so the eyebrow and the stage's status read as one row. */
  .hero {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.12fr);
    align-items: start;
    gap: clamp(2.5rem, 4.5vw, 5.5rem);
    padding-block: clamp(1rem, 2.5svh, 2rem);
  }

  .title {
    margin-top: 1.4rem;
    /* Height-capped as well, so a short laptop screen still fits the page in one view. */
    font-size: clamp(3.3rem, min(5.7vw, 10.5svh), 5.9rem);
    line-height: 0.92;
    letter-spacing: -0.038em;
  }

  /*
   * Height-capped so a short laptop keeps the stage beside the copy. The copy
   * column sets the row's height anyway, so the cap only has to stop the stage
   * outgrowing it, not fit the whole page into the viewport.
   */
  .stage {
    justify-self: end;
    max-width: min(46rem, calc((100svh - 13rem) * 680 / 560));
  }

  .stage-bar {
    padding-right: 8rem;
  }

  .hint {
    position: absolute;
    top: 0;
    right: 0;
    margin: 0;
    line-height: 1.5rem;
  }
}

/* Short laptop screens: tighten the vertical rhythm so the page still fits in one view. */
@media (min-width: 1024px) and (max-height: 820px) {
  .top {
    padding-block: 0.85rem;
  }

  .hero {
    padding-block: 0.25rem 0.75rem;
  }

  .title {
    margin-top: 1rem;
    font-size: clamp(3rem, min(5.7vw, 9.4svh), 5.9rem);
  }

  .lead {
    margin-top: 1rem;
  }

  .actions {
    margin-top: 1.4rem;
  }

  .fineprint {
    margin-top: 0.9rem;
  }

  .stage {
    max-width: min(46rem, calc((100svh - 14.25rem) * 680 / 560));
  }

  .rail {
    padding-bottom: 1rem;
  }
}

/* ---------- Entrance (CSS only, so it plays without JavaScript) ---------- */

@media (prefers-reduced-motion: no-preference) {
  .beacon::after {
    animation: beacon 2.4s var(--ease-out) infinite;
  }

  /* `backwards`, not `both`: a held end state would override the CTA's magnetic transform. */
  .top,
  .eyebrow,
  .lead,
  .actions > *,
  .fineprint,
  .stage-bar,
  .rail,
  .foot {
    animation: fade-up 0.85s var(--ease-out) backwards;
  }

  .ln > span {
    animation: rise 0.95s var(--ease-out) backwards;
  }

  .eyebrow { animation-delay: 0.05s; }
  .ln:nth-child(1) > span { animation-delay: 0.1s; }
  .ln:nth-child(2) > span { animation-delay: 0.17s; }
  .ln:nth-child(3) > span { animation-delay: 0.24s; }
  .lead { animation-delay: 0.36s; }
  .actions > :nth-child(1) { animation-delay: 0.46s; }
  .actions > :nth-child(2) { animation-delay: 0.52s; }
  .fineprint { animation-delay: 0.6s; }
  .stage-bar { animation-delay: 0.5s; }
  .rail { animation-delay: 0.66s; }
  .foot { animation-delay: 0.74s; }

  .is-swap {
    animation: swap 0.45s var(--ease-out);
  }

  /* The search is running right now. */
  .stage.is-live .status-dot {
    animation: live 1.8s ease-in-out infinite;
  }
}

@keyframes live {
  50% {
    opacity: 0.3;
  }
}

@keyframes beacon {
  0% {
    transform: scale(0.45);
    opacity: 0.9;
  }
  100% {
    transform: scale(1.7);
    opacity: 0;
  }
}

@keyframes rise {
  from {
    transform: translateY(108%);
  }
}

@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
}

@keyframes swap {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
}
