/* ===========================================================================
   Monty's birthday guestbook — Dodger Stadium celebration

   HOW TO USE THIS FILE
   --------------------
   Everything below "THEME TOKENS" is the personality of the site: change the
   colours, fonts, radii, and the decorative rules in the THEME LAYER at the
   bottom. Everything in the FUNCTIONAL LAYER (form, cards, progress bar,
   focus rings, reduced motion, responsive rules) is what keeps the guestbook
   usable and accessible — restyle it, but don't delete it.

   Non-negotiables when re-theming:
     * :focus-visible must stay clearly visible against its background.
     * Body text must keep at least 4.5:1 contrast (3:1 for large headings).
     * overflow-x: hidden on <body> plus max-width:100% on media — no
       horizontal scrollbar at 320px.
     * The prefers-reduced-motion block at the bottom must survive.
   =========================================================================== */

/* ============================ THEME TOKENS ============================ */
:root {
  --primary: #005A9C;
  --secondary: #1B2E5B;
  --accent: #E4572E;

  --surface: #F7F3EA;      /* page background            */
  --card: #FFFFFF;            /* raised cards and the form  */
  --ink: #16233A;              /* body text                  */
  --ink-soft: #4E5D74;    /* secondary text             */
  --on-primary: #FFFFFF;/* text on primary surfaces   */

  --font-display: "Oswald", "Arial Narrow", sans-serif;
  --font-body: system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-accent: "Caveat", "Segoe Script", cursive;

  --radius: 12px;
  --shadow: 0 10px 30px rgb(0 0 0 / 0.16);
  --wrap: 68rem;
}

/* ========================== FUNCTIONAL LAYER ========================== */

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

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.6;
  color: var(--ink);
  background: var(--surface);
  overflow-x: hidden;          /* belt for decorative overhangs */
}

img, svg, video { max-width: 100%; }
img, video { height: auto; }

h1, h2, h3, h4 {
  font-family: var(--font-display);
  line-height: 1.15;
  margin: 0 0 0.5em;
  text-wrap: balance;
}

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

.wrap {
  max-width: var(--wrap);
  margin-inline: auto;
  padding-inline: clamp(1.1rem, 4vw, 2rem);
}

/* Keyboard access -------------------------------------------------------- */
.skip-link {
  position: absolute;
  left: 0.75rem;
  top: -4rem;
  z-index: 50;
  background: var(--ink);
  color: var(--surface);
  padding: 0.6rem 1rem;
  border-radius: 0 0 10px 10px;
  text-decoration: none;
  font-weight: 700;
  transition: top 0.15s ease;
}
.skip-link:focus { top: 0; }

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

/* --------------------------------- HERO --------------------------------- */
.hero {
  position: relative;
  overflow: hidden;
  background: linear-gradient(180deg, var(--secondary), var(--primary));
  color: var(--on-primary);
  text-align: center;
}

.hero-bg { position: absolute; inset: 0; }
.hero-bg img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}
/* Scrim so the heading keeps its contrast over any photo. Tune the alpha,
   don't remove it — text over an unscrimmed photo will fail contrast. */
.hero-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgb(0 0 0 / 0.35), rgb(0 0 0 / 0.55));
}

.hero-inner {
  position: relative;
  z-index: 1;
  max-width: 46rem;
  margin-inline: auto;
  padding: clamp(3rem, 8vh, 5.5rem) 1.25rem clamp(3rem, 8vh, 4.5rem);
}

.eyebrow {
  margin: 0 0 0.9rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 0.82rem;
}

.hero h1 {
  font-size: clamp(2.4rem, 8vw, 4.4rem);
  margin-bottom: 0.25em;
}

.hero-sub {
  margin: 0 auto 2.4rem;
  max-width: 34rem;
  font-size: clamp(1.05rem, 2.4vw, 1.3rem);
  font-weight: 600;
}

