/* Letieb Family: the same paper, ink and type as letieb.com
   1. Tokens  2. Base  3. Header  4. Shared pieces  5. Forms and dialogs  6. Views  7. Phones */

/* ---------- 1. Tokens ---------- */
:root {
  --paper: #f7f3ec;
  --paper-2: #efe8dc;
  --ink: #2b2520;
  --ink-soft: #5e554c;
  --ink-faint: #8f8478;
  --line: #ddd3c4;
  --accent: #9a6b3f;
  --accent-ink: #fffdf9;
  --accent-soft: #f0e3d1;
  --card: #fffdf9;
  --danger: #a5463a;
  --danger-soft: #f3dcd6;

  --serif: "Newsreader", Georgia, "Times New Roman", serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --radius: 14px;
  --gutter: clamp(16px, 4vw, 40px);
  --max: 860px;
  --tabbar: 0px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #1b1815;
    --paper-2: #24201c;
    --ink: #eee6da;
    --ink-soft: #c2b7a8;
    --ink-faint: #8f8578;
    --line: #3a332c;
    --accent: #d6a874;
    --accent-ink: #1b1815;
    --accent-soft: #3a2e22;
    --card: #221e1a;
    --danger: #e0927a;
    --danger-soft: #3d2620;
  }
}

/* ---------- 2. Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: var(--serif); font-weight: 500; line-height: 1.15; margin: 0; }
p { margin: 0; }
ul { list-style: none; margin: 0; padding: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
img { max-width: 100%; display: block; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.icon { display: inline-flex; width: 18px; height: 18px; flex: none; }
.icon svg { width: 100%; height: 100%; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- 3. Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px var(--gutter);
  background: color-mix(in srgb, var(--paper) 90%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.wordmark { font-family: var(--serif); font-size: 22px; text-decoration: none; }
.wordmark-app { font-size: 12px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent); padding-left: 10px; border-left: 1px solid var(--line); }
.nav { margin-left: auto; display: flex; gap: 4px; }
.nav-link { display: inline-flex; align-items: center; gap: 7px; padding: 8px 12px; border-radius: 999px; font-size: 14px; color: var(--ink-soft); text-decoration: none; }
.nav-link:hover { color: var(--ink); background: var(--paper-2); }
.nav-link.is-active { color: var(--ink); background: var(--accent-soft); }
.nav-link .icon { width: 16px; height: 16px; }
body.signed-out .nav { display: none; }

.main { max-width: var(--max); margin: 0 auto; padding: clamp(28px, 5vw, 56px) var(--gutter) calc(64px + var(--tabbar)); }
.loading { padding: 64px 0; text-align: center; color: var(--ink-faint); font-family: var(--serif); font-size: 20px; }

/* ---------- 4. Shared pieces ---------- */
.view { display: flex; flex-direction: column; gap: 20px; animation: rise 0.25s ease; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .view { animation: none; } }

.view-head { margin-bottom: 8px; }
.view-head h1 { font-size: clamp(36px, 6vw, 54px); letter-spacing: -0.01em; margin-top: 6px; }
.view-head-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.lede { margin-top: 10px; font-family: var(--serif); font-size: clamp(18px, 2.2vw, 21px); color: var(--ink-soft); }
.verse { font-style: italic; }
.verse-ref { display: block; margin-top: 4px; font-family: var(--sans); font-style: normal; font-size: 12px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent); }

.eyebrow, .label { font-size: 12px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent); }
.label { margin-bottom: 8px; }
.muted { color: var(--ink-faint); font-size: 14px; }
.section-title { font-size: 26px; margin-bottom: 12px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.section-head .section-title { margin-bottom: 0; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.spacer { flex: 1; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: clamp(18px, 3vw, 24px); }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.card-title { font-size: 22px; margin-bottom: 12px; }
.empty { display: flex; flex-direction: column; align-items: flex-start; gap: 14px; color: var(--ink-soft); }
.prompt { font-family: var(--serif); font-size: 20px; color: var(--ink); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 9px 18px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
}
.btn:hover { border-color: var(--accent); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 88%, var(--ink)); }
.btn-quiet { background: transparent; }
.btn-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); background: transparent; }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn-wide { width: 100%; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; flex: none; border: none; border-radius: 50%; background: transparent; color: var(--ink-faint); cursor: pointer; }
.icon-btn:hover { background: var(--paper-2); color: var(--ink); }
.link-btn { border: none; background: none; padding: 6px; color: var(--accent); font-size: 14px; cursor: pointer; text-decoration: none; }
.link-btn:hover { text-decoration: underline; }
.back-link { align-self: flex-start; display: inline-flex; align-items: center; gap: 6px; color: var(--ink-soft); text-decoration: none; font-size: 14px; }
.back-link:hover { color: var(--accent); }

.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { padding: 7px 14px; border-radius: 999px; border: 1px solid var(--line); background: transparent; color: var(--ink-soft); font-size: 14px; white-space: nowrap; cursor: pointer; }
.chip:hover { border-color: var(--accent); }
.chip.is-active { background: var(--ink); border-color: var(--ink); color: var(--paper); }

