/* THEOS App. See docs/PHASE1_BRIEF.md §9, §11.
 *
 * Written for an embedded webview, not a browser: safe areas, no hover states
 * that matter, and nested horizontal scrollers inside a vertical one — which
 * §11 warns feels wrong on iOS by default and is the difference between "a
 * webpage" and "an app".
 */

/* THEME. Light is the default; dark is opt-in, and following the device is a
 * third option rather than the behaviour nobody chose.
 *
 * WHY LIGHT IS THE DEFAULT AND NOT `prefers-color-scheme`. This page renders
 * inside a Subsplash webview, and a webview does not necessarily report the
 * same appearance as the app around it. Defaulting to the device setting would
 * mean a member's homepage could come up dark inside a light app, which reads
 * as broken rather than as a preference. One appearance, chosen by the church,
 * until they choose otherwise.
 *
 * Three states, set as `data-theme` on <html>:
 *
 *   (absent) or "light"  light. The default, and what an unconfigured church
 *                        and a browser with JavaScript disabled both get.
 *   "dark"               dark, regardless of the device.
 *   "auto"               follow the device. OPT-IN, which is the whole point
 *                        of the attribute: the media query below is scoped to
 *                        it, so nothing follows the device by accident.
 *
 * Switching is therefore one attribute on <html> and no stylesheet change,
 * which is what makes this a church setting later rather than a rewrite.
 *
 * TWO ACCENTS, and this is the part that is not a straight inversion. The
 * brand orange is used both as a fill behind dark text and as text on the page
 * background. On the old dark navy it worked as both. On white it does not:
 * #f0862b on #ffffff is about 2.4:1, which fails WCAG AA for text at any size
 * a member would read. So `--accent-fill` keeps the brand orange for
 * backgrounds, where contrast is measured against the ink on top of it, and
 * `--accent` is the text-safe orange measured against the page. In dark they
 * are the same value; in light they are not, and collapsing them back into one
 * token is how this regresses.
 */
:root {
  color-scheme: light;

  --bg: #ffffff;
  /* Cards are a shade off-white so they read as surfaces ON white rather than
   * dissolving into it. The old dark theme got that separation for free. */
  --panel: #f6f8fb;
  --panel-2: #eef2f7;
  --line: #dde3ec;
  --ink: #10151f;
  /* Long-form body text. Softer than --ink so a write-up does not read as
   * shouting, and nowhere near --muted, which is for labels rather than for
   * paragraphs somebody actually has to read. 12:1 on white. */
  --ink-soft: #2b3446;
  /* 5.3:1 on white. Secondary text is still text. */
  --muted: #5d6a82;
  --accent: #b3590a;
  --accent-fill: #f0862b;
  --accent-ink: #1b2233;
  --danger: #c0392b;
  --ok: #1d7a54;

  --radius: 14px;
  --gutter: 16px;
  --card-w: 260px;
}

/* The original palette, unchanged, now behind an explicit choice. */
:root[data-theme='dark'] {
  color-scheme: dark;

  --bg: #161c2b;
  --panel: #1f2739;
  --panel-2: #262f45;
  --line: #313c55;
  --ink: #f4f6fa;
  --ink-soft: #d7deec;
  --muted: #9aa6bf;
  --accent: #f0862b;
  --accent-fill: #f0862b;
  --accent-ink: #1b2233;
  --danger: #e2574c;
  --ok: #4fbf8b;
}

/* Only for a church that has asked to follow the device. */
@media (prefers-color-scheme: dark) {
  :root[data-theme='auto'] {
    color-scheme: dark;

    --bg: #161c2b;
    --panel: #1f2739;
    --panel-2: #262f45;
    --line: #313c55;
    --ink: #f4f6fa;
    --ink-soft: #d7deec;
    --muted: #9aa6bf;
    --accent: #f0862b;
    --accent-fill: #f0862b;
    --accent-ink: #1b2233;
    --danger: #e2574c;
    --ok: #4fbf8b;
  }
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
}

body {
  min-height: 100dvh;
  /* §11: Subsplash chrome overlaps content without these. */
  padding-top: env(safe-area-inset-top);
  padding-bottom: calc(32px + env(safe-area-inset-bottom));
  overscroll-behavior-y: none;
}

a {
  color: inherit;
  text-decoration: none;
}

