/* The cover page: the family site's front door. Three layouts chosen by the theme's cover_layout
   (templates/cover/hero.html, split.html, framed.html), the typographic cover used when there is no
   photo, the public sections of a public site, the footer, the ?before= pages, and the family badge
   on the sign-in pages. Tokens only; nothing here needs JavaScript.

   Every cover photo is an <img> with width/height attributes inside a box whose size never depends
   on the image loading, so nothing moves when it arrives (no layout shift). */

.cover-page { position: relative; display: flex; flex-direction: column; width: 100%; padding: 0; }
/* Without public sections the cover is a full-screen composition with the footer at the bottom.
   The fallback guesses the footer's height; browsers with :has() size it exactly. */
.cover-page--full { min-height: calc(100vh - 56px); min-height: calc(100svh - 56px); }
body:has(> .cover-page--full) { display: flex; flex-direction: column; min-height: 100vh; min-height: 100svh; }
body:has(> .cover-page--full) > .cover-page--full { flex: 1 0 auto; min-height: 0; }
.cover-page--full > .cover { flex: 1 0 auto; }
/* With public sections the cover takes most of the first screen and the sections follow. */
.cover-page--public > .cover { min-height: 80vh; min-height: 80svh; }
.cover-page > .messages { max-width: 720px; margin: 64px auto var(--space-4); padding: 0 var(--space-4); } /* below the floating Sign in */

/* ---- Shared type ---- */
.cover__name {
  margin: 0;
  font-size: clamp(2.3rem, 1.3rem + 4.6vw, 4.75rem);
  line-height: 1.04;
  overflow-wrap: anywhere;
  text-wrap: balance;
}
.cover__welcome {
  max-width: 34ch;
  margin: var(--space-3) 0 0;
  font-size: clamp(1.05rem, 0.98rem + 0.4vw, 1.3rem);
  line-height: 1.5;
  color: var(--muted);
  overflow-wrap: anywhere;
  text-wrap: pretty;
}
.cover-actions {
  display: flex; flex-direction: column; align-items: inherit; gap: var(--space-3);
  margin-top: var(--space-5);
}
.cover-actions form { margin: 0; }
.cover__action { min-width: 190px; min-height: 48px; font-size: var(--step-body); }
.cover-notice { max-width: 40ch; margin: 0; font-size: var(--step-small); overflow-wrap: anywhere; }

.cover-photo { display: block; width: 100%; height: 100%; object-fit: cover; }

.cover-rule {
  display: block; width: 56px; height: 3px; border-radius: 3px;
  background: var(--accent);
  margin: var(--space-4) 0;
}

/* The monogram badge: the family's initial in the heading font, ringed like a seal. */
.cover-monogram {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 96px; height: 96px; border-radius: 50%;
  background: var(--accent-strong); color: var(--on-accent);
  font-family: var(--font-heading); font-weight: var(--heading-weight);
  font-size: 2.75rem; line-height: 1;
}
.cover-monogram--sm { width: 72px; height: 72px; font-size: 2rem; }
.cover-monogram--xs { width: 56px; height: 56px; font-size: var(--step-h2); box-shadow: none; }

/* ---- Typographic cover (no photo), all layouts ---- */
.cover--type {
  display: flex; align-items: center; justify-content: center;
  padding: 72px var(--space-4) var(--space-7); /* clears the floating Sign in link */
  text-align: center;
  background: var(--accent-soft); /* the default cover: the family's name set large on one flat field */
}
.cover-type { display: flex; flex-direction: column; align-items: center; gap: var(--space-5); max-width: 44rem; }
.cover-type__text { display: flex; flex-direction: column; align-items: center; }
.cover--type .cover-rule { margin-inline: auto; }
.cover--type .cover__welcome { margin-inline: auto; }

/* framed, no photo: the name set like a gallery label, inside a mat with a fine inner rule */
.cover--type.cover--framed .cover-type {
  padding: var(--space-7) var(--space-5);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  outline: 1px solid var(--line);
  outline-offset: -12px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  width: 100%;
}

