/* SpalterDVD — accessibility-first stylesheet (design spec §7).
 *
 * Audience: elderly family members. Every choice here favours legibility and
 * forgiveness over density:
 *   - base font 18px, grown via the [data-textsize] attribute on <html> so the
 *     whole rem cascade scales (A / A+ / A++).
 *   - warm, photo-friendly palette but text contrast aimed at 7:1 (WCAG AAA).
 *   - thick, high-contrast :focus-visible ring for keyboard users.
 *   - all interactive targets >= 44x44px.
 *   - prefers-reduced-motion: every transition/animation is killed.
 *   - NO autoplay anywhere (enforced by template tests, noted here for intent).
 */

/* ── Palette ──────────────────────────────────────────────────────────────
 * Warm parchment background with near-black ink. #2b2620 on #faf6ee is ~13:1,
 * comfortably past AAA. The accent brown #6b4f1d on the cream card is ~7.4:1,
 * so accent text on light surfaces also clears AAA.
 */
:root {
  --ink:        #2b2620;   /* primary text */
  --ink-soft:   #5b5142;   /* secondary text — ~7.1:1 on --paper */
  --paper:      #faf6ee;   /* page background — warm cream */
  --card:       #ffffff;   /* raised surfaces */
  --card-edge:  #e4dcc8;   /* hairline borders */
  --accent:     #6b4f1d;   /* warm brown — links, buttons */
  --accent-ink: #ffffff;   /* text on accent (white on #6b4f1d ~7.0:1) */
  --accent-deep:#4f3a13;   /* hover / active */
  --focus:      #0a3d91;   /* high-contrast focus ring (deep blue) */
  --error:      #8a1f1f;   /* ~7.3:1 on --paper */

  color-scheme: light;
  /* Base size — A. The rem cascade keys off this, so bumping it scales
   * everything. 18px is the spec floor. */
  font-size: 18px;
}

/* Text-size toggle: A+ and A++ raise the root font-size; rem-based sizing
 * downstream means headings, buttons, cards and gaps all grow together. */
html[data-textsize="lg"] { font-size: 21px; }
html[data-textsize="xl"] { font-size: 25px; }

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

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, sans-serif;
  font-size: 1rem;            /* == root, i.e. >= 18px */
  line-height: 1.55;
  color: var(--ink);
  background: var(--paper);
}

/* ── Skip link ───────────────────────────────────────────────────────────
 * Off-screen until focused, then it slides into the top-left as a solid
 * high-contrast pill. First focusable element in the document. */
.skip-link {
  position: absolute;
  left: 0.5rem;
  top: -4rem;
  z-index: 1000;
  background: var(--accent);
  color: var(--accent-ink);
  padding: 0.75rem 1.1rem;
  border-radius: 0 0 10px 10px;
  font-size: 1.1rem;
  font-weight: 700;
  text-decoration: none;
  transition: top 0.15s ease;
}
.skip-link:focus { top: 0; }

/* ── Header ──────────────────────────────────────────────────────────────*/
.site-header {
  background: var(--card);
  border-bottom: 3px solid var(--card-edge);
  padding: 0.75rem clamp(1rem, 4vw, 2.5rem);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.5rem;
}
.site-title {
  margin: 0;
  font-size: 1.5rem;
  line-height: 1.2;
  flex: 1 1 auto;
}
.site-title a { color: var(--ink); text-decoration: none; }
.site-title a:hover { text-decoration: underline; }

.site-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1.25rem;
}
.site-nav a {
  color: var(--accent);
  font-size: 1.1rem;
  font-weight: 600;
  text-decoration: none;
  /* 44px tap target */
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 0.25rem;
}
.site-nav a:hover { text-decoration: underline; }

