/* v25, the Moth reframe: a trip is a Moment while it happens and an Album after. The app's new pieces:
   the Moth Key (shown once), the header's Moment line and Invite, Capture, the invite (the Moment screen
   after Start and the Invite sheet after that, js/moments.js), the switch between Moments, and the
   Album's intro. The landing's story sections for the reframe are at the end, scoped to .hero-story.
   Uses the app's tokens (app.css :root). */

/* ---------- The Moth Key: shown once, to its owner ---------- */
.identity-name { margin-bottom: 2px; font-size: 15px; color: var(--muted); overflow-wrap: anywhere; }
.identity-content h1 { font-family: var(--serif); font-weight: 400; font-size: 30px; line-height: 1.15; letter-spacing: -.03em; }
.identity-value { margin: 20px 0 16px; font-size: inherit; letter-spacing: 0; }
.identity-value strong {
  display: inline-block; padding: 10px 20px 10px 26px; border-radius: 16px; background: #fff; border: 1px solid var(--line);
  box-shadow: 0 14px 28px -22px #3a3a2a66; font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: clamp(34px, 11vw, 44px);
  font-weight: 600; letter-spacing: .2em; line-height: 1.2; color: var(--ink); user-select: all; white-space: nowrap;
}
.identity-note { font-size: 15px; line-height: 1.6; color: var(--muted); text-wrap: pretty; }
.identity-actions { display: flex; gap: 10px; margin-top: 26px; }
.identity-actions .button { flex: 1; min-width: 0; }
.identity-actions #copy-code { margin-top: 0; text-decoration: none; }
.identity-actions #identity-continue { display: inline-flex; align-items: center; justify-content: center; width: auto; margin-top: 0; flex: 1.4; }
.identity-status { margin-top: 12px; font-size: 13px; color: var(--accent); min-height: 1.5em; }