@media (min-width: 900px) {
  /* split, no photo: a large monogram beside a left-aligned text column */
  .cover--type.cover--split .cover-type { flex-direction: row; gap: var(--space-7); max-width: 60rem; text-align: left; }
  .cover--type.cover--split .cover-type__text { align-items: flex-start; }
  .cover--type.cover--split .cover-rule, .cover--type.cover--split .cover__welcome { margin-inline: 0; }
  .cover--type.cover--split .cover-monogram { width: 180px; height: 180px; font-size: 5.5rem; }
  .cover--type.cover--framed .cover-type { padding: 72px var(--space-7); max-width: 48rem; }
}

/* ---- hero: the photo fills the top of the screen, the name sits on it ---- */
.cover--hero { --cover-ratio: 1.5; } /* width / height of the photo; the template sets the real one */
.cover--hero:not(.cover--type) {
  position: relative; isolation: isolate; overflow: hidden;
  display: flex; flex-direction: column; justify-content: flex-end;
  min-height: 80vh; min-height: 80svh;
  background: var(--overlay); /* while the photo loads */
  color: var(--on-media);
  --fade: clamp(150px, 30vh, 280px);
}
.cover--hero .cover-photo { position: absolute; inset: 0; z-index: -1; }
/* Contrast over ANY photo, without a hard dark band. Above the text, the photo fades through a tall
   eased ramp (the --fade zone, about 30 % of the screen): two stacked gradient layers that both end
   on --scrim (the theme's overlay colour at 50 %) and start at different heights, so the darkening
   begins gently (~18 % at a third of the way, ~50 % at 70 %). Where the text begins - the end of the
   fade zone - both layers are at full strength: 1 - 0.5 x 0.5 = 75 % overlay, and it stays 75 % down
   to the bottom. Worst case is a pure white photo: 0.75 x overlay + 0.25 x white. With the lightest
   overlay of any theme (#1d1612, warm) that is about rgb(86, 80, 77), relative luminance ~0.08, so
   white text has (1.05) / (0.08 + 0.05) = 8.1 : 1, comfortably above 4.5 : 1. The ramp plus the text
   block cover a little over half of the hero. tests/test_cover_pages.py recomputes this from the
   CSS and the registry for every theme. */
.cover-hero__text {
  padding: var(--fade) var(--space-4) var(--space-6);
  padding-bottom: max(var(--space-6), env(safe-area-inset-bottom));
  background:
    linear-gradient(to bottom, transparent 0, var(--scrim-light) calc(var(--fade) * 0.35), var(--scrim) var(--fade)),
    linear-gradient(to bottom, transparent calc(var(--fade) * 0.45), var(--scrim) var(--fade));
}
.cover-hero__inner {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  max-width: 1120px; margin: 0 auto;
}
.cover--hero:not(.cover--type) .cover__name { color: var(--on-media); }
.cover--hero:not(.cover--type) .cover__welcome { color: var(--on-media); margin-inline: auto; }
.cover--hero:not(.cover--type) .cover-notice { color: var(--on-media); }

/* The discreet "Sign in" at the top right, in every layout, floating over the top of the cover: on
   the hero photo on its own 75 % pill (same maths as the hero text); elsewhere a quiet outlined pill.
   The split and framed covers keep their top edge clear of it. */
.cover-chrome {
  display: flex; justify-content: flex-end;
  padding: var(--space-3) var(--space-4) 0;
  padding-top: max(var(--space-3), env(safe-area-inset-top));
}
.cover-chrome--photo, .cover-chrome--float { position: absolute; top: 0; left: 0; right: 0; z-index: 1; padding-bottom: var(--space-3); }
.cover-chrome--float { pointer-events: none; } /* only the link itself catches taps */
.cover-chrome--float .cover-chrome__signin { pointer-events: auto; }
.cover-chrome__signin {
  display: inline-flex; align-items: center; min-height: var(--tap); padding: 0 var(--space-4);
  border-radius: 999px; border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--text-strong);
  font-weight: 600; font-size: var(--step-small); text-decoration: none;
}
.cover-chrome__signin:hover { background: var(--accent-soft); color: var(--text-strong); }
.cover-chrome--photo .cover-chrome__signin {
  border-color: var(--on-media-soft);
  background: linear-gradient(var(--scrim), var(--scrim)), var(--scrim);
  color: var(--on-media);
}
.cover-chrome--photo .cover-chrome__signin:hover { background: var(--overlay); color: var(--on-media); }