/* Portrait / family photo */
.portrait {
  position: relative;
  display: inline-block;
  margin: 0;
  max-width: min(460px, 92vw);
  background: var(--card);
  padding: 14px 14px 10px;
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.portrait-photo { display: block; width: 100%; border-radius: 4px; }
.portrait-caption {
  font-family: var(--font-accent);
  font-size: 1.5rem;
  color: var(--ink-soft);
  margin: 0.35rem 0 0.1rem;
}

/* The World Series ring, pinned to the portrait like a champion's badge. */
.ring-badge {
  position: absolute;
  top: -26px;
  right: -20px;
  width: clamp(72px, 16vw, 104px);
  aspect-ratio: 1;
  border-radius: 50%;
  overflow: hidden;
  border: 3px solid #C9A227;
  background: #0b0b0e;
  box-shadow: var(--shadow);
  transform: rotate(8deg);
}
.ring-badge img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* -------------------------------- ABOUT -------------------------------- */
.about {
  background: var(--surface);
  text-align: center;
  padding: clamp(2.5rem, 6vw, 4rem) 0;
}
.about h2 { font-size: clamp(1.9rem, 5vw, 2.7rem); color: var(--primary); }

.lede {
  max-width: 40rem;
  margin: 0 auto 2.2rem;
  font-size: clamp(1.05rem, 2.2vw, 1.2rem);
  color: var(--ink-soft);
}

.pillars {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.8rem 1rem;
  padding: 0;
  margin: 0;
}
.pillars li {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  background: var(--card);
  border: 1.5px solid color-mix(in srgb, var(--primary) 25%, transparent);
  border-radius: 999px;
  padding: 0.55rem 1.15rem;
  font-weight: 700;
  color: var(--primary);
}

/* ------------------------------ GUESTBOOK ------------------------------ */
.guestbook {
  background: var(--primary);
  color: var(--on-primary);
  padding: clamp(2.8rem, 6vw, 4.5rem) 0;
}
.guestbook h2 {
  font-size: clamp(2rem, 5vw, 2.8rem);
  text-align: center;
  color: inherit;
}
.section-sub {
  text-align: center;
  max-width: 34rem;
  margin: 0 auto 2.4rem;
}

/* The signing form */
.signing-card {
  background: var(--card);
  color: var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-width: 40rem;
  margin: 0 auto 3.5rem;
  padding: clamp(1.3rem, 4vw, 2.2rem);
}

.field { margin-bottom: 1.2rem; }
.field label,
.file-label {
  display: block;
  font-weight: 800;
  margin-bottom: 0.35rem;
  color: var(--ink);
}
.file-label em { font-style: normal; font-weight: 600; color: var(--ink-soft); }

.field input[type="text"],
.field textarea {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: #fff;
  border: 2px solid color-mix(in srgb, var(--ink) 20%, transparent);
  border-radius: 10px;
  padding: 0.65rem 0.85rem;
  transition: border-color 0.15s ease;
}
.field input[type="text"]:focus-visible,
.field textarea:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--primary);
}
.field textarea { resize: vertical; min-height: 7.5rem; }
.field.invalid input,
.field.invalid textarea { border-color: #c0392b; }

.count { float: right; font-weight: 600; font-size: 0.8rem; color: var(--ink-soft); }
.field-err { margin: 0.35rem 0 0; color: #c0392b; font-weight: 700; font-size: 0.92rem; }
.field-hint { margin: 0.35rem 0 0; color: var(--ink-soft); font-size: 0.85rem; }

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1.1rem; }
@media (max-width: 620px) { .field-row { grid-template-columns: 1fr; } }

/* Styled file pickers. The real input stays in the accessibility tree —
   it is visually hidden, NOT display:none, so it remains focusable and the
   <label> keeps working for screen readers and keyboards alike. */
.file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  clip-path: inset(50%);
  overflow: hidden;
  white-space: nowrap;
}
.file-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  background: color-mix(in srgb, var(--secondary) 18%, #fff);
  color: var(--ink);
  border: 2px dashed var(--primary);
  border-radius: 10px;
  padding: 0.6rem 1rem;
  font-weight: 700;
  max-width: 100%;
}
.file-btn svg { width: 20px; height: 20px; flex: none; }
.file-btn [data-file-text] {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.field-file:focus-within .file-btn { outline: 3px solid var(--accent); outline-offset: 2px; }

.file-clear {
  margin-top: 0.4rem;
  background: none;
  border: none;
  cursor: pointer;
  color: #c0392b;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 700;
  text-decoration: underline;
  padding: 0;
}

/* Honeypot — off-screen rather than display:none, which some bots skip. */
.hp { position: absolute; left: -9999px; top: -9999px; }

.submit-row {
  display: flex;
  align-items: center;
  gap: 1.1rem;
  flex-wrap: wrap;
  margin-top: 1.4rem;
}

.btn-primary {
  font: inherit;
  font-weight: 800;
  font-size: 1.05rem;
  background: var(--accent);
  color: var(--on-primary);
  border: none;
  border-radius: 999px;
  padding: 0.75rem 1.6rem;
  cursor: pointer;
  transition: transform 0.12s ease, filter 0.12s ease;
}
.btn-primary:hover { filter: brightness(0.92); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary[disabled] { opacity: 0.6; cursor: wait; transform: none; }

/* Upload progress */
.progress { flex: 1 1 180px; min-width: 160px; }
.progress-bar {
  height: 10px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--ink) 12%, transparent);
  overflow: hidden;
  position: relative;
}
.progress-bar::after {
  content: "";
  position: absolute;
  inset: 0;
  width: var(--pct, 0%);
  background: linear-gradient(90deg, var(--secondary), var(--accent));
  border-radius: 999px;
  transition: width 0.2s ease;
}
.progress-text { font-size: 0.85rem; font-weight: 700; color: var(--ink-soft); }

