/* ==========================================================================
   goodbye-spuddy.org
   A memorial site. Warm, quiet, generous with whitespace.
   No framework, no build step, no external font requests — this should still
   render correctly in ten years on whatever browsers exist then.
   ========================================================================== */

:root {
  --bg:            #FBF9F5;
  --bg-sunk:       #F4F0E8;
  --surface:       #FFFFFF;
  --ink:           #2A2622;
  --ink-soft:      #5E564C;
  --ink-faint:     #8B8175;
  --accent:        #7A6248;
  --accent-soft:   #A0907C;
  --rule:          #E7E0D4;
  --shadow:        0 1px 2px rgba(42,38,34,.04), 0 8px 24px -12px rgba(42,38,34,.14);
  --shadow-lift:   0 2px 4px rgba(42,38,34,.05), 0 16px 40px -16px rgba(42,38,34,.22);
  --radius:        10px;
  --radius-lg:     14px;
  --measure:       34rem;

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua",
           Georgia, "Times New Roman", serif;
  --sans:  ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
           "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:          #1A1815;
    --bg-sunk:     #141210;
    --surface:     #232019;
    --ink:         #EDE7DC;
    --ink-soft:    #B8AE9F;
    --ink-faint:   #8A8073;
    --accent:      #C9AE8A;
    --accent-soft: #9C8B76;
    --rule:        #35302A;
    --shadow:      0 1px 2px rgba(0,0,0,.3), 0 8px 24px -12px rgba(0,0,0,.6);
    --shadow-lift: 0 2px 4px rgba(0,0,0,.35), 0 16px 40px -16px rgba(0,0,0,.7);
  }
}

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img { max-width: 100%; display: block; }
a { color: var(--accent); }

/* Visible focus for keyboard users — a lot of the people using this site
   will not be confident computer users. */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 3px;
}

.skip-link {
  position: absolute; left: -9999px;
  background: var(--surface); color: var(--ink);
  padding: .75rem 1.25rem; z-index: 200; border-radius: var(--radius);
}
.skip-link:focus { left: 1rem; top: 1rem; }

/* ---------- layout ------------------------------------------------------ */

.wrap {
  width: 100%;
  max-width: 76rem;
  margin-inline: auto;
  padding-inline: 1.25rem;
}
.wrap--narrow { max-width: 42rem; }

/* ---------- masthead ---------------------------------------------------- */

.masthead {
  border-bottom: 1px solid var(--rule);
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  position: sticky; top: 0; z-index: 50;
}
.masthead__inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; min-height: 4.25rem;
}
.brand {
  display: flex; flex-direction: column; gap: .1rem;
  text-decoration: none; color: inherit;
}
.brand__name {
  font-family: var(--serif);
  font-size: 1.3rem; font-weight: 600; letter-spacing: .005em;
  line-height: 1.15;
}
.brand__dates {
  font-size: .72rem; letter-spacing: .13em; text-transform: uppercase;
  color: var(--ink-faint);
}

.nav { display: flex; align-items: center; gap: .35rem; }
.nav a {
  display: inline-flex; align-items: center;
  padding: .5rem .85rem; border-radius: 999px;
  font-size: .93rem; text-decoration: none;
  color: var(--ink-soft); font-weight: 500;
  transition: background .18s ease, color .18s ease;
}
.nav a:hover { background: var(--bg-sunk); color: var(--ink); }
.nav a[aria-current="page"] { color: var(--ink); background: var(--bg-sunk); }