.wrap {
  max-width: 40rem;
  margin: 0 auto;
}

/* ── greeting ─────────────────────────────────────────────────────────────── */
.greeting {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 22px var(--gutter) 6px;
}

/* The photo and the initials occupy the same circle, the photo on top. Both
 * are rendered so that a photo which never loads uncovers something true about
 * the person rather than leaving a grey disc next to their own name. */
.avatar {
  position: relative;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  flex: none;
  background: var(--accent-fill);
  display: grid;
  place-items: center;
  overflow: hidden;
}

.avatar-initials {
  color: var(--accent-ink);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  /* The photo covers this rather than replacing it, so it must not be
   * selectable or read out when a photo is sitting on top of it. */
  user-select: none;
}

.avatar-photo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  /* No background: a transparent PNG should show the initials behind it rather
   * than a grey disc. */
}

.greeting h1 {
  font-size: 1.45rem;
  line-height: 1.2;
  margin: 0;
  letter-spacing: -0.01em;
}

.greeting .campus {
  color: var(--muted);
  font-size: 0.85rem;
}

/* ── sections ─────────────────────────────────────────────────────────────── */
.section {
  margin-top: 26px;
}

/* Both, because a collapsible row's heading lives inside its <summary> and a
 * child selector alone leaves it at the browser's default <h2> — which is half
 * again the size of every other heading on the page, and was exactly how it
 * first rendered. */
.section > h2,
.section > summary > h2 {
  font-size: 1.05rem;
  margin: 0 0 12px;
  padding: 0 var(--gutter);
  letter-spacing: -0.01em;
}

/* Horizontal carousel. scroll-snap plus contain make the nested scroller feel
 * like a carousel rather than a stuck page (§11). */
.carousel {
  display: flex;
  gap: 12px;
  overflow-x: auto;

  /* PROXIMITY, NOT MANDATORY, and this is the difference between a page that
   * feels glassy and one that fights the thumb.
   *
   * `mandatory` means the row MUST come to rest on a card, so the browser has
   * to take ownership of any gesture that might be horizontal — and a thumb
   * swiping up a phone is never perfectly vertical. The carousel grabs the few
   * degrees of sideways drift, snaps itself back, and the page underneath
   * stutters. That is the glitch: two scrollers arguing about one gesture,
   * several times per flick.
   *
   * `proximity` snaps only when the scroll already ends near a card edge. A
   * deliberate horizontal swipe still lands cleanly, and a vertical one is
   * simply let through. The carousel keeps its alignment and stops competing.
   */
  scroll-snap-type: x proximity;

  /* THIS WAS `pan-x`, AND `pan-x` IS WHAT FROZE THE PAGE.
   *
   * The comment that stood here said "sideways is mine, everything else
   * belongs to the page". That is not what it means. `touch-action: pan-x`
   * permits touches that begin on this element to pan HORIZONTALLY AND
   * NOTHING ELSE — vertical panning is forbidden for that gesture, not handed
   * upward. Every card on the homepage is inside a carousel, and the cards are
   * most of the page, so a thumb that landed on one could not scroll the page
   * at all. Land on a heading or the gap between rows and it scrolled
   * normally, which is why it read as the page freezing at random and
   * sometimes "letting go".
   *
   * Reported three times over an evening and chased through the render path,
   * the sermon player, image decoding and CPU throttling. It was one CSS
   * keyword, and the comment beside it was the reason nobody looked twice.
   *
   * `manipulation` is pan-x + pan-y + pinch-zoom: every scroll and the zoom a
   * low-vision member needs, with only double-tap-to-zoom dropped, which is
   * what removes the tap delay. It keeps the reason the declaration is here —
   * the compositor still knows immediately that this element will never want a
   * double-tap — without forbidding the gesture the page is made of.
   */
  touch-action: manipulation;

  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
  padding: 2px var(--gutter) 6px;
  /* Without this, snapping aligns the first card's edge with the scrollport
   * and scrolls straight past the padding — so the row sits flush to the
   * screen edge while its heading is inset, and the page looks misaligned. */
  scroll-padding-left: var(--gutter);
  scrollbar-width: none;
}

.carousel::-webkit-scrollbar {
  display: none;
}

.carousel > * {
  scroll-snap-align: start;
  flex: 0 0 var(--card-w);
}

.list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 0 var(--gutter);
}

