/* Mondaytide
   Layout: the pool fills the left; a field notebook runs down the right.
   The water itself is always dark (it is a rock pool at dusk in both themes);
   the notebook around it follows the viewer's light or dark setting.
   DECISION (Claude): all colours, fonts and layout choices here are mine. */

:root {
  --paper: #edf2f0;      /* notebook ground: cool sea-mist */
  --card: #f8fbfa;       /* raised notebook surfaces */
  --ink: #13302c;        /* deep kelp text */
  --ink-2: #4b6863;      /* secondary text */
  --rule: #c7d6d1;       /* hairlines */
  --accent: #c93f68;     /* anemone: the tide and the release button only */
  --accent-ink: #ffffff;
  --algae: #3f9a63;
  --good: #2f7d57;
  --warn: #b0661a;
  --water-deep: #0a2427; /* pool colours are theme-independent on purpose */
  --water-mid: #12393b;
  --water-rim: #2b5552;

  --f-display: "Young Serif", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --f-body: "Recursive", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-hand: "Recursive", ui-sans-serif, system-ui, sans-serif; /* casual axis on */
  --f-data: "Recursive", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px;
  --r: 10px;
  --t-xs: 0.75rem; --t-sm: 0.8125rem; --t-md: 0.9375rem; --t-lg: 1.125rem; --t-xl: 1.5rem;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0c1716; --card: #122120; --ink: #dce8e4; --ink-2: #93aba5; --rule: #264440;
    --accent: #ee6f98; --accent-ink: #1a0810; --algae: #69c28c; --good: #6cc796; --warn: #e2a25c;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0c1716; --card: #122120; --ink: #dce8e4; --ink-2: #93aba5; --rule: #264440;
  --accent: #ee6f98; --accent-ink: #1a0810; --algae: #69c28c; --good: #6cc796; --warn: #e2a25c;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--f-body);
  font-size: var(--t-md);
  line-height: 1.5;
  font-variation-settings: "CASL" 0, "MONO" 0;
}
button, input, textarea, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.app {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  padding-inline: 16px;
  padding-block: 12px 16px;
  gap: 12px;
}

/* ------------------------------------------------------------ top bar */
.bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 24px;
}
.brand { display: flex; align-items: baseline; gap: 10px; }
.brand-mark { width: 32px; height: 20px; align-self: center; }
.brand-mark path { fill: none; stroke: var(--accent); stroke-width: 2.4; stroke-linecap: round; }
.wordmark { font-family: var(--f-display); font-size: 1.625rem; letter-spacing: -0.01em; line-height: 1; }
.proto-tag {
  font-size: var(--t-xs); text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-2);
  border: 1px solid var(--rule); border-radius: 999px; padding: 1px 8px;
}
.clock { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-inline-start: auto; }
.clock-day { font-family: var(--f-data); font-variation-settings: "MONO" 1; font-variant-numeric: tabular-nums; font-size: var(--t-sm); }
.clock-weekday { color: var(--ink-2); }
.clock-next { font-size: var(--t-sm); color: var(--ink-2); }
.gauge { width: 140px; height: 28px; }
.gauge-wave { fill: none; stroke: var(--ink-2); stroke-width: 1.5; opacity: 0.6; }
.gauge-monday { stroke: var(--accent); stroke-width: 2; }
.gauge-dot { fill: var(--accent); }

.controls { display: flex; flex-wrap: wrap; gap: 4px; }
.controls button {
  border: 1px solid var(--rule); background: var(--card); border-radius: 8px;
  padding: 4px 10px; font-size: var(--t-sm); cursor: pointer; min-width: 44px;
}
.controls button[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.controls .skip { margin-inline-start: 8px; border-style: dashed; }
/* DECISION (Claude), after the owner's feedback: writing to the director is
   the heart of the game, so it gets the one accent-coloured button in the bar. */
.controls .write {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--accent); color: var(--accent-ink); border-color: var(--accent);
  font-size: var(--t-md); font-weight: 650; padding: 9px 18px; border-radius: 12px;
  margin-inline-end: 12px;
  box-shadow: 0 2px 0 color-mix(in srgb, var(--accent) 45%, #000 55%);
}
.controls .write:hover { filter: brightness(1.06); }
.controls .write svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; }
/* Owner feedback: bigger still. On phones it takes a full row of its own. */
@media (max-width: 560px) { .controls { width: 100%; } .controls .write { flex: 1 0 100%; justify-content: center; margin-inline-end: 0; } }

