/* castawayai.com -- hand-written CSS, no build step. */

/* --- Custom Properties (Light Mode) --- */
:root {
  --color-bg: #f6f4ef;
  --color-surface: #ffffff;
  --color-text: #1a1a17;
  --color-text-muted: #6b6b63;
  --color-border: #ddd8cc;
  --color-primary: #1f6f6b;      /* lagoon teal */
  --color-primary-hover: #175450;
  --color-accent: #a5541c;       /* sunburnt ochre */
  --color-danger: #b3261e;
  --color-on-primary: #ffffff;   /* text drawn ON a primary-filled surface */
  --color-field-border: #807b6e; /* see the note below -- not --color-border */
  --max-width: 42rem;
  --font-serif: Georgia, "Times New Roman", serif;
  --font-sans: system-ui, -apple-system, sans-serif;
}

/* --- Dark Mode Overrides --- */
@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #14171a;
    --color-surface: #1c2126;
    --color-text: #e9e6df;
    --color-text-muted: #9aa0a6;
    --color-border: #2c333a;
    --color-primary: #3fb0aa;
    --color-primary-hover: #6fd0cb;
    --color-accent: #e0894f;
    --color-danger: #f08a86;
    /* The dark-mode teal is a LIGHT fill. White on it is 2.6:1 -- it needs dark
       ink, not light. Never hardcode #fff on a primary background. */
    --color-on-primary: #14171a;
    --color-field-border: #767f88;
  }
}

/* --- A note on the two border tokens (WCAG 1.4.11, non-text contrast) ---
   --color-border is a hairline for decorative rules: table lines, card edges,
   section dividers. It is deliberately faint (1.3:1) and that is fine, because
   nothing is lost if it goes unnoticed.
   --color-field-border is for the boundary of anything a user operates -- text
   inputs, selects, textareas, bordered buttons. Those are user-interface
   components, so their boundary must clear 3:1 against BOTH the fill inside and
   the surface behind, or the control is invisible to low-vision users. Do not
   collapse these two tokens back into one: darkening every hairline to 3:1
   turns the page into a grid, and lightening the field borders hides the forms.
   ------------------------------------------------------------------------- */