.form-status { min-height: 1.4em; margin: 0.9rem 0 0; font-weight: 800; }
.form-status.ok { color: #1f6b4a; }
.form-status.err { color: #c0392b; }

/* Guestbook entries */
.entries-title { font-size: clamp(1.5rem, 4vw, 2rem); text-align: center; margin-bottom: 1.6rem; }
.entries-status { text-align: center; margin-bottom: 1.2rem; font-weight: 700; }
.entries-status .retry {
  background: none;
  border: 2px solid currentColor;
  color: inherit;
  font: inherit;
  font-weight: 800;
  border-radius: 999px;
  padding: 0.35rem 1rem;
  cursor: pointer;
  margin-left: 0.6rem;
}

.entries {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr));
  gap: 1.6rem;
  align-items: start;
}

.entry-card {
  background: var(--card);
  color: var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.15rem 1.2rem 1rem;
}

.entry-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.8rem;
  margin-bottom: 0.5rem;
}
.entry-name {
  font-family: var(--font-accent);
  font-size: 1.7rem;
  line-height: 1.05;
  color: var(--primary);
  margin: 0;
  overflow-wrap: anywhere;   /* a very long single "word" can't blow the grid */
}
.entry-date {
  flex: none;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.entry-msg {
  margin: 0 0 0.8rem;
  white-space: pre-line;     /* honour the line breaks a guest typed */
  overflow-wrap: anywhere;
}

.entry-media { margin: 0 0 0.8rem; }
.entry-media img {
  display: block;
  width: 100%;
  border-radius: 8px;
}
.entry-media video {
  display: block;
  width: 100%;
  border-radius: 8px;
  background: #000;
}
.media-fallback {
  font-size: 0.9rem;
  color: var(--ink-soft);
  background: color-mix(in srgb, var(--secondary) 15%, transparent);
  border-radius: 8px;
  padding: 0.6rem 0.8rem;
}

.entry-foot { display: flex; justify-content: flex-end; }

.react-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font: inherit;
  font-weight: 800;
  font-size: 0.95rem;
  background: color-mix(in srgb, var(--secondary) 18%, #fff);
  color: var(--ink);
  border: 2px solid var(--primary);
  border-radius: 999px;
  padding: 0.3rem 0.9rem;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.12s ease;
}
.react-icon { font-size: 1.2rem; line-height: 1; }
.react-btn:hover:not([disabled]) { transform: scale(1.04); }
.react-btn[disabled] {
  cursor: default;
  background: var(--accent);
  color: var(--on-primary);
  border-color: var(--accent);
}
.react-count { min-width: 1ch; }

@keyframes react-pop { 40% { transform: scale(1.3) rotate(-8deg); } }
.react-btn.pop .react-icon { animation: react-pop 0.45s ease; }

.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  border: 3px dashed color-mix(in srgb, currentColor 40%, transparent);
  border-radius: 14px;
  padding: 2.6rem 1.5rem;
}
.empty-state p {
  margin: 0;
  font-family: var(--font-accent);
  font-size: clamp(1.4rem, 4vw, 1.9rem);
}

