/* =========================================================================
   Showcase pages (/tide/ and /need-to-know/).
   These mirror the project pages in the Workshop on shaunparker.com.au: the
   same structure, the same words, and each app's own look, which is set by
   <html data-theme="..."> re-pointing the colour variables below.
   ========================================================================= */

:root {
  --bg: #0b0b0f; --bg-elevated: #0f172a; --bg-hover: #1e2937;
  --text: #f4f7fa; --text-dim: #94a3b8; --text-faint: #64748b;
  --accent: #14b8a6; --accent-hover: #67e8f9; --gold: #f59e0b; --on-accent: #042823;
  --border: rgba(255, 255, 255, 0.09); --border-strong: rgba(255, 255, 255, 0.18);
  --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: var(--font-sans);
  --maxw: 900px; --gutter: clamp(1rem, 4vw, 2.5rem); --radius: 10px;
}

/* --- Tide: the tideline ---------------------------------------------------- */
:root[data-theme="tide"] {
  color-scheme: dark;
  --bg: #06141f; --bg-elevated: #0b2132; --bg-hover: #123048;
  --text: #eef6f8; --text-dim: #9fb8c4; --text-faint: #8ba5b1;
  --accent: #5ec8d8; --accent-hover: #9be4ee; --gold: #f2c078; --on-accent: #06202a;
  --border: rgba(158, 216, 230, 0.12); --border-strong: rgba(158, 216, 230, 0.28);
  background:
    radial-gradient(900px 380px at 20% -5%, rgba(94, 200, 216, 0.16), transparent 65%),
    #06141f;
}
:root[data-theme="tide"] .article__head::after {
  content: ""; display: block; height: 18px; margin-top: 1.5rem; opacity: 0.6;
  background: repeat-x left center / 120px 18px
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 18'%3E%3Cpath d='M0 9c15 0 15-6 30-6s15 6 30 6 15-6 30-6 15 6 30 6' fill='none' stroke='%235ec8d8' stroke-width='2'/%3E%3C/svg%3E");
  animation: tide-roll 6s linear infinite;
}
@keyframes tide-roll { to { background-position-x: 120px; } }

/* --- Need to Know: a 1970s dossier on manila paper ------------------------ */
:root[data-theme="dossier"] {
  color-scheme: light;
  --bg: #e6dcc0; --bg-elevated: #f1e9d2; --bg-hover: #dfd3b1;
  --text: #1d1a14; --text-dim: #4a4436; --text-faint: #5d5645;
  --accent: #a3261c; --accent-hover: #8a1d14; --gold: #a3261c; --on-accent: #f7f0dc;
  --border: rgba(29, 26, 20, 0.16); --border-strong: rgba(29, 26, 20, 0.4);
  --font-display: "Courier New", Courier, ui-monospace, monospace;
  background: #e6dcc0;
}
:root[data-theme="dossier"] .article__head h1 { text-transform: uppercase; letter-spacing: 0.04em; }
:root[data-theme="dossier"] .article__head h1::after {
  content: "DECLASSIFIED"; display: inline-block; margin-left: 1rem; vertical-align: middle;
  font-size: 0.32em; letter-spacing: 0.18em; padding: 0.3em 0.7em;
  color: var(--accent); border: 3px solid var(--accent); border-radius: 4px;
  transform: rotate(-6deg); opacity: 0.85;
}
/* Section headings arrive inked out, and the ink lifts as you reach them. */
:root[data-theme="dossier"] .prose h2 { position: relative; width: fit-content; }
@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    :root[data-theme="dossier"] .prose h2::after {
      content: ""; position: absolute; inset: -0.1em -0.3em; background: #1d1a14;
      transform-origin: right center;
      animation: lift-ink linear both; animation-timeline: view(); animation-range: entry 60% cover 35%;
    }
  }
  @keyframes lift-ink { to { transform: scaleX(0); } }
}

/* --- Base ------------------------------------------------------------------ */
* { box-sizing: border-box; }
html {
  background: var(--bg); color: var(--text); font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: 100%; scroll-behavior: smooth;
}
body { margin: 0; min-height: 100vh; line-height: 1.6; }
a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent-hover); }
img, video { display: block; max-width: 100%; }
h1, h2, h3 { line-height: 1.15; letter-spacing: -0.02em; margin: 0 0 0.5em; font-weight: 600; }
h1 { font-size: clamp(2rem, 5vw, 3.25rem); }
p { margin: 0 0 1rem; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
.skip { position: absolute; left: 12px; top: -80px; z-index: 5; padding: 0.6rem 1rem; background: var(--bg-elevated); color: var(--text); border-radius: 6px; font-weight: 600; }
.skip:focus { top: 12px; }

.container { width: 100%; max-width: var(--maxw); margin-inline: auto; padding-inline: var(--gutter); }
.site-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding-block: 1.1rem; }
.brand { display: inline-flex; align-items: center; gap: 0.6rem; font-weight: 600; letter-spacing: 0.02em; }
.brand svg { width: 26px; height: 26px; flex: none; }
.site-header nav a { color: var(--text-dim); font-size: 0.95rem; padding: 0.4rem 0; }
.site-header nav a:hover { color: var(--accent-hover); }