/* --- Base Reset --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font-sans);
  background-color: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

a { color: var(--color-primary); }
a:hover { color: var(--color-primary-hover); }

main { flex: 1; display: flex; flex-direction: column; }
.container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 2rem 1.25rem;
  flex: 1;
}

/* --- Header / Footer --- */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface);
}
.brand { font-weight: 700; font-size: 1.25rem; text-decoration: none; color: var(--color-text); }
.brand span { color: var(--color-accent); }
.site-header nav { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.site-header nav a { text-decoration: none; font-weight: 600; }
.nav-logout { margin: 0; }
/* Render a POST logout button as a plain nav link (no browser button chrome). */
.linklike {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-weight: 600;
  color: var(--color-primary);
  cursor: pointer;
}
.linklike:hover { color: var(--color-primary-hover); }

.site-footer {
  border-top: 1px solid var(--color-border);
  padding: 1.5rem 1.25rem;
  text-align: center;
  font-size: 0.9rem;
  color: var(--color-text-muted);
}
.muted { color: var(--color-text-muted); }

/* --- Hero (full-width dramatic island backdrop) --- */
.hero {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: clamp(440px, 72vh, 760px);
  text-align: center;
  color: #f5f2ea;
  padding: 4rem 1.25rem;
  background:
    linear-gradient(180deg, rgba(11,15,19,0.30) 0%, rgba(11,15,19,0.55) 58%, rgba(11,15,19,0.82) 100%),
    url("../images/hero-island.72a0d5082969.jpg") center 44% / cover no-repeat;
  border-bottom: 1px solid var(--color-border);
}
.hero > * { max-width: 46rem; margin-left: auto; margin-right: auto; }
.hero h1 {
  font-family: var(--font-serif);
  font-size: 2.4rem;
  line-height: 1.15;
  margin-bottom: 1rem;
  color: #fff;
  text-shadow: 0 2px 14px rgba(0,0,0,0.55);
}
.hero .lede {
  font-size: 1.2rem;
  color: #efeae0;
  margin-bottom: 1.5rem;
  text-shadow: 0 1px 10px rgba(0,0,0,0.5);
}
.hero .muted { color: #e3ded4; }
.hero .ai-badge { background: rgba(0,0,0,0.34); border-color: rgba(255,255,255,0.45); color: #fff; }

/* The signup/waitlist card is a LIGHT surface sitting inside the dark hero, so
   it must opt back out of the hero's near-white type -- otherwise its heading
   inherits #f5f2ea onto a white card at 1.1:1 and the copy at 1.3:1, i.e.
   invisible. The card owns its own background, so it owns its own foreground.
   This applies to the HTMX success swap too (_waitlist_done.html), which is all
   heading and body copy and would otherwise vanish the moment the form is
   submitted. Any future light-on-dark card inside .hero needs the same reset. */
.hero .newsletter-signup { color: var(--color-text); }
.hero .newsletter-signup .muted { color: var(--color-text-muted); }
.hero .button-secondary { color: #fff; border-color: rgba(255,255,255,0.75); background: rgba(0,0,0,0.22); }
.hero .button-secondary:hover { background: rgba(0,0,0,0.42); color: #fff; }

@media (max-width: 40rem) {
  .hero { min-height: clamp(420px, 70vh, 640px); padding: 3rem 1rem; background-position: center 45%; }
  .hero h1 { font-size: 1.95rem; }
  .hero .lede { font-size: 1.08rem; }
}

/* --- Compact hero banner (content pages: about, privacy, terms, chronicle,
       auth, newsletter, beta) -- an island backdrop behind the page title. --- */
.hero-banner {
  position: relative;
  min-height: clamp(190px, 30vh, 320px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  text-align: center;
  color: #f5f2ea;
  padding: 2.5rem 1.25rem;
  border-bottom: 1px solid var(--color-border);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}
.hero-banner.entry-hero { min-height: clamp(280px, 46vh, 520px); }
.hero-eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.8rem;
  color: #f2d9be;
  margin-bottom: 0.4rem;
  text-shadow: 0 1px 6px rgba(0,0,0,0.55);
  font-family: var(--font-sans);
}
.hero-banner h1 {
  font-family: var(--font-serif);
  font-size: 2rem;
  line-height: 1.15;
  margin: 0 auto;
  max-width: 44rem;
  color: #fff;
  text-shadow: 0 2px 12px rgba(0,0,0,0.55);
}
.hero-banner p {
  max-width: 42rem;
  margin: 0.5rem auto 0;
  color: #efeae0;
  text-shadow: 0 1px 8px rgba(0,0,0,0.5);
}
.hero-banner.bg-front { background: linear-gradient(180deg, rgba(11,15,19,0.36), rgba(11,15,19,0.64)), url("../images/hero-island.72a0d5082969.jpg") center 42% / cover no-repeat; }
.hero-banner.bg-lagoon { background: linear-gradient(180deg, rgba(11,15,19,0.36), rgba(11,15,19,0.64)), url("../images/island-lagoon.2263b463ef1c.jpg") center 48% / cover no-repeat; }
.hero-banner.bg-threequarter { background: linear-gradient(180deg, rgba(11,15,19,0.36), rgba(11,15,19,0.64)), url("../images/island-threequarter.33ded2a43b86.jpg") center 52% / cover no-repeat; }
.hero-banner.bg-low { background: linear-gradient(180deg, rgba(11,15,19,0.34), rgba(11,15,19,0.62)), url("../images/island-low.1e987bcb27da.jpg") center 46% / cover no-repeat; }
.hero-banner.bg-ridge { background: linear-gradient(180deg, rgba(11,15,19,0.36), rgba(11,15,19,0.64)), url("../images/island-ridge.75fcb2188dd1.jpg") center 40% / cover no-repeat; }
@media (max-width: 40rem) {
  .hero-banner { min-height: clamp(160px, 26vh, 240px); padding: 2rem 1rem; }
  .hero-banner h1 { font-size: 1.6rem; }
}

.button {
  display: inline-block;
  background: var(--color-primary);
  color: var(--color-on-primary);
  padding: 0.6rem 1.4rem;
  border-radius: 6px;
  text-decoration: none;
  font-weight: 600;
}
.button:hover { background: var(--color-primary-hover); color: var(--color-on-primary); }

/* Focus ring. Once field borders are styled by hand it is easy to lose the UA
   default, so state it: 3:1 against the adjacent surface, offset so it reads on
   filled buttons too (WCAG 2.4.7). :focus-visible keeps it off mouse clicks. */
:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}
.hero :focus-visible { outline-color: #fff; }
/* ...but not inside the light card, where a white ring would disappear. */
.hero .newsletter-signup :focus-visible { outline-color: var(--color-primary); }

/* --- Prose / Entry --- */
.prose { font-family: var(--font-serif); font-size: 1.1rem; }
.prose h1 { font-size: 1.9rem; margin-bottom: 1rem; line-height: 1.2; }
.prose h2 { font-size: 1.3rem; margin: 1.5rem 0 0.5rem; }
.prose p { margin-bottom: 1rem; }
.prose ul { margin: 0 0 1rem 1.25rem; }

.entry .day-number {
  font-family: var(--font-sans);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.8rem;
  color: var(--color-accent);
  margin-bottom: 0.25rem;
}
.event-note { font-family: var(--font-sans); font-size: 0.9rem; border-left: 3px solid var(--color-accent); padding-left: 0.75rem; }

.entry-illustration { margin: 0 0 1.5rem; }
.entry-illustration img {
  width: 100%;
  height: auto;
  border-radius: 0.5rem;
  border: 1px solid var(--color-border);
}
.entry-illustration figcaption {
  font-family: var(--font-sans);
  font-size: 0.8rem;
  text-align: center;
  margin-top: 0.4rem;
}

.entry-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--color-border);
  font-family: var(--font-sans);
}

/* --- The Castaway's Kit (affiliate block under an entry) ---
   Deliberately quiet: a bordered footnote in the sans face, so it reads as an
   appendix to the day rather than a storefront interrupting it. The disclosure
   line is muted but never below the body's contrast floor -- it is the part a
   reader is entitled to see. */
.kit {
  margin-top: 2.5rem;
  padding: 1.1rem 1.25rem;
  border: 1px solid var(--color-border);
  border-radius: 0.5rem;
  background: var(--color-surface);
  font-family: var(--font-sans);
}
.kit h2 {
  font-family: var(--font-sans);
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--color-accent);
  margin: 0 0 0.4rem;
}
.kit-disclosure {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin: 0 0 0.75rem;
}
.kit-items { list-style: none; margin: 0; padding: 0; }
.kit-items li {
  padding: 0.35rem 0;
  font-size: 0.95rem;
}
.kit-items li + li { border-top: 1px solid var(--color-border); }
.kit-items a { color: var(--color-primary); font-weight: 600; }
.kit-note {
  display: block;
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

/* --- Chronicle index --- */
.entry-index { list-style: none; }
.entry-index li { border-bottom: 1px solid var(--color-border); }
.entry-index a { display: flex; gap: 0.75rem; padding: 0.75rem 0; text-decoration: none; }
.entry-index .day { color: var(--color-accent); font-weight: 600; min-width: 4.5rem; }
.entry-index .entry-title { color: var(--color-text); }

/* --- Newsletter signup --- */
.newsletter-signup {
  font-family: var(--font-sans);
  border: 1px solid var(--color-border);
  border-radius: 0.5rem;
  padding: 1.25rem;
  margin-bottom: 1.5rem;
  text-align: center;
  background: var(--color-surface);
}
.newsletter-signup h3 { margin-bottom: 0.25rem; }
.newsletter-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  margin-top: 0.75rem;
}
.newsletter-form input[type="email"],
.newsletter-form input[type="tel"] {
  flex: 1 1 16rem;
  max-width: 22rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--color-field-border);
  border-radius: 0.375rem;
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 1rem;
}
.newsletter-form button {
  padding: 0.5rem 1.25rem;
  border: none;
  border-radius: 0.375rem;
  background: var(--color-primary);
  color: var(--color-on-primary);
  font-weight: 600;
  cursor: pointer;
}
.newsletter-form button:hover { background: var(--color-primary-hover); color: var(--color-on-primary); }
/* Set the placeholder explicitly: the browser default is ~4.4:1 in Chrome and
   lighter still in some engines. The aria-label carries the real label. */
.newsletter-form input::placeholder,
.auth-form input::placeholder { color: var(--color-text-muted); opacity: 1; }
/* Honeypot: hidden from real users, tempting to bots. */
.hp-field {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}
.form-error { color: var(--color-danger); font-size: 0.9rem; margin-top: 0.5rem; }

/* --- Footer links --- */
.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: center;
  margin: 0.75rem 0;
}
.footer-links a { text-decoration: none; }