/* -------------------------------- FOOTER -------------------------------- */
.footer {
  background: var(--secondary);
  color: var(--ink);
  text-align: center;
  padding: 3rem 1.25rem 2.4rem;
}
.footer-big {
  font-family: var(--font-accent);
  font-size: clamp(2rem, 6vw, 2.8rem);
  margin: 0 0 0.2rem;
}
.footer-line { margin: 0; font-weight: 800; font-size: 1.1rem; }
.footer-fine { margin: 1.6rem 0 0; font-size: 0.85rem; font-weight: 600; opacity: 0.75; }

/* ---------------------- CELEBRATION (post-submit) ---------------------- */
#celebration-root {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 60;
}
.confetti-bit {
  position: absolute;
  top: -4vh;
  border-radius: 3px;
  animation: confetti-fall var(--dur, 2.8s) ease-in forwards;
  transform: rotate(var(--rot, 0deg));
}
@keyframes confetti-fall {
  to { transform: translateY(110vh) rotate(calc(var(--rot, 0deg) + 300deg)); opacity: 0.9; }
}

/* ------------------------ MOTION & REDUCED MOTION ------------------------ */
@media (prefers-reduced-motion: no-preference) {
  .reveal {
    opacity: 0;
    transform: translateY(18px);
    transition: opacity 0.6s ease, transform 0.6s ease;
  }
  .reveal.in { opacity: 1; transform: none; }
}

/* Everything decorative stops here when the visitor asks for less motion.
   main.js also skips the confetti and the reaction "pop". */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ------------------------------ SMALL SCREENS ------------------------------ */
@media (max-width: 640px) {
  .ring-badge { top: -16px; right: -8px; width: clamp(60px, 14vw, 80px); }
  .entry-head { flex-direction: column; align-items: flex-start; gap: 0.2rem; }
}

/* ===============================================================
   THEME LAYER — Dodger Stadium at dusk, World Series edition.
   Palette sampled from the supplied stadium photo (twilight navy sky,
   sunset coral clouds, outfield green kept in the photo itself) plus
   championship gold from the ring. One motif family, carried through:
   baseball seams + ticket stubs + the ring.
   =============================================================== */

:root {
  --gold: #C9A227;
  --gold-bright: #FFD54A;
  --cream: #F7F3EA;
}

/* --- Type: scoreboard capitals for the big moments --- */
h1, .about h2, .guestbook h2, .entries-title {
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* --- Hero: the stadium photo is the foundation --- */
.hero-bg picture { display: block; width: 100%; height: 100%; }
.hero h1 { text-shadow: 0 2px 20px rgb(0 0 0 / 0.5); }
.hero-sub { text-shadow: 0 1px 12px rgb(0 0 0 / 0.55); }

/* Eyebrow reads like the top line of the big screen. */
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  color: var(--gold-bright);
  text-shadow: 0 1px 10px rgb(0 0 0 / 0.6);
}
.eyebrow::before, .eyebrow::after {
  content: "◆";
  font-size: 0.7em;
  color: var(--accent);
  text-shadow: none;
}

