/* I Love Patrick Stewart: site styles. No build step; keep it small. */

:root {
  --bg: #fbf7f0;
  --surface: #ffffff;
  --text: #221d18;
  --muted: #6b6158;
  --border: #e7ddd0;
  --accent: #8f1d2c;        /* command red */
  --accent-text: #ffffff;
  --accent-soft: #f6e7e4;
  --gold: #9a7410;
  --focus: #1d5fbf;
  --error: #b3261e;
  --error-soft: #fdecea;
  --warn-soft: #fff4d6;
  --radius: 14px;
  --shadow: 0 1px 2px rgb(60 40 20 / 6%), 0 4px 16px rgb(60 40 20 / 5%);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #15120f;
  --surface: #1f1a16;
  --text: #f1e9de;
  --muted: #b3a797;
  --border: #3a322b;
  --accent: #e0707d;
  --accent-text: #1a0d0f;
  --accent-soft: #3a2024;
  --gold: #e3c26a;
  --focus: #8ab4ff;
  --error: #ff8a80;
  --error-soft: #3b1e1c;
  --warn-soft: #3a3016;
  --shadow: none;
  color-scheme: dark;
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 1.0625rem/1.6 var(--sans);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

main { flex: 1; padding-block: 2rem 3rem; }

.wrap { width: 100%; max-width: 46rem; margin-inline: auto; padding-inline: 1rem; }

h1, h2, h3 { font-family: var(--serif); line-height: 1.2; font-weight: 600; }
h1 { font-size: clamp(1.75rem, 4.5vw, 2.5rem); margin: 0 0 0.75rem; }
h2 { font-size: 1.35rem; margin: 2rem 0 0.5rem; }

a { color: var(--accent); text-underline-offset: 0.15em; }
a:hover { text-decoration-thickness: 2px; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }

.skip-link {
  position: absolute; left: 1rem; top: -3rem;
  background: var(--surface); padding: 0.5rem 1rem; border-radius: 8px; z-index: 10;
}
.skip-link:focus { top: 1rem; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* Header & footer */
.site-header { border-bottom: 1px solid var(--border); background: var(--surface); }
.header-inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding-block: 0.85rem;
}
.wordmark {
  font-family: var(--serif); font-size: 1.25rem; font-weight: 600;
  color: var(--text); text-decoration: none; white-space: nowrap;
}
.wordmark .heart { color: var(--accent); }

.site-footer {
  border-top: 1px solid var(--border); color: var(--muted);
  font-size: 0.9rem; padding-block: 1.5rem;
}
.site-footer nav { display: flex; flex-wrap: wrap; gap: 0.25rem 1.25rem; }
.site-footer a { color: var(--muted); }
.disclaimer { margin: 0 0 0.5rem; }

/* Buttons */
.button {
  display: inline-block; padding: 0.55rem 1.05rem; border-radius: 999px;
  background: var(--accent); color: var(--accent-text);
  font-weight: 600; font-size: 0.95rem; text-decoration: none; white-space: nowrap;
}
.button:hover { filter: brightness(1.08); }
.button-quiet { background: var(--surface); color: var(--accent); border: 1px solid var(--border); }

/* Category colours: accent bar, legend dot and label (text contrast >= 4.5:1). */
.cat-star-trek { --cat: #b3261e; }
.cat-x-men     { --cat: #1e5fb3; }
.cat-stage     { --cat: #7b3fa0; }
.cat-screen    { --cat: #0f7a6c; }
.cat-advocacy  { --cat: #96620a; }
.cat-personal  { --cat: #c2410c; }
[data-theme="dark"] .cat-star-trek { --cat: #ff8a80; }
[data-theme="dark"] .cat-x-men     { --cat: #8ab4ff; }
[data-theme="dark"] .cat-stage     { --cat: #c9a0ff; }
[data-theme="dark"] .cat-screen    { --cat: #6fd6c5; }
[data-theme="dark"] .cat-advocacy  { --cat: #e3c26a; }
[data-theme="dark"] .cat-personal  { --cat: #fdba74; }

/* Header navigation */
.header-nav { display: flex; align-items: center; gap: 1.1rem; }
.header-nav > a:not(.button) { color: var(--muted); text-decoration: none; font-size: 0.95rem; }
.header-nav > a:not(.button):hover, .header-nav > a[aria-current] { color: var(--text); }

/* Shared card bits (admin queue) */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1.25rem 1.25rem 1rem;
}
.card-body p { margin: 0; overflow-wrap: anywhere; }
.card-body { font-family: var(--serif); font-size: 1.1rem; }
.meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem 0.9rem;
  margin-top: 0.9rem; font-size: 0.88rem; color: var(--muted);
}
.author { font-weight: 600; color: var(--text); }
.empty, .error-page { text-align: center; padding-block: 3rem; }
.error-code { font-family: var(--serif); font-size: 3.5rem; color: var(--accent); margin: 0; }

/* ---- Landing --------------------------------------------------------- */
body.landing { min-height: 100svh; }
.landing-main {
  flex: 1; display: grid; place-content: center; justify-items: center;
  padding: 2rem 1rem 3rem; text-align: center;
}
.four-lights {
  display: block; width: min(74vw, 22rem); border-radius: 50%;
  transition: transform 0.25s ease;
}
.four-lights svg { display: block; width: 100%; height: auto; overflow: visible; }
.four-lights:hover, .four-lights:focus-visible { transform: scale(1.03); }
.four-lights:focus-visible { outline-offset: 6px; }
.badge-ring { fill: var(--surface); filter: drop-shadow(0 6px 18px rgb(40 25 10 / 18%)); }
.badge-room { stroke: rgb(255 255 255 / 6%); stroke-width: 1; }
.rig { fill: #3b322b; }
.stem { stroke: #3b322b; stroke-width: 3; stroke-linecap: round; }
.glow { opacity: 0.75; transform-box: fill-box; transform-origin: center; animation: hum 4.8s ease-in-out infinite; }
.lamp-2 .glow { animation-delay: -1.2s; }
.lamp-3 .glow { animation-delay: -2.4s; }
.lamp-4 .glow { animation-delay: -3.6s; }
.four-lights:hover .glow, .four-lights:focus-visible .glow { opacity: 1; }
.badge-caption {
  fill: #d9c9ac; font: 600 13px/1 var(--sans); letter-spacing: 0.32em; opacity: 0.75;
}
@keyframes hum {
  0%, 100% { opacity: 0.7; transform: scale(1); }
  50% { opacity: 0.95; transform: scale(1.06); }
}
.landing-line { margin: 1.75rem 0 0; font-size: 1.1rem; color: var(--text); }
.landing-bar {
  background: #1c1815; color: #d8cdbf; font-size: 0.85rem;
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.4rem 1.5rem;
  padding: 0.7rem 1rem;
}
.landing-bar p { margin: 0; }
.landing-bar a { color: #f3d37a; }
.landing-bar nav { display: flex; gap: 1rem; }
.landing-bar nav a { color: #b8ab9b; }
[data-theme="dark"] .badge-ring { fill: #2a241f; filter: none; }
[data-theme="dark"] .landing-bar { background: #0b0908; border-top: 1px solid var(--border); }

/* ---- Gallery ----------------------------------------------------------- */
.wrap-wide { max-width: 72rem; }
.gallery-head {
  display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between;
  gap: 0.75rem 1.5rem; margin-bottom: 1rem;
}
.gallery-head h1 { margin: 0; }
.stats { margin: 0.25rem 0 0; color: var(--muted); }

.sort-toggle {
  display: inline-flex; padding: 3px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border);
}
.sort-toggle a {
  padding: 0.35rem 0.9rem; border-radius: 999px; font-size: 0.9rem;
  color: var(--muted); text-decoration: none;
}
.sort-toggle a[aria-current] { background: var(--accent); color: var(--accent-text); font-weight: 600; }

/* The colour legend doubles as the category filter: one quiet line, scrolls on phones. */
.legend {
  display: flex; gap: 0.25rem 1.1rem; overflow-x: auto; scrollbar-width: none;
  padding: 0.35rem 0 0.9rem; margin-bottom: 1.25rem; border-bottom: 1px solid var(--border);
  -webkit-mask-image: linear-gradient(to right, #000 92%, transparent);
  mask-image: linear-gradient(to right, #000 92%, transparent);
}
.legend::-webkit-scrollbar { display: none; }
.legend a {
  display: inline-flex; align-items: center; gap: 0.45rem; white-space: nowrap;
  color: var(--muted); text-decoration: none; font-size: 0.9rem; padding: 0.2rem 0;
  border-bottom: 2px solid transparent;
}
.legend a:hover { color: var(--text); }
.legend a[aria-current] { color: var(--text); font-weight: 600; border-bottom-color: var(--cat, var(--accent)); }

.tiles {
  list-style: none; margin: 0; padding: 0;
  display: grid; gap: 1.1rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 19rem), 1fr));
}
.tile article {
  position: relative; height: 100%; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1.15rem 1.25rem 1rem 1.5rem;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
.tile article::before {
  content: ""; position: absolute; left: 0.6rem; top: 1.1rem; bottom: 1.1rem;
  width: 4px; border-radius: 4px; background: var(--cat);
}
.tile article:hover, .tile article:focus-within {
  transform: translateY(-2px); border-color: var(--cat);
  box-shadow: 0 2px 4px rgb(60 40 20 / 6%), 0 12px 28px rgb(60 40 20 / 9%);
}
.tile-body {
  font-family: var(--serif); font-size: 1.05rem; line-height: 1.55; flex: 1;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 6; line-clamp: 6;
  overflow: hidden;
}
.tile-body p { margin: 0; overflow-wrap: anywhere; }
.tile-meta {
  display: grid; gap: 0.6rem; margin-top: 0.9rem; font-size: 0.85rem; color: var(--muted);
}
.byline { display: inline-flex; flex-wrap: wrap; gap: 0.2rem 0.6rem; align-items: baseline; }

/* Category tag: a small pill with the category's colour dot. */
.tag-pill {
  display: inline-flex; align-items: center; gap: 0.4rem; white-space: nowrap;
  padding: 0.12rem 0.6rem 0.12rem 0.5rem; border-radius: 999px;
  border: 1px solid var(--border); background: var(--bg);
  font-size: 0.8rem; color: var(--muted); text-decoration: none;
}
.tag-pill .dot, .legend .dot { width: 0.55rem; height: 0.55rem; border-radius: 50%; background: var(--cat); flex: none; }
a.tag-pill:hover { color: var(--text); border-color: var(--cat); }

/* 🖖 "Live long and prosper" button */
.tile-actions { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.heart-btn {
  position: relative; z-index: 1; /* above the tile's full-card link */
  display: inline-flex; align-items: center; gap: 0.3rem;
  min-height: 2rem; padding: 0.15rem 0.6rem; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); color: var(--muted);
  font: inherit; font-size: 0.85rem; font-variant-numeric: tabular-nums; cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}
.heart-btn:hover { border-color: var(--gold); color: var(--text); }
.heart-btn .heart-icon { filter: grayscale(1); opacity: 0.7; transition: filter 0.15s ease, opacity 0.15s ease; }
.heart-btn:hover .heart-icon, .heart-btn.is-on .heart-icon { filter: none; opacity: 1; }
.heart-btn.is-on { border-color: var(--gold); background: var(--warn-soft); color: var(--text); font-weight: 600; }
.heart-btn:disabled { cursor: progress; }
.heart-btn.pop .heart-icon { animation: pop 0.35s ease; }
@keyframes pop { 40% { transform: scale(1.35) rotate(-8deg); } }
.heart-count:empty { display: none; }
.heart-btn-large { min-height: 2.9rem; padding: 0.4rem 1rem; font-size: 1rem; }
.heart-btn-large .heart-icon { font-size: 1.2rem; }
.heart-static { font-size: 0.85rem; color: var(--muted); }
/* The whole tile is one link. */
.tile-link { position: absolute; inset: 0; border-radius: var(--radius); }
.tile-link:focus-visible { outline-offset: 3px; }

.pager {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 1rem;
  margin-top: 2.25rem;
}
.pager ol { list-style: none; display: flex; gap: 0.25rem; margin: 0; padding: 0; }
.pager li a, .pager .gap {
  display: inline-grid; place-items: center; min-width: 2.3rem; height: 2.3rem; padding: 0 0.4rem;
  border-radius: 999px; text-decoration: none; color: var(--muted);
}
.pager li a:hover { background: var(--surface); color: var(--text); }
.pager li a[aria-current] { background: var(--accent); color: var(--accent-text); font-weight: 700; }
.pager-step { text-decoration: none; font-weight: 600; }
.pager-step[rel="next"] { justify-self: end; }
@media (max-width: 34rem) {
  .pager { grid-template-columns: 1fr 1fr; }
  .pager ol { grid-column: 1 / -1; grid-row: 1; justify-content: center; }
}

/* ---- Single story -------------------------------------------------------- */
.story-view main { display: grid; align-content: center; padding-block: clamp(2rem, 8vh, 5rem); }
.story { max-width: 38rem; margin-inline: auto; width: 100%; }
.story-body {
  position: relative; margin: 0; padding-left: 1.4rem; border-left: 3px solid var(--cat);
  font-family: var(--serif); font-size: clamp(1.25rem, 3vw, 1.6rem); line-height: 1.6;
}
.story-body p { margin: 0; overflow-wrap: anywhere; }
.story-meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1rem; margin-top: 1.5rem; padding-left: 1.7rem;
  color: var(--muted); font-size: 0.95rem;
}
.story-actions {
  max-width: 38rem; width: 100%; margin: 2.5rem auto 0;
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem 1.5rem;
}
.story-actions a:not(.button) { color: var(--muted); }
.story-links { display: inline-flex; gap: 1.25rem; }

.label-short { display: none; }
@media (max-width: 30rem) {
  .label-long { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .label-short { display: inline; }
  .header-nav { gap: 0.75rem; }
}

/* Prose pages */
.prose { max-width: 40rem; }
.prose ul { padding-left: 1.25rem; }
.prose li { margin-block: 0.35rem; }
code { font-size: 0.9em; background: var(--accent-soft); padding: 0.1em 0.35em; border-radius: 4px; }

/* Forms */
.form-page { max-width: 40rem; }
.form-page.narrow { max-width: 24rem; }
.story-form { display: grid; gap: 1.25rem; margin-top: 1.5rem; }
.field { display: grid; gap: 0.4rem; align-content: start; }
.field-row { display: grid; gap: 1.25rem; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); }
label { font-weight: 600; }
.optional { font-weight: 400; color: var(--muted); }
textarea, select, input[type="text"], input[type="password"] {
  width: 100%; font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px; padding: 0.65rem 0.8rem;
}
textarea { font-family: var(--serif); font-size: 1.1rem; line-height: 1.55; resize: vertical; min-height: 12rem; }
textarea:focus, select:focus, input:focus { border-color: var(--focus); }
.hint { margin: 0; font-size: 0.9rem; color: var(--muted); }
.counter-warn { color: var(--error); font-weight: 600; }
.error { margin: 0; color: var(--error); font-size: 0.92rem; font-weight: 600; }
.has-error textarea, .has-error select, .has-error input { border-color: var(--error); }
.checkbox { grid-template-columns: auto 1fr; align-items: start; column-gap: 0.6rem; }
.checkbox input { width: 1.15rem; height: 1.15rem; margin-top: 0.25rem; accent-color: var(--accent); }
.checkbox label { font-weight: 400; }
.checkbox .error { grid-column: 1 / -1; }
.form-errors {
  background: var(--error-soft); border: 1px solid var(--error); border-radius: 10px;
  padding: 0.75rem 1rem; margin-top: 1rem;
}
.form-errors p, .form-errors ul { margin: 0.25rem 0; }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
button { cursor: pointer; }
button.button { border: 0; font: inherit; font-weight: 600; }
button.button-quiet { border: 1px solid var(--border); }
.button-large { justify-self: start; padding: 0.75rem 1.5rem; font-size: 1.05rem; }
.button-danger, button.button-danger { background: transparent; color: var(--error); border: 1px solid var(--error); }
.link-button { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; text-decoration: underline; }
.inline { display: inline; }

/* Admin */
.admin-nav { display: flex; flex-wrap: wrap; gap: 0.5rem 1.25rem; align-items: center; margin-bottom: 1.5rem; }
.admin-nav a[aria-current] { font-weight: 700; text-decoration: none; }
.admin-nav form { margin-left: auto; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: 0.75rem; margin: 1rem 0 0; }
.stat-grid div { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; }
.stat-grid dt { color: var(--muted); font-size: 0.9rem; }
.stat-grid dd { margin: 0.25rem 0 0; font-family: var(--serif); font-size: 2rem; }
.count { color: var(--muted); font-weight: 400; }
kbd { font: 0.85em ui-monospace, monospace; border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 4px; padding: 0 0.3em; }
.queue { list-style: none; margin: 1rem 0 0; padding: 0; display: grid; gap: 1rem; }
.queue-item:focus { outline: none; }
.queue-item:focus .card { outline: 3px solid var(--focus); outline-offset: 2px; }
.badges { display: flex; flex-wrap: wrap; gap: 0.35rem; margin: 0 0 0.75rem; }
.badge { font-size: 0.8rem; border: 1px solid var(--border); border-radius: 999px; padding: 0.05rem 0.55rem; color: var(--muted); }
.badge-warn { background: var(--warn-soft); color: var(--text); font-weight: 600; }
.mono { font-family: ui-monospace, monospace; font-size: 0.85em; }
.actions { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.reject-form { display: flex; gap: 0.5rem; flex: 1 1 16rem; }
.reject-form input { padding: 0.45rem 0.7rem; }
.done-note { margin: 0; padding: 0.75rem 1rem; color: var(--muted); border: 1px dashed var(--border); border-radius: var(--radius); }
.table-wrap { overflow-x: auto; }
.audit { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.audit th, .audit td { text-align: left; padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--border); vertical-align: top; }

@media (max-width: 30rem) {
  .wordmark { font-size: 1.05rem; }
  .button { padding: 0.5rem 0.85rem; font-size: 0.88rem; }
}

/* Theme toggle: small and quiet, in the footers. */
.theme-toggle {
  display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.1rem 0.5rem;
  border: 1px solid transparent; border-radius: 999px; background: none;
  color: inherit; font: inherit; font-size: inherit; cursor: pointer; opacity: 0.85;
}
.theme-toggle:hover { opacity: 1; border-color: currentColor; }
.theme-icon { width: 1em; height: 1em; flex: none; }
.theme-icon g { display: none; }
.theme-toggle[data-pref="auto"] .i-auto,
.theme-toggle[data-pref="light"] .i-light,
.theme-toggle[data-pref="dark"] .i-dark { display: inline; }
.site-footer .wrap { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 0.5rem 1.5rem; }
.site-footer .footer-text { display: grid; gap: 0.5rem; }

/* Smooth cross-page fades (supporting browsers only). */
@view-transition { navigation: auto; }

@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
  .glow { animation: none; }
  * { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