.eyebrow { text-transform: uppercase; letter-spacing: 0.18em; font-size: 0.72rem; color: var(--gold); font-weight: 600; margin: 0; }
.lead { font-size: clamp(1.05rem, 2vw, 1.25rem); color: var(--text-dim); max-width: 60ch; }
.btn {
  display: inline-flex; align-items: center; gap: 0.5rem; padding: 0.7rem 1.25rem;
  border: 1px solid var(--border-strong); border-radius: var(--radius); font-weight: 500;
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}
.btn:hover { background: var(--bg-hover); border-color: var(--accent); color: var(--text); }
.btn--accent { background: var(--accent); color: var(--on-accent); border-color: var(--accent); font-weight: 600; }
.btn--accent:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--on-accent); }

/* --- The article ----------------------------------------------------------- */
.article { padding-top: 0.5rem; padding-bottom: clamp(3rem, 8vw, 6rem); }
.back { color: var(--text-dim); font-size: 0.9rem; }
.back:hover { color: var(--accent-hover); }
.article__head { margin-top: 1.5rem; }
.article__head h1 { font-family: var(--font-display); margin-top: 0.5rem; }
.article__meta { display: flex; align-items: center; flex-wrap: wrap; gap: 0.75rem 1rem; margin-top: 1.25rem; }
.tags { list-style: none; display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0; padding: 0; }
.tags li { font-size: 0.75rem; color: var(--text-dim); border: 1px solid var(--border); border-radius: 999px; padding: 0.2rem 0.65rem; }
.article__cover { margin: 2rem 0; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); background: var(--bg-elevated); aspect-ratio: 4 / 3; }
.article__cover img, .article__cover video { width: 100%; height: 100%; object-fit: cover; }

.prose { max-width: 720px; }
.prose h2 { margin-top: 2.25rem; font-size: 1.4rem; font-family: var(--font-display); }
.prose p, .prose li { color: var(--text-dim); }
.prose strong { color: var(--text); }
.prose ul { padding-left: 1.2rem; }

.how, .demo, .stack { margin-top: 3rem; }
.how h2, .demo h2, .stack h2 { font-size: 1.4rem; font-family: var(--font-display); }
.how h2, .stack h2 { margin-bottom: 1rem; }
.how__row {
  list-style: none; margin: 0; padding: 0 0 0.75rem;
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(260px, 1fr);
  gap: 1rem; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: thin;
}
.step { scroll-snap-align: start; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; }
.step__media { aspect-ratio: 4 / 3; background: var(--bg-hover); }
.step__media video, .step__media img { width: 100%; height: 100%; object-fit: cover; }
.step__text { display: flex; gap: 0.8rem; padding: 1rem 1.1rem 1.1rem; }
.step__n { flex: none; width: 1.8rem; height: 1.8rem; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 0.9rem; background: var(--accent); color: var(--on-accent); }
.step h3 { font-size: 1rem; margin: 0.15rem 0 0.3rem; letter-spacing: 0; }
.step p { margin: 0; color: var(--text-dim); font-size: 0.92rem; }

.demo h2 { margin-bottom: 0.25rem; }
.demo__head p { color: var(--text-dim); margin-bottom: 1rem; }
.demo__frame {
  position: relative; width: 100%; aspect-ratio: 16 / 10; min-height: 420px;
  border-radius: var(--radius); overflow: hidden;
  border: 1px solid var(--border-strong); background: var(--bg-elevated);
  display: grid; place-items: center;
}
.demo__frame img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; filter: brightness(0.45) blur(1px); }
.demo__frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #fff; }
.demo__go { position: relative; z-index: 1; cursor: pointer; font: inherit; font-weight: 600; }
.demo__out { display: inline-block; margin-top: 0.75rem; font-size: 0.9rem; color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.js .demo__fallback { display: none; }

.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 4rem; }
.pager a { display: flex; flex-direction: column; gap: 0.2rem; padding: 1rem 1.2rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-elevated); transition: border-color 0.18s ease; }
.pager a:hover { border-color: var(--accent); color: var(--text); }
.pager span { font-size: 0.78rem; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.1em; }
.pager__next { text-align: right; }

/* --- Motion ----------------------------------------------------------------
   Sections fade up as they scroll in, but only once the script has confirmed
   it can show them again (it adds .has-motion). */
.has-motion [data-reveal] { opacity: 0; transform: translateY(18px); transition: opacity 0.6s ease, transform 0.6s cubic-bezier(0.2, 0.7, 0.2, 1); }
.has-motion [data-reveal].is-in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