/* --- Landing page --- */
.ai-badge {
  display: inline-block;
  font-family: var(--font-sans);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.75rem;
  color: var(--color-accent);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  padding: 0.3rem 0.9rem;
  margin-bottom: 1rem;
}
.hero-cta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: center;
  margin-bottom: 0.5rem;
}
.button-secondary {
  background: transparent;
  color: var(--color-primary);
  border: 1px solid var(--color-primary);
}
.button-secondary:hover { background: var(--color-surface); color: var(--color-primary-hover); }

.featured h2,
.recent h2 { font-family: var(--font-serif); font-size: 1.4rem; margin-bottom: 1rem; }

.featured {
  margin: 2.5rem 0;
  padding: 1.5rem;
  border: 1px solid var(--color-border);
  border-radius: 0.5rem;
  background: var(--color-surface);
}
.featured h2 { margin: 0.25rem 0 0.75rem; }
.featured h2 a { text-decoration: none; color: var(--color-text); }
.featured-excerpt { font-family: var(--font-serif); color: var(--color-text-muted); margin-bottom: 0.75rem; }

.recent { margin: 2.5rem 0; }

/* --- Auth forms (login / register / beta accept) --- */
.auth-page { max-width: 26rem; }
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  margin: 1.25rem 0;
  font-family: var(--font-sans);
}
.auth-form label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.9rem;
  color: var(--color-text-muted);
}
.auth-form input {
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--color-field-border);
  border-radius: 0.375rem;
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 1rem;
  font-family: var(--font-sans);
}
.auth-form input[readonly] { opacity: 0.65; cursor: not-allowed; }
.auth-form button { align-self: flex-start; cursor: pointer; border: none; }
.auth-note { font-size: 0.82rem; color: var(--color-text-muted); margin-top: 0.25rem; }

