/* The Last Good Days — visual system.
 *
 * Spec §21: calm, grounded and adult. No rainbow gradients, no cartoon paws, no
 * clinical hospital styling, no sentimental stock imagery. Mobile-first, large
 * touch targets, scalable text, reduced-motion respected, nothing that autoplays.
 */

:root {
  --paper: #f7f5f2;
  --card: #fffdfb;
  --ink: #24201d;
  --ink-soft: #4a423b;
  --ink-quiet: #6f665e;
  --rule: #e2dbd2;
  --accent: #3c4a3e;      /* deep green, the only saturated color */
  --accent-ink: #fffdfb;
  --accent-soft: #eef0ec;
  --permission-bg: #f2eee8;
  --permission-rule: #b8aa96;
  --warn: #7a3b2e;
  --focus: #8a6d3b;
  --radius: 4px;
  --measure: 34rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #171513;
    --card: #201d1a;
    --ink: #ece7e0;
    --ink-soft: #c9c1b8;
    --ink-quiet: #9a9089;
    --rule: #35302b;
    --accent: #9fb59f;
    --accent-ink: #171513;
    --accent-soft: #262a26;
    --permission-bg: #262320;
    --permission-rule: #6b6154;
    --warn: #d99e8e;
    --focus: #d6b877;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html {
  font-size: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: Georgia, 'Iowan Old Style', 'Times New Roman', serif;
  font-size: 1.0625rem;
  line-height: 1.65;
}

main {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 1.5rem 1.25rem 5rem;
}

.wide { max-width: 60rem; }

h1, h2, h3 {
  font-weight: normal;
  line-height: 1.3;
  color: var(--ink);
  margin: 0 0 0.75rem;
}

h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; margin-top: 2rem; }
h3 { font-size: 1.05rem; margin-top: 1.5rem; }

p { margin: 0 0 1rem; color: var(--ink-soft); }
.lede { font-size: 1.15rem; color: var(--ink); }
.quiet { color: var(--ink-quiet); font-size: 0.95rem; }
.small { font-size: 0.9rem; }

a { color: var(--ink); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--accent); }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

hr { border: 0; border-top: 1px solid var(--rule); margin: 2rem 0; }

/* --- site chrome ------------------------------------------------------ */

.masthead {
  border-bottom: 1px solid var(--rule);
  background: var(--card);
}
.masthead-inner {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 0.85rem 1.25rem;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}
.masthead a { text-decoration: none; }
.wordmark { font-size: 1rem; letter-spacing: 0.02em; color: var(--ink); }
.masthead nav { font-size: 0.9rem; }
.masthead nav a { color: var(--ink-quiet); margin-left: 0.9rem; }

/* The death transition is reachable from every authenticated screen (§7.6).
   Present, never shouting. */
.persistent-exit {
  border-top: 1px solid var(--rule);
  margin-top: 3rem;
  padding-top: 1rem;
  font-size: 0.9rem;
  color: var(--ink-quiet);
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.1rem;
}
.persistent-exit a { color: var(--ink-quiet); }

/* --- cards and notes -------------------------------------------------- */

.card {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 1.5rem 1.25rem;
  margin: 0 0 1.25rem;
}

.note-action {
  font-size: 1.35rem;
  line-height: 1.35;
  margin: 0 0 1rem;
  color: var(--ink);
}

.note-reason { color: var(--ink-soft); }

.permission {
  background: var(--permission-bg);
  border-left: 3px solid var(--permission-rule);
  padding: 0.9rem 1rem;
  margin: 1.25rem 0 0;
  color: var(--ink-soft);
  font-size: 1rem;
}

.tip {
  color: var(--ink-quiet);
  font-size: 0.95rem;
  margin: 1rem 0 0;
}

.scope-note {
  font-size: 0.9rem;
  color: var(--ink-quiet);
  font-style: italic;
  margin-top: 1.25rem;
}

.eyebrow {
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-quiet);
  margin: 0 0 0.75rem;
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
}

/* --- controls --------------------------------------------------------- */

.button, button, input[type='submit'] {
  display: inline-block;
  font-family: inherit;
  font-size: 1.05rem;
  line-height: 1.3;
  padding: 0.85rem 1.4rem;
  min-height: 3rem;            /* large touch targets (§21) */
  border-radius: var(--radius);
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
  text-decoration: none;
  text-align: center;
  cursor: pointer;
}

.button.secondary, button.secondary {
  background: transparent;
  color: var(--ink);
  border-color: var(--rule);
}

.button.quiet, button.quiet {
  background: transparent;
  border-color: transparent;
  color: var(--ink-quiet);
  text-decoration: underline;
  padding-left: 0.25rem;
  padding-right: 0.25rem;
}