.portrait picture { display: block; }

/* --- Baseball-seam rule under section headings --- */
.about h2::after,
.guestbook h2::after {
  content: "";
  display: block;
  width: 130px;
  height: 16px;
  margin: 0.55rem auto 0;
  border-bottom: 3px dashed var(--accent);
  border-radius: 50%;
}

/* --- About: faint bunting shadows in the corners --- */
.about {
  background-image:
    radial-gradient(circle at 10% 16%, rgb(0 90 156 / 0.05) 0 22px, transparent 23px),
    radial-gradient(circle at 88% 72%, rgb(228 87 46 / 0.05) 0 26px, transparent 27px);
}

.pillars svg { width: 20px; height: 20px; flex: none; }

/* --- Mementos: hand-placed keepsakes --- */
.mementos {
  margin-top: 2.6rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-start;
  gap: 1.8rem 2.2rem;
}
.memento {
  margin: 0;
  background: var(--card);
  padding: 12px 12px 8px;
  border-radius: 8px;
  box-shadow: var(--shadow);
  max-width: min(380px, 88vw);
  transform: rotate(-1.2deg);
  transition: transform 0.15s ease;
}
.memento-card { max-width: min(250px, 70vw); transform: rotate(1.6deg); }
.memento:hover { transform: rotate(0deg); }
.memento picture { display: block; }
.memento img { display: block; width: 100%; height: auto; border-radius: 4px; }
.memento figcaption {
  font-family: var(--font-accent);
  font-size: 1.35rem;
  color: var(--ink-soft);
  margin-top: 0.4rem;
  text-align: center;
}

/* --- Guestbook: mowed-outfield stripes over Dodger blue --- */
.guestbook {
  background-image: repeating-linear-gradient(
    90deg,
    rgb(255 255 255 / 0.04) 0 72px,
    transparent 72px 144px
  );
}

/* Gold focus ring where the background is Dodger blue — orange vanishes there. */
.guestbook :focus-visible { outline-color: var(--gold-bright); }

/* The signing form wears a champion's gold band. */
.signing-card { border-top: 6px solid var(--gold); }

/* --- Entries heading: an old scoreboard panel --- */
.entries-title {
  display: table;
  margin-inline: auto;
  background: var(--secondary);
  color: var(--cream);
  border: 2px solid var(--gold);
  border-radius: 8px;
  padding: 0.45rem 1.5rem 0.4rem;
  letter-spacing: 0.12em;
  box-shadow: var(--shadow);
}

/* --- Entry cards: ticket stubs from Monty's big night --- */
.entry-card {
  border-top: 6px solid var(--primary);
  transform: rotate(-0.5deg);
  transition: transform 0.15s ease;
}
.entries .entry-card:nth-child(even) { transform: rotate(0.6deg); }
.entry-card:hover { transform: rotate(0deg); }

/* Perforation line above the reaction row, like a tear-off stub. */
.entry-foot {
  border-top: 2px dashed color-mix(in srgb, var(--ink) 22%, transparent);
  padding-top: 0.6rem;
  margin-top: 0.4rem;
}

/* --- The ring, wherever it appears --- */
.react-icon-ring {
  width: 1.5em;
  height: 1.5em;
  border-radius: 50%;
  object-fit: cover;
  border: 1.5px solid var(--gold);
  background: #0b0b0e;
}

.confetti-ring {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--gold);
  background: #0b0b0e;
  box-shadow: 0 2px 8px rgb(0 0 0 / 0.3);
}

/* --- Footer: night sky over the pavilion; cream text for contrast --- */
.footer {
  background: linear-gradient(180deg, var(--secondary), #10203f);
  color: var(--cream);
}
.footer-big { color: #ffffff; }
.footer :focus-visible { outline-color: var(--gold-bright); }
