/* ==========================================================================
   TechSabby — styles
   One 12-column grid, one neutral palette, one brand blue. Each product sets
   --accent and colour lives only inside that product's section.
   Motion is scroll-linked (animation-timeline) and purely progressive: without
   support, or with reduced motion, every visual shows its finished still.
   ========================================================================== */

:root {
  /* Colour */
  --bg: #0b0b0d;
  --raise: #131316;
  --line: rgba(255, 255, 255, 0.1);
  --line-strong: rgba(255, 255, 255, 0.2);
  --fg: #ececef;
  --muted: #9c9ca6;
  --blue: #4a8dff;      /* from the logo's ribbon gradient, lifted for text contrast */

  --burner: #ff6a4a;
  --idle: #3ddc97;
  --camera: #ffc93c;
  --ratchet: #b39bff;
  --accent: var(--blue);

  /* Type */
  --font-display: "Bricolage Grotesque", system-ui, sans-serif;
  --font-body: "Geist", system-ui, sans-serif;
  --font-mono: "Geist Mono", ui-monospace, monospace;

  --step--1: 0.8125rem;
  --step-0: 1.0625rem;
  --step-1: clamp(1.15rem, 1rem + 0.5vw, 1.375rem);
  --step-2: clamp(1.5rem, 1.1rem + 1.4vw, 2rem);
  --step-3: clamp(2.25rem, 1.5rem + 3vw, 4rem);
  --step-4: clamp(3.25rem, 0.8rem + 9.4vw, 10rem);

  /* Space & layout */
  --gutter: clamp(16px, 4vw, 56px);
  --col-gap: clamp(16px, 2.2vw, 32px);
  --max: 1320px;
  --section: clamp(88px, 12vw, 168px);
  --radius: 6px;

  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

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

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

html { scroll-behavior: smooth; scroll-padding-top: 72px; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 400 var(--step-0)/1.6 var(--font-body);
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}

img, svg { display: block; max-width: 100%; }

a { color: inherit; }

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.03em;
  margin: 0;
  text-wrap: balance;
}
h2 { font-size: var(--step-3); }
h3 { font-size: var(--step-3); }

p { margin: 0; }

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

.skip-link {
  position: absolute;
  left: 16px;
  top: -60px;
  padding: 10px 14px;
  background: var(--fg);
  color: var(--bg);
  border-radius: var(--radius);
  z-index: 100;
}
.skip-link:focus { top: 12px; }

.label {
  font: 500 var(--step--1)/1.2 var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
}

/* The grid every section sits on */
.grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  column-gap: var(--col-gap);
  max-width: var(--max);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.text-link,
.work-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  font: 500 var(--step-0)/1 var(--font-mono);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 6px;
  transition: color 0.2s, gap 0.25s var(--ease);
}
.text-link:hover,
.work-link:hover { gap: 12px; }

.button {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 24px;
  border: 0;
  border-radius: 999px;
  background: var(--fg);
  color: var(--bg);
  font: 500 var(--step-0)/1 var(--font-body);
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.button:hover { background: #1a55f0; color: #fff; } /* logo's deep blue: 5.8:1 with white */

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

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  /* aligns with the .grid content edges */
  padding: 6px max(var(--gutter), calc((100% - var(--max)) / 2 + var(--gutter)));
  background: rgba(11, 11, 13, 0.82);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  text-decoration: none;
  font: 600 1.125rem/1 var(--font-display);
  letter-spacing: -0.01em;
}
sup { font-size: 0.5em; vertical-align: super; line-height: 0; color: var(--muted); }

.site-header nav { display: flex; }
.site-header nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 clamp(8px, 1.4vw, 16px);
  white-space: nowrap;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9375rem;
  transition: color 0.2s;
}
.site-header nav a:last-child { padding-right: 0; }
.site-header nav a:hover { color: var(--fg); }

/* ---------- Hero ---------- */

.hero {
  padding-block: clamp(56px, 10vw, 136px) var(--section);
  row-gap: 0;
}
.hero > * { grid-column: 1 / -1; }

.hero-label { margin-bottom: clamp(20px, 3vw, 36px); }

.hero h1 {
  font-size: var(--step-4);
  line-height: 0.9;
  letter-spacing: -0.045em;
  margin-left: -0.05em; /* optical alignment with the label above */
}
.hero h1 em { font-style: normal; color: var(--blue); }

.hero-intro {
  grid-column: 1 / 6;
  margin-top: clamp(40px, 6vw, 88px);
}
.lede {
  max-width: 34ch;
  font-size: var(--step-1);
  line-height: 1.5;
  color: var(--muted);
  margin-bottom: 20px;
}

