/* Bloomward — shared design tokens and base components.
   Quiet and botanical (brief §13): thin lines, pressed-plant palette, generous
   whitespace, never covering more of the world than it must.
   System fonts only — the game makes no network requests. */

:root {
  /* Paper & ink (sheets, journal) */
  --paper: #f3eee2;
  --paper-2: #ebe4d3;
  --paper-3: #e1d8c3;
  --ink: #2e2a22;
  --ink-2: #5a5243;
  --ink-3: #8a7f6a;
  --rule: #b9ab8c;
  --rule-soft: rgba(138, 127, 106, 0.28);

  /* Botanical accents (never the only carrier of meaning — shape/label too) */
  --moss: #5f7446;
  --sage: #8fa079;
  --ochre: #b9892f;
  --rust: #a2512d;
  --plum: #6e4a63;
  --sky: #4f7390;
  --honey: #d39a2a;

  /* Over-the-world HUD */
  --hud-ink: #f4eedf;
  --hud-ink-2: rgba(244, 238, 223, 0.84);
  --hud-ink-3: rgba(244, 238, 223, 0.64);
  --hud-rule: rgba(244, 238, 223, 0.32);
  --hud-scrim: rgba(24, 22, 17, 0.34);
  --hud-shadow: 0 1px 2px rgba(0, 0, 0, 0.75), 0 0 6px rgba(0, 0, 0, 0.45), 0 0 16px rgba(0, 0, 0, 0.3);
  /* a feathered shade behind text over the world, so it reads over bright sky, fog and snow */
  --hud-shade: rgba(12, 12, 9, 0.46);

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", "URW Palladio L", Georgia, serif;
  --sans: "Avenir Next", Avenir, "Segoe UI", "Helvetica Neue", "Noto Sans", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --ui-scale: 1;               /* settings: text size */
  --fs-xs: calc(11px * var(--ui-scale));
  --fs-s: calc(12.5px * var(--ui-scale));
  --fs-m: calc(14px * var(--ui-scale));
  --fs-l: calc(17px * var(--ui-scale));
  --fs-xl: calc(22px * var(--ui-scale));
  --fs-xxl: calc(32px * var(--ui-scale));

  --r: 3px;
  --ease: cubic-bezier(.22, .61, .36, 1);
  --t-fast: 180ms;
  --t-med: 420ms;
  --t-slow: 1200ms;
}

html.reduced-motion { --t-fast: 0ms; --t-med: 0ms; --t-slow: 0ms; }
@media (prefers-reduced-motion: reduce) { :root { --t-fast: 0ms; --t-med: 0ms; --t-slow: 0ms; } }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #10110d; color: var(--hud-ink); font-family: var(--sans); font-size: var(--fs-m); overflow: hidden; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
canvas#view { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; outline: none; touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
#ui { position: fixed; inset: 0; pointer-events: none; }
#ui > * { pointer-events: auto; }
#ui .passthrough { pointer-events: none; }
#ui .passthrough > * { pointer-events: auto; }

:focus-visible { outline: 1.5px solid var(--ochre); outline-offset: 2px; }

/* ---------- HUD primitives (over the world) ---------- */
.hud { color: var(--hud-ink); text-shadow: var(--hud-shadow); transition: opacity var(--t-slow) var(--ease); }
.hud.faded { opacity: 0; }
.hud-kicker { font-size: var(--fs-xs); letter-spacing: .14em; text-transform: uppercase; color: var(--hud-ink-2); }
.hud-title { font-family: var(--serif); font-size: var(--fs-l); font-weight: 400; letter-spacing: .01em; }
.hud-line { height: 1px; background: var(--hud-rule); border: 0; margin: 6px 0; }

