/*
 * KinetiBloom — Stage 2 validation prototype.
 * Original styling. No third-party CSS, no web fonts, no external requests.
 *
 * Accessibility commitments encoded here (§9, WCAG 2.2 AA target):
 *   - Interactive targets are at least 44x44 CSS px.
 *   - Focus is always visible, and never removed without a replacement.
 *   - Text scales through a user setting as well as browser zoom.
 *   - A high-contrast palette is available independent of the OS setting.
 *   - Reduced motion removes decoration, never information.
 */

:root {
  --bg: #080c0a;
  --surface: rgba(255, 255, 255, 0.045);
  --surface-2: rgba(255, 255, 255, 0.08);
  --ink: #eaf2ec;
  --ink-soft: #9db0a4;
  --line: rgba(255, 255, 255, 0.13);
  --line-2: rgba(255, 255, 255, 0.22);
  --accent: #f0be4d;
  --accent-ink: #17130a;
  --green: #7fd4a8;
  --focus: #8fd4ff;
  --warn-bg: rgba(240, 190, 77, 0.08);
  --warn-line: rgba(240, 190, 77, 0.34);
  --radius: 14px;
  --tap: 46px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --fs: 16px;
}

/* Explicit high-contrast mode, and the OS-level request for one. */
body[data-contrast="true"] {
  --bg: #000000;
  --surface: #05080b;
  --surface-2: #0d1218;
  --ink: #ffffff;
  --ink-soft: #e2e8ec;
  --line: #ffffff;
  --line-2: #ffffff;
  --accent: #ffd166;
  --accent-ink: #000000;
  --focus: #7CFFB2;
  --warn-bg: #0d1218;
  --warn-line: #ffd166;
}

body[data-text-size="large"] { --fs: 18.5px; }
body[data-text-size="xlarge"] { --fs: 21px; }

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--fs);
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
}

/* Focus is never removed. Two rings so it survives any background. */
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 4px;
}

a { color: var(--green); }
.brand a { color: var(--ink); text-decoration: none; }
body[data-contrast="true"] a { color: var(--accent); text-decoration: underline; }

h1, h2, h3 { line-height: 1.25; margin: 0 0 0.5em; }
h1 { font-size: 1.9rem; letter-spacing: -0.01em; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 1em; }

.wrap { max-width: 60rem; margin: 0 auto; padding: 1.5rem 1.15rem 4rem; }
.narrow { max-width: 44rem; }

.skip {
  position: absolute; left: -9999px;
  background: var(--accent); color: var(--accent-ink);
  padding: 0.75rem 1rem; border-radius: var(--radius); z-index: 100;
}
.skip:focus { left: 1rem; top: 1rem; }

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

.masthead { border-bottom: 1px solid var(--line); background: rgba(255,255,255,0.03); backdrop-filter: blur(12px); position: sticky; top: 0; z-index: 20; }
.masthead .wrap { padding-block: 1rem; display: flex; flex-wrap: wrap; gap: 0.75rem 1.25rem; align-items: baseline; }
.brand { font-weight: 800; font-size: 1.15rem; letter-spacing: -0.01em; margin: 0; }
.tagline { color: var(--ink-soft); margin: 0; font-size: 0.95rem; }
.masthead nav { margin-left: auto; display: flex; gap: 0.5rem; }

/* ---------- honest status banner ---------- */