/* ── Text-size control ───────────────────────────────────────────────────*/
.textsize {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.textsize-label {
  font-size: 0.95rem;
  color: var(--ink-soft);
}
.textsize button {
  min-width: 44px;
  min-height: 44px;
  padding: 0 0.6rem;
  border: 2px solid var(--accent);
  background: var(--card);
  color: var(--accent);
  border-radius: 8px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
}
.textsize button[aria-pressed="true"] {
  background: var(--accent);
  color: var(--accent-ink);
}
.textsize button:nth-child(2) { font-size: 1rem; }
.textsize button:nth-child(3) { font-size: 1.2rem; }
.textsize button:nth-child(4) { font-size: 1.45rem; }

/* ── Main + footer ───────────────────────────────────────────────────────*/
main {
  flex: 1 1 auto;
  width: 100%;
  max-width: 70rem;
  margin: 0 auto;
  padding: clamp(1rem, 4vw, 2.5rem);
}
.site-footer {
  border-top: 3px solid var(--card-edge);
  background: var(--card);
  color: var(--ink-soft);
  padding: 1.25rem clamp(1rem, 4vw, 2.5rem);
  font-size: 1rem;
  text-align: center;
}

/* ── Links, buttons, forms ───────────────────────────────────────────────*/
a { color: var(--accent); }
a:hover { color: var(--accent-deep); }

button, .btn {
  font: inherit;
  min-height: 44px;
  padding: 0.7rem 1.1rem;
  background: var(--accent);
  color: var(--accent-ink);
  border: 0;
  border-radius: 10px;
  cursor: pointer;
}
button:hover, .btn:hover { background: var(--accent-deep); }

input[type=email], input[type=text] {
  width: 100%;
  font-size: 1.15rem;
  min-height: 44px;
  padding: 0.7rem 0.8rem;
  border: 2px solid var(--card-edge);
  border-radius: 10px;
  background: var(--card);
  color: var(--ink);
}

/* ── Focus — thick, high-contrast, never removed ─────────────────────────*/
:focus-visible {
  outline: 4px solid var(--focus);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ── Auth card (consolidated from the old _base.html) ────────────────────*/
.card {
  background: var(--card);
  max-width: 32rem;
  margin: 2rem auto;
  padding: 2rem 2.25rem;
  border: 1px solid var(--card-edge);
  border-radius: 14px;
  box-shadow: 0 6px 28px rgba(0, 0, 0, 0.08);
}
.card h1 { font-size: 1.8rem; margin: 0 0 0.5rem; }
.card p { font-size: 1.15rem; }
.card label {
  display: block;
  font-size: 1.1rem;
  margin: 1rem 0 0.35rem;
  font-weight: 700;
}
.card button { width: 100%; margin-top: 1.25rem; font-size: 1.2rem; }
.error { color: var(--error); font-weight: 700; margin-top: 1rem; }
.muted { color: var(--ink-soft); font-size: 1rem; }
hr { border: 0; border-top: 1px solid var(--card-edge); margin: 1.75rem 0; }

/* ── Timeline ────────────────────────────────────────────────────────────*/
.page-title { font-size: 1.9rem; margin: 0 0 0.5rem; }
.lede { font-size: 1.2rem; color: var(--ink-soft); margin: 0 0 2rem; }

.year-group { margin: 0 0 2.5rem; }
.year-heading {
  font-size: 1.6rem;
  margin: 0 0 1rem;
  padding-bottom: 0.35rem;
  border-bottom: 3px solid var(--card-edge);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: 1.25rem;
}

/* The whole event card is one big tappable target. */
.event-card {
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--card-edge);
  border-radius: 14px;
  overflow: hidden;
  text-decoration: none;
  color: var(--ink);
  box-shadow: 0 3px 14px rgba(0, 0, 0, 0.07);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  min-height: 44px;
}
.event-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.13);
}
.event-card__cover {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  display: block;
  background: #efe7d4;
}
/* Graceful placeholder when an event has no cover image. */
.event-card__cover--placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  color: var(--ink-soft);
  background: linear-gradient(135deg, #efe7d4, #e0d4b8);
}
.event-card__body { padding: 1rem 1.1rem 1.25rem; }
.event-card__title {
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.25;
  margin: 0 0 0.25rem;
}
.event-card__year { font-size: 1.05rem; color: var(--ink-soft); }
.event-card__badge {
  display: inline-block;
  margin-top: 0.5rem;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent-ink);
  background: var(--accent-deep);
  padding: 0.15rem 0.5rem;
  border-radius: 6px;
}

/* ── Event detail page ───────────────────────────────────────────────────*/
.breadcrumb {
  font-size: 1.05rem;
  margin: 0 0 1rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  color: var(--ink-soft);
}
.breadcrumb a { font-weight: 600; }

.event-header { margin: 0 0 2rem; }
.event-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  font-size: 1.15rem;
  color: var(--ink-soft);
  margin: 0 0 0.75rem;
}
.event-meta__year { font-weight: 700; color: var(--ink); }
.event-description { font-size: 1.2rem; max-width: 48rem; }

.asset-group { margin: 0 0 2.75rem; }
.asset-group__heading {
  font-size: 1.6rem;
  margin: 0 0 1.25rem;
  padding-bottom: 0.35rem;
  border-bottom: 3px solid var(--card-edge);
}

/* Each asset is a card with generous spacing. */
.asset {
  background: var(--card);
  border: 1px solid var(--card-edge);
  border-radius: 14px;
  padding: 1.25rem;
  margin: 0 0 1.75rem;
  box-shadow: 0 3px 14px rgba(0, 0, 0, 0.07);
}
/* Anchor target offset so a deep-linked asset isn't hidden under the header. */
.asset { scroll-margin-top: 1.5rem; }