/* Project index: a table of contents that previews each product's colour */
.index {
  grid-column: 7 / -1;
  margin-top: clamp(40px, 6vw, 88px);
}
.index .label { margin-bottom: 12px; }
.index ol { list-style: none; margin: 0; padding: 0; border-bottom: 1px solid var(--line); }
.index a {
  display: grid;
  grid-template-columns: 3.5ch 1fr auto;
  align-items: baseline;
  gap: 12px;
  padding: 16px 0;
  min-height: 44px;
  border-top: 1px solid var(--line);
  text-decoration: none;
  transition: padding 0.3s var(--ease);
}
.index .num { font: 400 var(--step--1)/1 var(--font-mono); color: var(--muted); transition: color 0.2s; }
.index b { font: 600 var(--step-1)/1.2 var(--font-display); letter-spacing: -0.01em; transition: color 0.2s; }
.index .kind { font-size: 0.9375rem; color: var(--muted); text-align: right; }
.index a:hover { padding-left: 8px; }
.index a:hover .num,
.index a:hover b { color: var(--accent); }

/* ---------- Sections ---------- */

.section { padding-bottom: clamp(40px, 6vw, 72px); }
.section-head + .work,
.section-head + .oss { padding-top: clamp(16px, 3vw, 40px); }

.section-head {
  align-items: baseline;
  margin-bottom: clamp(16px, 4vw, 48px);
}

/* Section rules span the content columns, not the gutters */
.section-head::before,
.about::before,
.contact::before,
.site-footer::before {
  content: "";
  grid-column: 1 / -1;
  border-top: 1px solid var(--line-strong);
  margin-bottom: 28px;
}
.site-footer::before { border-color: var(--line); margin-bottom: 16px; }
.section-head .label { grid-column: 1 / 4; }
.section-head h2 { grid-column: 4 / -1; max-width: 18ch; }

/* ---------- Products ---------- */

.work,
.oss {
  row-gap: 32px;
  align-items: center;
  padding-block: clamp(48px, 8vw, 104px);
}

.work-meta {
  grid-column: 1 / -1;
  display: flex;
  gap: 16px;
  align-items: baseline;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font: 500 var(--step--1)/1 var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
}
.work-meta .num { color: var(--accent); }

.work-copy { grid-column: 1 / 6; grid-row: 2; }
.work .plate { grid-column: 7 / -1; grid-row: 2; }
.work.flip .work-copy { grid-column: 8 / -1; }
.work.flip .plate { grid-column: 1 / 7; }

.tagline {
  margin: 14px 0 20px;
  font: 600 var(--step-1)/1.3 var(--font-display);
  color: var(--accent);
}
.work-copy > p:not([class]),
.oss-intro > p:not([class]) { color: var(--muted); max-width: 46ch; }

/* Facts: quiet, mono, separated by hairlines rather than pills */
.facts {
  display: flex;
  flex-wrap: wrap;
  margin: 24px 0 20px;
  padding: 0;
  list-style: none;
  font: 400 var(--step--1)/1 var(--font-mono);
  color: var(--fg);
}
.facts li:not(:last-child)::after { content: "/"; margin: 0 10px; color: var(--muted); }

.work-link { color: var(--accent); }
.link-row { display: flex; flex-wrap: wrap; gap: 28px; margin-top: 20px; }

/* ---------- Plates (product visuals) ---------- */

.plate {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 4 / 3;
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--accent) 5%, var(--raise));
  overflow: hidden;
  view-timeline: --plate block;
}
.plate svg { width: 100%; height: 100%; }