.notice {
  background: var(--warn-bg);
  border: 1px solid var(--warn-line);
  border-radius: var(--radius);
  padding: 0.9rem 1.1rem;
  margin: 0 0 1.75rem;
}
.notice p:last-child { margin-bottom: 0; }
.notice strong { display: block; margin-bottom: 0.2rem; }

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

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: var(--tap); min-width: var(--tap);
  padding: 0.5rem 1.1rem;
  font: inherit; font-weight: 600;
  color: var(--ink); background: var(--surface);
  border: 1px solid var(--line-2); border-radius: 999px;
  cursor: pointer;
  transition: transform 140ms ease, background 140ms ease, border-color 140ms ease;
}
.btn:hover:not(:disabled) { background: var(--surface-2); border-color: var(--ink-soft); transform: translateY(-1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn--primary {
  background: linear-gradient(180deg, #ffd571, var(--accent));
  color: var(--accent-ink); border-color: transparent; font-weight: 700;
  box-shadow: 0 8px 24px -12px rgba(240, 190, 77, 0.8);
}
.btn[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn--big { font-size: 1.05rem; padding: 0.8rem 1.6rem; }

/* ---------- landing page ---------- */

.hero { padding: 2.5rem 0 1rem; }
.hero p.lead { font-size: 1.15rem; color: var(--ink-soft); max-width: 38rem; }
.cta { display: flex; flex-wrap: wrap; gap: 0.75rem; margin: 1.5rem 0 0; }

.shots { display: grid; gap: 1.25rem; grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr)); margin: 2rem 0; }
.shot { margin: 0; }
.shot canvas {
  width: 100%; aspect-ratio: 8 / 5; display: block;
  background: var(--surface-2);
  border: 1px solid var(--line); border-radius: var(--radius);
}
.shot figcaption { color: var(--ink-soft); font-size: 0.9rem; margin-top: 0.5rem; }

.cols { display: grid; gap: 1.5rem 2.5rem; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); }
.cols ul { margin: 0; padding-left: 1.2rem; }
.cols li { margin-bottom: 0.4rem; }

/* ---------- play page ---------- */

.stage { display: grid; gap: 1rem; grid-template-columns: minmax(0, 1fr); }

#garden {
  width: 100%; aspect-ratio: 8 / 5; display: block;
  background: #0d1411;
  border: 1px solid var(--line); border-radius: 18px;
  touch-action: none;                 /* we handle drag ourselves */
  cursor: crosshair;
}
#garden:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }

.controls { display: flex; flex-wrap: wrap; gap: 0.6rem; }

.hud {
  display: flex; flex-wrap: wrap; gap: 0.5rem 1.5rem;
  padding: 0.9rem 1.15rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px;
}
.hud div { display: flex; gap: 0.4rem; align-items: baseline; }
.hud dt, .hud .k { color: var(--ink-soft); font-size: 0.9rem; }
.hud .v { font-weight: 700; font-variant-numeric: tabular-nums; }

/* Goal meter. Width conveys progress; the adjacent number conveys it in text,
   so the information is never carried by the bar alone. */
.meter {
  --fill: 0%;
  position: relative; height: 12px; flex: 1 1 8rem; min-width: 8rem;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px;
  overflow: hidden; align-self: center;
}
.meter::after {
  content: ""; position: absolute; inset: 0 auto 0 0;
  width: var(--fill); background: var(--accent);
}

.help { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 1.15rem 1.3rem; }
.help ul { margin: 0.4rem 0 0; padding-left: 1.2rem; }
.help kbd {
  font: inherit; font-size: 0.87em; font-weight: 700;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 4px; padding: 0.05em 0.4em;
}

/* ---------- dialogs ---------- */

dialog {
  border: 1px solid var(--line); border-radius: 20px;
  background: var(--surface); color: var(--ink);
  padding: 1.5rem; max-width: min(34rem, 92vw); width: 100%;
}
dialog::backdrop { background: rgba(0, 0, 0, 0.72); backdrop-filter: blur(3px); }
.dialog-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 1.25rem; }

fieldset { border: 1px solid var(--line); border-radius: var(--radius); margin: 0 0 1rem; padding: 0.9rem 1rem; }
legend { font-weight: 600; padding: 0 0.35rem; }

.field { display: flex; align-items: center; gap: 0.65rem; min-height: var(--tap); }
.field label { flex: 1; }
.field input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--accent); }
.field select, .form textarea, .form input[type="text"] {
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1.5px solid var(--line); border-radius: 6px;
  padding: 0.45rem 0.6rem; min-height: var(--tap);
}
.form textarea { width: 100%; min-height: 6.5rem; resize: vertical; }
.radios { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.radios label {
  display: inline-flex; align-items: center; gap: 0.45rem;
  min-height: var(--tap); padding: 0 0.9rem;
  border: 1.5px solid var(--line); border-radius: var(--radius); cursor: pointer;
}
.radios input { width: 20px; height: 20px; accent-color: var(--accent); }
.radios label:has(input:checked) { border-color: var(--accent); background: var(--surface-2); }

.muted { color: var(--ink-soft); font-size: 0.9rem; }

/* ---------- utility ---------- */

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

footer.site { border-top: 1px solid var(--line); margin-top: 3rem; }
footer.site .wrap { padding-block: 1.5rem; }

/* Honour both the OS setting and our own toggle. Decoration only —
   the simulation is never altered, because that would change outcomes. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
body[data-motion="reduce"] *, body[data-motion="reduce"] *::before {
  animation-duration: 0.001ms !important;
  transition-duration: 0.001ms !important;
}
