/* Good Morning. Yellow from the old site (Mantine customYellow), per-GIF palette on top. */
:root {
  --sun: #ffe300;
  --sun-pale: #fff8e1;
  --bg: var(--sun);
  --card: #ffffff;
  --ink: #1a1a1a;
  --muted: #4d4d4d;
  --line: #1a1a1a;
  --pill: #ffffff;
  --pill-ink: #1a1a1a;
  --pill-on: #1a1a1a;
  --pill-on-ink: #ffe300;
  --focus: #1a1a1a;
  --danger: #a30000;
  --radius: 16px;
  --c1: #ffe300; --c2: #fff499; --c3: #ffb300; --c4: #ff7a00; --c5: #1a1a1a;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17140a;
    --card: #221e0f;
    --ink: #fff8e1;
    --muted: #d9d0a8;
    --line: #ffe300;
    --pill: #221e0f;
    --pill-ink: #fff8e1;
    --pill-on: #ffe300;
    --pill-on-ink: #1a1a1a;
    --focus: #ffe300;
    --danger: #ff8a80;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[x-cloak] { display: none !important; }
html:not(.js) .js-only { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font: 400 1rem/1.5 'Work Sans', system-ui, sans-serif;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 16px 48px;
  transition: filter 1s, background-color 1s;
}
body > * { position: relative; z-index: 1; }
a { color: inherit; text-underline-offset: 0.15em; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; box-shadow: 0 0 0 7px var(--card); }

.sr-only {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}
.skip { position: absolute; left: 16px; top: -100px; background: var(--card); padding: 8px 12px; border-radius: 8px; z-index: 10; }
.skip:focus { top: 8px; }

/* ---- psychedelic layers, outside every swap target ---- */
#backdrop {
  position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none;
  background: linear-gradient(160deg, var(--c1), var(--c3));
  opacity: 0.5;
  animation: drift 90s linear infinite;
}
#backdrop > * {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
  transform: scale(1.4);
  filter: blur(40px) saturate(1.6);
  mix-blend-mode: screen;
}
@keyframes drift { to { filter: hue-rotate(360deg); } }
#kaleido { position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: 0; opacity: 0.6; pointer-events: none; }

body[data-mood='asleep'] { filter: saturate(0.45) brightness(0.85); }
.dream { font-style: italic; color: var(--ink); background: var(--card); padding: 4px 12px; border-radius: 999px; }

/* ---- masthead ---- */
.masthead { text-align: center; padding: 16px 0 8px; }
.brand { display: inline-flex; flex-direction: column; align-items: center; text-decoration: none; }
.brand img { width: 160px; height: auto; display: block; }
.brand span {
  font-weight: 800; font-size: clamp(2rem, 6vw, 2.75rem); line-height: 1.1; letter-spacing: -0.01em;
  /* solid backing: the per-GIF backdrop behind it can be any color */
  background: var(--sun); color: #1a1a1a; padding: 2px 16px 6px; border-radius: 999px; margin-top: -8px;
}

/* ---- stage ---- */
#stage {
  width: 100%;
  max-width: 720px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: 0 10px 40px rgb(0 0 0 / 0.18);
  padding: 16px;
}
#stage:focus { outline: none; }
.gif { margin: 0; }
/* One fixed shape for every entry (letterboxed), so nothing on the stage moves between GIFs. */
.frame {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  max-height: 70vh;
  background: var(--c5);
  border-radius: calc(var(--radius) - 6px);
  overflow: hidden;
  /* horizontal swipes are ours (site.js); vertical scroll and pinch-zoom stay the browser's */
  touch-action: pan-y pinch-zoom;
}
.frame .media { display: block; width: 100%; height: 100%; object-fit: contain; }

/* Older / newer: arrows on the frame's sides, centered on it. Solid fill, border and
   shadow keep them visible over any GIF. */