.player {
  width: 100%;
  max-height: 70vh;
  background: #000;
  border-radius: 10px;
  display: block;
}
.player__nofallback { color: var(--ink-soft); padding: 1rem; }

.asset__caption {
  font-size: 1.2rem;
  margin: 0.85rem 0 0;
  line-height: 1.45;
}

/* Photo gallery — responsive grid of caption cards. */
.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr));
  gap: 1.5rem;
}
.gallery .asset { margin: 0; }
.gallery__img {
  width: 100%;
  border-radius: 10px;
  display: block;
  background: #efe7d4;
}

.document__scan, .document__embed {
  width: 100%;
  border-radius: 10px;
  display: block;
}
.document__embed { min-height: 60vh; border: 1px solid var(--card-edge); }
.document__download { margin-top: 1rem; }

/* Per-asset footer: people tags + permalink + downloads. */
.asset__footer {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--card-edge);
}
.asset__people { margin: 0 0 0.75rem; font-size: 1.05rem; }
.asset__people-label { color: var(--ink-soft); margin-right: 0.4rem; }
.person-tag {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0.2rem 0.6rem;
  margin: 0.15rem 0.3rem 0.15rem 0;
  border-radius: 8px;
  background: #efe7d4;
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}
.person-tag:hover { background: #e0d4b8; }
.person-tag--anon { color: var(--ink-soft); font-style: italic; cursor: default; }

.asset__links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1.25rem;
  margin: 0;
}
.asset__links a {
  font-weight: 600;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}
.asset__download--master { color: var(--accent-deep); }

/* ── Search ──────────────────────────────────────────────────────────────*/
.search-form { margin: 0 0 2rem; max-width: 40rem; }
.search-form__label {
  display: block;
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0 0 0.4rem;
}
.search-form__row { display: flex; gap: 0.6rem; }
.search-form__row input { flex: 1 1 auto; }
.search-form__row button { flex: 0 0 auto; }

.search-count { font-size: 1.15rem; color: var(--ink-soft); margin: 0 0 1.25rem; }
.search-results { list-style: none; margin: 0; padding: 0; }
.search-result {
  background: var(--card);
  border: 1px solid var(--card-edge);
  border-radius: 12px;
  padding: 1rem 1.25rem;
  margin: 0 0 1rem;
}
.search-result__link {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem 0.85rem;
  text-decoration: none;
  min-height: 44px;
}
.search-result__link:hover .search-result__title { text-decoration: underline; }
.search-result__title { font-size: 1.25rem; font-weight: 700; color: var(--accent); }
.search-result__kind {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent-ink);
  background: var(--accent-deep);
  padding: 0.1rem 0.5rem;
  border-radius: 6px;
}
.search-result__snippet { margin: 0.5rem 0 0; color: var(--ink-soft); font-size: 1.05rem; }

/* ── Empty state ─────────────────────────────────────────────────────────*/
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--ink-soft);
}
.empty-state h2 { font-size: 1.6rem; color: var(--ink); margin: 0 0 0.5rem; }
.empty-state p { font-size: 1.2rem; }

/* ── People index + person pages ─────────────────────────────────────────*/
.people-help { margin: 0 0 1.5rem; font-size: 1.15rem; }
.people-help__link { font-weight: 700; }

.people-list { list-style: none; margin: 0; padding: 0; }
.people-list__item {
  background: var(--card);
  border: 1px solid var(--card-edge);
  border-radius: 12px;
  margin: 0 0 0.85rem;
}
.people-list__link {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.4rem 0.85rem;
  padding: 1rem 1.25rem;
  text-decoration: none;
  min-height: 44px;
}
.people-list__link:hover .people-list__name { text-decoration: underline; }
.people-list__name { font-size: 1.3rem; font-weight: 700; color: var(--accent); }
.people-list__dates { color: var(--ink-soft); font-size: 1.05rem; }
.people-list__count {
  margin-left: auto;
  color: var(--ink-soft);
  font-size: 1.05rem;
}

.person-header { margin: 0 0 1.5rem; }
.person-meta, .person-notes { font-size: 1.15rem; color: var(--ink-soft); margin: 0.25rem 0 0; }
.person-count { font-size: 1.15rem; color: var(--ink-soft); margin: 0 0 1.25rem; }
.person-memoriam {
  font-size: 1.25rem;
  font-style: italic;
  color: var(--accent-deep);
  margin: 0 0 0.25rem;
}
.person-gallery__link { text-decoration: none; display: block; }
.person-gallery__link:hover .asset__caption { text-decoration: underline; }
.person-gallery__event { display: block; color: var(--ink-soft); font-size: 0.95rem; margin-top: 0.2rem; }