/* Burner Room: charcoal room, ember only where something is burning */
.plate-burner { background: #15120f; }
.plate-burner .msg rect:first-child { fill: rgba(255, 255, 255, 0.05); stroke: var(--line-strong); }
.plate-burner .msg-out rect:first-child { fill: color-mix(in srgb, var(--accent) 12%, transparent); stroke: color-mix(in srgb, var(--accent) 55%, transparent); }
.plate-burner .msg-burn rect:first-child { fill: color-mix(in srgb, var(--accent) 22%, transparent); stroke: var(--accent); }
.plate-burner .txt { fill: rgba(255, 255, 255, 0.4); }
.plate-burner .embers { fill: var(--accent); opacity: 0; }
.plate-burner .keys { fill: var(--accent); }

/* IdleLogi: an inventory floor plan, lit tiles are rented */
.ledger {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: clamp(6px, 1vw, 10px);
  width: 76%;
}
.ledger span {
  aspect-ratio: 1;
  border: 1px solid var(--line-strong);
  border-radius: 3px;
}
.ledger .on { background: var(--accent); border-color: var(--accent); }
.legend {
  position: absolute;
  left: 20px;
  bottom: 16px;
  display: flex;
  gap: 18px;
  font: 400 0.75rem/1 var(--font-mono);
  color: var(--muted);
}
.legend span::before {
  content: "";
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-right: 7px;
  border-radius: 2px;
  border: 1px solid var(--line-strong);
}
.legend .key-on::before { background: var(--accent); border-color: var(--accent); }

/* Camera Ahead: night road from the driver's seat */
.plate-camera { background: #0e0e11; }
.plate-camera .road { fill: rgba(255, 255, 255, 0.04); }
.plate-camera .edge { stroke: var(--line-strong); stroke-width: 1.5; fill: none; }
.plate-camera .lane { stroke: var(--accent); stroke-width: 3; stroke-dasharray: 14 16; }
.plate-camera .cam { fill: var(--accent); transform: translate(256px, 140px); }
.plate-camera .cam circle { fill: #0e0e11; }
.plate-camera .caption > rect { fill: rgba(0, 0, 0, 0.6); stroke: var(--line-strong); }
.plate-camera .wave rect { fill: var(--accent); }
.plate-camera text { fill: var(--fg); font: 500 13px var(--font-mono); }

/* ---------- Open source: spec sheet ---------- */

.oss { align-items: start; }
.oss-intro { grid-column: 1 / 6; grid-row: 2; }
.oss-intro h3 { font-size: var(--step-2); font-family: var(--font-mono); font-weight: 500; letter-spacing: -0.02em; }

.spec { grid-column: 7 / -1; grid-row: 2; margin: 0; }
.spec div {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
  gap: 16px;
  padding: 14px 0;
  border-top: 1px solid var(--line);
}
.spec div:last-child { border-bottom: 1px solid var(--line); }
.spec dt { font: 400 var(--step--1)/1.6 var(--font-mono); color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em; }
.spec dd { margin: 0; font-size: 0.9375rem; }

.terminal {
  grid-column: 1 / 7;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--raise);
  font: 400 0.875rem/1.7 var(--font-mono);
  min-width: 0;
}
.install {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 6px 6px 20px;
  border-bottom: 1px solid var(--line);
}
.install code { font: inherit; overflow-x: auto; white-space: nowrap; }
.copy {
  flex: none;
  min-height: 44px;
  min-width: 72px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: transparent;
  color: var(--fg);
  font: 500 0.8125rem/1 var(--font-mono);
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}
.copy:hover { border-color: var(--accent); color: var(--accent); }
.code { margin: 0; padding: 20px; overflow-x: auto; }
.code code { font: inherit; }
.c-dim { color: var(--muted); }
.c-key { color: var(--accent); }
.c-str { color: var(--idle); }

.ratchet { grid-column: 7 / -1; margin: 0; }
.ratchet .chain { stroke: var(--line-strong); stroke-width: 1.5; fill: none; }
.ratchet .step circle { fill: var(--accent); }
.ratchet .step path { stroke: color-mix(in srgb, var(--accent) 60%, transparent); stroke-width: 1.5; stroke-dasharray: 3 4; fill: none; }
.ratchet .step rect { fill: color-mix(in srgb, var(--accent) 18%, transparent); stroke: var(--accent); }
.ratchet .row-label { fill: var(--muted); font: 400 15px var(--font-mono); }
.ratchet figcaption { margin-top: 16px; font-size: 0.9375rem; color: var(--muted); max-width: 46ch; }
.ratchet figcaption em { font-style: normal; color: var(--fg); }

/* ---------- About / Contact ---------- */

.about > .label,
.contact > .label { grid-column: 1 / 4; padding-top: 0.6em; }
.about-body,
.contact-body { grid-column: 4 / -1; }

.about-body p { max-width: 52ch; margin-top: 28px; font-size: var(--step-1); line-height: 1.55; color: var(--muted); }

.contact-body h2 { font-size: var(--step-2); max-width: 26ch; margin-bottom: 36px; letter-spacing: -0.02em; line-height: 1.15; }

.contact-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  max-width: 760px;
}
.contact-form label { display: grid; gap: 8px; }
.contact-form label span { font: 500 var(--step--1)/1 var(--font-mono); color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em; }
.contact-form .full { grid-column: 1 / -1; }

.contact-form input,
.contact-form textarea {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--raise);
  color: var(--fg);
  font: inherit;
  resize: vertical;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.contact-form input:focus,
.contact-form textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(74, 141, 255, 0.25);
}

.form-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
/* Turnstile widget: reserve its height so the layout doesn't jump when it loads */
.form-foot .cf-turnstile { min-height: 65px; }

