/* =============================================================================
   meadow-life.css — "A life remembered": an editorial spread.
   Desktop: title and tabs share one left edge and one hairline; the
   introduction reads on the left while a photo mosaic holds the right.
   Phones: a swipeable strip of photographs, then the words.
   Plus the full-screen photograph viewer (photo-viewer.js).
   ============================================================================= */

/* ---------------------------------------------------------------- header */
.life { --life-gap: clamp(2.4rem, 5vw, 5rem); }
.life-head { margin: 0 0 clamp(1.8rem, 4vw, 3rem); }
.life-head .life-title { margin: 0; }
.life-tabs[hidden] { display: none !important; }

/* phones + tablets: a calm segmented control, full width under the title */
.life-tabs {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; margin-top: 1.4rem;
  border-radius: 999px; background: rgba(43,32,21,.06); box-shadow: inset 0 0 0 1px rgba(43,32,21,.06);
  max-width: 420px;
}
.life-tab {
  min-height: 44px; padding: 0 1.2em; border: 0; border-radius: 999px; background: none; cursor: pointer;
  font: 500 1rem var(--sans); color: var(--ink-70); -webkit-tap-highlight-color: transparent;
  transition: background .3s, color .3s, box-shadow .3s;
}
.life-tab[aria-selected="true"] { background: var(--card); color: var(--ink); box-shadow: 0 6px 18px -10px rgba(43,32,21,.45), 0 0 0 1px rgba(43,32,21,.06); }
.life-tab:focus-visible { outline: 2px solid var(--amber-ink); outline-offset: 2px; }

/* desktop: title and quiet underline tabs on one edge, one hairline */
@media (min-width: 960px) {
  .life-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 2rem; border-bottom: 1px solid var(--line); padding-bottom: 1.1rem; }
  .life-tabs { display: flex; gap: 2.2rem; padding: 0; margin: 0 0 -1.15rem; background: none; box-shadow: none; border-radius: 0; max-width: none; }
  .life-tab { min-height: 0; padding: 0 0 1rem; border-radius: 0; border-bottom: 2px solid transparent; font-size: 1.02rem; letter-spacing: .01em; }
  .life-tab:hover { color: var(--ink); }
  .life-tab[aria-selected="true"] { background: none; box-shadow: none; border-bottom-color: var(--amber-ink); color: var(--ink); }
  .life-tab:focus-visible { outline-offset: 6px; border-radius: 4px; }
}

.life-panel { animation: life-in .55s cubic-bezier(.16,1,.3,1); }
@keyframes life-in { from { opacity: 0; transform: translateY(8px); } }

/* ----------------------------------------------------- introduction spread */
.life-intro { display: grid; grid-template-columns: 1fr; gap: clamp(1.8rem, 5vw, 2.6rem); }
.life-intro .life-photos { order: -1; }                 /* phones: photographs first */
.life .prose, .life .overview-empty { margin: 0 !important; max-width: 36rem; }
.life .prose { font-size: clamp(1.22rem, 4.6vw, 1.42rem); line-height: 1.7; color: #3a2d1f; }
.life .prose p:first-child { font-size: 1.12em; }
@media (min-width: 960px) {
  .life-intro { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: var(--life-gap); align-items: start; }
  .life-intro .life-photos { order: 0; }
  .life-text { position: sticky; top: 2.4rem; padding-top: .3rem; }
  .life .prose { font-size: clamp(1.2rem, 1.45vw, 1.42rem); }
  .life-intro.no-photos { grid-template-columns: minmax(0, 40rem); justify-content: center; }
  .life-intro.no-text { grid-template-columns: 1fr; }
  .life-intro.no-text .life-text { display: none; }
}

/* ------------------------------------------------------------ the mosaic */
.mosaic { margin: 0; padding: 0; list-style: none; }
.m-item { position: relative; margin: 0; overflow: hidden; border-radius: 14px; background: var(--cream-2); cursor: zoom-in; isolation: isolate; }
.m-item button { all: unset; display: block; width: 100%; height: 100%; cursor: zoom-in; }
.m-item button:focus-visible { outline: 3px solid var(--amber-ink); outline-offset: -3px; border-radius: 14px; }
.m-item img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 1.2s cubic-bezier(.16,1,.3,1), filter .6s; }
.m-item::after { content: ""; position: absolute; inset: 0; pointer-events: none; border-radius: inherit; box-shadow: inset 0 0 0 1px rgba(43,32,21,.06); }
@media (hover: hover) {
  .m-item:hover img { transform: scale(1.035); }
  .m-item:hover { box-shadow: 0 24px 50px -28px rgba(43,32,21,.55), 0 0 40px -12px rgba(243,182,90,.35); }
}
.m-more { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(28,24,30,.48); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); color: #f6efe2; font: 400 1.6rem/1.2 var(--serif); text-align: center; pointer-events: none; }
.m-more small { display: block; font: 500 .78rem var(--sans); letter-spacing: .14em; text-transform: uppercase; opacity: .8; margin-top: .3rem; }