.steps .step {
  position: absolute; top: 50%; transform: translateY(-50%);
  display: grid; place-items: center;
  width: 48px; height: 48px; border-radius: 50%;
  font: 800 1.5rem/1 'Work Sans', system-ui, sans-serif;
  background: var(--pill); color: var(--pill-ink);
  border: 2px solid var(--line);
  box-shadow: 0 2px 10px rgb(0 0 0 / 0.35);
  text-decoration: none;
}
.steps .prev { left: 10px; }
.steps .next { right: 10px; }
.steps .step:hover { background: var(--pill-on); color: var(--pill-on-ink); }
.steps .step:focus-visible { outline-offset: 2px; }
@media (min-width: 640px) {
  .steps .step { width: 56px; height: 56px; font-size: 1.75rem; }
  .steps .prev { left: 14px; }
  .steps .next { right: 14px; }
}
figcaption { padding: 12px 4px 0; }
figcaption h1 { font-size: 1rem; font-weight: 600; margin: 0; color: var(--muted); }
figcaption h1:focus { outline: none; }
figcaption h1:focus-visible { outline: 3px solid var(--focus); }
.caption { font-size: clamp(1.25rem, 3.5vw, 1.75rem); font-weight: 800; line-height: 1.25; margin: 4px 0 0; }
.caption .word { display: inline-block; white-space: nowrap; }
.caption .glyph {
  display: inline-block;
  white-space: pre;
  text-shadow: calc(var(--glitch, 0) * 1px) 0 var(--c2), calc(var(--glitch, 0) * -1px) 0 var(--c4);
}
.caption .glyph:nth-child(3n) { transform: translateY(calc(var(--glitch, 0) * 0.3px)); }
.credit { color: var(--muted); font-size: 0.875rem; margin: 6px 0 0; }
figcaption h1 a { color: inherit; }
.tags { list-style: none; padding: 0; margin: 10px 0 0; display: flex; flex-wrap: wrap; gap: 6px; }
.tags a {
  display: inline-block; font-size: 0.8125rem; font-weight: 600; line-height: 1.2;
  padding: 4px 10px; border: 1px solid var(--line); border-radius: 999px; text-decoration: none;
}
.tags a:hover { background: var(--pill-on); color: var(--pill-on-ink); }

/* ---- controls ---- */
#controls { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
#controls .speed, .button, button {
  font: 600 1rem/1 'Work Sans', system-ui, sans-serif;
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 44px; padding: 10px 18px;
  border: 2px solid var(--line); border-radius: 999px;
  background: var(--pill); color: var(--pill-ink);
  text-decoration: none; cursor: pointer;
}
.button:hover, button:hover { background: var(--pill-on); color: var(--pill-on-ink); }
/* icon buttons: name in sr-only text, tooltip from title */
#controls .icon-btn {
  display: inline-grid; place-items: center;
  width: 38px; height: 38px; min-height: 0; padding: 0; border-radius: 50%;
  border: 2px solid var(--line); background: var(--pill); color: var(--pill-ink); cursor: pointer;
}
#controls .icon-btn:hover, #controls .icon-btn[aria-pressed='true'] { background: var(--pill-on); color: var(--pill-on-ink); }
#controls .icon { display: block; }
#controls .speed { font-size: 0.875rem; min-height: 40px; padding: 4px 14px; cursor: default; }
/* Floats under the row while wandering, out of flow, so toggling Wander moves nothing. */
#controls { position: relative; }
#controls .speed {
  position: absolute; z-index: 3; top: calc(100% + 8px); left: 50%; transform: translateX(-50%);
  white-space: nowrap; box-shadow: 0 4px 16px rgb(0 0 0 / 0.25);
}
#controls .speed.off { visibility: hidden; }
#controls input[type='range'] { width: 110px; accent-color: var(--ink); }

.toys { display: flex; flex-direction: column; align-items: center; gap: 12px; margin: 4px 0 14px; z-index: 2; }
.foot { margin-top: 32px; font-size: 0.875rem; background: var(--card); padding: 6px 14px; border-radius: 999px; }
/* a button that reads as one of the footer links */
.foot button.linkish {
  font: inherit; color: inherit; background: none; border: 0; border-radius: 4px;
  padding: 0; min-height: 24px; display: inline; cursor: pointer;
  text-decoration: underline; text-underline-offset: 0.15em;
}
.foot button.linkish:hover { background: none; color: inherit; text-decoration-thickness: 2px; }