/* The one action we actually want people to take. */
.nav .nav__cta {
  background: var(--accent); color: #fff;
  padding-inline: 1.15rem;
  box-shadow: var(--shadow);
}
.nav .nav__cta:hover { background: var(--ink); color: #fff; }
@media (prefers-color-scheme: dark) {
  .nav .nav__cta { color: #1A1815; }
  .nav .nav__cta:hover { background: var(--ink); color: #1A1815; }
}

@media (max-width: 34rem) {
  .brand__name { font-size: 1.08rem; }
  .nav a { padding: .45rem .6rem; font-size: .86rem; }
  .nav .nav__cta { padding-inline: .85rem; }
  .nav__plain { display: none; }
}

/* ---------- hero -------------------------------------------------------- */

.hero { padding: clamp(2.5rem, 7vw, 5rem) 0 clamp(1.75rem, 4vw, 3rem); }
.hero__grid {
  display: grid; gap: clamp(1.75rem, 5vw, 3.5rem);
  grid-template-columns: 1fr;
  align-items: center;
}
@media (min-width: 52rem) {
  .hero__grid { grid-template-columns: minmax(0, 20rem) minmax(0, 1fr); }
  /* No portrait supplied (or it failed to load) — don't leave the text
     stranded in a 20rem column with a void beside it. */
  .hero__grid--solo { grid-template-columns: minmax(0, 1fr); }
  .hero__grid--solo .hero__lede,
  .hero__grid--solo .hero__title { max-width: 46rem; }
}
.hero__portrait {
  width: 100%; aspect-ratio: 4 / 5; object-fit: cover;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lift);
  background: var(--bg-sunk);
}
.hero__title {
  font-family: var(--serif);
  font-size: clamp(2.1rem, 6vw, 3.4rem);
  line-height: 1.08; font-weight: 600; margin: 0 0 .6rem;
  letter-spacing: -.012em;
}
.hero__dates {
  font-size: .8rem; letter-spacing: .16em; text-transform: uppercase;
  color: var(--ink-faint); margin: 0 0 1.4rem;
}
.hero__lede {
  font-family: var(--serif);
  font-size: clamp(1.08rem, 2.1vw, 1.25rem);
  line-height: 1.62; color: var(--ink-soft);
  max-width: var(--measure); margin: 0 0 1.9rem;
}
.hero__lede p { margin: 0 0 1rem; }
.hero__lede p:last-child { margin-bottom: 0; }

/* ---------- buttons ----------------------------------------------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: .55rem;
  font: inherit; font-weight: 600; font-size: .97rem;
  padding: .8rem 1.5rem; border-radius: 999px;
  border: 1px solid transparent; cursor: pointer;
  text-decoration: none; line-height: 1.2;
  transition: background .18s ease, border-color .18s ease,
              transform .12s ease, box-shadow .18s ease;
}
.btn:active { transform: translateY(1px); }
.btn--primary {
  background: var(--accent); color: #fff; box-shadow: var(--shadow);
}
.btn--primary:hover { background: var(--ink); box-shadow: var(--shadow-lift); }
@media (prefers-color-scheme: dark) {
  .btn--primary { color: #1A1815; }
  .btn--primary:hover { color: #1A1815; }
}
.btn--ghost {
  background: transparent; color: var(--ink-soft); border-color: var(--rule);
}
.btn--ghost:hover { background: var(--bg-sunk); color: var(--ink); }
.btn--danger { background: transparent; color: #A8402F; border-color: #E0BDB5; }
.btn--danger:hover { background: #A8402F; color: #fff; border-color: #A8402F; }
.btn--sm { padding: .48rem .95rem; font-size: .87rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn[disabled]:active { transform: none; }

/* ---------- section headings -------------------------------------------- */

.section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap;
  padding-block: clamp(1.5rem, 3vw, 2.25rem) 1.5rem;
  border-top: 1px solid var(--rule);
}
.section-head__title {
  font-family: var(--serif); font-weight: 600;
  font-size: clamp(1.35rem, 3vw, 1.7rem); margin: 0;
  letter-spacing: -.008em;
}
.section-head__count { font-size: .88rem; color: var(--ink-faint); }

/* ---------- gallery ----------------------------------------------------- */

/* CSS columns give a masonry flow without JS. Cards must not break across
   columns — break-inside handles that. */
.gallery {
  columns: 1;
  column-gap: 1.15rem;
  padding-bottom: 4rem;
}
@media (min-width: 40rem)  { .gallery { columns: 2; } }
@media (min-width: 64rem)  { .gallery { columns: 3; } }
@media (min-width: 88rem)  { .gallery { columns: 4; } }

.card {
  break-inside: avoid;
  -webkit-column-break-inside: avoid;
  page-break-inside: avoid;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  margin: 0 0 1.15rem;
  overflow: hidden;
  transition: box-shadow .22s ease, transform .22s ease;
}
.card:hover { box-shadow: var(--shadow-lift); transform: translateY(-2px); }

.card__figure { margin: 0; background: var(--bg-sunk); cursor: zoom-in; }
.card__img {
  width: 100%; height: auto; display: block;
  background: var(--bg-sunk);
}
.card__body { padding: 1.05rem 1.15rem 1.15rem; }

.card__message {
  font-family: var(--serif);
  font-size: 1.02rem; line-height: 1.6; color: var(--ink);
  margin: 0 0 .85rem;
  white-space: pre-wrap;   /* honour the line breaks people type */
  overflow-wrap: anywhere;
}
/* A text-only memory is the whole card, so let it breathe more. */
.card--text .card__body { padding: 1.4rem 1.35rem; }
.card--text .card__message { font-size: 1.1rem; line-height: 1.65; }

.card__meta {
  display: flex; align-items: baseline; gap: .5rem; flex-wrap: wrap;
  font-size: .84rem; color: var(--ink-faint);
}
.card__author { font-weight: 600; color: var(--ink-soft); font-size: .89rem; }
.card__dot { color: var(--rule); }

/* ---------- empty / loading states -------------------------------------- */

.state {
  text-align: center; padding: clamp(3rem, 9vw, 6rem) 1rem;
  color: var(--ink-faint); max-width: 30rem; margin-inline: auto;
}
.state__title {
  font-family: var(--serif); font-size: 1.3rem; color: var(--ink-soft);
  margin: 0 0 .6rem;
}
.state p { margin: 0 0 1.5rem; }

.skeleton {
  background: linear-gradient(90deg, var(--bg-sunk) 25%,
              color-mix(in srgb, var(--bg-sunk) 55%, var(--surface)) 50%,
              var(--bg-sunk) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
  border-radius: var(--radius-lg);
  margin-bottom: 1.15rem;
  break-inside: avoid;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- forms ------------------------------------------------------- */

.page-head { padding: clamp(2.25rem, 6vw, 4rem) 0 clamp(1.25rem, 3vw, 2rem); }
.page-head__title {
  font-family: var(--serif); font-weight: 600;
  font-size: clamp(1.9rem, 5vw, 2.8rem); margin: 0 0 .7rem;
  letter-spacing: -.012em; line-height: 1.12;
}
.page-head__lede {
  font-size: 1.05rem; color: var(--ink-soft);
  max-width: var(--measure); margin: 0;
}

.form { padding-bottom: 5rem; }
.field { margin-bottom: 1.6rem; }
.field__label {
  display: block; font-weight: 600; font-size: .95rem;
  margin-bottom: .1rem; color: var(--ink);
}
.field__hint {
  display: block; font-size: .87rem; color: var(--ink-faint);
  margin-bottom: .55rem;
}
.field__optional { font-weight: 400; color: var(--ink-faint); font-size: .87rem; }

.input, .textarea {
  width: 100%; font: inherit; color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--rule); border-radius: var(--radius);
  padding: .8rem .95rem;
  transition: border-color .18s ease, box-shadow .18s ease;
}
.input:focus, .textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
.textarea { min-height: 9.5rem; resize: vertical; line-height: 1.6; }
.input[aria-invalid="true"], .textarea[aria-invalid="true"] {
  border-color: #A8402F;
  box-shadow: 0 0 0 3px rgba(168,64,47,.14);
}

.field__error {
  display: none; color: #A8402F; font-size: .87rem; margin-top: .4rem;
  font-weight: 500;
}
.field__error--on { display: block; }

.counter { font-size: .82rem; color: var(--ink-faint); text-align: right; margin-top: .35rem; }
.counter--warn { color: #A8402F; }

/* photo drop zone */
.dropzone {
  border: 1.5px dashed var(--rule); border-radius: var(--radius-lg);
  background: var(--surface);
  padding: 2rem 1.25rem; text-align: center; cursor: pointer;
  transition: border-color .18s ease, background .18s ease;
}
.dropzone:hover, .dropzone--over {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 5%, var(--surface));
}
.dropzone__icon { color: var(--ink-faint); margin-bottom: .6rem; }
.dropzone__text { font-weight: 600; color: var(--ink-soft); margin-bottom: .2rem; }
.dropzone__hint { font-size: .85rem; color: var(--ink-faint); }

.preview { display: none; position: relative; }
.preview--on { display: block; }
.preview__img {
  width: 100%; max-height: 22rem; object-fit: contain;
  background: var(--bg-sunk);
  border: 1px solid var(--rule); border-radius: var(--radius-lg);
}
.preview__bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; margin-top: .7rem; font-size: .87rem; color: var(--ink-faint);
}

.progress {
  height: 5px; background: var(--bg-sunk); border-radius: 999px;
  overflow: hidden; margin-top: .8rem; display: none;
}
.progress--on { display: block; }
.progress__bar {
  height: 100%; width: 0%; background: var(--accent);
  transition: width .25s ease;
}

.form__actions {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding-top: .5rem;
}
.form__note {
  font-size: .87rem; color: var(--ink-faint);
  max-width: var(--measure); margin-top: 1.75rem;
  padding-top: 1.25rem; border-top: 1px solid var(--rule);
}

/* the "thank you" panel that replaces the form */
.thanks { display: none; text-align: center; padding: clamp(2.5rem, 8vw, 5rem) 0 6rem; }
.thanks--on { display: block; }
.thanks__mark {
  width: 3.75rem; height: 3.75rem; margin: 0 auto 1.5rem;
  border-radius: 999px; display: grid; place-items: center;
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  color: var(--accent);
}
.thanks__title {
  font-family: var(--serif); font-size: clamp(1.6rem, 4vw, 2.1rem);
  margin: 0 0 .8rem; font-weight: 600;
}
.thanks__body { color: var(--ink-soft); max-width: 30rem; margin: 0 auto 2rem; }

.alert {
  display: none; padding: .9rem 1.1rem; border-radius: var(--radius);
  font-size: .93rem; margin-bottom: 1.5rem;
  border: 1px solid; line-height: 1.55;
}
.alert--on { display: block; }
.alert--error { background: #FCF2F0; border-color: #E8C8C0; color: #8C3527; }
.alert--info  { background: var(--bg-sunk); border-color: var(--rule); color: var(--ink-soft); }
@media (prefers-color-scheme: dark) {
  .alert--error { background: #2E1C18; border-color: #5A3128; color: #E8B4A8; }
}

/* ---------- lightbox ---------------------------------------------------- */

.lightbox {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(20,18,16,.94);
  display: none; place-items: center;
  padding: clamp(1rem, 4vw, 3rem);
}
.lightbox--on { display: grid; }
.lightbox__img {
  max-width: 100%; max-height: 78vh; object-fit: contain;
  border-radius: var(--radius); box-shadow: 0 30px 80px -20px rgba(0,0,0,.8);
}
.lightbox__caption {
  color: #E8E2D8; text-align: center; margin-top: 1.25rem;
  max-width: 40rem; font-family: var(--serif); line-height: 1.6;
  white-space: pre-wrap;
}
.lightbox__author { display: block; margin-top: .6rem; font-size: .85rem;
  color: #A69C8E; font-family: var(--sans); letter-spacing: .04em; }
.lightbox__close {
  position: absolute; top: 1rem; right: 1rem;
  width: 2.75rem; height: 2.75rem; border-radius: 999px;
  background: rgba(255,255,255,.12); color: #fff; border: 0;
  cursor: pointer; display: grid; place-items: center;
  font-size: 1.5rem; line-height: 1;
}
.lightbox__close:hover { background: rgba(255,255,255,.24); }
.lightbox__nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 3rem; height: 3rem; border-radius: 999px; border: 0;
  background: rgba(255,255,255,.12); color: #fff; cursor: pointer;
  display: grid; place-items: center; font-size: 1.4rem;
}
.lightbox__nav:hover { background: rgba(255,255,255,.24); }
.lightbox__nav--prev { left: 1rem; }
.lightbox__nav--next { right: 1rem; }
@media (max-width: 40rem) { .lightbox__nav { display: none; } }

/* ---------- admin ------------------------------------------------------- */

.tabs {
  display: flex; gap: .3rem; border-bottom: 1px solid var(--rule);
  margin-bottom: 1.75rem; overflow-x: auto; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  font: inherit; font-weight: 600; font-size: .93rem;
  background: none; border: 0; border-bottom: 2px solid transparent;
  padding: .75rem .95rem; color: var(--ink-faint); cursor: pointer;
  white-space: nowrap; transition: color .18s ease, border-color .18s ease;
}
.tab:hover { color: var(--ink-soft); }
.tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.tab__badge {
  display: inline-block; min-width: 1.35rem; padding: 0 .4rem;
  margin-left: .4rem; border-radius: 999px;
  background: var(--accent); color: #fff;
  font-size: .74rem; line-height: 1.35rem; text-align: center;
}
.tab__badge:empty, .tab__badge[data-count="0"] { display: none; }

.mod-list { display: grid; gap: 1rem; padding-bottom: 5rem; }
.mod-item {
  display: grid; gap: 1.1rem;
  grid-template-columns: 1fr;
  background: var(--surface); border: 1px solid var(--rule);
  border-radius: var(--radius-lg); padding: 1.15rem; box-shadow: var(--shadow);
}
@media (min-width: 44rem) {
  .mod-item--photo { grid-template-columns: 11rem minmax(0, 1fr); }
}
.mod-item__thumb {
  width: 100%; aspect-ratio: 1; object-fit: cover;
  border-radius: var(--radius); background: var(--bg-sunk); cursor: zoom-in;
}
.mod-item__main { min-width: 0; }
.mod-item__head {
  display: flex; align-items: center; gap: .6rem; flex-wrap: wrap;
  margin-bottom: .5rem;
}
.mod-item__author { font-weight: 700; }
.mod-item__time { font-size: .84rem; color: var(--ink-faint); }
.mod-item__message {
  font-family: var(--serif); line-height: 1.6; margin: 0 0 .9rem;
  white-space: pre-wrap; overflow-wrap: anywhere; color: var(--ink-soft);
}
.mod-item__actions { display: flex; gap: .55rem; flex-wrap: wrap; }

.pill {
  display: inline-flex; align-items: center; gap: .35rem;
  font-size: .75rem; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; padding: .2rem .6rem; border-radius: 999px;
}
.pill--live      { background: #E4EFE4; color: #2F6135; }
.pill--held      { background: #FBF0DC; color: #8A5B14; }
.pill--rejected  { background: #F6E7E4; color: #8C3527; }
@media (prefers-color-scheme: dark) {
  .pill--live     { background: #1E3320; color: #A8D6AC; }
  .pill--held     { background: #352912; color: #E6C078; }
  .pill--rejected { background: #33201C; color: #E0A99C; }
}
.pill__reason { text-transform: none; letter-spacing: 0; font-weight: 500; }

.mod-flags {
  font-size: .84rem; color: #8A5B14; background: #FBF0DC;
  border: 1px solid #EBD9B4; border-radius: var(--radius);
  padding: .55rem .75rem; margin-bottom: .85rem;
}
@media (prefers-color-scheme: dark) {
  .mod-flags { background: #2E2412; border-color: #4A3A1C; color: #E6C078; }
}

.login-card {
  max-width: 24rem; margin: clamp(3rem, 12vh, 7rem) auto;
  background: var(--surface); border: 1px solid var(--rule);
  border-radius: var(--radius-lg); padding: 2rem; box-shadow: var(--shadow-lift);
  text-align: center;
}
.login-card__title {
  font-family: var(--serif); font-size: 1.4rem; margin: 0 0 .5rem; font-weight: 600;
}
.login-card__body { color: var(--ink-soft); font-size: .95rem; margin: 0 0 1.5rem; }

/* ---------- footer ------------------------------------------------------ */

.footer {
  border-top: 1px solid var(--rule);
  padding: 2.5rem 0 3.5rem; margin-top: auto;
  color: var(--ink-faint); font-size: .88rem;
}
.footer__inner {
  display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  align-items: center;
}
.footer a { color: var(--ink-faint); text-decoration: none; }
.footer a:hover { color: var(--ink-soft); text-decoration: underline; }

body { display: flex; flex-direction: column; min-height: 100vh; }
main { flex: 1; }

/* ---------- print: someone will want to print these ---------------------- */

@media print {
  .masthead, .nav, .footer, .btn, .lightbox { display: none !important; }
  body { background: #fff; color: #000; font-size: 11pt; }
  .gallery { columns: 2; }
  .card { border: 1px solid #ccc; box-shadow: none; break-inside: avoid; }
}
