/* Keepsake — styles.css
   Quiet, warm, readable. Fluid layout; mobile-first; no horizontal scroll
   at any width; touch targets >= 44px; text reflows rather than overflows. */

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: clamp(16px, 1rem + 0.1vw, 17px);
  line-height: 1.6;
  letter-spacing: 0.1px;
  overflow-x: hidden;
}
img, svg, video, canvas { max-width: 100%; height: auto; display: block; }

h1, h2, h3, .display {
  font-family: var(--font-display);
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: -0.01em;
  color: var(--text);
}
h1 { font-size: clamp(2rem, 1.4rem + 2.6vw, 3.3rem); margin: 0 0 0.4em; }
h2 { font-size: clamp(1.5rem, 1.2rem + 1.4vw, 2.1rem); margin: 1.6em 0 0.5em; }
h3 { font-size: clamp(1.15rem, 1.05rem + 0.5vw, 1.35rem); margin: 1.4em 0 0.4em; }
p { margin: 0 0 1em; }
a { color: var(--accent-ink); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--accent); }
small, .muted { color: var(--text-muted); }

.wrap { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 var(--gutter); }

/* Focus is always visible. */
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 6px;
}

/* --- Buttons --------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5em;
  min-height: var(--tap); min-width: var(--tap);
  padding: 0.7em 1.25em;
  font: inherit; font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.08s ease, background 0.15s ease, border-color 0.15s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--sunrise); color: #3A2410; border: none; box-shadow: 0 4px 14px rgba(232,106,92,0.28); }
.btn-primary:hover { filter: brightness(1.04); }
.btn-ghost { background: var(--bg-raised); color: var(--text); border-color: var(--border-strong); }
.btn-ghost:hover { border-color: var(--accent); }
.btn-quiet { background: transparent; color: var(--text-muted); }
.btn-quiet:hover { color: var(--text); }

/* --- Header / nav ---------------------------------------------------- */
.site-head {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.1) blur(8px);
  border-bottom: 1px solid var(--border);
}
.site-head .wrap { display: flex; align-items: center; gap: 1rem; min-height: 60px; }
.brand { display: flex; align-items: center; gap: 0.6rem; font-family: var(--font-display); font-size: 1.25rem; color: var(--text); text-decoration: none; }
.brand .mark { width: 30px; height: 30px; display: inline-flex; }
.brand .mark img { width: 30px; height: 30px; }
.nav-spacer { flex: 1; }
.nav-links { display: flex; align-items: center; gap: 0.25rem; flex-wrap: wrap; }
.nav-links a { padding: 0.5em 0.7em; border-radius: var(--radius-sm); color: var(--text-muted); text-decoration: none; min-height: var(--tap); display: inline-flex; align-items: center; }
.nav-links a:hover { color: var(--text); background: var(--bg-sunken); }

/* --- Hero ------------------------------------------------------------ */
.hero { padding: clamp(2.5rem, 6vw, 5rem) 0 clamp(2rem, 4vw, 3.5rem); background: var(--bg-warm); border-bottom: 1px solid var(--border); }
.hero .lede { font-size: clamp(1.1rem, 1rem + 0.6vw, 1.35rem); color: var(--text-muted); max-width: 34rem; }
.hero .cta-row { display: flex; gap: 0.75rem; flex-wrap: wrap; margin-top: 1.6rem; }
.hero h1 { background: var(--sunrise); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* Photo hero — the golden-hour album. A real <img> covers the section so it
   always loads; a warm left-to-right scrim keeps the headline readable while
   the photo stays clearly visible on the right. */
.hero-photo { position: relative; background: var(--bg-warm); overflow: hidden; padding: 0; border-bottom: 1px solid var(--border); min-height: 440px; display: flex; align-items: center; }
.hero-photo .hero-img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; object-position: center right;
  z-index: 0;
}
.hero-photo .hero-scrim {
  position: absolute; inset: 0; z-index: 1;
  background: linear-gradient(90deg, rgba(251,246,236,0.92) 0%, rgba(251,246,236,0.74) 38%, rgba(251,246,236,0.28) 64%, rgba(251,246,236,0) 100%);
}
.hero-photo .hero-inner { position: relative; z-index: 2; width: 100%; padding: clamp(2.5rem, 6vw, 5rem) var(--gutter) clamp(2rem, 4vw, 3.5rem); max-width: var(--maxw); }
.hero-photo .lede { max-width: 32rem; }
:root[data-theme="dark"] .hero-photo .hero-scrim {
  background: linear-gradient(90deg, rgba(33,24,18,0.92) 0%, rgba(33,24,18,0.74) 38%, rgba(33,24,18,0.28) 64%, rgba(33,24,18,0) 100%);
}
@media (max-width: 680px) {
  .hero-photo { min-height: 0; }
  .hero-photo .hero-scrim { background: linear-gradient(180deg, rgba(251,246,236,0.70) 0%, rgba(251,246,236,0.88) 48%, rgba(251,246,236,0.96) 100%); }
  :root[data-theme="dark"] .hero-photo .hero-scrim { background: linear-gradient(180deg, rgba(33,24,18,0.72) 0%, rgba(33,24,18,0.90) 48%, rgba(33,24,18,0.97) 100%); }
}

