/* =========================================================================
   LEXICON — scaffold styling
   Deliberately restrained. This is not the visual direction for the game,
   it's a legible surface for testing the engine. The real design pass
   happens once the systems are locked.
   ========================================================================= */

:root {
  --plate:       #dfe3e4;   /* photographic plate, cold and pale */
  --plate-deep:  #cbd2d3;
  --ink:         #1b2224;
  --ink-soft:    #5a6669;
  --resolved:    #b07326;   /* the one warm colour: comprehension */
  --line:        #b3bcbe;

  --space:  1rem;
  --radius: 2px;

  --font-ui:   system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-data: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --plate:      #171b1c;
    --plate-deep: #0f1213;
    --ink:        #dfe3e4;
    --ink-soft:   #8b9698;
    --resolved:   #d99a45;
    --line:       #2e3739;
  }
}

* { box-sizing: border-box; }

/* iOS ignores user-scalable=no for accessibility reasons, so rapid taps on
   a button register as a double-tap-to-zoom gesture. touch-action tells
   Safari this element has no gesture behaviour to wait for — which also
   removes the 300ms tap delay. Applied to every interactive element, not
   just buttons, because the whole UI is tap-driven. */
button, .btn, [data-glyph], [data-producer], [data-meta] {
  touch-action: manipulation;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--plate);
  color: var(--ink);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
}

/* The strip and the nav are pinned; the plate scrolls between them.
   Padding on body reserves the space so content never hides under either. */
body {
  padding:
    calc(env(safe-area-inset-top) + 92px)
    calc(env(safe-area-inset-right) + var(--space))
    calc(env(safe-area-inset-bottom) + 76px)
    calc(env(safe-area-inset-left) + var(--space));
}

.plate {
  max-width: 32rem;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: var(--space);
}

/* --- header ------------------------------------------------------------ */

.plate__head { margin-bottom: 0.5rem; }

.eyebrow {
  font-family: var(--font-data);
  font-size: 0.6875rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 0 0 0.25rem;
}

h1 {
  font-size: 1.5rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  margin: 0;
}

h2 {
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin: 0;
}

/* --- panels ------------------------------------------------------------ */

.panel {
  background: var(--plate-deep);
  border-radius: var(--radius);
  padding: var(--space);
}

.panel__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.375rem;
}

.panel__note {
  font-size: 0.8125rem;
  color: var(--ink-soft);
  margin: 0 0 0.75rem;
}

.count {
  font-family: var(--font-data);
  font-size: 1.125rem;
  font-variant-numeric: tabular-nums;
}

.panel--return {
  border-left: 2px solid var(--resolved);
}

.panel--return p {
  margin: 0 0 0.75rem;
  font-size: 0.9375rem;
}

.panel--return strong {
  font-family: var(--font-data);
  color: var(--resolved);
}

/* --- buttons ----------------------------------------------------------- */

.btn {
  font-family: var(--font-ui);
  font-size: 0.9375rem;
  color: var(--ink);
  background: var(--plate);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  width: 100%;
  min-height: 44px;              /* Apple's minimum touch target */
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  transition: background 120ms ease, border-color 120ms ease;
  -webkit-tap-highlight-color: transparent;
}

.btn:hover:not(:disabled) { border-color: var(--ink-soft); }
.btn:active:not(:disabled) { background: var(--plate-deep); }

.btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.btn:focus-visible {
  outline: 2px solid var(--resolved);
  outline-offset: 2px;
}