/* --- Episode narration (play-on-demand AI TTS) --- */
.narration { margin: 0 0 1.5rem; }
.narration summary {
  cursor: pointer; display: inline-block; font-weight: 600;
  padding: 0.5rem 1rem; border: 1px solid var(--color-field-border);
  border-radius: 0.5rem; list-style: none;
}
.narration summary::-webkit-details-marker { display: none; }
.narration summary::before { content: "\25B6\FE0E"; margin-right: 0.5rem; font-size: 0.8em; }
.narration[open] summary::before { content: "\25BC\FE0E"; }
.narration audio { display: block; width: 100%; margin: 0.75rem 0 0.25rem; }
.narration-note { margin: 0; }

/* --- Discreet app version tag (stamped by .githooks/post-commit) --- */
.app-version { font-size: 0.75rem; color: var(--color-text-muted); }

/* --- Launch countdown (beta splash) ---
   Refreshed server-side by HTMX, so these numbers are a snapshot, not a ticking
   clock -- which is why the units read "days / hours / min" and seconds are
   absent. Nothing here may imply a precision the poll does not have. */
.countdown {
  /* `auto` on the side margins is load-bearing, not decorative. `.hero > *`
     centers every direct child of the hero with `margin-left/right: auto`, and
     this rule has the same specificity but comes later -- so writing the
     shorthand as `1.75rem 0` silently overrode it and pinned the card to the
     left edge while the headline, lede and waitlist card stayed centered. Any
     later margin shorthand here must keep the `auto`. */
  max-width: 34rem;
  margin: 1.75rem auto;
  padding: 1.1rem 1.25rem;
  border: 1px solid var(--color-border);
  border-radius: 0.5rem;
  background: var(--color-surface);
  font-family: var(--font-sans);
  text-align: center;
}
/* A light card inside the dark hero owns its own foreground -- see the note on
   .hero .newsletter-signup above. Every element in here sets its own color,
   but this keeps a future addition from inheriting the hero's near-white type
   onto a white card. */
.hero .countdown { color: var(--color-text); }
.countdown-label {
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin-bottom: 0.5rem;
}
.countdown-units {
  list-style: none;
  display: flex;
  justify-content: center;
  gap: 1.75rem;
  margin: 0 0 0.6rem;
  padding: 0;
}
.countdown-units li { display: flex; flex-direction: column; line-height: 1.1; }
.countdown-n {
  font-size: 2.1rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--color-accent);
}
.countdown-u {
  font-size: 0.78rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}
.countdown-note { font-size: 0.88rem; color: var(--color-text-muted); margin: 0; }