/* Honeypot: off-screen rather than display:none, which some bots skip */
.contact-form .hp { position: absolute; left: -9999px; }

/* Shown only when the URL hash matches, set by the Worker's redirect */
.form-status { display: none; max-width: 760px; padding: 14px 18px; border-radius: var(--radius); margin: 0 0 24px; }
.form-status:target { display: block; }
.form-status.ok { background: rgba(61, 220, 151, 0.12); color: var(--idle); }
.form-status.err { background: rgba(255, 106, 74, 0.12); color: #ff8a70; }

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

.site-footer {
  row-gap: 12px;
  padding-bottom: 28px;
  color: var(--muted);
  font-size: 0.875rem;
}
.site-footer > p:first-child { grid-column: 1 / 7; align-self: center; }
.footer-links { grid-column: 7 / -1; display: flex; flex-wrap: wrap; justify-content: flex-end; column-gap: 20px; }
.footer-links a { display: inline-flex; align-items: center; min-height: 44px; text-decoration: none; transition: color 0.2s; }
.footer-links a:hover { color: var(--fg); }

/* ---------- Scroll-linked motion (progressive enhancement, no JS) ---------- */

@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    /* Plates settle into place; content is never hidden */
    .plate,
    .terminal,
    .ratchet {
      animation: settle linear both;
      animation-timeline: view();
      animation-range: entry 0% entry 70%;
    }
    @keyframes settle { from { transform: translateY(36px); } }

    /* Burner Room: the last message burns away */
    .plate-burner .msg-burn {
      animation: burn linear both;
      animation-timeline: --plate;
      animation-range: contain 0% contain 60%;
    }
    .plate-burner .embers {
      animation: embers linear both;
      animation-timeline: --plate;
      animation-range: contain 0% contain 70%;
    }
    @keyframes burn {
      0%, 30% { opacity: 1; transform: none; filter: none; }
      100% { opacity: 0.14; transform: translateY(-6px); filter: blur(2px) grayscale(1); }
    }
    @keyframes embers {
      0%, 30% { opacity: 0; transform: none; }
      60% { opacity: 1; }
      100% { opacity: 0; transform: translateY(-48px); }
    }

    /* IdleLogi: tiles switch from idle to rented in three waves */
    .ledger .on {
      animation: rent linear both;
      animation-timeline: --plate;
    }
    .ledger .a { animation-range: entry 60% contain 10%; }
    .ledger .b { animation-range: contain 10% contain 25%; }
    .ledger .c { animation-range: contain 25% contain 40%; }
    @keyframes rent { from { background: transparent; border-color: var(--line-strong); } }

    /* Camera Ahead: drive forward, the camera approaches, the voice speaks up */
    .plate-camera .lane {
      animation: drive linear both;
      animation-timeline: --plate;
    }
    .plate-camera .cam {
      animation: approach linear both;
      animation-timeline: --plate;
      animation-range: entry 50% contain 40%;
    }
    .plate-camera .caption {
      animation: speak linear both;
      animation-timeline: --plate;
      animation-range: contain 30% contain 45%;
    }
    @keyframes drive { to { stroke-dashoffset: -300; } }
    @keyframes approach { from { transform: translate(206px, 104px) scale(0.3); } }
    @keyframes speak { from { opacity: 0; transform: translateY(8px); } }
  }
}

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

@media (max-width: 900px) {
  .grid > *,
  .work.flip > *,
  .work-copy,
  .oss-intro,
  .hero-intro,
  .index,
  .work .plate { grid-column: 1 / -1 !important; grid-row: auto !important; }

  /* Visual first, then copy — the same for every product */
  .work .plate { order: 1; }
  .work-copy { order: 2; }
  .work-meta { order: 0; }

  .section-head .label,
  .about > .label,
  .contact > .label { margin-bottom: 16px; padding-top: 0; }

  .oss { row-gap: 40px; }
  .plate { aspect-ratio: 16 / 10; }
  .footer-links { justify-content: flex-start; }
}

@media (max-width: 560px) {
  .brand span { display: none; }
  .site-header nav a { padding: 0 9px; font-size: 0.875rem; }
  .index a { grid-template-columns: 3.5ch 1fr; row-gap: 6px; }
  .index .kind { grid-column: 2; text-align: left; }
  .contact-form { grid-template-columns: 1fr; }
  .spec div { grid-template-columns: 1fr; gap: 4px; }
  .terminal { font-size: 0.8125rem; }
  .install { padding-left: 14px; }
  .install .c-dim { display: none; }
  .code { padding: 16px 14px; }
  .plate { aspect-ratio: 1 / 1; }
  .plate-burner, .plate-camera { aspect-ratio: 4 / 3; }
}

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