/* Both Sign in buttons keep a ring that shows on any photo and any page: a light ring with a dark
   halo around it. */
.cover .cover__action:focus-visible, .cover-chrome__signin:focus-visible {
  outline: 2px solid var(--on-media); outline-offset: 2px;
  box-shadow: 0 0 0 6px var(--overlay);
}

@media (min-width: 768px) {
  /* public site: never taller than the photo itself at full width, never under 440 px, at most
     80 % of the screen; a private site's hero fills the screen above the footer */
  .cover-page--public > .cover--hero:not(.cover--type) {
    min-height: 0;
    height: clamp(440px, min(80vh, 100vw / var(--cover-ratio)), 80vh);
  }
  .cover--hero:not(.cover--type) { --fade: clamp(160px, 28vh, 300px); }
  .cover-hero__text { padding: var(--fade) var(--space-6) var(--space-7); }
  .cover-hero__inner { align-items: flex-start; text-align: left; }
  .cover--hero:not(.cover--type) .cover__welcome { margin-inline: 0; }
  .cover-chrome { padding: var(--space-4) var(--space-6); }
}

/* ---- split: photo and text side by side (photo on top on phones) ---- */
.cover--split:not(.cover--type) { display: flex; flex-direction: column; }
.cover-split__media { position: relative; flex: none; overflow: hidden; height: 45vh; height: 45svh; background: var(--surface-2); }
.cover-split__media .cover-photo { position: absolute; inset: 0; }
.cover-split__text {
  display: flex; flex: 1 0 auto; flex-direction: column; align-items: flex-start; justify-content: center;
  padding: var(--space-5) var(--space-4) var(--space-6);
}
.cover-split__text .cover-rule { margin-top: 0; }
/* soft and outlined themes: the photo sits inset with rounded corners; flat themes run it to the edge */
:root:not([data-card="flat"]) .cover--split:not(.cover--type) { padding: var(--space-4) var(--space-4) 0; }
:root:not([data-card="flat"]) .cover-split__media { border-radius: var(--radius-lg); }
:root[data-card="soft"] .cover-split__media { box-shadow: var(--shadow-pop); }
:root[data-card="outlined"] .cover-split__media { border: 1px solid var(--line-strong); }
@media (max-width: 899px) { :root:not([data-card="flat"]) .cover-split__text { padding-inline: 0; } }

@media (min-width: 900px) {
  .cover--split:not(.cover--type) {
    display: grid; grid-template-columns: 55fr 45fr;
    min-height: min(86vh, 820px);
  }
  .cover-split__media { height: auto; min-height: 480px; }
  .cover-split__text { justify-content: center; padding: var(--space-7) clamp(32px, 5vw, 88px); }
  :root:not([data-card="flat"]) .cover--split:not(.cover--type) { padding: var(--space-5); gap: var(--space-3); }
}

/* ---- framed: the photo as a print in a mat, the name beneath like a gallery label ---- */
.cover--framed:not(.cover--type) {
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  padding: 72px var(--space-4) var(--space-6);
}
.cover-print {
  width: 100%;
  /* keeps the whole print (photo + label) on a laptop screen */
  max-width: min(880px, calc((100vh - 420px) * 1.5));
  min-width: min(100%, 560px);
  margin: 0;
  padding: clamp(10px, 2.4vw, 22px) clamp(10px, 2.4vw, 22px) 0;
  background: var(--surface);
  border: 1px solid var(--card-line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-pop);
}
:root[data-card="flat"] .cover-print, :root[data-card="outlined"] .cover-print { box-shadow: none; }
.cover-print__photo { position: relative; overflow: hidden; aspect-ratio: 4 / 3; background: var(--surface-2); }
.cover-print__photo .cover-photo { position: absolute; inset: 0; }
.cover-print__label { padding: var(--space-4) var(--space-3) var(--space-5); }
.cover-print .cover__name { font-size: clamp(1.7rem, 1.2rem + 2.4vw, 2.9rem); }
.cover-framed__text { display: flex; flex-direction: column; align-items: center; max-width: 40rem; margin-top: var(--space-5); }
.cover-framed__text .cover__welcome { margin: 0 auto; }
@media (min-width: 640px) {
  .cover--framed:not(.cover--type) { padding: 72px var(--space-5) var(--space-6); }
  .cover-print__photo { aspect-ratio: 3 / 2; }
}

