/*
  Warped — Techie direction, v1
  Dark terminal system for mini-apps, mockups, and prototypes.
  See ./DESIGN.md for rationale, contrast numbers, and open questions.

  Fonts: Fira Code only (400/600/700), subsetted to Latin + punctuation.
  SIL Open Font License — free to embed and redistribute. Files in ./fonts.
*/

@font-face {
  font-family: 'Fira Code';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('./fonts/FiraCode-Regular.woff2') format('woff2');
}
@font-face {
  font-family: 'Fira Code';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('./fonts/FiraCode-SemiBold.woff2') format('woff2');
}
@font-face {
  font-family: 'Fira Code';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('./fonts/FiraCode-Bold.woff2') format('woff2');
}

:root {
  /* this direction is a committed dark world — a terminal, not a theme
     toggle — so tokens are defined once and never re-mapped for light */

  /* colour */
  --brown-950: #17100a; /* page ground */
  --brown-900: #2a1c12; /* tiles, panels, code blocks */
  --brown-800: #382616; /* elevated / hover surfaces */
  --border: #5c4630;    /* hairlines, dividers */

  --cream: #f3e8d6;  /* body copy, primary text */
  --tan: #b8a58c;    /* meta, paths, secondary text */

  --avocado: #9dbf6a;      /* interactive / live state, links */
  --avocado-dim: #7c9a54;  /* hover borders, selection */
  --mustard: #dba13f;      /* titles, all heading levels */
  --mustard-dim: #a97b2e;  /* tag borders */

  /* type — one face, three weights, no pairing */
  --font: 'Fira Code', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* spacing scale — 4px base, roughly 1.5x steps */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;
  --space-8: 4.5rem;

  /* shape */
  --radius: 6px;     /* tiles, panels, buttons — modest, reads as hardware */
  --radius-sm: 3px;  /* tags, nav pills — closer to a keycap */

  /* scanline hint — confirmed at 0.30. Repeating 1px line every 3px,
     applied as each surface's own background-image so it never sits
     between two elements at double strength. */
  --scanline-alpha: 0.30;
  --scanlines: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, var(--scanline-alpha)) 0px,
    rgba(0, 0, 0, var(--scanline-alpha)) 1px,
    transparent 1px,
    transparent 3px
  );
}

/* ---------- reset ---------- */
* { box-sizing: border-box; }
p { margin: 0; }

html, body {
  margin: 0;
  background-color: var(--brown-950);
  color: var(--cream);
}

body {
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  background-image: var(--scanlines);
}

::selection { background: var(--avocado-dim); color: var(--brown-950); }

a { color: var(--avocado); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--mustard); }
a:focus-visible, button:focus-visible {
  outline: 2px solid var(--mustard);
  outline-offset: 2px;
}

/* ---------- layout ---------- */
.wrap {
  max-width: 1040px;
  margin: 0 auto;
  padding: 0 var(--space-5);
}

/* ---------- heading system ----------
   rule: every title (page / section / tile) is retro yellow (mustard);
   every run of body copy and meta is retro white (cream) or dimmer tan.

   rhythm rule: headings carry no bottom margin. The element that follows
   carries the top margin instead, sized in em relative to ITS OWN
   font-size (1.25em by default) — not the heading's — so the gap stays
   constant no matter how large a fluid/clamp() heading gets. */
.title {
  color: var(--mustard);
  font-weight: 700;
  margin: 0;
  text-wrap: balance;
  letter-spacing: -0.01em;
}
.title-page    { font-size: clamp(1.9rem, 4vw, 2.8rem); line-height: 1.15; }
.title-section { font-size: 1.15rem; font-weight: 600; letter-spacing: 0; }
.title-card    { font-size: 1.05rem; font-weight: 600; letter-spacing: 0; }

.body-text { color: var(--cream); font-weight: 400; margin: 0; }
.meta-text { color: var(--tan); font-weight: 400; font-size: 0.78rem; }

.eyebrow {
  font-weight: 600;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--mustard);
}

/* utility: attach to any element immediately after a .title to apply
   the rhythm rule described above */
.rhythm-below { margin-top: 1.25em; }

code { font-family: var(--font); }

/* optional flourish — a blinking terminal cursor. Use sparingly, once
   per page at most; it's decoration, not a state indicator. */
.cursor {
  display: inline-block;
  width: 0.5em;
  height: 0.95em;
  background: var(--mustard);
  margin-left: 0.15em;
  vertical-align: -0.1em;
  animation: blink 1.1s steps(1) infinite;
}
@media (prefers-reduced-motion: reduce) {
  .cursor { animation: none; }
}
@keyframes blink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

/* ---------- nav tabs ---------- */
nav.tabs { display: flex; gap: var(--space-2); font-size: 0.78rem; }
nav.tabs a {
  color: var(--tan); text-decoration: none;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: var(--space-1) var(--space-3);
}
nav.tabs a.active { color: var(--brown-950); background: var(--avocado); border-color: var(--avocado); }
nav.tabs a:hover:not(.active) { color: var(--cream); border-color: var(--tan); }

/* ---------- buttons & tags ---------- */
.btn {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  font-family: var(--font);
}
.btn-primary { background: var(--avocado); color: var(--brown-950); font-weight: 600; }
.btn-primary:hover { background: var(--mustard); }
.btn-secondary { background: transparent; color: var(--cream); border-color: var(--border); }
.btn-secondary:hover { border-color: var(--tan); }