/* ---- help dialog ---- */
dialog { border: 2px solid var(--line); border-radius: var(--radius); background: var(--card); color: var(--ink); max-width: 360px; }
dialog::backdrop { background: rgb(0 0 0 / 0.5); }
dialog dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; }
dialog dd { margin: 0; }
kbd { border: 1px solid var(--line); border-radius: 4px; padding: 0 6px; font-family: ui-monospace, monospace; }
.check { display: flex; gap: 8px; align-items: center; margin: 12px 0; }

/* ---- pages ---- */
.page { width: 100%; }
.page h1 { margin-top: 0; }
.months { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.months a { display: inline-block; padding: 8px 14px; border: 2px solid var(--line); border-radius: 999px; text-decoration: none; font-weight: 600; }
.months a:hover { background: var(--pill-on); color: var(--pill-on-ink); }
.count { font-weight: 400; color: var(--muted); font-size: 0.875em; }
.months a:hover .count { color: inherit; }
body[data-page='page'] #stage { max-width: 960px; }

.mosaic { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 6px; }
.mosaic li { background: var(--tile, var(--c1)); aspect-ratio: 1; border-radius: 8px; overflow: hidden; }
.mosaic a { position: relative; display: block; width: 100%; height: 100%; }
.mosaic img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mosaic .tip {
  position: absolute; inset: auto 0 0 0; padding: 6px;
  background: rgb(0 0 0 / 0.82); color: #fff; font-size: 0.75rem; line-height: 1.25;
  opacity: 0; transition: opacity 0.15s;
}
.mosaic a:hover .tip, .mosaic a:focus-visible .tip { opacity: 1; }
.mosaic a:focus-visible { outline-offset: -3px; }

/* ---- admin ---- */
body.admin { align-items: stretch; max-width: 720px; margin: 0 auto; }
.admin-head { display: flex; gap: 16px; align-items: center; padding: 12px 0; flex-wrap: wrap; }
.admin-head .brand { font-weight: 800; flex-direction: row; }
.admin-head nav { display: flex; gap: 12px; }
.admin-head .who { margin-left: auto; font-size: 0.875rem; color: var(--muted); }
body.admin main { background: var(--card); border-radius: var(--radius); padding: 16px; }
.admin-list { list-style: none; padding: 0; }
.admin-list li { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid color-mix(in srgb, var(--ink) 20%, transparent); }
.admin-list img { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; background: var(--sun); flex: none; }
.admin-list p { margin: 4px 0 0; }
.badge { font-size: 0.75rem; border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; margin-left: 6px; }
.badge.hidden, .badge.draft { border-style: dashed; }
.field { margin: 0 0 16px; border: 0; padding: 0; }
.field label, legend { display: block; font-weight: 600; margin-bottom: 4px; }
.field .check { font-weight: 400; }
input[type='text'], input[type='datetime-local'], input[type='file'], textarea {
  width: 100%; font: inherit; padding: 10px; border: 2px solid var(--line); border-radius: 8px;
  background: var(--card); color: var(--ink);
}
.hint { margin: 4px 0 0; font-size: 0.875rem; color: var(--muted); }
.error { color: var(--danger); font-weight: 600; margin: 4px 0 0; }
[aria-invalid='true'] { border-color: var(--danger) !important; }
.error-summary { border: 2px solid var(--danger); border-radius: 8px; padding: 8px 16px; margin-bottom: 16px; }
.error-summary h2 { font-size: 1rem; margin: 4px 0; }
.saved { font-weight: 600; }
#preview { margin-top: 8px; }
#preview .swatches { display: flex; gap: 4px; margin-top: 6px; }
#preview .swatches span { width: 28px; height: 28px; border-radius: 6px; border: 1px solid var(--line); }
#preview img, .admin-preview { max-width: 100%; height: auto; border-radius: 8px; display: block; }
#media-form { margin-top: 32px; border-top: 2px solid var(--line); padding-top: 16px; }
.pager { display: flex; justify-content: space-between; }