/* ---- Public sections (public sites only) ---- */
.cover-sections {
  display: flex; flex-direction: column; gap: var(--space-7);
  max-width: 1120px; margin: 0 auto;
  padding: var(--space-7) var(--space-4) var(--space-5);
}
.cover-section__head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  margin-bottom: var(--space-4); padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--line);
}
.cover-section__title { margin: 0; font-size: clamp(1.35rem, 1.15rem + 0.8vw, 1.75rem); }
.cover-section__more {
  display: inline-flex; align-items: center; min-height: var(--tap);
  font-weight: 600; text-decoration: none; white-space: nowrap;
}
.cover-section__more:hover { text-decoration: underline; color: var(--accent-strong); }

.cover-grid { display: grid; grid-template-columns: 1fr; gap: var(--space-4); }
.cover-grid--albums { grid-template-columns: repeat(2, 1fr); }
.cover-grid--latest { align-items: start; } /* a photo card and a short note keep their own heights */
@media (min-width: 640px) { .cover-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 960px) { .cover-grid, .cover-grid--albums { grid-template-columns: repeat(3, 1fr); gap: var(--space-5); } }

/* Latest: compact post cards */
.latest-card { min-width: 0; }
.latest-card__link {
  display: flex; flex-direction: column; height: 100%; padding: 0; overflow: hidden;
  color: inherit; text-decoration: none;
}
.latest-card__photos { display: grid; gap: 2px; aspect-ratio: 16 / 10; background: var(--surface-2); }
.latest-card__photos--2 { grid-template-columns: 1fr 1fr; }
.latest-card__photos--3 { grid-template-columns: 2fr 1fr; grid-template-rows: 1fr 1fr; }
.latest-card__photos--3 img:first-child { grid-row: span 2; }
.latest-card__photos img { display: block; width: 100%; height: 100%; min-height: 0; object-fit: cover; }
.latest-card__body { display: flex; flex-direction: column; gap: var(--space-2); flex: 1; padding: var(--space-4); }
.latest-card__text {
  line-height: 1.55; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 4; line-clamp: 4; overflow: hidden;
}
.latest-card__link--text .latest-card__body { padding: var(--space-5); }
.latest-card__link--text .latest-card__text {
  font-family: var(--font-heading); color: var(--text-strong); font-size: var(--step-name); line-height: 1.45; -webkit-line-clamp: 6; line-clamp: 6;
}
.latest-card__date { margin-top: auto; font-size: var(--step-small); color: var(--muted); }
.latest-card__link:hover .latest-card__text { color: var(--text-strong); }
.latest-card__link:focus-visible, .cover-story__link:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* Albums */
.cover-album { min-width: 0; }
.cover-album__link { display: flex; flex-direction: column; color: inherit; text-decoration: none; border-radius: var(--radius); }
.cover-album__cover {
  display: flex; align-items: center; justify-content: center;
  aspect-ratio: 4 / 3; overflow: hidden; border-radius: var(--radius);
  background: var(--accent-soft); color: var(--accent-strong);
}
:root[data-card="soft"] .cover-album__cover { box-shadow: var(--shadow); }
:root[data-card="outlined"] .cover-album__cover { border: 1px solid var(--line-strong); }
.cover-album__cover img { display: block; width: 100%; height: 100%; object-fit: cover; }
.cover-album__title { margin-top: var(--space-2); font-weight: 650; color: var(--text-strong); overflow-wrap: anywhere; }
.cover-album__meta { font-size: var(--step-small); color: var(--muted); }
.cover-album__link:hover .cover-album__title { text-decoration: underline; text-underline-offset: 0.15em; }