/* ------------------------------------------------------------- stage */
.stage {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 380px);
  gap: 16px;
  min-height: 0;
}
@media (max-width: 860px) {
  .stage { grid-template-columns: minmax(0, 1fr); }
}

.pool-wrap { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.pool {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  max-width: 100%;
  border-radius: 22px;
  overflow: hidden;
  background: var(--water-deep);
  box-shadow: inset 0 0 0 3px var(--water-rim), 0 1px 0 var(--rule);
}
.pool canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: crosshair; touch-action: manipulation; }
.pool-hint {
  position: absolute; left: 50%; top: 14px; transform: translateX(-50%);
  background: rgba(8, 26, 28, 0.82); color: #e8f3ef; border: 1px solid rgba(255,255,255,0.18);
  padding: 6px 14px; border-radius: 999px; font-size: var(--t-sm); pointer-events: none; max-width: calc(100% - 24px); text-align: center;
}
.pool.placing { box-shadow: inset 0 0 0 3px var(--accent), 0 0 0 4px color-mix(in srgb, var(--accent) 35%, transparent); }
.pool.placing .pool-hint {
  top: 50%; transform: translate(-50%, -50%);
  background: var(--accent); color: var(--accent-ink); border-color: transparent;
  font-size: var(--t-md); font-weight: 600; padding: 8px 18px;
  animation: hint-fade 2.4s ease-in-out forwards;
}
/* The big centred hint fades after a moment so it doesn't hide the spot you want. */
@keyframes hint-fade { 0%, 60% { opacity: 1; } 100% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .pool.placing .pool-hint { animation: none; top: 14px; transform: translateX(-50%); } }
.busy {
  position: absolute; inset: 0; display: grid; place-items: center;
  background: rgba(6, 20, 22, 0.55); color: #e8f3ef; font-size: var(--t-md);
}