.btn__cost {
  font-family: var(--font-data);
  font-size: 0.8125rem;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

.btn--quiet {
  width: auto;
  flex: 1;
  justify-content: center;
  padding: 0.625rem 0.75rem;
  font-size: 0.8125rem;
  background: transparent;
}

.btn--danger:hover { border-color: #a33; color: #a33; }

.tools {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

/* --- toast ------------------------------------------------------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 1.5rem);
  transform: translateX(-50%) translateY(0.5rem);
  background: var(--ink);
  color: var(--plate);
  font-family: var(--font-data);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.5rem 0.875rem;
  border-radius: var(--radius);
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease, transform 200ms ease;
}

.toast.is-visible {
  opacity: 0.92;
  transform: translateX(-50%) translateY(0);
}

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 0.01ms !important; }
}

/* =========================================================================
   ARCHIVE, LEXICON, CAPTURE
   -------------------------------------------------------------------------
   The one visual idea this game has: unresolved glyphs are voids, resolved
   ones are ink. The page physically fills in as the player learns. Every
   choice below serves that and nothing else.
   ========================================================================= */

.stack { display: flex; flex-direction: column; gap: 0.5rem; }

.empty {
  font-size: 0.8125rem;
  color: var(--ink-soft);
  font-style: italic;
  margin: 0;
  padding: 0.5rem 0;
}

/* --- capture bar -------------------------------------------------------- */

.bar {
  height: 2px;
  background: var(--line);
  margin-bottom: 0.75rem;
  overflow: hidden;
}

.bar__fill {
  height: 100%;
  background: var(--resolved);
  width: 0%;
  /* No transition. The bar is a clock, and a clock that eases is lying. */
}

/* --- fragments ---------------------------------------------------------- */

.frag {
  background: var(--plate);
  border-left: 2px solid var(--line);
  padding: 0.625rem 0.75rem;
}

.frag--clear { border-left-color: var(--resolved); }

.frag__meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.375rem;
  font-family: var(--font-data);
  font-size: 0.625rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.frag__tag {
  border: 1px solid var(--line);
  padding: 0 0.25rem;
}

.frag__count { margin-left: auto; }

.frag__text {
  margin: 0;
  font-size: 1rem;
  line-height: 1.7;
  /* Wide word spacing: these are discrete units, not flowing prose. */
  word-spacing: 0.15em;
}

/* Unresolved. Monospace, faded, letterspaced — deliberately unreadable
   as language, deliberately readable as a shape you'll recognise again. */
.unknown {
  font-family: var(--font-data);
  font-size: 0.8125em;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
  opacity: 0.55;
}

/* Resolved. Full ink, normal type. The contrast is the whole point. */
.known { color: var(--ink); }

.lit { color: var(--ink-soft); }

/* --- lexicon ------------------------------------------------------------ */

.glyph {
  background: var(--plate);
  padding: 0.625rem 0.75rem;
}

.glyph--done { border-left: 2px solid var(--resolved); }

.glyph__head {
  display: flex;
  align-items: baseline;
  gap: 0.625rem;
  margin-bottom: 0.375rem;
}

.glyph__form {
  font-family: var(--font-data);
  font-size: 0.875rem;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
}

.glyph__word {
  font-size: 1rem;
  color: var(--resolved);
}

.glyph__tier {
  margin-left: auto;
  font-family: var(--font-data);
  font-size: 0.625rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.glyph__note {
  margin: 0.25rem 0 0;
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--ink-soft);
}

.btn--glyph {
  padding: 0.5rem 0.625rem;
  min-height: 36px;
  font-size: 0.8125rem;
  justify-content: center;
}

.glyph__cost {
  font-family: var(--font-data);
  font-variant-numeric: tabular-nums;
  color: var(--ink-soft);
  margin-left: 0.375rem;
}

/* --- producer ladder ---------------------------------------------------- */

.prod {
  background: var(--plate);
  padding: 0.75rem;
  border-left: 2px solid var(--line);
}

.prod--owned { border-left-color: var(--resolved); }

.prod__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
}

.prod__name { font-size: 0.9375rem; }

.prod__count {
  font-family: var(--font-data);
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
  color: var(--ink-soft);
}

.prod__blurb {
  margin: 0.25rem 0 0.375rem;
  font-size: 0.8125rem;
  line-height: 1.45;
  color: var(--ink-soft);
}

.prod__rate {
  margin: 0 0 0.5rem;
  font-family: var(--font-data);
  font-size: 0.6875rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.btn--buy { min-height: 40px; padding: 0.5rem 0.75rem; }

.btn--secondary {
  margin-top: 0.5rem;
  background: transparent;
  justify-content: center;
  font-size: 0.875rem;
}

/* --- method / realign --------------------------------------------------- */

.panel--meta { border-top: 1px solid var(--resolved); }

.meta {
  background: var(--plate);
  padding: 0.75rem;
  border-left: 2px solid var(--line);
}

.meta--owned { border-left-color: var(--resolved); }

.meta__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
}

.meta__name { font-size: 0.9375rem; }

.meta__lvl {
  font-family: var(--font-data);
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
  color: var(--ink-soft);
}

.meta__blurb {
  margin: 0.25rem 0 0.25rem;
  font-size: 0.8125rem;
  line-height: 1.45;
  color: var(--ink-soft);
  font-style: italic;
}

.meta__effect {
  margin: 0 0 0.5rem;
  font-family: var(--font-data);
  font-size: 0.6875rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--resolved);
}

.meta__maxed {
  margin: 0;
  font-family: var(--font-data);
  font-size: 0.6875rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

/* The one destructive button in the game. Warm border, not red — this is
   a choice the player should want to make eventually, not a hazard. */
.btn--realign {
  margin-top: 0.75rem;
  border-color: var(--resolved);
  justify-content: center;
  gap: 0.5rem;
}

.btn--realign:hover:not(:disabled) { background: var(--plate-deep); }


/* =========================================================================
   PINNED STRIP
   -------------------------------------------------------------------------
   Always visible. Signal is what every tab spends, so hiding it behind a
   tab or a drawer would mean tabbing back and forth to check whether you
   can afford a glyph — the most frequent interaction in the game made two
   taps slower.
   ========================================================================= */

.strip {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 10;
  background: var(--plate-deep);
  border-bottom: 1px solid var(--line);
  padding:
    calc(env(safe-area-inset-top) + 0.5rem)
    calc(env(safe-area-inset-right) + var(--space))
    0.5rem
    calc(env(safe-area-inset-left) + var(--space));
}

.strip__main { display: flex; justify-content: space-between; align-items: baseline; }

.strip__label {
  font-family: var(--font-data);
  font-size: 0.625rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.strip__label--r { text-align: right; padding-left: 0.75rem; }

.strip__big {
  font-family: var(--font-data);
  font-size: 1.375rem;
  font-variant-numeric: tabular-nums;
}

.strip__cap {
  font-family: var(--font-data);
  font-size: 0.75rem;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

.strip__grid { width: 100%; border-collapse: collapse; margin-top: 0.25rem; }

.strip__val {
  font-family: var(--font-data);
  font-size: 0.6875rem;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

/* Hitting the cap is a state you must not miss mid-scroll — it means you
   are losing production. Bar and rate both go red. */
.strip__val.is-full { color: #c0504a; }

.bar--cap { margin: 0.375rem 0 0.125rem; }
.bar__fill.is-full { background: #c0504a; }

/* =========================================================================
   BOTTOM NAV
   ========================================================================= */

.nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 10;
  display: flex;
  background: var(--plate-deep);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}

.nav__item {
  flex: 1;
  background: none;
  border: none;
  border-top: 2px solid transparent;
  margin-top: -1px;
  padding: 0.75rem 0.25rem;
  min-height: 48px;
  color: var(--ink-soft);
  font-family: var(--font-ui);
  font-size: 0.75rem;
  cursor: pointer;
  position: relative;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.nav__item.is-on { color: var(--resolved); border-top-color: var(--resolved); }

.nav__dot {
  position: absolute;
  top: 0.5rem;
  left: 50%;
  margin-left: 1.75rem;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--resolved);
}

/* =========================================================================
   ARCHIVE BLOCKS
   ========================================================================= */

.blk {
  background: var(--plate);
  border-left: 2px solid var(--line);
  padding: 0.625rem 0.75rem;
}

.blk--done { border-left-color: var(--resolved); }

.blk__head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  margin: 0 0 0.5rem;
  font-family: var(--font-data);
  font-size: 0.625rem;
  font-weight: 400;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.blk--done .blk__head { color: var(--resolved); }

.blk__count { color: var(--ink-soft); }

.blk .frag__text { margin: 0 0 0.5rem; }
.blk .frag__text:last-child { margin-bottom: 0; }