.tag {
  display: inline-flex;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 3px var(--space-2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--mustard-dim);
  color: var(--mustard);
}

/* ---------- terminal / code panel ---------- */
.terminal {
  background: var(--brown-900);
  background-image: var(--scanlines);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.terminal-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-2) var(--space-4);
  border-bottom: 1px solid var(--border);
  font-size: 0.7rem; color: var(--tan); letter-spacing: 0.03em;
}
.terminal pre { margin: 0; padding: var(--space-5); overflow-x: auto; font-size: 0.85rem; line-height: 1.7; }
/* syntax roles, not a full highlighter: c1 comment, c2 string, c3 keyword, c4 identifier */
.terminal .c1 { color: var(--tan); }
.terminal .c2 { color: var(--avocado); }
.terminal .c3 { color: var(--mustard); }
.terminal .c4 { color: var(--cream); }

/* ---------- tiles (click or Enter/Space to flip) ----------
   Structure required:
     .tile-flip[role=button][tabindex=0][aria-pressed]
       .tile-flip-inner
         .tile-face.tile-front  (defines the box's height — keep this the
                                  taller/more-content face if the two differ)
         .tile-face.tile-back   (position: absolute, matches front's box)

   Axis rule: 1-wide and 2-wide tiles flip left-right (rotateY, the
   default). Add .is-flip-x for short/wide tiles (typically 3-up) to flip
   top-to-bottom (rotateX) instead — it reads better on squat proportions.

   JS required: toggle aria-pressed on click and on Enter/Space keydown.
   See ./example.html for the reference script (~15 lines, no deps). */
.tile-flip {
  display: block;
  width: 100%;
  height: 100%;
  cursor: pointer;
  perspective: 1400px;
}
.tile-flip:focus-visible { outline: 2px solid var(--mustard); outline-offset: 2px; border-radius: var(--radius); }
.tile-flip-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.6s cubic-bezier(0.4, 0.1, 0.2, 1);
}
.tile-flip[aria-pressed="true"] .tile-flip-inner { transform: rotateY(180deg); }
.tile-flip.is-flip-x[aria-pressed="true"] .tile-flip-inner { transform: rotateX(180deg); }
@media (prefers-reduced-motion: reduce) {
  .tile-flip-inner { transition: none; }
}

.tile-face {
  background: var(--brown-900);
  background-image: var(--scanlines);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  backface-visibility: hidden;
}
.tile-flip:hover .tile-face { border-color: var(--avocado-dim); }
.tile-front { position: relative; height: 100%; }
.tile-back { position: absolute; inset: 0; transform: rotateY(180deg); }
.tile-flip.is-flip-x .tile-back { transform: rotateX(180deg); }

.tile-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-2) var(--space-4);
  border-bottom: 1px solid var(--border);
  font-size: 0.7rem;
}
.tile-path { color: var(--tan); }
.tile-status { color: var(--tan); text-transform: uppercase; letter-spacing: 0.06em; font-size: 0.65rem; }
.tile-status.is-live { color: var(--avocado); }

.tile-body { padding: var(--space-5); display: flex; flex-direction: column; gap: var(--space-3); flex: 1; }
.tile-desc { color: var(--cream); font-size: 0.9rem; line-height: 1.6; max-width: 56ch; }
.flip-hint { margin-top: auto; text-align: right; font-size: 0.62rem; color: var(--tan); text-transform: uppercase; letter-spacing: 0.05em; }

.tile-back-body {
  padding: var(--space-5); display: flex; flex-direction: column; gap: var(--space-2);
  flex: 1; justify-content: center; overflow-y: auto;
  scrollbar-width: thin; scrollbar-color: var(--border) transparent;
}
.tile-back-body::-webkit-scrollbar { width: 6px; }
.tile-back-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: var(--radius-sm); }
.back-row { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-3); flex-shrink: 0; }
.back-row .k { color: var(--tan); text-transform: uppercase; letter-spacing: 0.05em; font-size: 0.65rem; }
.back-row .v { color: var(--cream); font-size: 0.82rem; text-align: right; }

/* feature-tile modifier — bigger title, bigger padding, for a single
   1-wide tile that leads a grid */
.tile-flip.is-feature .title-card { font-size: 1.4rem; }
.tile-flip.is-feature .tile-body,
.tile-flip.is-feature .tile-back-body { padding: var(--space-6); }

/* ---------- tile grids ---------- */
.grid-1 { display: grid; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-5); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-5); }
@media (max-width: 720px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

/* ---------- callout ----------
   dashed-border note box. Originally built for in-page review notes;
   generic enough to reuse for any aside/warning/note. */
.callout {
  background: var(--brown-900);
  background-image: var(--scanlines);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: var(--space-5);
  font-size: 0.8rem;
  color: var(--tan);
  line-height: 1.8;
}
.callout .eyebrow { display: block; margin-bottom: var(--space-3); }
.callout ul { margin: 0; padding-left: 1.2em; }
.callout li { margin-bottom: var(--space-2); }
.callout li::marker { color: var(--mustard); }

/* ---------- measure (provisional) ----------
   Wide single-column reading width from the original plan (12-15 words
   per line). Untested at paragraph length in Fira Code — mono body copy
   reads differently than the serif it was originally scoped for. Treat
   as a starting point, not a settled value. See DESIGN.md, Open questions. */
.measure { max-width: 74ch; }