/* ---------- Header: the Moment's name, "7 here · Live now" under it, and Invite ---------- */
.brand { flex: 1; }
.app-header.in-moment .brand-stack .wordmark { display: none; }
.app-header.in-moment .trip-open {
  margin-top: 0; max-width: 100%; font-family: var(--sans); font-size: 16px; font-weight: 600; line-height: 1.25;
  letter-spacing: -.012em; color: var(--ink);
}
.app-header.in-moment .trip-open::after { inset: -10px -8px -20px; } /* 44px+ even at the screen's top edge: it takes in "7 here · Live now" (words only) */
.moment-line { display: flex; align-items: center; min-width: 0; max-width: 100%; margin-top: 1px; font-size: 12.5px; line-height: 1.3; color: var(--muted); white-space: nowrap; }
.moment-line .presence { margin-left: 0; font-size: inherit; }
.presence:not(:empty) + .moment-state:not([hidden])::before { content: "·"; margin: 0 5px; color: var(--faint); }
.moment-state { overflow: hidden; text-overflow: ellipsis; }
.app-header[data-moment="live"] .moment-state { color: #557563; font-weight: 550; }
/* An Album (nobody here, nothing new for a while): "Pooja's Birthday · 84 photos". */
.app-header[data-moment="album"] .presence { display: none; }
.invite-open {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 6px; flex-shrink: 0; height: 36px; padding: 0 14px 0 11px;
  border-radius: 18px; background: var(--mine); font-size: 14px; font-weight: 600; color: var(--accent-deep);
}
.invite-open::after { content: ""; position: absolute; inset: -4px -2px; } /* a 44px tap area */
.invite-open svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.invite-open:hover { background: #d6e3d8; }
/* Phones: the Moment's name needs the room, so Invite is its icon alone (named for screen readers), in
   the same soft green so it still reads as the thing to tap. */
@media (max-width: 480px) {
  .app-header.in-moment .header-row { gap: 6px; }
  .invite-open { width: 40px; height: 40px; padding: 0; border-radius: 50%; }
  .invite-open span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .invite-open + #albums-open { margin-left: 0; }
}
.invite-open + #albums-open { margin-left: -4px; }
@media (max-width: 380px) {
  .app-header.in-moment .header-row { gap: 4px; }
  .app-header.in-moment .brand-logo { width: 28px; height: 28px; }
  .app-header.in-moment .trip-open { font-size: 15px; }
}

/* ---------- Capture: the one action, named ---------- */
.capture-bar { flex-direction: column; align-items: center; }
.camera-label { margin-top: 7px; font-size: 12.5px; font-weight: 600; letter-spacing: .01em; color: var(--ink); pointer-events: none !important; }
.chat-history { --chat-end: calc(152px + env(safe-area-inset-bottom)); }

/* ---------- The invite: QR, code, Share. As a sheet, and as the Moment screen right after Start ---------- */
.invite { width: min(390px, calc(100% - 28px)); padding: 10px 22px max(22px, env(safe-area-inset-bottom)); text-align: center; }
.invite[open] { display: flex; flex-direction: column; }
.invite-head { display: flex; align-items: center; justify-content: space-between; margin-right: -12px; text-align: left; }
.invite-kicker { font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.invite-body { display: flex; flex-direction: column; align-items: center; min-height: 0; }
.invite-name:focus, .invite-name:focus-visible { outline: none; }
.invite-name { margin-top: 2px; font-family: var(--serif); font-weight: 400; font-size: 28px; line-height: 1.15; letter-spacing: -.03em; overflow-wrap: anywhere; text-wrap: balance; outline: none; }
.invite-qr {
  position: relative; margin-top: 18px; width: min(244px, 64vw); aspect-ratio: 1; padding: 12px; border-radius: 20px;
  background: #fff; border: 1px solid var(--line); box-shadow: 0 16px 34px -24px #3a3a2a73;
}
.invite-qr img { display: block; width: 100%; height: 100%; image-rendering: crisp-edges; }
.invite-qr[data-state="wait"] img { opacity: 0; }
.invite-qr[data-state="ready"] img { opacity: 1; transition: opacity .25s ease; }
.invite-qr[data-state="wait"]::before {
  content: ""; position: absolute; inset: 22%; border-radius: 12px; background: var(--sk-base, #efeee8);
}
@media (prefers-reduced-motion: no-preference) { .invite-qr[data-state="wait"]::before { animation: invite-wait 1.4s ease-in-out infinite; } }
@keyframes invite-wait { 50% { opacity: .45; } }
/* No QR (an older server, or it couldn't load): the code is the way in. */
.invite-qr[data-state="none"] { display: none; }
.invite-scan { margin-top: 16px; font-size: 16px; font-weight: 600; }
.invite-qr[data-state="none"] + .invite-scan { display: none; }
.invite-code { margin-top: 2px; font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 24px; font-weight: 600; letter-spacing: .12em; color: var(--ink); user-select: all; white-space: nowrap; }
.invite-qr[data-state="none"] ~ .invite-code { margin-top: 22px; font-size: clamp(30px, 10vw, 38px); }
.invite-row { display: flex; gap: 10px; width: 100%; margin-top: 18px; }
.invite-row .button { flex: 1; min-width: 0; }
.invite-status { margin-top: 10px; font-size: 14px; color: var(--accent); }
.invite-status:empty { display: none; }
.invite-go { width: 100%; margin-top: 14px; }
@media (max-width: 600px) {
  .invite[data-mode="sheet"] { margin: auto auto max(14px, env(safe-area-inset-bottom)); max-height: min(92dvh, calc(var(--viewport-height, 100dvh) - 28px)); overflow-y: auto; overscroll-behavior: contain; }
}
/* The Moment screen: the whole screen, so six friends can scan it off one phone. */
.invite[data-mode="created"] {
  width: 100%; max-width: 100%; height: 100%; max-height: 100%; margin: 0; border: 0; border-radius: 0; box-shadow: none;
  padding: max(10px, env(safe-area-inset-top)) max(22px, env(safe-area-inset-right)) max(22px, env(safe-area-inset-bottom)) max(22px, env(safe-area-inset-left));
}
.invite[data-mode="created"]::backdrop { background: var(--bg); }
.invite[data-mode="created"] .invite-head { width: 100%; max-width: 420px; margin: 0 auto; padding-right: 0; }
.invite[data-mode="created"] .invite-body { flex: 1; justify-content: center; width: 100%; max-width: 420px; margin: 0 auto; padding: 8px 0; }
.invite[data-mode="created"] .invite-name { font-size: clamp(30px, 8.4vw, 42px); }
.invite[data-mode="created"] .invite-qr { width: min(288px, 72vw, 44dvh); margin-top: 22px; }
.invite[data-mode="created"] .invite-go { max-width: 420px; margin: 12px auto 0; }
@media (max-height: 680px) {
  .invite[data-mode="created"] .invite-qr { width: min(220px, 64vw, 38dvh); margin-top: 14px; }
  .invite[data-mode="created"] .invite-row { margin-top: 12px; }
}
@media (prefers-reduced-motion: no-preference) {
  dialog[open].invite[data-mode="sheet"] { animation: appear .18s var(--settle); }
  dialog[open].invite[data-mode="created"] { animation: fade-in .25s ease-out; }
  .invite[data-mode="created"][open] .invite-qr { animation: invite-print .7s var(--spring) .05s backwards; }
}
@keyframes invite-print { from { opacity: 0; transform: translateY(14px) rotate(-2deg); } }

/* ---------- An invite to another Moment while in one ---------- */
.moment-switch { width: min(360px, calc(100% - 28px)); padding: 22px; }
.moment-switch-title { font-family: var(--serif); font-weight: 400; font-size: 24px; line-height: 1.2; letter-spacing: -.03em; overflow-wrap: anywhere; text-wrap: balance; }
.moment-switch-text { margin-top: 10px; font-size: 15px; line-height: 1.55; color: var(--muted); text-wrap: pretty; overflow-wrap: anywhere; }
.moment-switch .button { display: block; width: 100%; margin-top: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.moment-switch-text + .button { margin-top: 20px; }
.moment-switch .error { margin-top: 10px; font-size: 14px; }

/* ---------- v28 Your Moments: every Moment on this device, from the header's Moment name ---------- */
.moments-sheet { width: min(400px, calc(100% - 28px)); padding: 8px 22px max(20px, env(safe-area-inset-bottom)); }
.moments-sheet .trip-sheet-head h2 { margin: 0; }
.moments-count { margin-top: -6px; font-size: 13px; color: var(--muted); }
.moments-count:empty { display: none; }
.moments-list { display: grid; gap: 8px; margin: 10px 0 0; padding: 0; list-style: none; }
.moments-item { border-radius: 16px; background: #fff; border: 1px solid var(--line); }
.moments-item.is-active { background: #f3f7f3; border-color: #cddcd1; }
.moments-row {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 64px; padding: 11px 14px;
  border-radius: 16px; text-align: left; color: var(--ink);
}
.moments-switch:hover:not(:disabled) { background: var(--surface-soft); }
.moments-switch:disabled { cursor: default; }
.moments-badge {
  display: grid; place-items: center; flex-shrink: 0; width: 40px; height: 40px; border-radius: 12px;
  background: var(--surface-soft); border: 1px solid var(--line); font-family: var(--serif); font-size: 20px; line-height: 1; color: var(--ink);
}
.is-active .moments-badge { background: var(--accent); border-color: var(--accent); color: #fff; }
.moments-text { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.moments-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 16px; font-weight: 600; letter-spacing: -.01em; }
.moments-meta { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; color: var(--muted); }
.moments-meta:empty { display: none; }
.moments-row > svg { flex-shrink: 0; width: 18px; height: 18px; fill: none; stroke: var(--muted); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.moments-here { display: inline-flex; flex-shrink: 0; }
.moments-here svg { width: 22px; height: 22px; fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.moments-actions { display: flex; gap: 8px; padding: 0 14px 14px; }
.moments-actions .button { flex: 1; min-width: 0; min-height: 44px; padding: 9px 14px; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sk-moments .sk-name { width: 60%; }
.sk-moments .sk-meta { width: 40%; }
.sk-moments .moments-badge { border: 0; }
.moments-error { margin-top: 10px; font-size: 14px; }
.moments-error:empty { display: none; }
.moments-more { display: grid; gap: 8px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.moments-wide { width: 100%; }
.moments-join label { display: block; margin-bottom: 6px; font-size: 13px; color: var(--muted); }
.moments-join-row { display: flex; gap: 8px; }
.moments-join input {
  flex: 1; min-width: 0; min-height: 46px; font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 18px;
  font-weight: 600; letter-spacing: .12em; text-transform: uppercase;
}
.moments-join input::placeholder { color: var(--faint); font-weight: 500; }
.moments-join .button { flex-shrink: 0; }
.moments-note { margin-top: 8px; font-size: 13px; line-height: 1.5; color: var(--muted); }
/* Phones: a sheet from the bottom that never grows past what can be seen (and rises above the keyboard). */
@media (max-width: 600px) {
  .moments-sheet {
    margin-bottom: calc(max(14px, env(safe-area-inset-bottom)) + var(--sheet-lift, 0px));
    max-height: min(85dvh, calc(var(--viewport-height, 100dvh) - 28px)); overflow-y: auto; overscroll-behavior: contain;
  }
}
/* The hero's Your Moments (v28): whose name you have in each, and whether it's live. */
.your-moment-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.your-moment-meta { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 400; color: var(--muted); }

/* ---------- The Album: the Moment's, already there ---------- */
.album-intro {
  max-width: 760px; margin: 0 auto;
  padding: 20px max(28px, env(safe-area-inset-right)) 0 max(28px, env(safe-area-inset-left));
}
.album-intro-name { font-family: var(--serif); font-size: 28px; line-height: 1.15; letter-spacing: -.03em; overflow-wrap: anywhere; }
.album-intro-count { margin-top: 4px; font-size: 14px; color: var(--muted); }
.album-intro-count:empty { display: none; }
.album-intro-line { margin-top: 8px; font-family: var(--serif); font-style: italic; font-size: 16px; color: #5c625d; }