/* phones + tablets: a swipeable strip — the next photo peeks in */
.mosaic {
  display: flex; gap: 10px; overflow-x: auto; scroll-snap-type: x mandatory; overscroll-behavior-x: contain;
  scrollbar-width: none; margin: 0 calc(-1 * clamp(1.25rem, 5vw, 3rem)); padding: 2px clamp(1.25rem, 5vw, 3rem) 6px;
  scroll-padding: 0 clamp(1.25rem, 5vw, 3rem);
}
.mosaic::-webkit-scrollbar { display: none; }
.m-item { flex: 0 0 82%; aspect-ratio: 4 / 5; scroll-snap-align: start; box-shadow: 0 18px 40px -26px rgba(43,32,21,.55); }
.m-item.is-landscape { aspect-ratio: 4 / 5; }
.m-more { display: none; }
.strip-foot { display: flex; align-items: center; justify-content: space-between; margin-top: .9rem; color: var(--ink-70); font: 500 .85rem var(--sans); }
.strip-dots { display: flex; gap: 6px; }
.strip-dots i { width: 6px; height: 6px; border-radius: 999px; background: rgba(43,32,21,.18); transition: width .35s, background .35s; }
.strip-dots i.on { width: 18px; background: var(--amber-ink); }
.strip-all { border: 0; background: none; padding: 6px 0; color: var(--amber-ink); font: 500 .9rem var(--sans); cursor: pointer; text-decoration: underline; text-underline-offset: 4px; }

/* desktop: an editorial mosaic — the portrait leads, the rest gather */
@media (min-width: 960px) {
  .mosaic { display: grid; grid-template-columns: repeat(6, 1fr); grid-auto-rows: clamp(84px, 7.2vw, 118px); gap: 12px; overflow: visible; margin: 0; padding: 0; }
  .m-item { aspect-ratio: auto !important; box-shadow: 0 18px 40px -30px rgba(43,32,21,.55); transition: box-shadow .5s; }
  .m-item.lead   { grid-column: span 6; grid-row: span 4; }
  .m-item.third  { grid-column: span 2; grid-row: span 2; }
  .m-item.half   { grid-column: span 3; grid-row: span 3; }
  .m-item.whole  { grid-column: span 6; grid-row: span 3; }
  .m-item.beyond { display: none; }
  .m-more { display: grid; }
  .strip-foot { display: none; }
  .life-intro.no-text .mosaic { grid-auto-rows: clamp(90px, 6vw, 120px); }
  .life-intro.no-text .m-item.lead { grid-column: span 4; grid-row: span 5; }
  .life-intro.no-text .m-item.third { grid-column: span 2; grid-row: span 2; }
}

/* -------------------------------------------------------- the obituary tab */
.life-obit { max-width: 42rem; margin: 0 auto; }
@media (min-width: 960px) { .life-obit { padding-top: .6rem; } }