/* ── cards ────────────────────────────────────────────────────────────────── */
.card {
  display: block;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.card:active {
  background: var(--panel-2);
}

.card .media {
  aspect-ratio: 16 / 9;
  background: var(--panel-2);
  display: block;
  width: 100%;
  object-fit: cover;
}

.card .body {
  padding: 12px 14px 14px;
}

.card h3 {
  font-size: 0.98rem;
  margin: 0 0 4px;
  line-height: 1.3;
}

.card .meta {
  color: var(--muted);
  font-size: 0.82rem;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.list .card {
  display: flex;
  align-items: center;
  gap: 12px;
}

.list .card .media {
  width: 84px;
  height: 64px;
  aspect-ratio: auto;
  flex: none;
}

.list .card .body {
  padding: 10px 14px 10px 0;
  min-width: 0;
}

/* ── badges ───────────────────────────────────────────────────────────────── */
.badge {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--muted);
  border: 1px solid var(--line);
  white-space: nowrap;
}

.badge.soon {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
}

.badge.full,
.badge.closed {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 40%, transparent);
}

.badge.when {
  color: var(--ok);
  border-color: color-mix(in srgb, var(--ok) 35%, transparent);
}

/* ── module cards ─────────────────────────────────────────────────────────── */
.module {
  margin: 18px var(--gutter) 0;
  background: linear-gradient(135deg, var(--accent-fill), #d8701d);
  color: var(--accent-ink);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  font-weight: 600;
}

.module .sub {
  font-weight: 500;
  font-size: 0.85rem;
  opacity: 0.8;
}

.module .go {
  font-size: 1.3rem;
  opacity: 0.7;
}

.module.quiet {
  background: var(--panel);
  color: var(--ink);
  border: 1px solid var(--line);
}

/* ── buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-block;
  background: var(--accent-fill);
  color: var(--accent-ink);
  font-weight: 600;
  padding: 12px 20px;
  border-radius: 10px;
  border: none;
  font-size: 1rem;
}

.btn.ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
  font-weight: 500;
}

/* ── states ───────────────────────────────────────────────────────────────── */
/* §9: skeletons, not spinners — the section layout is known before the data is. */
.skeleton {
  background: linear-gradient(90deg, var(--panel) 25%, var(--panel-2) 37%, var(--panel) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
  border-radius: var(--radius);
}

@keyframes shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: 0 0; }
}

@media (prefers-reduced-motion: reduce) {
  .skeleton { animation: none; }
}

.skeleton.card-sk {
  height: 190px;
}

.empty,
.error {
  margin: 28px var(--gutter);
  padding: 24px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-align: center;
}

.empty h2,
.error h2 {
  margin: 0 0 8px;
  font-size: 1.1rem;
}

.empty p,
.error p {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.92rem;
}

/* ── detail (a route, not a modal — §9) ───────────────────────────────────── */
.detail {
  padding-bottom: 24px;
}

.detail .hero {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: var(--panel-2);
  display: block;
}

.detail .inner {
  padding: 18px var(--gutter) 0;
}

.detail h1 {
  font-size: 1.4rem;
  margin: 0 0 10px;
  line-height: 1.25;
}

.detail dl {
  margin: 18px 0 0;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px 16px;
  font-size: 0.92rem;
}

.detail dt {
  color: var(--muted);
}

.detail dd {
  margin: 0;
}

.detail .actions {
  margin-top: 22px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.9rem;
  padding: 16px var(--gutter) 4px;
  background: none;
  border: none;
  font-family: inherit;
}

/* ── sign-in ──────────────────────────────────────────────────────────────── */
.signin {
  margin: 20vh var(--gutter) 0;
  text-align: center;
}

.signin h1 {
  font-size: 1.5rem;
  margin: 0 0 10px;
}

.signin p {
  color: var(--muted);
  margin: 0 0 22px;
}

/* Sign in first, New here under it: stacked, so on a phone neither is squeezed
 * and the one most people want stays on top. */