.avatar { flex: none; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; overflow: hidden; background: var(--accent-soft); color: var(--accent); font-family: var(--serif); }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-xs { width: 22px; height: 22px; font-size: 12px; }
.avatar-md { width: 40px; height: 40px; font-size: 20px; }
.avatar-lg { width: 72px; height: 72px; font-size: 34px; }
.avatar-xl { width: 120px; height: 120px; font-size: 56px; }

.person-chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 4px; border: 1px solid var(--line); border-radius: 999px; font-size: 13px; color: var(--ink-soft); text-decoration: none; }
a.person-chip:hover { border-color: var(--accent); color: var(--ink); }
.people-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }

.toast { position: fixed; left: 50%; bottom: calc(24px + var(--tabbar)); z-index: 50; max-width: calc(100vw - 32px); padding: 12px 18px; border-radius: 999px; background: var(--ink); color: var(--paper); font-size: 14px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s; }
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.toast[data-kind="error"] { background: var(--danger); color: #fff; }

/* ---------- 5. Forms and dialogs ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; min-width: 0; }
.field-label { font-size: 13px; font-weight: 500; color: var(--ink-soft); }
.field-hint { font-size: 13px; color: var(--ink-faint); }
.field-error { min-height: 20px; margin-bottom: 8px; font-size: 14px; color: var(--danger); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field input:not([type="checkbox"]), .field select, .field textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
  font-size: 16px; /* 16px keeps iPhone from zooming in */
}
.field textarea { resize: vertical; line-height: 1.5; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.picks { display: flex; flex-wrap: wrap; gap: 8px; }
.pick { display: inline-flex; align-items: center; gap: 7px; padding: 6px 12px 6px 8px; border: 1px solid var(--line); border-radius: 999px; font-size: 14px; cursor: pointer; }
.pick:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.pick input { width: 16px; height: 16px; accent-color: var(--accent); }

.sheet { width: min(560px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); padding: 0; border: 1px solid var(--line); border-radius: 18px; background: var(--card); color: var(--ink); box-shadow: 0 24px 64px -24px rgb(0 0 0 / 0.45); }
.sheet::backdrop { background: rgb(27 24 21 / 0.45); backdrop-filter: blur(3px); }
.sheet-body { padding: 22px 24px 24px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.sheet-head h2 { font-size: 26px; }
.sheet-actions { display: flex; align-items: center; gap: 10px; margin-top: 8px; }

.photo-strip { display: flex; flex-wrap: wrap; gap: 8px; }
.photo-thumb { position: relative; width: 84px; height: 84px; border-radius: 10px; overflow: hidden; background: var(--paper-2); }
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; }
.photo-remove { position: absolute; top: 4px; right: 4px; display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border: none; border-radius: 50%; background: rgb(27 24 21 / 0.7); color: #fff; cursor: pointer; }
.photo-remove .icon { width: 14px; height: 14px; }
.photo-add { display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; width: 84px; height: 84px; border: 1px dashed var(--line); border-radius: 10px; background: transparent; color: var(--ink-soft); font-size: 13px; cursor: pointer; }
.photo-add:hover { border-color: var(--accent); color: var(--accent); }

.lightbox { max-width: 96vw; max-height: 96dvh; padding: 0; border: none; background: transparent; }
.lightbox::backdrop { background: rgb(15 13 11 / 0.9); }
.lightbox img { max-width: 96vw; max-height: 96dvh; border-radius: 8px; cursor: zoom-out; }

/* ---------- 6. Views ---------- */

/* The door */
.signin { max-width: 400px; margin: clamp(24px, 8vh, 80px) auto 0; display: flex; flex-direction: column; }
.signin h1 { font-size: 44px; margin: 4px 0 6px; }
.signin-intro { margin-bottom: 22px; font-family: var(--serif); font-size: 18px; color: var(--ink-soft); }
.signin .link-btn { margin-top: 14px; align-self: center; }

/* Home */
.family-row { display: flex; flex-wrap: wrap; gap: 8px 22px; }
.family-person { display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 84px; text-align: center; text-decoration: none; }
.family-person:hover .family-name { color: var(--accent); }
.family-name { font-family: var(--serif); font-size: 19px; line-height: 1.2; }
.birthday { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 30%, var(--line)); display: flex; flex-direction: column; align-items: flex-start; gap: 10px; }
.birthday .card-title { margin: 0; }
.memory-lane { display: flex; flex-direction: column; gap: 10px; }
.letters-teaser { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.letters-teaser .card-title { margin-bottom: 4px; }

/* Moments */
.moment { display: flex; flex-direction: column; gap: 10px; }
.moment-head { display: flex; align-items: center; gap: 10px; }
.badge { font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; padding: 2px 9px; border-radius: 999px; border: 1px solid currentColor; color: var(--accent); }
.moment-title { font-size: 24px; }
.moment-text { font-family: var(--serif); font-size: 19px; line-height: 1.55; white-space: pre-wrap; }
.moment-text.is-quote { font-style: italic; font-size: 22px; padding-left: 16px; border-left: 2px solid var(--accent); }
.photo-grid { display: grid; gap: 6px; border-radius: 10px; overflow: hidden; }
.photo-grid.count-1 { grid-template-columns: 1fr; }
.photo-grid.count-2 { grid-template-columns: 1fr 1fr; }
.photo-grid.count-3 { grid-template-columns: repeat(3, 1fr); }
.photo { padding: 0; border: none; background: var(--paper-2); cursor: zoom-in; aspect-ratio: 1; overflow: hidden; }
.count-1 .photo { aspect-ratio: 3 / 2; }
.photo img { width: 100%; height: 100%; object-fit: cover; }
.month { margin-top: 8px; }

/* People */
.people-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.person-card { display: flex; align-items: center; gap: 16px; text-decoration: none; transition: border-color 0.15s; }
.person-card:hover { border-color: var(--accent); }
.person-card-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.person-name { font-family: var(--serif); font-size: 24px; line-height: 1.2; }
.person-photo { display: flex; align-items: center; gap: 18px; margin-bottom: 16px; }
.cover-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.person-hero { display: flex; align-items: center; gap: clamp(18px, 4vw, 32px); }
.person-hero-text { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.person-hero-text h1 { font-size: clamp(34px, 6vw, 52px); }
.person-hero-text .lede { margin-top: 0; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }
.growth-form { display: grid; grid-template-columns: 1.2fr 1fr 1fr auto; gap: 12px; align-items: end; }
.growth-form .btn { margin-bottom: 14px; }
.growth-table { width: 100%; border-collapse: collapse; font-size: 15px; }
.growth-table th { text-align: left; font-size: 12px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-faint); padding: 8px 8px 8px 0; }
.growth-table td { padding: 8px 8px 8px 0; border-top: 1px solid var(--line); }
.growth-table td:last-child, .growth-table th:last-child { width: 40px; padding-right: 0; }

/* Letters */
.letter-list { display: flex; flex-direction: column; gap: 14px; }
.letter-card { display: flex; flex-direction: column; gap: 6px; text-decoration: none; transition: border-color 0.15s; }
.letter-card:hover { border-color: var(--accent); }
.letter-title { font-family: var(--serif); font-size: 26px; line-height: 1.2; }
.letter-excerpt { font-family: var(--serif); font-size: 17px; color: var(--ink-soft); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.letter { display: flex; flex-direction: column; gap: 12px; padding: clamp(22px, 5vw, 48px); }
.letter h1 { font-size: clamp(32px, 5vw, 46px); }
.letter-open { display: inline-flex; align-items: center; gap: 8px; align-self: flex-start; padding: 6px 14px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: 14px; }
.letter-body { margin-top: 12px; font-family: var(--serif); font-size: 20px; line-height: 1.7; white-space: pre-wrap; max-width: 62ch; }
.field textarea.letter-body-input { font-family: var(--serif); font-size: 19px; line-height: 1.65; min-height: 320px; }

/* Settings */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; display: flex; flex-direction: column; gap: 2px; }
.stat-value { font-family: var(--serif); font-size: 30px; line-height: 1.1; }
.stat-label { font-size: 13px; color: var(--ink-faint); }
.card > .muted { margin-bottom: 14px; }
.sign-out { align-self: flex-start; }

/* ---------- 7. Phones: the menu becomes a tab bar at the bottom ---------- */
@media (max-width: 720px) {
  :root { --tabbar: calc(64px + env(safe-area-inset-bottom)); }
  /* No blur on the header here: it would pin the fixed tab bar to the header instead of the screen */
  .site-header { padding-top: 12px; padding-bottom: 12px; background: var(--paper); backdrop-filter: none; -webkit-backdrop-filter: none; }
  .nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; gap: 0; padding: 6px 6px env(safe-area-inset-bottom); background: var(--paper); border-top: 1px solid var(--line); }
  .nav-link { flex: 1; flex-direction: column; gap: 3px; padding: 6px 0 8px; border-radius: 12px; font-size: 11px; }
  .nav-link .icon { width: 22px; height: 22px; }
  .nav-link.is-active { background: transparent; color: var(--accent); }

  .field-row { grid-template-columns: 1fr; gap: 0; }
  .stats { grid-template-columns: 1fr 1fr; }
  .sheet { width: 100vw; max-width: none; max-height: 92dvh; margin: auto 0 0; border-radius: 18px 18px 0 0; border-bottom: none; }
  .sheet-body { padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
  .sheet-actions { flex-wrap: wrap; }
  .person-hero { flex-direction: column; align-items: flex-start; }
  .avatar-xl { width: 96px; height: 96px; font-size: 44px; }
  .growth-form { grid-template-columns: 1fr 1fr; }
  .growth-form .field:first-child { grid-column: 1 / -1; }
  .growth-form .btn { grid-column: 1 / -1; }
  .growth-table { font-size: 14px; }
  .growth-table th:nth-child(2), .growth-table td:nth-child(2) { display: none; }
}