/* ── Tag-someone form (per-asset footer) ─────────────────────────────────*/
.tag-form { margin: 0.75rem 0 0; }
.tag-form summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--accent);
  min-height: 36px;
  display: inline-flex;
  align-items: center;
}
.tag-form__body { margin-top: 0.6rem; display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: flex-end; }
.tag-form__field { display: flex; flex-direction: column; gap: 0.25rem; }
.tag-form__field label { font-weight: 600; font-size: 1rem; }
.tag-form__field input { min-width: 14rem; }
.tag-form__hint { flex-basis: 100%; margin: 0; color: var(--ink-soft); font-size: 0.95rem; }
.tag-untag { margin-left: 0.4rem; }
.tag-untag button {
  background: none;
  border: none;
  color: var(--ink-soft);
  font-size: 0.9rem;
  cursor: pointer;
  text-decoration: underline;
  min-height: 36px;
}

/* ── Caption provenance + crowdsourced caption editing ───────────────────── */
/* An AI-generated caption is a GUESS, never family knowledge: make it visibly,
   unmistakably distinct from a human caption so no one reads it as fact. */
.caption-badge--ai {
  display: inline-block;
  margin: 0 0 0.35rem;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  background: #ede4ff;
  color: #4b2e83;
  border: 1px solid #c9b6ef;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}
.asset__caption--ai .caption-text { font-style: italic; color: var(--ink-soft); }
.asset__caption--empty { color: var(--ink-soft); font-style: italic; }
.caption-empty-hint { font-size: 1rem; }

.caption-form { margin: 0.75rem 0 0; }
.caption-form summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--accent);
  min-height: 36px;
  display: inline-flex;
  align-items: center;
}
.caption-form__body { margin-top: 0.6rem; display: flex; flex-direction: column; gap: 0.6rem; align-items: stretch; }
.caption-form__field { display: flex; flex-direction: column; gap: 0.3rem; }
.caption-form__field label { font-weight: 600; font-size: 1rem; }
.caption-form__field textarea {
  width: 100%;
  box-sizing: border-box;
  min-height: 5.5rem;
  padding: 0.6rem 0.7rem;
  font-family: inherit;
  font-size: 1.1rem;
  line-height: 1.4;
  resize: vertical;
}
.caption-form button { align-self: flex-start; }
.caption-form__hint { margin: 0; color: var(--ink-soft); font-size: 0.95rem; }

/* ── Faces (Apple-Photos-style cluster grid + naming) ────────────────────*/
.faces-section { margin: 2rem 0; }
.faces-section__title { margin: 0 0 0.3rem; }
.faces-section__hint { margin: 0 0 1rem; color: var(--ink-soft); }

/* Circular face thumbnails in a forgiving, large-target grid. */
.faces-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr));
  gap: 1.25rem;
}
.faces-grid__item { margin: 0; }

.face-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem;
  min-height: 44px;
  text-align: center;
  text-decoration: none;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--card-edge);
  border-radius: 12px;
}
.face-card:hover { background: #fbf7ef; color: var(--ink); }
.face-card__img {
  width: 7rem;
  height: 7rem;
  object-fit: cover;
  border-radius: 50%;
  background: #efe7d4;
  border: 2px solid var(--card-edge);
}
.face-card--unnamed .face-card__img { border-color: var(--accent); }
.face-card__label { display: flex; flex-direction: column; gap: 0.15rem; }
.face-card__name { font-weight: 600; font-size: 1.05rem; }
.face-card__name--unknown { color: var(--accent); }
.face-card__count { color: var(--ink-soft); font-size: 0.95rem; }

/* Naming form on a single cluster page. */
.face-name {
  margin: 1.5rem 0 2rem;
  padding: 1.25rem;
  background: var(--card);
  border: 1px solid var(--card-edge);
  border-radius: 12px;
}
.face-name__title { margin: 0 0 0.3rem; }
.face-name__hint { margin: 0 0 1rem; color: var(--ink-soft); }
.face-name__form { display: flex; flex-direction: column; gap: 0.75rem; max-width: 32rem; }
.face-name__label { font-weight: 600; }
.face-name__submit { align-self: flex-start; }

/* Face crops in the cluster gallery — square so heads read clearly. */
.face-cluster__face { aspect-ratio: 1 / 1; object-fit: cover; }
.faces-cluster__event { display: block; color: var(--ink-soft); font-size: 0.95rem; margin-top: 0.25rem; }
.face-cluster__count-h { margin-top: 2rem; }

@media (max-width: 30rem) {
  .faces-grid { grid-template-columns: repeat(auto-fill, minmax(7rem, 1fr)); gap: 1rem; }
  .face-card__img { width: 6rem; height: 6rem; }
}

/* ── Reduced motion — kill every transition / animation ──────────────────*/
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