.inspector {
  position: absolute; left: 12px; bottom: 12px; width: min(300px, calc(100% - 24px));
  max-height: calc(100% - 24px); overflow: auto;
  background: rgba(8, 26, 28, 0.9); color: #e2eee9; border: 1px solid rgba(255,255,255,0.14);
  border-radius: 14px; padding: 12px 14px; font-size: var(--t-sm);
}
.inspector h3 { margin: 0 24px 2px 0; font-family: var(--f-display); font-weight: 400; font-size: var(--t-lg); line-height: 1.2; }
.inspector .sub { color: #9fb9b3; margin: 0 0 8px; }
.inspector-close {
  position: absolute; top: 6px; right: 8px; width: 28px; height: 28px; border: 0; border-radius: 8px;
  background: transparent; color: #e2eee9; font-size: 1.25rem; cursor: pointer;
}
.inspector dl { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; margin: 0 0 8px; }
.inspector dt { color: #9fb9b3; }
.inspector dd { margin: 0; font-variant-numeric: tabular-nums; }
.inspector ol { margin: 0; padding-inline-start: 18px; }
.meter { height: 6px; border-radius: 3px; background: rgba(255,255,255,0.12); overflow: hidden; margin-top: 5px; }
.meter > i { display: block; height: 100%; background: #7fd39f; }

.ticker { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; min-height: 4.5em; }
.ticker li {
  font-family: var(--f-hand); font-variation-settings: "CASL" 1; font-size: var(--t-sm); color: var(--ink-2);
  display: flex; gap: 10px; min-width: 0;
}
.ticker li:first-child { color: var(--ink); }
.ticker .when { font-family: var(--f-data); font-variation-settings: "MONO" 1, "CASL" 0; white-space: nowrap; font-variant-numeric: tabular-nums; }
.ticker .what { min-width: 0; overflow-wrap: anywhere; }

/* ---------------------------------------------------------- notebook */
.notebook {
  display: flex; flex-direction: column; min-width: 0; min-height: 0;
  border: 1px solid var(--rule); border-radius: 16px; background: var(--card);
}
@media (min-width: 861px) {
  .notebook { max-height: calc(100vh - 90px); position: sticky; top: env(safe-area-inset-top, 0px); }
}
.tabs { display: flex; border-bottom: 1px solid var(--rule); padding-inline: 8px; overflow-x: auto; }
.tabs button {
  position: relative; border: 0; background: none; padding: 12px 10px 10px; cursor: pointer; white-space: nowrap;
  color: var(--ink-2); border-bottom: 2px solid transparent; margin-bottom: -1px; font-size: var(--t-md);
}
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.tabs .dot { position: absolute; top: 10px; right: 2px; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.panel { padding: 16px; overflow-y: auto; min-height: 0; flex: 1; }
.notebook-foot {
  display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap;
  border-top: 1px solid var(--rule); padding: 8px 16px;
}

.note { font-size: var(--t-sm); color: var(--ink-2); margin: 0; }
.field-label { display: block; font-size: var(--t-xs); text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-2); margin-bottom: 4px; }
button.ghost {
  border: 1px solid var(--rule); background: transparent; border-radius: 8px; padding: 5px 10px;
  font-size: var(--t-sm); cursor: pointer;
}
button.ghost:hover { border-color: var(--ink-2); }
button.danger { color: var(--warn); }
input[type="range"] { width: 100%; accent-color: var(--accent); }
input:not([type]), textarea, select {
  background: var(--paper); border: 1px solid var(--rule); border-radius: 8px; padding: 6px 8px; min-width: 0;
}

/* ---------------------------------------------------------- builder */
.builder { display: flex; flex-direction: column; gap: 18px; }
.specimen { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 14px; align-items: center; }
#preview {
  width: 120px; height: 120px; border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, var(--water-mid), var(--water-deep));
  box-shadow: inset 0 0 0 2px var(--water-rim);
}
.specimen-fields { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.name-row { display: flex; gap: 6px; }
.name-row input { flex: 1; font-family: var(--f-display); font-size: var(--t-lg); padding: 4px 8px; }

.group { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.group legend {
  font-family: var(--f-display); font-size: var(--t-lg); padding: 0; margin-bottom: 6px;
  display: flex; width: 100%; align-items: baseline; justify-content: space-between;
}
.budget { font-family: var(--f-data); font-variation-settings: "MONO" 1; font-size: var(--t-sm); color: var(--ink-2); font-variant-numeric: tabular-nums; }
.budget.full { color: var(--accent); }

.diet { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.diet button {
  border: 1px solid var(--rule); background: var(--paper); border-radius: 10px; padding: 8px 6px;
  cursor: pointer; text-align: left; display: flex; flex-direction: column; gap: 2px; min-width: 0;
}
.diet button b { font-weight: 600; }
.diet button span { font-size: var(--t-xs); color: var(--ink-2); }
.diet button[aria-checked="true"] { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }

.traits { display: flex; flex-direction: column; gap: 10px; }
.trait { display: grid; grid-template-columns: 70px auto minmax(0, 1fr); gap: 4px 10px; align-items: center; }
.trait-name { font-weight: 600; }
.stepper { display: flex; align-items: center; gap: 6px; }
.stepper button {
  width: 28px; height: 28px; border-radius: 8px; border: 1px solid var(--rule); background: var(--paper); cursor: pointer; line-height: 1;
}
.stepper button:disabled { opacity: 0.35; cursor: default; }
.pips { display: flex; gap: 3px; }
.pips i { width: 9px; height: 14px; border-radius: 3px; border: 1px solid var(--ink-2); }
.pips i.on { background: var(--ink); border-color: var(--ink); }
.trait-note { grid-column: 2 / -1; font-size: var(--t-xs); color: var(--ink-2); }

.rules { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; counter-reset: rule; }
.rule {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 6px; align-items: center;
  background: var(--paper); border: 1px solid var(--rule); border-radius: 10px; padding: 6px 8px;
  counter-increment: rule;
}
.rule::before { content: counter(rule); font-family: var(--f-data); font-variation-settings: "MONO" 1; color: var(--ink-2); font-size: var(--t-sm); }
.rule-body { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; font-size: var(--t-sm); min-width: 0; }
.rule-body select { max-width: 100%; padding: 3px 4px; font-size: var(--t-sm); background: var(--card); }
.rule-tools { display: flex; gap: 2px; }
.rule-tools button { border: 0; background: none; cursor: pointer; color: var(--ink-2); width: 26px; height: 26px; border-radius: 6px; }
.rule-tools button:hover { background: var(--card); color: var(--ink); }

.errors { margin: 0; padding: 8px 12px 8px 28px; border-radius: 10px; background: var(--paper); color: var(--warn); font-size: var(--t-sm); }
.release {
  border: 0; border-radius: 12px; padding: 12px 16px; cursor: pointer;
  background: var(--accent); color: var(--accent-ink); font-weight: 650; font-size: var(--t-md);
}
.release:disabled { opacity: 0.5; cursor: default; }
.release.armed { background: var(--card); color: var(--accent); box-shadow: inset 0 0 0 2px var(--accent); }
.release-row { display: flex; gap: 8px; align-items: stretch; flex-wrap: wrap; }
.release-row .release { flex: 1 1 12em; }
.release-note:not(:empty) { color: var(--ink); background: var(--paper); border-radius: 8px; padding: 8px 10px; }

/* ------------------------------------------------------------ lines */
.records { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 16px; }
@media (max-width: 420px) { .records { grid-template-columns: minmax(0, 1fr); } }
.record { border: 1px solid var(--rule); border-radius: 10px; padding: 8px 10px; min-width: 0; }
.record h4 { margin: 0 0 4px; font-size: var(--t-xs); text-transform: uppercase; letter-spacing: 0.07em; color: var(--ink-2); font-weight: 500; }
.record .who { font-family: var(--f-display); font-size: var(--t-md); overflow-wrap: anywhere; line-height: 1.25; }
.record .val { font-size: var(--t-xs); color: var(--ink-2); overflow-wrap: anywhere; }

.lines { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.line { border-top: 1px solid var(--rule); }
.line:first-child { border-top: 0; }
.line-head {
  width: 100%; border: 0; background: none; cursor: pointer; text-align: left; padding: 10px 2px;
  display: grid; grid-template-columns: 14px minmax(0, 1fr) auto; gap: 4px 10px; align-items: center;
}
.swatch { width: 12px; height: 12px; border-radius: 50%; }
.line-name { font-family: var(--f-display); font-size: var(--t-md); overflow-wrap: anywhere; }
.line-name .owner { font-family: var(--f-body); font-size: var(--t-xs); color: var(--ink-2); margin-inline-start: 6px; text-transform: uppercase; letter-spacing: 0.06em; }
.line-name .owner.you { color: var(--accent); }
.line-count { font-family: var(--f-data); font-variation-settings: "MONO" 1; font-variant-numeric: tabular-nums; font-size: var(--t-sm); text-align: right; }
.line-niche { grid-column: 2 / 3; font-size: var(--t-xs); color: var(--ink-2); }
.spark { grid-column: 3 / 4; width: 84px; height: 22px; }
.spark path.l { fill: none; stroke-width: 1.5; }
.spark path.a { opacity: 0.18; }
.line.gone .line-name, .line.gone .line-count { color: var(--ink-2); }
.line-detail { padding: 0 2px 14px 24px; display: flex; flex-direction: column; gap: 10px; }
.story { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.story li { font-family: var(--f-hand); font-variation-settings: "CASL" 1; font-size: var(--t-sm); display: grid; grid-template-columns: 3.4em minmax(0, 1fr); gap: 8px; }
.story .d { font-family: var(--f-data); font-variation-settings: "MONO" 1, "CASL" 0; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.branches { font-size: var(--t-sm); margin: 0; padding-inline-start: 18px; }
.branches .gone { color: var(--ink-2); text-decoration: line-through; }
.subhead { font-size: var(--t-xs); text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-2); margin: 0; }
.design-summary { font-size: var(--t-sm); margin: 0; }

/* ------------------------------------------------ tide notes, journal */
.forecast {
  border: 1px dashed var(--accent); border-radius: 12px; padding: 10px 12px; margin-bottom: 16px;
}
.forecast:empty { display: none; }
.forecast .when { font-family: var(--f-data); font-variation-settings: "MONO" 1; font-size: var(--t-xs); color: var(--accent); text-transform: uppercase; letter-spacing: 0.06em; }
.forecast p { margin: 4px 0 0; font-family: var(--f-hand); font-variation-settings: "CASL" 1; }

.doc { padding-bottom: 20px; margin-bottom: 20px; border-bottom: 1px solid var(--rule); max-width: 65ch; }
.doc:last-child { border-bottom: 0; }
.doc h1, .doc h2, .doc h3 { font-family: var(--f-display); font-weight: 400; line-height: 1.2; text-wrap: balance; margin: 0.9em 0 0.35em; }
.doc h1 { font-size: var(--t-xl); margin-top: 0; }
.doc h2 { font-size: var(--t-lg); }
.doc h3 { font-size: var(--t-md); }
.doc p, .doc li { font-size: var(--t-md); }
.doc p { margin: 0 0 0.7em; }
.doc ul, .doc ol { margin: 0 0 0.7em; padding-inline-start: 20px; }
.doc blockquote {
  margin: 0 0 0.8em; padding: 6px 12px; border-inline-start: 3px solid var(--accent);
  font-family: var(--f-hand); font-variation-settings: "CASL" 1; background: var(--paper); border-radius: 0 8px 8px 0;
}
.doc blockquote p:last-child { margin: 0; }
.doc .meta { font-family: var(--f-data); font-variation-settings: "MONO" 1; font-size: var(--t-xs); color: var(--ink-2); text-transform: uppercase; letter-spacing: 0.06em; }
.doc code { font-family: var(--f-data); font-variation-settings: "MONO" 1; font-size: 0.9em; }
.doc hr { border: 0; border-top: 1px solid var(--rule); margin: 1em 0; }

.letter {
  margin-bottom: 20px; display: flex; flex-direction: column; gap: 8px;
  border: 1px solid var(--rule); border-radius: 12px; padding: 12px; background: var(--paper);
}
.letter-title { font-family: var(--f-display); font-size: var(--t-lg); }
.letter textarea { background: var(--card); }
.letter .send { border: 0; border-radius: 8px; padding: 6px 14px; background: var(--accent); color: var(--accent-ink); font-weight: 600; cursor: pointer; }
.letter textarea { width: 100%; resize: vertical; }
.letter-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.letter-row .note { flex: 1; min-width: 12em; }
.letters { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.letters li { font-size: var(--t-sm); background: var(--paper); border-radius: 8px; padding: 6px 10px; overflow-wrap: anywhere; font-family: var(--f-hand); font-variation-settings: "CASL" 1; }

/* -------------------------------------------------------------- toast */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  background: var(--ink); color: var(--paper); padding: 8px 16px; border-radius: 999px;
  font-size: var(--t-sm); max-width: calc(100% - 32px); text-align: center; z-index: 5;
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
}

/* ------------------------------------------------------------ about page */
.about { max-width: 70ch; margin-inline: auto; padding-block: 24px 48px; padding-inline: 16px; }
.about a { color: var(--accent); }
.notebook-foot a { color: var(--ink-2); font-size: var(--t-sm); }