/* --- Cards / sections ------------------------------------------------ */
.card {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: clamp(1.1rem, 2.5vw, 1.6rem);
  box-shadow: var(--shadow);
}
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 17rem), 1fr)); }
.feature h3 { margin-top: 0; display: flex; align-items: center; gap: 0.5rem; }
.feature .ic { color: var(--calm); flex: none; font-size: 1.15rem; }
.feature p { color: var(--text-muted); margin-bottom: 0; }
/* Living color rotation so the grid feels like a life, not a ledger. */
.grid .feature:nth-child(5n+1) .ic { color: var(--garden); }
.grid .feature:nth-child(5n+2) .ic { color: var(--coral); }
.grid .feature:nth-child(5n+3) .ic { color: var(--sun); }
.grid .feature:nth-child(5n+4) .ic { color: var(--sky); }
.grid .feature:nth-child(5n+5) .ic { color: var(--plum); }
.card { position: relative; }
.feature::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 4px; border-radius: var(--radius) var(--radius) 0 0; background: var(--sunrise); opacity: 0.85; }
.grid .feature:nth-child(5n+1)::before { background: var(--meadow); }
.grid .feature:nth-child(5n+4)::before { background: linear-gradient(135deg, #79C0E8, #4F9BC4); }

.badge { display: inline-block; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; padding: 0.2em 0.6em; border-radius: 999px; }
.badge-free { background: color-mix(in srgb, var(--garden) 18%, transparent); color: var(--calm); }
.badge-pro { background: color-mix(in srgb, var(--sun) 24%, transparent); color: var(--accent-ink); }
.badge-print { background: color-mix(in srgb, var(--coral) 20%, transparent); color: #B23E31; }

.lock { font-size: 0.8rem; color: var(--text-muted); display: inline-flex; align-items: center; gap: 0.35rem; }

/* --- App shell ------------------------------------------------------- */
.app-tabs { display: flex; gap: 0.25rem; overflow-x: auto; padding: 0.5rem 0; scrollbar-width: thin; -webkit-overflow-scrolling: touch; }
.app-tabs button {
  flex: none; min-height: var(--tap); padding: 0.5em 0.9em;
  background: transparent; border: 1px solid transparent; border-radius: var(--radius-sm);
  color: var(--text-muted); font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.app-tabs button[aria-selected="true"] { background: var(--bg-raised); color: var(--text); border-color: var(--border-strong); }
.panel { padding: 1.25rem 0 2rem; }
.panel[hidden] { display: none; }

.empty { text-align: center; color: var(--text-muted); padding: 2.5rem 1rem; }
.empty .ic { color: var(--calm); margin-bottom: 0.75rem; }

/* --- Forms ----------------------------------------------------------- */
label { display: block; font-weight: 600; margin: 0.9rem 0 0.35rem; }
input[type="text"], input[type="date"], input[type="email"], textarea, select {
  width: 100%; min-height: var(--tap); padding: 0.6em 0.75em;
  font: inherit; color: var(--text);
  background: var(--bg-raised); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
}
textarea { min-height: 7rem; resize: vertical; line-height: 1.55; }

/* --- Reminder cards (gentle, dismissible) ---------------------------- */
.reminder { border-left: 3px solid var(--calm); }
.reminder .actions { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.75rem; }

/* --- Checklist how-to links ------------------------------------------ */
.checklist li.card { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.checklist .ctl { flex: 1; }
.how-to { flex: none; font-weight: 700; color: var(--accent-ink); text-decoration: none; white-space: nowrap; }
.how-to:hover { color: var(--accent); }

/* --- Rituals: candle ------------------------------------------------- */
.candle { display: inline-flex; flex-direction: column; align-items: center; margin-top: .3rem; }
.candle .flame { width: 14px; height: 22px; border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%; background: radial-gradient(ellipse at 50% 70%, #FFF3C4 0%, #F7C96B 40%, #EE9F5A 70%, #E86A5C 100%); box-shadow: 0 0 14px 4px rgba(238,159,90,.6); animation: flicker 1.6s ease-in-out infinite; transform-origin: 50% 90%; }
.candle .wick { width: 2px; height: 5px; background: #3A2E26; }
.candle .wax { width: 26px; height: 46px; border-radius: 4px 4px 3px 3px; background: linear-gradient(180deg, #FBF6EC, #ECE0CB); border: 1px solid var(--border-strong); }
@keyframes flicker { 0%,100% { transform: scaleY(1) rotate(-1deg); opacity: 1; } 50% { transform: scaleY(1.08) rotate(1deg); opacity: .9; } }
@media (prefers-reduced-motion: reduce) { .candle .flame { animation: none; } }

/* --- The person: header + intake ------------------------------------- */
.field-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr)); gap: 0 1rem; }
.person-header { background: var(--bg-warm); border: 1px solid var(--border-strong); border-radius: var(--radius); padding: clamp(1.1rem, 3vw, 1.8rem); margin-bottom: 1.5rem; box-shadow: var(--shadow); }
.person-header .ph-name { font-family: var(--font-display); margin: 0; background: var(--sunrise); -webkit-background-clip: text; background-clip: text; color: transparent; }
.person-header .ph-photo { float: right; width: clamp(80px, 18vw, 140px); height: clamp(80px, 18vw, 140px); object-fit: cover; border-radius: 12px; border: 2px solid var(--bg-raised); box-shadow: var(--shadow); margin: 0 0 .6rem 1rem; }
.person-header .ph-nick { font-family: var(--font-display); font-style: italic; margin: 0.1rem 0 0; color: var(--text-muted); }
.person-header .ph-dates { font-family: var(--font-mono); font-size: 0.9rem; margin: 0.5rem 0 0; }
.person-header .ph-rel { margin: 0.2rem 0 0; }
.person-header .ph-epitaph { font-family: var(--font-display); font-size: 1.1rem; font-style: italic; margin: 0.8rem 0 0; color: var(--accent-ink); max-width: 44rem; }
.ph-honors { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 1rem; }
.emblem { display: inline-block; font-size: 0.82rem; padding: 0.3em 0.7em; border-radius: 999px; background: var(--bg-raised); border: 1px solid var(--border-strong); color: var(--text); }
.emblem-mil { background: color-mix(in srgb, var(--sky) 16%, transparent); border-color: var(--sky); color: #2a6a8a; font-weight: 600; }
.emblem-ach { background: color-mix(in srgb, var(--sun) 16%, transparent); border-color: var(--gold); color: var(--accent-ink); }

/* --- Shared photos: reactions + comments ----------------------------- */
.photo-card { margin-top: 1rem; }
.contrib-img { width: 100%; max-height: 320px; object-fit: cover; border-radius: var(--radius-sm); margin-bottom: 0.6rem; }
.photo-card h3 { margin-top: 0; }
.react-bar { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.75rem 0; }
.react { display: inline-flex; align-items: center; gap: 0.3rem; min-height: var(--tap); padding: 0.35em 0.7em; font: inherit; background: var(--bg-sunken); border: 1px solid var(--border); border-radius: 999px; cursor: pointer; color: var(--text); }
.react:hover { border-color: var(--border-strong); }
.react.on { background: color-mix(in srgb, var(--sun) 22%, transparent); border-color: var(--sun); }
.react .g { font-size: 1.15rem; line-height: 1; }
.react .n { font-size: 0.85rem; color: var(--text-muted); min-width: 0.5rem; }
.react.on .n { color: var(--accent-ink); font-weight: 700; }
.comments { display: grid; gap: 0.4rem; margin: 0.5rem 0; }
.comment { background: var(--bg-sunken); border-radius: var(--radius-sm); padding: 0.5em 0.7em; font-size: 0.95rem; }
.comment .who { font-weight: 700; color: var(--calm); }
.comment-form { display: flex; gap: 0.5rem; margin-top: 0.5rem; }
.comment-form input { flex: 1; }

/* --- Family events: invites ------------------------------------------ */
.join-banner { border-left: 3px solid var(--calm); background: var(--bg-warm); margin-bottom: 1rem; }
.event-card h3 { margin-top: 0; }
.invite { display: flex; flex-wrap: wrap; gap: 1.25rem; margin-top: 1rem; align-items: flex-start; }
.invite .qr { flex: none; text-align: center; }
.invite .qr svg { width: 160px; height: 160px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.invite .qr-cap { margin: 0.4rem 0 0; font-size: 0.85rem; }
.invite-methods { flex: 1; min-width: min(100%, 16rem); display: grid; gap: 0.75rem; }
.method { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.method-label { font-weight: 700; font-size: 0.85rem; color: var(--text-muted); min-width: 4.5rem; }
.join-code { font-family: var(--font-mono); font-size: 1.05rem; font-weight: 700; color: var(--accent-ink); background: var(--bg-sunken); padding: 0.3em 0.6em; border-radius: var(--radius-sm); letter-spacing: 0.02em; }
.method input[type="text"] { flex: 1; min-width: 10rem; font-family: var(--font-mono); font-size: 0.85rem; }
.btn-copy { padding: 0.5em 0.9em; min-height: 40px; }

/* --- Shop / storefront ----------------------------------------------- */
.shop-cat { margin-top: 2rem; }
.shop-grid { margin-top: 1rem; }
.shop-item { display: flex; flex-direction: column; text-decoration: none; color: var(--text); transition: transform 0.08s ease, border-color 0.15s ease, box-shadow 0.15s ease; }
.shop-item:hover { transform: translateY(-2px); border-color: var(--accent); box-shadow: 0 8px 24px rgba(232,163,61,0.14); }
.shop-item .shop-thumb { font-size: 2.2rem; line-height: 1; margin-bottom: 0.5rem; }
.shop-item h3 { margin: 0 0 0.25rem; }
.shop-item p { color: var(--text-muted); flex: 1; }
.shop-item .shop-link { margin-top: 0.75rem; font-weight: 700; color: var(--accent-ink); }
.shop-item:hover .shop-link { color: var(--accent); }

/* --- Book CTA (Amazon) ----------------------------------------------- */
.book-steps { display: grid; gap: 0.75rem; margin: 1rem 0 0; }
.book-step { display: flex; gap: 0.75rem; align-items: flex-start; }
.book-step .num { flex: none; width: 1.9rem; height: 1.9rem; border-radius: 50%; background: var(--sunrise); color: #3A2410; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.book-step strong { display: block; }
.book-step p { margin: 0.1rem 0 0; }
.book-estimate { margin-top: 1rem; }
.estimate-box { background: var(--bg-raised); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 0.9rem 1rem; }
.estimate-box p:first-child { margin: 0 0 0.4rem; }
.estimate-box p:last-child { margin: 0; }

/* --- Footer ---------------------------------------------------------- */
.site-foot { border-top: 1px solid var(--border); margin-top: 3rem; padding: 2rem 0 2.5rem; color: var(--text-muted); font-size: 0.92rem; }
.site-foot .wrap { display: flex; flex-wrap: wrap; gap: 1rem 2rem; align-items: center; }
.site-foot .foot-brand { display: flex; align-items: center; gap: 0.5rem; }
.site-foot .foot-brand .mark { width: 22px; height: 22px; display: inline-flex; }
.site-foot .foot-brand .mark img { width: 22px; height: 22px; }
.foot-links { display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; }
.foot-links a { color: var(--text-muted); text-decoration: none; min-height: var(--tap); display: inline-flex; align-items: center; }
.foot-links a:hover { color: var(--text); }
.social { display: flex; gap: 0.5rem; align-items: center; }
.social a { width: var(--tap); height: var(--tap); display: inline-flex; align-items: center; justify-content: center; border-radius: var(--radius-sm); color: var(--text-muted); }
.social a:hover { color: var(--text); background: var(--bg-sunken); }
.social svg { width: 20px; height: 20px; }
.rel { font-family: var(--font-mono); font-size: 0.8rem; opacity: 0.8; }

/* Theme + lang controls */
.ctl { display: inline-flex; align-items: center; gap: 0.25rem; }
.icon-btn { width: var(--tap); height: var(--tap); display: inline-flex; align-items: center; justify-content: center; background: transparent; border: 1px solid transparent; border-radius: var(--radius-sm); color: var(--text-muted); cursor: pointer; }
.icon-btn:hover { color: var(--text); background: var(--bg-sunken); }
.lang-switch a { padding: 0.4em 0.55em; border-radius: var(--radius-sm); color: var(--text-muted); text-decoration: none; font-weight: 600; min-height: var(--tap); display: inline-flex; align-items: center; }
.lang-switch a[aria-current="true"] { color: var(--text); background: var(--bg-sunken); }

/* Skip link */
.skip { position: absolute; left: -9999px; top: 0; background: var(--accent); color: #241a05; padding: 0.6em 1em; border-radius: var(--radius-sm); z-index: 50; }
.skip:focus { left: 0.5rem; top: 0.5rem; }

/* Narrow screens */
@media (max-width: 560px) {
  .site-head .wrap { gap: 0.5rem; }
  .nav-links .hide-sm { display: none; }
  .hero { padding-top: 2rem; }
}