.signin-actions {
  align-items: center;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* The input. FULL WIDTH AND 16px MINIMUM, and the font size is not taste: iOS
 * Safari zooms the whole page when a text field under 16px takes focus, and it
 * does not zoom back out. On the sign-in screen that leaves somebody typing an
 * email address into a page they now have to pinch to escape — on the first
 * screen of the app, before they have any reason to persevere. */
.signin-input {
  background: var(--panel, #fff);
  border: 1px solid var(--line, #d7d7dc);
  border-radius: 10px;
  color: var(--ink, #15151a);
  display: block;
  font: inherit;
  font-size: 16px;
  margin: 0 auto 14px;
  max-width: 320px;
  padding: 14px 16px;
  text-align: center;
  width: 100%;
}

.signin-input:focus-visible {
  border-color: var(--accent, #e8661e);
  outline: 2px solid var(--accent, #e8661e);
  outline-offset: 1px;
}

/* A code is read digit by digit off a notification, so it is set wide and
 * monospaced — "000000" at body spacing is a smear.
 *
 * ITS OWN CLASS, not [inputmode='numeric']. That selector was written when the
 * code box was the only numeric field on this screen; the birthday's day and
 * year are numeric too, and they inherited 24px type and a third of an em of
 * tracking inside a 72px box. Styling by a behavioural attribute means every
 * future field that happens to want a number keypad gets the look of a
 * verification code. */
.signin-code {
  font-size: 24px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.3em;
  /* The tracking is applied to the right of each glyph, so centred text sits
   * half a space left. Pushed back, or the placeholder looks misaligned. */
  text-indent: 0.3em;
}

/* Month, day, year on one line — the three parts of one answer, so they read as
 * one question rather than three. Month takes the room because it holds a word;
 * the two numbers need four characters at most. */
.signin-row {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin: 0 auto 14px;
  max-width: 320px;
}

.signin-row .signin-input {
  margin: 0;
}

.signin-row select.signin-input {
  flex: 1 1 auto;
  min-width: 0;
}

.signin-short {
  flex: 0 0 72px;
  padding-left: 8px;
  padding-right: 8px;
}

.signin-prompt {
  margin: 0 0 16px;
}

/* The name of a field whose own boxes cannot hold it — the birthday, which is
 * three controls and one question. Small and quiet: it is a label, not a
 * heading, and it sits 6px above the row so the two read as one block rather
 * than as a sentence followed by some inputs.
 *
 * Centred over the row, like everything else on this screen. Left-aligned it
 * would be the only thing on the sign-in card that is, which reads as a
 * mistake.
 *
 * `p.` IS LOAD-BEARING, and leaving it off is how this shipped wrong the first
 * time. `.signin p` above sets `margin: 0 0 22px` and a class selector alone
 * loses to it — so the label took the paragraph's left-aligned box AND its
 * 22px gap: a 320px box starting at the gutter while the row it names is
 * centred 19px to the right of it, with a paragraph's worth of air between
 * them. It read as a stray sentence rather than as the row's label, which is
 * the one thing it had to do. Caught by measuring both boxes in a browser;
 * every source-level assertion about it passed. */
.signin p.signin-label {
  margin: 0 auto 6px;
  max-width: 320px;
  font-size: 0.85rem;
  opacity: 0.75;
  text-align: center;
}

.signin-status {
  margin: 12px 0 0;
  min-height: 1.2em;
  font-size: 0.9rem;
  opacity: 0.8;
}

.signin-status.bad {
  color: var(--bad, #b3261e);
  opacity: 1;
}

.signin-secondary {
  margin-top: 22px;
}

.signin-alt {
  font-size: 0.85rem;
}

.signin p.signin-note {
  font-size: 0.85rem;
  margin: 12px 0 0;
}

.footer {
  margin: 34px var(--gutter) 0;
  text-align: center;
}

/* ── video module (§9, §11) ───────────────────────────────────────────────── */
.video-module {
  margin-top: 26px;
}

/* The box is 16:9 before anything loads, so revealing the player does not
 * shove the rest of the page down — the same reason §9 asks for skeletons
 * rather than spinners. */
.video-frame {
  position: relative;
  margin: 0 var(--gutter);
  aspect-ratio: 16 / 9;
  /* The FALLBACK, and it lives here rather than on the button now that a
   * poster can sit between them. A church whose channel we cannot read, or
   * whose latest upload has no thumbnail, gets a deliberate-looking frame
   * rather than a flat grey box that reads as a failed image. */
  background: radial-gradient(circle at center, var(--panel-2), var(--bg));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

/* The newest video's thumbnail (services/api/src/home/youtube.js). Behind the
 * button, so the button keeps its hit area and the image cannot swallow a tap.
 * It removes itself on error, and the frame's gradient is underneath. */
.video-poster {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.video-frame iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.video-play {
  position: absolute;
  inset: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  /* Transparent now, so the poster shows through, with a light scrim to keep
   * the glyph legible over a bright thumbnail — a sermon graphic is as likely
   * to be white as black, and the play control has to read on both. */
  background: linear-gradient(
    180deg,
    rgb(0 0 0 / 12%),
    rgb(0 0 0 / 28%)
  );
  border: none;
  cursor: pointer;
  font-family: inherit;
}

.video-glyph {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: var(--accent-fill);
  color: var(--accent-ink);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  /* the glyph's own left bearing makes it look off-centre otherwise */
  padding-left: 5px;
}

.video-play:active .video-glyph {
  transform: scale(0.95);
}

.video-handout {
  display: block;
  margin: 12px var(--gutter) 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--accent);
  font-weight: 600;
  font-size: 0.95rem;
  text-align: center;
}

.video-handout:active {
  background: var(--panel-2);
}

.video-sub {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 10px var(--gutter) 0;
}

/* ── the event write-up ──────────────────────────────────────────────────────
 * Church-authored rich text, sanitized in the Worker to an allowlist of tags
 * (services/api/src/home/richtext.js). It arrives after the page has painted,
 * so these rules have to hold for a block that appears a beat late without
 * shifting what is above it — which is why .writeup itself has no margin until
 * it has something in it.
 */
.writeup:empty {
  display: none;
}

.writeup {
  margin-top: 20px;
  /* WAS #d7deec, hard-coded, and that is exactly why it survived the move to
   * light: a literal hex is invisible to a search for tokens. It is a value
   * from the dark palette, and on white it lands at about 1.2:1 — the write-up
   * was legible as a shape rather than as words, and read as a DISABLED page
   * rather than a faint one. Every colour here is a token now; the only
   * literals left in this file are gradient stops sitting behind dark text. */
  color: var(--ink-soft);
  /* Long-form text wants more air between lines than a card label does. */
  line-height: 1.65;
  font-size: 0.97rem;
  /* A pasted URL in a description would otherwise push the page sideways on a
   * narrow phone, and horizontal scroll inside a webview is unrecoverable. */
  overflow-wrap: anywhere;
}

.writeup > :first-child {
  margin-top: 0;
}

.writeup > :last-child {
  margin-bottom: 0;
}

.writeup p,
.writeup ul,
.writeup ol,
.writeup blockquote {
  margin: 0 0 14px;
}

.writeup h2,
.writeup h3,
.writeup h4 {
  /* Whatever heading level staff reached for, it is a subheading of the event
   * title — so they are levelled here rather than trusted to be hierarchical. */
  font-size: 1rem;
  font-weight: 650;
  color: var(--text);
  margin: 22px 0 8px;
}

.writeup ul,
.writeup ol {
  padding-left: 22px;
}

.writeup li {
  margin-bottom: 6px;
}

.writeup a {
  color: var(--accent);
  /* An underline, not just colour: §11 assumes the least capable environment,
   * and colour alone fails for a member who cannot distinguish it. */
  text-decoration: underline;
  text-underline-offset: 2px;
}

.writeup blockquote {
  padding-left: 14px;
  border-left: 2px solid color-mix(in srgb, var(--accent) 50%, transparent);
  color: var(--muted);
}

/* A sign-in that ended badly. Amber rather than red: for a member this is
 * information, not a failure they caused. */
.signin-problem {
  color: var(--accent);
}

/* ── the staff people search (§5.2) ──────────────────────────────────────────
 *
 * Only staff ever see this, and it sits above the greeting: it is a tool bar
 * over a member's page rather than part of it. Everything below is sized for a
 * thumb on a phone at a check-in desk, which is the only place it gets used.
 */
.staff-search {
  margin: 0 0 18px;
}

.people-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 6px 0 16px;
}

/* Focus on the CONTAINER rather than the input, because the input's own outline
 * would be drawn inside the pill and clipped by the radius. */
.people-box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}

.people-field {
  flex: 1;
  min-width: 0;
  border: 0;
  background: none;
  color: var(--ink);
  /* 16px exactly. Anything smaller and iOS zooms the whole page when the field
   * takes focus, which on a phone means the layout jumps and the member has to
   * pinch back out. */
  font: inherit;
  font-size: 16px;
  padding: 13px 0;
  outline: none;
}

.people-field::placeholder {
  color: var(--muted);
}

/* The native clear button, removed: there is an explicit one beside it, and two
 * crosses in one field is a puzzle rather than a convenience. */
.people-field::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
}

.people-close {
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1;
  /* 44px, the minimum a thumb can reliably hit. */
  min-width: 44px;
  min-height: 44px;
  cursor: pointer;
  border-radius: 999px;
}

.people-close:active {
  background: var(--panel-2);
}

.people-status {
  margin: 8px 2px 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.people-status.bad {
  color: var(--danger);
}

.people-status:empty {
  display: none;
}

.people-results {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 10px;
  /* The results are a world of their own: nothing inside them can change the
   * layout of the homepage below, so appending a page of cards cannot force the
   * browser to re-lay-out the sections underneath. */
  contain: layout style;
}

.people-results:empty {
  display: none;
}

.person-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;

  /* OFF-SCREEN CARDS COST NOTHING. A full page of results is fifty cards, each
   * with a photo, a contact list and a household — and scrolling past them made
   * the page hesitate, reported right after the search shipped: "I get out of
   * the people search, go back to the page to move it, and it freezes".
   *
   * `content-visibility: auto` lets the browser skip layout, paint and even
   * style for anything scrolled out of view, which is most of them most of the
   * time. `contain-intrinsic-size` is what makes that safe: without a size to
   * assume, skipped cards measure zero, the scrollbar jumps as they enter and
   * leave, and the fix becomes a worse bug than the one it replaced. 220px is a
   * typical card with a household on it — wrong by a little for a card without
   * one, which costs a small correction as it scrolls in, rather than wrong by
   * everything.
   *
   * This is also why the cards are plain blocks rather than anything absolutely
   * positioned: containment only works on an element whose size does not depend
   * on its contents being laid out.
   *
   * `auto 220px` RATHER THAN `0 220px`, and the keyword is the whole
   * difference. Without it the browser assumes 220px for a skipped card EVERY
   * time it leaves the viewport — so a card that is really 380px collapses back
   * to 220 on the way out and expands again on the way back, and the page
   * height changes under the finger on every pass. That is felt as scrolling
   * that will not settle, with no dropped frame anywhere to point at.
   *
   * `auto` tells the browser to remember each element's LAST REAL size and use
   * that instead. 220px is then only the guess for a card nobody has seen yet,
   * which is what a guess should be. */
  content-visibility: auto;
  contain-intrinsic-size: auto 220px;
}

.person-head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.person-who {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.person-name {
  font-weight: 650;
  color: var(--ink);
}

.person-meta {
  font-size: 0.82rem;
  color: var(--muted);
}

.chip.child,
.chip.inactive {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 3px 8px;
  flex: none;
}

/* Contact details stack rather than sit in a row: a phone number and an email
 * side by side both truncate on a phone, and a truncated phone number is worse
 * than no phone number. */
.contact-row {
  display: flex;
  flex-direction: column;
  margin-top: 10px;
}

.contact-link {
  display: flex;
  align-items: baseline;
  gap: 10px;
  text-decoration: none;
  color: inherit;
  /* 44px of tap target, because every one of these is hit with a thumb. */
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}

.contact-link:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.contact-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  width: 4.5rem;
  flex: none;
}

.contact-value {
  color: var(--accent);
  /* An address wraps; a phone number and an email must not be cut in half. */
  overflow-wrap: anywhere;
}

.person-flagged,
.person-none {
  margin: 10px 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.household {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
}

.household-name {
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.household-members {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.household-member {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  font-size: 0.92rem;
}

.household-who {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.household-call {
  color: var(--accent);
  text-decoration: none;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  flex: none;
}

.people-more {
  align-self: flex-start;
  background: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  font: inherit;
  padding: 10px 18px;
  min-height: 44px;
  cursor: pointer;
}

/* The avatar in a result, smaller than the greeting's. */
.avatar-sm {
  width: 38px;
  height: 38px;
  flex: none;
}

.avatar-sm .avatar-initials {
  font-size: 0.8rem;
}

/* ── a collapsible row ───────────────────────────────────────────────────────
 * Upcoming Events, which is the longest on the page and the one somebody
 * BROWSES rather than reads. Closed until tapped (seed 0020).
 */
.section-collapsible > summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 var(--gutter);
  margin-bottom: 12px;
  /* 44px of thumb, and the whole bar is the target rather than the words. */
  min-height: 44px;
  cursor: pointer;
  /* The native triangle is removed and drawn below, because Safari and Chrome
   * disagree about its size and position and the difference is visible. */
  list-style: none;
}

.section-collapsible > summary::-webkit-details-marker {
  display: none;
}

.section-collapsible > summary > h2 {
  /* The gutter is on the summary instead, so the count and the arrow sit inside
   * the page margin rather than against the screen edge. */
  margin: 0;
  padding: 0;
  flex: 1;
}

/* How many are inside. A closed row has to say what it is hiding, or a member
 * has no reason to open it. */
.section-count {
  font-size: 0.78rem;
  color: var(--muted);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 9px;
  flex: none;
}

/* The disclosure arrow, drawn rather than inherited. Rotates on open. */
.section-collapsible > summary::after {
  content: '';
  width: 9px;
  height: 9px;
  flex: none;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg) translate(-2px, -2px);
  transition: transform 120ms ease;
}

.section-collapsible[open] > summary::after {
  transform: rotate(-135deg) translate(-2px, -2px);
}

/* No focus ring lost: the summary is a real control and is reached by keyboard. */
.section-collapsible > summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 8px;
}

/* A pinned event: one card the church has put above everything else.
 *
 * Marked rather than merely first. Without it the card reads as one that has
 * lost its heading — every other row on this page announces itself, and this
 * one deliberately does not.
 *
 * THE MARK IS ON THE CARD, NOT ON THE SECTION. A rule on the section drew a bar
 * down the left edge of the SCREEN while the card sat a gutter inside it, so
 * the two looked unrelated and the bar read as a stray element. Seen in a
 * browser; it looked perfectly reasonable in the stylesheet. */
.section-pinned .card {
  border-color: var(--accent);
  box-shadow: inset 3px 0 0 var(--accent);
}

/* ── a pinned event shows its graphic whole ──────────────────────────────────
 * Pinning is the church saying "everybody sees this first", and it used to
 * render as a list row: an 84x64 thumbnail beside a title. The graphic they
 * made for it — usually square, from the same file that goes on Instagram —
 * arrived cropped to a postage stamp.
 *
 * So the one pinned card is full width and the image keeps its own shape.
 * `aspect-ratio: auto` with `height: auto` is what "the whole graphic" means:
 * no 16/9 box to crop into, and no letterbox bars either, because the card is
 * exactly as tall as the picture.
 */
.section-pinned .carousel {
  display: block;
  padding: 0 var(--gutter) 6px;
  /* It is one card; none of the scroller's behaviour applies, and leaving it a
   * scroll container would hand a swipe to a rail with nothing to scroll. */
  overflow: visible;
}

.section-pinned .card {
  width: 100%;
  max-width: none;
}

.section-pinned .card .media {
  aspect-ratio: auto;
  height: auto;
  object-fit: contain;
  /* A very tall graphic must not take the whole screen before a member has
   * seen anything else. At this cap a portrait image still reads as a poster
   * and the next row is still reachable with one thumb. */
  max-height: 70vh;
  /* AND A FLOOR, because `height: auto` on an image that has not loaded is
   * ZERO. Measured: the card collapsed to a title with no picture area at all
   * until the bytes arrived, and on a slow connection that is the state a
   * member sees first — the pinned thing rendering as the smallest row on the
   * page. The floor reserves somewhere for it to appear. */
  min-height: 160px;
}

/* ── the quick-link row ──────────────────────────────────────────────────────
 * Events · Español · Notes · Sermons · Check-in · Giving, under the greeting.
 * The things a member opens the app to DO; everything below them is to read.
 *
 * TILES, NOT CIRCLES. The circles were filled orange with the label shouted
 * underneath in orange capitals, and at six across that is a band of solid
 * colour above the content — it read as the subject of the page rather than as
 * the way to leave it. The tile inverts the weight: a quiet surface, the icon
 * in the accent, the label in ink at its normal size. The buttons recede and
 * the content is what you see.
 *
 * ONE ROW, ALWAYS. Six 44px tiles plus gaps fit a 320px screen, and the label
 * lives INSIDE the tile, so nothing can wrap a seventh button onto a second
 * line and leave a hole under the fifth.
 */
.quick-links {
  display: flex;
  justify-content: center;
  align-items: stretch;
  gap: 5px;
  padding: 16px var(--gutter) 10px;
}

/* ── "Which campus do you call home?" ────────────────────────────────────────
 *
 * Shown only to a member Planning Center has not placed, directly under the
 * button row, because it is about the button row: they are looking at two tiles
 * where the person beside them has six.
 *
 * A PANEL, NOT A BANNER. It is a question with an answer, not a notice — and
 * the thing it must not look like is an error, because nothing is broken and
 * nothing they did caused it. Same card surface as everything else on the page
 * so it reads as part of the app rather than as an interruption pasted over it. */
.campus-ask {
  background: var(--panel, #fff);
  border: 1px solid var(--line, #d7d7dc);
  border-radius: 14px;
  margin: 4px var(--gutter) 12px;
  padding: 14px 16px;
}

.campus-ask-q {
  font-weight: 600;
  margin: 0 0 4px;
}

.campus-ask-why {
  color: var(--muted);
  font-size: 0.88rem;
  margin: 0 0 12px;
}

/* Wraps, and each name takes a whole line once three will not fit. "South Hill,
 * Washington" and "Kathmandu, Nepal" squeezed into thirds of a 390px phone
 * truncate to "South Hi…" and "Kathman…", which is a choice nobody can make. */
.campus-ask-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.campus-ask-btn {
  flex: 1 1 10rem;
}

.campus-ask-btn:disabled {
  opacity: 0.55;
}

.campus-ask-status {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 10px 0 0;
  min-height: 1.2em;
}

.campus-ask-status.ok {
  color: var(--ok);
}

.campus-ask-status.bad {
  color: var(--danger);
}

.quick-link {
  /* Equal widths from zero, so six tiles divide the row evenly whatever the
   * labels say. A flex item will not shrink below its content without
   * min-width: 0, and its content is a word. */
  flex: 1 1 0;
  min-width: 0;
  max-width: 96px;

  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;

  /* The tile IS the button: the whole surface is the target, not the glyph. */
  background: var(--panel-2);
  border-radius: var(--radius);
  /* 3px of side padding, not 4+: the budget for the label is the tile minus
   * this, and "Check-in" is the word that has to fit on a 320px screen. */
  padding: 10px 3px 8px;

  text-decoration: none;
  color: var(--accent);
  transition: transform 90ms ease, background-color 90ms ease;
}

.quick-icon {
  /* A bare glyph now. The tile behind it carries the shape, so a second
   * rounded container inside it was one border radius too many.
   *
   * clamp keeps six across on the narrowest phone without a media query: the
   * thing that varies is how many buttons the CHURCH has configured, and a
   * breakpoint cannot see that. */
  width: clamp(22px, 7vw, 28px);
  height: clamp(22px, 7vw, 28px);
  display: grid;
  place-items: center;
  flex: none;
  color: var(--accent-fill);
}

.quick-icon svg {
  width: 100%;
  height: 100%;
}

.quick-link:active {
  transform: scale(0.96);
  background: var(--line);
}

.quick-label {
  /* Sentence case at a readable size, in ink rather than in the accent. The
   * capitals and the letter-spacing were doing the work the orange circle
   * should have been doing, and together they shouted twice.
   *
   * ONE LINE. Inside a tile a second line changes the tile's height and the
   * row goes ragged, so a long name is ellipsised — and the names that matter
   * are short because the church writes them ("Notes", not "Sermon Notes"). */
  /* Sized so the LONGEST label fits whole at the narrowest width. 2.9vw
   * ellipsised "Sermons" and "Check-in" on a 390px phone — measured in a
   * browser, not reasoned about — and a button reading "Check…" is worse than
   * a smaller one reading "Check-in". */
  font-size: clamp(0.56rem, 2.5vw, 0.7rem);
  font-weight: 600;
  color: var(--ink);
  text-align: center;
  line-height: 1.15;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.quick-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Reduced motion means no press animation. The background still changes on
 * :active, so the button is plainly responding to a finger. */
@media (prefers-reduced-motion: reduce) {
  .quick-link,
  .quick-link:active {
    transition: none;
    transform: none;
  }
}
}