.hbtn {
  appearance: none; background: transparent; border: 1px solid var(--hud-rule); border-radius: 999px;
  color: var(--hud-ink); padding: 5px 12px; cursor: pointer; font-size: var(--fs-s); letter-spacing: .02em;
  text-shadow: var(--hud-shadow); transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); background-color: rgba(24, 22, 17, 0.18);
}
.hbtn:hover { border-color: var(--hud-ink-2); background-color: rgba(24, 22, 17, 0.32); }
.hbtn[aria-pressed="true"], .hbtn.on { border-color: var(--hud-ink); background-color: rgba(244, 238, 223, 0.16); }
.hbtn.icon { width: 32px; height: 32px; padding: 0; display: inline-grid; place-items: center; }
.hbtn svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.3; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Sheets (paper panels) ---------- */
.sheet {
  background: var(--paper); color: var(--ink); font-family: var(--sans);
  border: 1px solid var(--rule); border-radius: var(--r);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35), 0 2px 6px rgba(0, 0, 0, 0.2);
  text-shadow: none;
  background-image:
    radial-gradient(ellipse at 20% 0%, rgba(255, 255, 255, 0.35), transparent 60%),
    radial-gradient(ellipse at 100% 100%, rgba(185, 137, 47, 0.07), transparent 55%);
}
.sheet h1, .sheet h2, .sheet h3 { font-family: var(--serif); font-weight: 400; color: var(--ink); margin: 0; }
.sheet h1 { font-size: var(--fs-xxl); letter-spacing: .005em; }
.sheet h2 { font-size: var(--fs-xl); }
.sheet h3 { font-size: var(--fs-l); }
.sheet p { line-height: 1.55; color: var(--ink-2); }
.sheet .kicker { font-size: var(--fs-xs); letter-spacing: .16em; text-transform: uppercase; color: var(--ink-3); }
.sheet .rule { height: 0; border: 0; border-top: 1px solid var(--rule); margin: 14px 0; }
.sheet .rule.soft { border-top-color: var(--rule-soft); }
.sheet .caption { font-size: var(--fs-s); color: var(--ink-3); font-style: italic; font-family: var(--serif); }
.sheet .num { font-variant-numeric: tabular-nums; }
.sheet a { color: var(--sky); }
.sheet ::selection { background: rgba(185, 137, 47, 0.3); }

.btn {
  appearance: none; background: transparent; border: 1px solid var(--rule); border-radius: 999px;
  color: var(--ink); padding: 6px 14px; cursor: pointer; font-size: var(--fs-s); letter-spacing: .02em;
  transition: background var(--t-fast), border-color var(--t-fast);
}
.btn:hover { background: var(--paper-2); border-color: var(--ink-3); }
.btn.primary { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.btn.primary:hover { background: #45402f; }
.btn[disabled] { opacity: .45; cursor: default; }
.btn.small { padding: 3px 10px; font-size: var(--fs-xs); }
.btn.quiet { border-color: transparent; }
.btn.quiet:hover { border-color: var(--rule-soft); }

.tabs { display: flex; gap: 18px; border-bottom: 1px solid var(--rule); }
.tabs button { appearance: none; background: none; border: 0; padding: 8px 0; cursor: pointer; color: var(--ink-3); font-family: var(--serif); font-size: var(--fs-m); border-bottom: 1.5px solid transparent; margin-bottom: -1px; }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--ink); }

.field { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center; margin: 10px 0; }
.field label { font-size: var(--fs-s); color: var(--ink-2); }
.field .hint { grid-column: 1 / -1; font-size: var(--fs-xs); color: var(--ink-3); }
.field output { font-variant-numeric: tabular-nums; font-size: var(--fs-s); color: var(--ink); min-width: 5.5em; text-align: right; }

input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 18px; background: transparent; grid-column: 1 / -1; }
input[type="range"]::-webkit-slider-runnable-track { height: 1px; background: var(--ink-3); }
input[type="range"]::-moz-range-track { height: 1px; background: var(--ink-3); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 12px; height: 12px; border-radius: 50%; background: var(--paper); border: 1.5px solid var(--ink); margin-top: -6px; }
input[type="range"]::-moz-range-thumb { width: 10px; height: 10px; border-radius: 50%; background: var(--paper); border: 1.5px solid var(--ink); }

input[type="text"], input[type="number"], select, textarea {
  background: var(--paper); border: 0; border-bottom: 1px solid var(--rule); padding: 4px 2px; color: var(--ink); border-radius: 0;
}
input[type="number"] { width: 6em; text-align: right; font-variant-numeric: tabular-nums; }

.seg { display: inline-flex; border: 1px solid var(--rule); border-radius: 999px; overflow: hidden; }
.seg button { appearance: none; background: none; border: 0; padding: 4px 12px; cursor: pointer; font-size: var(--fs-s); color: var(--ink-2); }
.seg button + button { border-left: 1px solid var(--rule); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }

.scroll { overflow: auto; scrollbar-width: thin; scrollbar-color: var(--rule) transparent; }

/* Modal layer for screens */
.modal-layer { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(12, 12, 9, 0.35); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); opacity: 0; transition: opacity var(--t-med) var(--ease); pointer-events: none; }
.modal-layer.open { opacity: 1; pointer-events: auto; }

.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