/* Stories */
.cover-story { min-width: 0; }
.cover-story__link { display: flex; flex-direction: column; height: 100%; padding: 0; overflow: hidden; color: inherit; text-decoration: none; }
.cover-story__cover { display: flex; align-items: center; justify-content: center; aspect-ratio: 16 / 9; overflow: hidden; background: var(--accent-soft); }
.cover-story__cover img { display: block; width: 100%; height: 100%; object-fit: cover; }
.cover-story__initial { font-family: var(--font-heading); font-weight: var(--heading-weight); font-size: 3.5rem; color: var(--accent-strong); }
.cover-story__body { display: flex; flex-direction: column; gap: var(--space-2); padding: var(--space-4); min-width: 0; }
.cover-story__label {
  align-self: flex-start; padding: 2px var(--space-2); border-radius: var(--radius-sm);
  background: var(--accent-soft); color: var(--accent-strong);
  font-size: var(--step-small); font-weight: 700;
}
.cover-story__title {
  font-family: var(--font-heading); font-weight: var(--heading-weight); letter-spacing: var(--heading-tracking);
  font-size: var(--step-name); line-height: 1.3; color: var(--text-strong); overflow-wrap: anywhere;
}
.cover-story__excerpt {
  line-height: 1.5; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; line-clamp: 3; overflow: hidden;
}
.cover-story__link:hover .cover-story__title { color: var(--accent-strong); }

/* Coming up */
.cover-event { display: flex; align-items: center; gap: var(--space-4); padding: var(--space-4); min-width: 0; }
.cover-event__body { display: flex; flex-direction: column; min-width: 0; }
.cover-event__title { font-weight: 650; color: var(--text-strong); overflow-wrap: anywhere; }
.cover-event__meta { font-size: var(--step-small); color: var(--muted); overflow-wrap: anywhere; }

/* Motion only for people who have not asked for less. */
@media (prefers-reduced-motion: no-preference) {
  .cover-chrome__signin { transition: background-color 0.15s ease; }
  .cover-album__cover img { transition: transform 0.4s ease; }
  .cover-album__link:hover img { transform: scale(1.03); }
}

/* ---- Footer ---- */
.cover-footer { border-top: 1px solid var(--line); }
.cover-page--public + .cover-footer { margin-top: var(--space-5); }
.cover-footer__inner {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 0 var(--space-3);
  max-width: 1120px; margin: 0 auto;
  padding: 0 var(--space-3) env(safe-area-inset-bottom);
  font-size: var(--step-small); line-height: 1.3; color: var(--muted); text-align: center;
}
.cover-footer__site, .cover-footer__made { white-space: nowrap; }
.cover-footer__site { margin: 0; }
.cover-footer__made { display: inline-flex; align-items: center; min-height: var(--tap); color: var(--muted); text-decoration: none; }
.cover-footer__made:hover { color: var(--accent-strong); text-decoration: underline; }
@media (max-width: 339px) {
  .cover-footer__inner { flex-direction: column; padding-top: var(--space-2); }
  .cover-footer__site, .cover-footer__made { white-space: normal; }
}
@media (min-width: 768px) {
  .cover-footer__inner { justify-content: space-between; padding-inline: var(--space-4); font-size: var(--step-small); }
}

/* ---- ?before= pages: older public posts and stories ---- */
.cover-more { max-width: 720px; margin: 0 auto; padding: var(--space-5) var(--space-4); }
.cover-more__head { display: flex; align-items: center; gap: var(--space-4); margin-bottom: var(--space-5); }
.cover-more__home { display: inline-flex; border-radius: 50%; text-decoration: none; }
.cover-more__photo { width: 56px; height: 56px; border-radius: 50%; object-fit: cover; }
.cover-more__name { margin: 0; font-size: var(--step-h2); }
.cover-more__sub { margin: 0; }

/* ---- Sign-in, password reset and join pages on a family host ---- */
.auth-header { display: flex; justify-content: center; padding: var(--space-6) var(--space-4) 0; }
.auth-brand {
  display: flex; flex-direction: column; align-items: center; gap: var(--space-3);
  border-radius: var(--radius); color: var(--text-strong); text-decoration: none; text-align: center;
}
.auth-brand__photo {
  width: 72px; height: 72px; border-radius: 50%; object-fit: cover;
  background: var(--surface-2);
  box-shadow: 0 0 0 4px var(--bg), 0 0 0 5px var(--line);
}
.auth-brand__name {
  font-family: var(--font-heading); font-weight: var(--heading-weight); letter-spacing: var(--heading-tracking);
  font-size: var(--step-h2); line-height: 1.25; overflow-wrap: anywhere;
}
.auth-brand:hover .auth-brand__name { color: var(--accent-strong); }
.auth-header + .container .auth { margin-top: var(--space-4); }
