:root {
  --rust: #D8542F; --rust-700: #B8421F; --rust-300: #EE9273; --rust-100: #FBE2D8;
  --ink: #2A1C16; --ink-700: #4A3A32; --ink-500: #7A695F;
  --ink-300: #B5A79D; --ink-100: #E6DED6; --paper: #FDFAF6;
  --radius: 8px; --border: 1.5px;
  --ease: cubic-bezier(.22, 1, .36, 1); --dur: 550ms;
  /* desktop stage geometry */
  --rail-w: 170px; --tile-h: 44px; --rail-gap: 14px;
  --box-left: 218px;            /* rail-w + 48px gap */
  --chip-w: 200px;
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--ink); color: var(--ink-100);
  font-family: Sora, system-ui, sans-serif;
  min-height: 100vh; display: grid; place-items: center;
}
a { color: var(--rust-300); }
a:hover { color: var(--rust); }
:is(a, button):focus-visible { outline: 2px solid var(--rust); outline-offset: 2px; }

/* ---------- stage & content box ---------- */
.stage {
  position: relative;
  width: min(1200px, 100vw - 56px);
  height: min(72vh, 640px);
}
.content-box {
  position: absolute; inset: 0 0 0 var(--box-left);
  border: var(--border) solid var(--ink-500); border-radius: var(--radius);
}
.logo { position: absolute; left: 0; bottom: 0; width: 185px; display: block; }
.logo svg { width: 100%; height: auto; display: block; }

/* ---------- nav tiles ---------- */
.tile {
  position: absolute; display: flex; align-items: center; gap: 10px;
  height: var(--tile-h); padding: 0 14px;
  background: var(--ink); border: var(--border) solid var(--ink-700);
  border-radius: var(--radius); cursor: pointer;
  font: inherit; text-align: left; text-decoration: none;
  transition: all var(--dur) var(--ease);
}
.tile:hover { border-color: var(--rust); }
.tile-num {
  font: 500 11px "IBM Plex Mono", monospace;
  letter-spacing: .06em; color: var(--ink-300);
}
.tile-name { font: 600 14px Sora, sans-serif; color: var(--paper); }
.tile-dot {
  position: absolute; left: 11px; bottom: 9px; width: 9px; height: 9px;
  border-radius: 50%; background: var(--paper);
  opacity: 0; transition: opacity var(--dur) var(--ease);
}

/* rail slots (inactive) */
.rail-slot-0 { left: 0; top: 0;                                           width: var(--rail-w); }
.rail-slot-1 { left: 0; top: calc(1 * (var(--tile-h) + var(--rail-gap))); width: var(--rail-w); }
.rail-slot-2 { left: 0; top: calc(2 * (var(--tile-h) + var(--rail-gap))); width: var(--rail-w); }
.rail-slot-3 { left: 0; top: calc(3 * (var(--tile-h) + var(--rail-gap))); width: var(--rail-w); }
.rail-slot-4 { left: 0; top: calc(4 * (var(--tile-h) + var(--rail-gap))); width: var(--rail-w); } /* error pages: full rail of 5 */

/* docked (active) — glides inside the content box */
.tile.is-docked {
  left: calc(100% - var(--chip-w) - 40px); top: 28px; width: var(--chip-w);
  justify-content: flex-end; z-index: 2;
  background: var(--rust); border-color: var(--rust); cursor: default;
}
.tile.is-docked .tile-num { color: var(--rust-100); }
.tile.is-docked:hover { border-color: var(--rust); }
.tile.is-docked .tile-dot { opacity: 1; }

/* ---------- content panels ---------- */
.panel {
  position: absolute; inset: 0 0 0 var(--box-left);
  padding: 118px 40px 32px;
  display: flex; flex-direction: column; gap: 16px;
}
.panel[hidden] { display: none; }
.panel h1 {
  margin: 0; font: 700 38px/1.1 Sora, sans-serif;
  letter-spacing: -.04em; color: var(--paper); text-wrap: pretty;
}
.panel p { margin: 0; font: 400 15px/1.6 Sora, sans-serif; color: var(--ink-100); max-width: 54ch; }
.tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: auto; }
.tag {
  font: 500 11px "IBM Plex Mono", monospace; letter-spacing: .05em;
  text-transform: uppercase; color: var(--rust-300);
  background: var(--ink-700); padding: 6px 11px; border-radius: 6px;
}

/* ---------- contact form ---------- */
.contact-form { display: flex; flex-direction: column; gap: 10px; max-width: 460px; margin-top: 6px; }
.form-row { display: flex; gap: 10px; }
.field {
  flex: 1; min-width: 0; font: 400 13px/1.5 Sora, sans-serif;
  color: var(--paper); background: var(--ink-700);
  border: var(--border) solid var(--ink-500); border-radius: var(--radius);
  padding: 10px 12px; outline: none;
}
.field::placeholder { color: var(--ink-300); }
.field:focus { border-color: var(--rust); }
textarea.field { height: 84px; resize: none; }
.turnstile-slot { min-height: 65px; }
.turnstile-slot:empty { min-height: 0; }
.send-btn {
  align-self: flex-start; font: 600 13px Sora, sans-serif;
  color: var(--paper); background: var(--rust);
  border: none; border-radius: var(--radius); padding: 11px 20px; cursor: pointer;
}
.send-btn:hover { background: var(--rust-700); }
.send-btn:disabled { opacity: .6; cursor: default; }
.form-error { margin: 0; font: 400 13px Sora, sans-serif; color: var(--rust-300); }
.form-confirm { margin: 6px 0 0; font: 400 15px/1.6 Sora, sans-serif; color: var(--paper); }
.socials { display: flex; gap: 8px; margin-top: auto; }
.social {
  font: 500 10.5px "IBM Plex Mono", monospace; letter-spacing: .06em;
  color: var(--ink-300); background: none;
  border: var(--border) solid var(--ink-700); border-radius: 6px;
  padding: 7px 11px; cursor: pointer; text-decoration: none;
}
.social:hover { border-color: var(--rust); color: var(--rust-300); }