/* "That is enough for now" is the primary choice after any action (§6.10). */
.button.primary-rest {
  font-size: 1.15rem;
  padding: 1.05rem 1.5rem;
  width: 100%;
}

.button.danger {
  background: transparent;
  color: var(--warn);
  border-color: var(--warn);
}

.actions {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-top: 1.5rem;
}
.actions.row { flex-direction: row; flex-wrap: wrap; }

@media (min-width: 34rem) {
  .actions.wide-row { flex-direction: row; }
  .actions.wide-row > * { flex: 1; }
}

label { display: block; margin: 1.25rem 0 0.35rem; color: var(--ink); }
label .hint { display: block; color: var(--ink-quiet); font-size: 0.9rem; margin-top: 0.15rem; }

input[type='text'], input[type='email'], input[type='tel'], input[type='date'],
input[type='datetime-local'], input[type='file'], select, textarea {
  width: 100%;
  font-family: inherit;
  font-size: 1.05rem;
  padding: 0.75rem 0.8rem;
  min-height: 3rem;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
}
textarea { min-height: 8rem; line-height: 1.6; }

fieldset { border: 0; padding: 0; margin: 1.5rem 0 0; }
legend { padding: 0; margin-bottom: 0.5rem; color: var(--ink); font-size: 1.05rem; }

/* The whole row is the target, but the label is a real <label for> so screen
   readers announce the choice rather than the input's default value. */
.choice {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  padding: 0.85rem 0.9rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--card);
  margin-bottom: 0.5rem;
}
.choice input { margin-top: 0.3rem; width: 1.15rem; height: 1.15rem; flex: none; }
.choice label { display: block; margin: 0; flex: 1; cursor: pointer; min-height: 1.5rem; }
.choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.choice:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
.choice .label-text { color: var(--ink); }
.choice .label-hint { display: block; color: var(--ink-quiet); font-size: 0.9rem; }

/* Fields that only make sense once a particular option is chosen.
   Hidden by CSS rather than script so the form still works with JavaScript off,
   and only where :has() is supported — where it is not, the field stays visible
   and usable rather than becoming unreachable. */
@supports selector(:has(*)) {
  .conditional { display: none; }
  fieldset:has(.reveal-scheduled input:checked) ~ .conditional-scheduled { display: block; }
  fieldset:has(.reveal-on-date input:checked) ~ .conditional-on-date { display: block; }
}

/* --- messages --------------------------------------------------------- */

.message {
  border: 1px solid var(--rule);
  border-left: 3px solid var(--accent);
  background: var(--card);
  padding: 0.9rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1.25rem;
}
.message.warn { border-left-color: var(--warn); }

/* Hosted QA preview: present on every page, quiet enough to review UX around. */
.banner-preview {
  background: #2f3a45;
  color: #f2f4f6;
  padding: 0.5rem 1.25rem;
  font-size: 0.85rem;
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  text-align: center;
}
.banner-preview a { color: #f2f4f6; }

.banner-unreviewed {
  background: var(--warn);
  color: #fffdfb;
  padding: 0.5rem 1.25rem;
  font-size: 0.85rem;
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  text-align: center;
}

/* --- archive ---------------------------------------------------------- */

.views {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 1rem 0 1.5rem;
  padding: 0;
  list-style: none;
}
.views a {
  display: inline-block;
  padding: 0.5rem 0.8rem;
  border: 1px solid var(--rule);
  border-radius: 2rem;
  font-size: 0.9rem;
  text-decoration: none;
  color: var(--ink-soft);
  background: var(--card);
}
.views a[aria-current='true'] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.views .count { color: var(--ink-quiet); }
.views a[aria-current='true'] .count { color: var(--accent-ink); }

.asset-list { list-style: none; padding: 0; margin: 0; }
.asset {
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--card);
  padding: 1rem;
  margin-bottom: 0.75rem;
}
.asset-meta { color: var(--ink-quiet); font-size: 0.9rem; margin: 0.35rem 0 0; }
.asset img, .asset video { max-width: 100%; height: auto; border-radius: 2px; display: block; margin-bottom: 0.6rem; }
.asset audio { width: 100%; margin-bottom: 0.6rem; }
.asset blockquote { margin: 0 0 0.6rem; padding-left: 0.9rem; border-left: 2px solid var(--rule); color: var(--ink-soft); white-space: pre-wrap; }

table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
th, td { text-align: left; padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--rule); vertical-align: top; }
th { color: var(--ink-quiet); font-weight: normal; font-size: 0.85rem; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.9em; }

.progress { margin-top: 0.75rem; font-size: 0.9rem; color: var(--ink-quiet); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
