/* Layout: one column, a timeline of polaroids tossed on a dark table (the
   camera's own screen colours), alternating sides on wide screens. */
:root {
  --table: #101418; --table-2: #171D23; --fg: #F5F2EA; --muted: #9AA4AE; --line: #2A333C;
  --paper: #FAF8F3; --ink: #23272D; --ink-soft: #6B7079;
  --orange: #E8973A; --teal: #4FB3B7; --red: #E5574C;
  --display: "Fredoka", "Nunito Sans", system-ui, sans-serif;
  --body: "Nunito Sans", system-ui, -apple-system, sans-serif;
  --hand: "Caveat", "Segoe Print", "Bradley Hand", cursive;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) { :root:not([data-theme="dark"]) {
  --table: #DCE2E6; --table-2: #E8ECEF; --fg: #182027; --muted: #55616C; --line: #B9C3CB;
  --paper: #FFFFFF; color-scheme: light } }
:root[data-theme="light"] {
  --table: #DCE2E6; --table-2: #E8ECEF; --fg: #182027; --muted: #55616C; --line: #B9C3CB;
  --paper: #FFFFFF; color-scheme: light }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; background: var(--table); color: var(--fg); font: 16px/1.5 var(--body);
  background-image: radial-gradient(ellipse at 50% -10%, var(--table-2), transparent 60%);
  background-attachment: fixed;
}
img { max-width: 100%; display: block; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.app {
  max-width: 980px; margin: 0 auto; padding-block: 28px 40px;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
  display: flex; flex-direction: column; gap: 24px;
}

/* Header: the camera's eyes */
.top { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.eyes { display: flex; gap: 14px; height: 54px; align-items: center; }
.eyes span { width: 34px; height: 50px; border-radius: 17px; background: var(--fg); transform-origin: 50% 50%; }
h1 { font: 600 clamp(2.2rem, 7vw, 3.4rem)/1 var(--display); margin: 0; letter-spacing: -.01em; text-wrap: balance; }
.stats { margin: 0; color: var(--muted); font-weight: 600; font-variant-numeric: tabular-nums; }
.stats b { color: var(--orange); font-weight: 700; }
.tabs { display: flex; gap: 4px; padding: 4px; border-radius: 99px; background: var(--table-2); border: 1px solid var(--line); margin-top: 4px; }
.tab { font: 600 15px var(--body); color: var(--muted); background: none; border: 0; border-radius: 99px; padding: 6px 18px; cursor: pointer; }
.tab[aria-pressed="true"] { background: var(--fg); color: var(--table); }

/* Cards (sign-in, family) */
.card { background: var(--table-2); border: 1px solid var(--line); border-radius: 16px; padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.card h2 { font: 600 1.35rem/1.2 var(--display); margin: 0; }
.card p { margin: 0; }
.gate { max-width: 440px; width: 100%; align-self: center; text-align: center; align-items: center; }
#family { display: flex; flex-direction: column; gap: 16px; max-width: 560px; width: 100%; align-self: center; }
.note { font-size: 14px; color: var(--muted); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  font: 700 15px var(--body); color: var(--fg); background: transparent; border: 1px solid var(--line);
  border-radius: 12px; padding: 10px 16px; cursor: pointer; min-height: 44px;
}
.btn svg { width: 20px; height: 20px; flex: none; }
.btn.primary { background: var(--fg); color: var(--table); border-color: var(--fg); }
.btn:focus-visible, .tab:focus-visible, .link:focus-visible, input:focus-visible, summary:focus-visible, .polaroid:focus-visible {
  outline: 3px solid var(--orange); outline-offset: 3px;
}
.link { font: 600 14px var(--body); color: var(--muted); background: none; border: 0; text-decoration: underline; cursor: pointer; padding: 4px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; width: 100%; }
.row input { flex: 1 1 200px; min-width: 0; }
input {
  font: 16px var(--body); color: var(--fg); background: var(--table); border: 1px solid var(--line);
  border-radius: 12px; padding: 10px 12px; min-height: 44px;
}
.maillink { width: 100%; text-align: left; }
.maillink summary { cursor: pointer; color: var(--muted); font-size: 14px; text-align: center; padding: 4px; }
.maillink form { display: flex; flex-direction: column; gap: 8px; padding-top: 10px; }
.maillink label { font-size: 14px; font-weight: 600; }

/* Timeline */
.timeline { position: relative; display: flex; flex-direction: column; gap: 8px; padding-bottom: 20px; overflow-x: clip; overflow-y: visible; padding-top: 14px; }
.line { position: absolute; top: 0; bottom: 0; left: 22px; width: 2px; background: var(--line); transform-origin: top; border-radius: 2px; }
.day {
  position: relative; z-index: 1; align-self: flex-start; margin: 26px 0 6px;
  font: 600 14px var(--display); letter-spacing: .02em; color: var(--table); background: var(--fg);
  border-radius: 99px; padding: 5px 14px;
}
.day:first-child { margin-top: 0; }
.slot { position: relative; padding-left: 56px; display: flex; }
.slot::before { content: ""; position: absolute; left: 17px; top: 46%; width: 12px; height: 12px; border-radius: 50%; background: var(--table); border: 2px solid var(--muted); }

@media (min-width: 760px) {
  .line { left: 50%; margin-left: -1px; }
  .day { align-self: center; }
  .slot { padding-left: 0; width: 50%; }
  .slot.left { align-self: flex-start; justify-content: flex-end; padding-right: 48px; }
  .slot.right { align-self: flex-end; justify-content: flex-start; padding-left: 48px; }
  .slot::before { left: auto; }
  .slot.left::before { right: -7px; }
  .slot.right::before { left: -7px; }
  .slot + .slot { margin-top: -90px; }
}

/* Polaroid */
.polaroid {
  --tilt: 0deg;
  position: relative; margin: 0; width: min(300px, 100%); background: var(--paper); color: var(--ink);
  padding: 12px 12px 14px; border-radius: 3px; cursor: pointer;
  transform: rotate(var(--tilt));
  box-shadow: 0 1px 2px rgba(0,0,0,.25), 0 10px 24px rgba(0,0,0,.35);
  -webkit-tap-highlight-color: transparent;
}
.polaroid .photo { aspect-ratio: 4 / 3; background: #2b2f35; overflow: hidden; }
.polaroid .photo img { width: 100%; height: 100%; object-fit: cover; filter: saturate(1.05) contrast(1.02); }
.polaroid figcaption { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding: 10px 4px 0; min-height: 52px; }
.polaroid .word { font: 700 34px/1 var(--hand); color: var(--ink); overflow-wrap: anywhere; }
.polaroid .pt { font: 600 22px/1 var(--hand); color: var(--ink-soft); white-space: nowrap; }
.polaroid .time { position: absolute; right: 16px; top: 18px; font: 700 12px var(--body); color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,.6); font-variant-numeric: tabular-nums; }
/* Tape: one strip of translucent crepe masking tape per photo, placed and
   torn per photo in app.js, with a paper grain and a soft shadow. */
.polaroid.time-left .time { right: auto; left: 16px; }
.tape-wrap { position: absolute; z-index: 2; pointer-events: none; filter: drop-shadow(0 1px 1.2px rgba(0,0,0,.25)); }
.tape-wrap.top { top: -15px; left: var(--x, 50%); width: var(--w, 108px); height: 30px; transform: translateX(-50%) rotate(var(--r, 0deg)); }
.tape-wrap.tl { top: 2px; left: -26px; width: 96px; height: 28px; transform: rotate(calc(-40deg + var(--r, 0deg))); }
.tape-wrap.tr { top: 2px; right: -26px; width: 96px; height: 28px; transform: rotate(calc(40deg + var(--r, 0deg))); }
.tape {
  position: absolute; inset: 0;
  background-color: rgba(231, 218, 186, .82);
  background-image:
    linear-gradient(180deg, rgba(255,255,255,.18), rgba(255,255,255,0) 35%, rgba(0,0,0,.05) 100%),
    repeating-linear-gradient(90deg, rgba(110, 88, 48, .07) 0 1px, transparent 1px 2.5px, rgba(110, 88, 48, .04) 2.5px 3.5px, transparent 3.5px 6px),
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='140' height='140'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .42 0 0 0 0 .35 0 0 0 0 .22 0 0 0 .5 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}
.tape.clear {
  background-color: rgba(255, 255, 255, .16);
  background-image:
    linear-gradient(100deg, rgba(255,255,255,0) 18%, rgba(255,255,255,.38) 42%, rgba(255,255,255,.08) 55%, rgba(255,255,255,0) 70%),
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='140' height='140'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='1.4' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 .12 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}
.tape-wrap:has(.clear) { filter: drop-shadow(0 0 .6px rgba(0,0,0,.28)); }
.sticker {
  position: absolute; right: -8px; bottom: 46px; width: 72px; height: 72px; border-radius: 50%;
  background: var(--orange); color: #fff; display: grid; place-items: center; text-align: center;
  font: 600 13px/1.05 var(--display); text-transform: uppercase; letter-spacing: .02em;
  transform: rotate(12deg); box-shadow: 0 3px 8px rgba(0,0,0,.3); border: 3px solid #fff;
}
.pile { position: relative; width: min(300px, 100%); }
.pile .polaroid { width: 100%; }
.pile .ghost { position: absolute; inset: 0; background: var(--paper); border-radius: 3px; box-shadow: 0 6px 16px rgba(0,0,0,.3); }
.pile .ghost:nth-child(1) { transform: rotate(-7deg) translate(-6px, 4px); }
.pile .ghost:nth-child(2) { transform: rotate(5deg) translate(6px, 2px); }
.badge {
  position: absolute; left: -10px; top: 26px; z-index: 2; background: var(--teal); color: #fff;
  font: 700 15px var(--display); border-radius: 99px; padding: 3px 10px; box-shadow: 0 2px 6px rgba(0,0,0,.3);
}

.empty { text-align: center; color: var(--muted); margin: 40px 0; }
.more { height: 1px; }

/* Lightbox */
.lightbox {
  position: fixed; inset: 0; z-index: 20; background: rgba(8, 10, 12, .82); backdrop-filter: blur(6px);
  display: grid; place-items: center; overflow-y: auto;
  padding: max(20px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) max(20px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
}
.lb-inner { display: flex; flex-direction: column; align-items: center; gap: 18px; width: min(520px, 100%); }
.polaroid.big { width: 100%; cursor: default; padding: 16px 16px 18px; }
.polaroid.big .word { font-size: 52px; }
.polaroid.big .pt { font-size: 30px; }
.lb-info { color: #F5F2EA; text-align: center; display: flex; flex-direction: column; gap: 4px; }
.lb-info p { margin: 0; }
.lb-info #lb-count { color: #C3CAD1; }
.lb-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 10px; }
.lightbox .btn { color: #F5F2EA; border-color: rgba(255,255,255,.3); }

/* Family */
.health { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 0; font-variant-numeric: tabular-nums; }
.health dt { color: var(--muted); }
.health dd { margin: 0; font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.health .ok { color: var(--teal); } .health .warn { color: var(--orange); } .health .bad { color: var(--red); }
.people { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.people li { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); min-height: 52px; }
.people li:first-child { border-top: 0; }
.people .email { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.people .role { font-size: 12px; font-weight: 700; color: var(--teal); text-transform: uppercase; letter-spacing: .05em; }
.people .confirm { display: flex; gap: 6px; align-items: center; font-size: 14px; }

.foot { display: flex; justify-content: center; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; flex-wrap: wrap; text-align: center; }