/* ---------- tablet (768–1023px): rail becomes a top row ---------- */
@media (max-width: 1023px) {
  :root { --box-left: 0px; }
  .stage { width: calc(100vw - 48px); height: min(calc(100vh - 140px), 660px); }
  .logo { top: 0; bottom: auto; width: 148px; }
  .content-box, .panel { inset: 58px 0 60px 0; }   /* logo ~43 + gap above; tile row 44 + 16 gap below */
  .panel { padding: 96px 32px 28px; }
  .tile { width: calc((100% - 36px) / 4); }
  .rail-slot-0 { left: 0;                            top: auto; bottom: 0; width: calc((100% - 36px) / 4); }
  .rail-slot-1 { left: calc(1 * (25% - 9px + 12px)); top: auto; bottom: 0; width: calc((100% - 36px) / 4); }
  .rail-slot-2 { left: calc(2 * (25% - 9px + 12px)); top: auto; bottom: 0; width: calc((100% - 36px) / 4); }
  .rail-slot-3 { left: calc(3 * (25% - 9px + 12px)); top: auto; bottom: 0; width: calc((100% - 36px) / 4); }
  /* chip docks 24px inside the box, top-RIGHT (away from the logo's corner).
     left/bottom stay length-based so dock ↔ rail transitions tween cleanly:
     box top 58 + 24 + 44 tall = 126 */
  .tile.is-docked { left: calc(100% - var(--chip-w) - 24px); top: auto; bottom: calc(100% - 126px); }
  .panel h1 { font-size: 32px; }
  /* error pages: five tiles share the bottom row */
  .stage--error .rail-slot-0 { left: 0;                             width: calc((100% - 48px) / 5); }
  .stage--error .rail-slot-1 { left: calc(1 * (20% - 9.6px + 12px)); width: calc((100% - 48px) / 5); }
  .stage--error .rail-slot-2 { left: calc(2 * (20% - 9.6px + 12px)); width: calc((100% - 48px) / 5); }
  .stage--error .rail-slot-3 { left: calc(3 * (20% - 9.6px + 12px)); width: calc((100% - 48px) / 5); }
  .stage--error .rail-slot-4 { left: calc(4 * (20% - 9.6px + 12px)); top: auto; bottom: 0; width: calc((100% - 48px) / 5); }
}

/* ---------- mobile (<768px): 2×2 grid below the box ---------- */
@media (max-width: 767px) {
  :root { --tile-h: 40px; --chip-w: 180px; }
  /* place-items must be reset too: modern Chrome applies justify-items to
     block-level children, which would shrink-wrap and center the stage */
  body { display: block; place-items: normal; }
  .stage { width: auto; height: auto; margin: 16px; min-height: min(calc(100vh - 32px), 688px); }
  .logo { position: static; width: 148px; margin-bottom: 14px; }
  .content-box, .panel { position: absolute; inset: 52px 0 108px 0; } /* logo above, grid below */
  .panel { padding: 92px 24px 20px; gap: 11px; }
  .panel h1 { font-size: 26px; line-height: 1.12; letter-spacing: -.03em; }
  .panel p { font-size: 13.5px; line-height: 1.55; }
  .tile { width: calc(50% - 8px); gap: 9px; }
  .tile-dot { left: 10px; bottom: 8px; width: 8px; height: 8px; }
  /* every slot AND the chip use left+bottom lengths (never right/top/auto) so the
     whole dock ↔ rail glide interpolates — mixed properties would snap instantly */
  .rail-slot-0 { left: 0;               top: auto; bottom: 52px; }
  .rail-slot-1 { left: calc(50% + 8px); top: auto; bottom: 52px; }
  .rail-slot-2 { left: 0;               top: auto; bottom: 0; }
  .rail-slot-3 { left: calc(50% + 8px); top: auto; bottom: 0; }
  /* chip top 70 + 40 tall from a stage 100% tall → bottom: 100% - 110px */
  .tile.is-docked { left: calc(100% - var(--chip-w) - 16px); top: auto; bottom: calc(100% - 110px); }
  .contact-form { gap: 8px; margin-top: 2px; }
  .form-row { flex-direction: column; gap: 8px; }
  .field { font-size: 12.5px; padding: 9px 11px; }
  textarea.field { height: 56px; }
  .send-btn { font-size: 12.5px; padding: 10px 18px; }
  .tag { font-size: 10.5px; padding: 5px 10px; }
  .socials { gap: 6px; flex-wrap: wrap; }
  .social { font-size: 9.5px; padding: 6px 9px; }
  /* error pages: grid grows a third row for the fifth tile */
  .stage--error .content-box, .stage--error .panel { inset: 52px 0 160px 0; }
  .stage--error .rail-slot-0 { left: 0;               top: auto; bottom: 104px; }
  .stage--error .rail-slot-1 { left: calc(50% + 8px); top: auto; bottom: 104px; }
  .stage--error .rail-slot-2 { left: 0;               top: auto; bottom: 52px; }
  .stage--error .rail-slot-3 { left: calc(50% + 8px); top: auto; bottom: 52px; }
  .stage--error .rail-slot-4 { left: 0;               top: auto; bottom: 0; }
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .tile, .tile-dot { transition: none; }
}