/* ------------------------------------------------------- the photo viewer */
html.pv-locked, html.pv-locked body { overflow: hidden; }
.pv { position: fixed; inset: 0; z-index: 1500; background: #0d0f15; color: #f1e9da; visibility: hidden; opacity: 0; transition: opacity .35s ease, visibility 0s linear .35s; }
.pv.open { visibility: visible; opacity: 1; transition: opacity .35s ease; }
.pv-bg { position: absolute; inset: 0; overflow: hidden; }
.pv-bg i { position: absolute; inset: -10%; background-size: cover; background-position: center; filter: blur(48px) saturate(1.25) brightness(.42); transform: scale(1.1); opacity: 0; transition: opacity .7s ease; }
.pv-bg i.on { opacity: 1; }
.pv-top { position: absolute; top: 0; left: 0; right: 0; z-index: 3; display: flex; align-items: center; justify-content: space-between; padding: calc(10px + env(safe-area-inset-top, 0px)) 14px 10px 20px; background: linear-gradient(180deg, rgba(10,12,18,.6), rgba(10,12,18,0)); }
.pv-count { font: 500 .9rem var(--sans); letter-spacing: .06em; color: rgba(241,233,218,.8); }
.pv-close { width: 46px; height: 46px; display: grid; place-items: center; border: 0; border-radius: 50%; cursor: pointer; background: rgba(241,233,218,.1); color: #f1e9da; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.pv-close svg, .pv-nav svg { width: 22px; height: 22px; }
.pv-close:hover, .pv-nav:hover:not(:disabled) { background: rgba(241,233,218,.2); }
.pv-track { position: absolute; inset: 0; z-index: 1; display: flex; overflow-x: auto; overflow-y: hidden; scroll-snap-type: x mandatory; scrollbar-width: none; overscroll-behavior: contain; touch-action: pan-x pinch-zoom; outline: none; }
.pv-track::-webkit-scrollbar { display: none; }
.pv-slide { flex: 0 0 100%; height: 100%; margin: 0; display: grid; place-items: center; scroll-snap-align: center; scroll-snap-stop: always; padding: 70px 16px calc(24px + env(safe-area-inset-bottom, 0px)); }
.pv-slide img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 10px; box-shadow: 0 40px 100px -30px rgba(0,0,0,.85); }
.pv-nav { position: absolute; z-index: 3; top: 50%; transform: translateY(-50%); width: 52px; height: 52px; display: none; place-items: center; border: 0; border-radius: 50%; cursor: pointer; background: rgba(241,233,218,.1); color: #f1e9da; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); transition: background .25s, opacity .25s; }
.pv-nav:disabled { opacity: 0; pointer-events: none; }
.pv-prev { left: 20px; } .pv-next { right: 20px; }
.pv-thumbs { position: absolute; z-index: 3; left: 0; right: 0; bottom: 0; display: none; gap: 8px; justify-content: center; overflow-x: auto; padding: 14px 20px calc(16px + env(safe-area-inset-bottom, 0px)); background: linear-gradient(0deg, rgba(10,12,18,.65), rgba(10,12,18,0)); scrollbar-width: none; }
.pv-thumb { flex: 0 0 auto; width: 56px; height: 56px; padding: 0; border: 0; border-radius: 8px; overflow: hidden; cursor: pointer; opacity: .5; transition: opacity .25s, transform .25s, box-shadow .25s; background: #222; }
.pv-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pv-thumb:hover { opacity: .85; }
.pv-thumb[aria-current="true"] { opacity: 1; transform: translateY(-3px); box-shadow: 0 0 0 2px #f3b65a, 0 8px 20px -6px rgba(243,182,90,.6); }
.pv.is-single .pv-nav, .pv.is-single .pv-thumbs { display: none !important; }
@media (min-width: 900px) and (hover: hover) {
  .pv-nav { display: grid; }
  .pv-thumbs { display: flex; }
  .pv-slide { padding: 80px 96px 110px; }
}
@media (prefers-reduced-motion: reduce) {
  .life-panel { animation: none; }
  .m-item img, .pv, .pv-bg i { transition: none !important; }
}
@media print {
  .mosaic { display: grid !important; grid-template-columns: repeat(3, 1fr); gap: 8px; overflow: visible; margin: 0; padding: 0; }
  .m-item { aspect-ratio: 1 !important; box-shadow: none; grid-row: auto !important; }
  .m-item.beyond { display: block !important; }
  .m-more, .strip-foot, .life-tabs { display: none !important; }
  .life-intro { grid-template-columns: 1fr !important; }
  .life-text { position: static; }
}
