/* ==========================================================================
   Life at Our Company: interactive photo album
   Styles for the section, the book, the page layouts and the controls.

   Theming: override the --lb-* custom properties on .lifebook, or map them to
   your site's tokens (e.g. --lb-sage: var(--brand-primary)). Fonts follow the
   optional --site-font-heading / --site-font-body variables if your site
   defines them.
   ========================================================================== */

.lifebook {
  --lb-bg: #efe8da;
  --lb-ink: #2c312e;
  --lb-muted: #5b625c;
  --lb-paper: #f8f3e9;
  --lb-paper-2: #ece3d0;
  --lb-sage: #5c7664;
  --lb-sage-deep: #46604f;
  --lb-ivory: #f5f0e4;
  --lb-serif: var(--site-font-heading, "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif);
  --lb-sans: var(--site-font-body, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);

  /* Paper grain and linen weave, as tiny inline SVG / gradients (no extra requests) */
  --lb-grain: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .42  0 0 0 0 .34  0 0 0 0 .22  0 0 0 .09 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  --lb-linen:
    repeating-linear-gradient(0deg, rgba(255, 255, 255, .045) 0 1px, transparent 1px 3px),
    repeating-linear-gradient(90deg, rgba(0, 0, 0, .06) 0 1px, transparent 1px 3px);
  --lb-cloth: var(--lb-linen), var(--lb-sage-deep);

  position: relative;
  isolation: isolate;
  padding: clamp(48px, 8vw, 104px) 16px clamp(40px, 6vw, 80px);
  overflow-x: clip;
  background: var(--lb-bg);
  color: var(--lb-ink);
  font-family: var(--lb-sans);
  -webkit-text-size-adjust: 100%;
}

.lifebook *,
.lifebook *::before,
.lifebook *::after {
  box-sizing: border-box;
}

/* --------------------------------------------------------------------------
   Section header
   -------------------------------------------------------------------------- */
.lifebook__header {
  max-width: 44rem;
  margin: 0 auto clamp(24px, 4vw, 48px);
  text-align: center;
}

.lifebook__eyebrow {
  margin: 0 0 .9rem;
  font: 600 .75rem/1 var(--lb-sans);
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--lb-sage-deep);
}

.lifebook__title {
  margin: 0 0 .75rem;
  font: 400 clamp(2rem, 4.6vw, 3.25rem)/1.1 var(--lb-serif);
  letter-spacing: -.01em;
}

.lifebook__lede {
  margin: 0;
  font-size: clamp(1rem, 1.6vw, 1.125rem);
  line-height: 1.6;
  color: var(--lb-muted);
}

/* --------------------------------------------------------------------------
   Stage: the box the book is fitted into
   -------------------------------------------------------------------------- */
.lifebook__viewport {
  container-type: inline-size;
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  border-radius: 6px;
}

.lifebook__viewport:focus-visible {
  outline: 3px solid var(--lb-ink);
  outline-offset: 8px;
}

/* The stage is the book plus room for the hardcover rim and its shadow
   (the shift layer below is inset by 24px / 14px to make that room). */
.lifebook__stage {
  position: relative;
  width: 100%;
  height: clamp(388px, calc(60vw + 48px), 768px); /* fallback for browsers without container units */
  height: clamp(388px, calc(66cqw + 48px), 768px);
}

/* Single-page (mobile) layout: taller stage, one page at a time */
@container (width < 600px) {
  .lifebook__stage {
    height: clamp(430px, calc(136cqw + 10px), 84svh);
  }
}

.lifebook__shift {
  position: absolute;
  inset: 24px 14px;
  transform: translate3d(var(--shift-x, 0px), 0, 0);
  transition: transform .6s cubic-bezier(.4, 0, .2, 1);
}

/* --------------------------------------------------------------------------
   Hardcover board, page-edge stacks
   (positioned from JavaScript so they follow the book as it resizes)
   -------------------------------------------------------------------------- */
.lifebook__board {
  position: absolute;
  left: var(--board-x, 0px);
  top: var(--board-y, 0px);
  width: var(--board-w, 0px);
  height: var(--board-h, 0px);
  border-radius: 4px;
  background: var(--lb-cloth);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .16),
    inset 0 -2px 0 rgba(0, 0, 0, .28),
    0 24px 30px -16px rgba(34, 26, 14, .5),
    0 5px 10px rgba(34, 26, 14, .22);
  transition: left .6s cubic-bezier(.4, 0, .2, 1), width .6s cubic-bezier(.4, 0, .2, 1), opacity .3s;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
}

.lifebook__stack {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none;
}

.lifebook__stack--l {
  display: none !important;
}

.lifebook__stack--r {
  display: none !important;
}

.lifebook__book {
  position: relative;
  height: 100%;
  margin-inline: auto;
}

@container (width < 600px) {
  .lifebook__stack { display: none; }
}

/* --------------------------------------------------------------------------
   StPageFlip base styles
   The library's browser bundle ships no CSS, so the rules it expects live here.
   (.stf__wrapper is deliberately left unstyled, exactly as upstream.)
   -------------------------------------------------------------------------- */
.lifebook .stf__parent {
  position: relative;
  display: block;
  box-sizing: border-box;
  transform: translateZ(0);
  touch-action: pan-y;
}

.lifebook .stf__parent canvas {
  position: absolute;
  width: 100%;
  height: 100%;
  left: 0;
  top: 0;
}

.lifebook .stf__block {
  position: absolute;
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  perspective: 2000px;
}

.lifebook .stf__item {
  display: none;
  position: absolute;
  transform-style: preserve-3d;
}

.lifebook .stf__outerShadow,
.lifebook .stf__innerShadow,
.lifebook .stf__hardShadow,
.lifebook .stf__hardInnerShadow {
  position: absolute;
  left: 0;
  top: 0;
}

/* Before the library takes over: show only the cover, so nothing else loads or shifts */
.lifebook__book > .page:not(.stf__item) {
  position: relative;
  width: min(100%, calc(var(--lb-stage-h, 560px) * .7333));
  height: 100%;
  margin-inline: auto;
}

.lifebook__book > .page:not(.stf__item):not(.page--cover) {
  display: none;
}

/* --------------------------------------------------------------------------
   Pages: paper, spine shading
   -------------------------------------------------------------------------- */
.lifebook .page {
  overflow: hidden;
  background-color: var(--lb-paper);
  background-image: var(--lb-grain);
  color: var(--lb-ink);
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

/* Soft shading that darkens the paper towards the spine */
.lifebook .page.--left::after,
.lifebook .page.--right::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 16%;
  z-index: 3;
  pointer-events: none;
}

.lifebook .page.--right::after {
  left: 0;
  background: linear-gradient(to right, rgba(70, 52, 28, .32), rgba(70, 52, 28, .1) 30%, rgba(70, 52, 28, 0));
}

.lifebook .page.--left::after {
  right: 0;
  background: linear-gradient(to left, rgba(70, 52, 28, .32), rgba(70, 52, 28, .1) 30%, rgba(70, 52, 28, 0));
}

.page__inner {
  position: absolute;
  inset: 0;
  container-type: size; /* lets text and spacing scale with the page, not the viewport */
}

.page__body {
  position: absolute;
  inset: 7cqh 9cqw;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* Extra margin on the spine side so nothing sits in the gutter */
.lifebook .page.--right .page__body { left: 12cqw; right: 8cqw; }
.lifebook .page.--left .page__body { left: 8cqw; right: 12cqw; }

.page__eyebrow {
  margin: 0 0 3cqh;
  font: 600 clamp(9px, 2.4cqw, 12px)/1 var(--lb-sans);
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--lb-sage-deep);
}

.page__heading {
  margin: 0;
  font: 400 clamp(1.4rem, 9cqw, 2.5rem)/1.12 var(--lb-serif);
  letter-spacing: -.01em;
}

.page__text {
  margin: 3cqh 0 0;
  font: 400 clamp(.8rem, 3.6cqw, 1.05rem)/1.6 var(--lb-serif);
  color: var(--lb-muted);
}

.page__rule {
  width: 14cqw;
  height: 2px;
  margin: 4cqh 0;
  border: 0;
  background: var(--lb-sage);
  opacity: .7;
}

.page__hint {
  margin: auto 0 0;
  font: italic 400 clamp(.75rem, 3.2cqw, .95rem)/1.4 var(--lb-serif);
  color: var(--lb-muted);
}

/* --------------------------------------------------------------------------
   Photographs and captions
   -------------------------------------------------------------------------- */
.print {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
  margin: 0;
}

.print__frame {
  position: relative;
  flex: 1 1 0;
  min-height: 0;
  overflow: hidden;
  background: var(--lb-paper-2);
}

.print__frame img {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.print__caption {
  margin: 0;
  padding-top: 1.6cqh;
  font: italic 400 clamp(.72rem, 3.1cqw, .95rem)/1.35 var(--lb-serif);
  color: var(--lb-muted);
  text-align: center;
}

/* Missing image: neutral tile instead of a broken-image icon */
.print.is-missing img { display: none; }
.print.is-missing .print__frame {
  background: repeating-linear-gradient(45deg, #ece3d0 0 10px, #e5dac5 10px 20px);
}
.print.is-missing .print__frame::after {
  content: "Photo unavailable";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font: 600 clamp(10px, 2.6cqw, 13px)/1 var(--lb-sans);
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--lb-muted);
}

/* Full-page photograph, edge to edge, caption over a soft scrim */
.page--full .page__body { inset: 0 !important; }
.page--full .print { position: absolute; inset: 0; }
.page--full .print__frame { position: absolute; inset: 0; }
.page--full .print__caption {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  padding: 14cqh 10cqw 5cqh;
  background: linear-gradient(to top, rgba(24, 26, 24, .62), rgba(24, 26, 24, 0));
  font: 400 clamp(.85rem, 4cqw, 1.15rem)/1.35 var(--lb-serif);
  font-style: italic;
  color: #fbf8f0;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .35);
}
.page--full.page--cap-left .print__caption { padding-left: 10cqw; padding-right: 14cqw; }
.page--full.page--cap-right .print__caption { padding-left: 14cqw; padding-right: 10cqw; }

/* Mounted prints: a white border and a soft drop shadow, like a photo corner-mounted on the page */
.page--matted .print__frame,
.page--grid .print__frame {
  box-shadow: 0 0 0 1.4cqw #fffdf7, 0 1px 3px 1.4cqw rgba(60, 44, 20, .28);
}
.page--matted .print { margin: 0; }
.page--matted .page__body { justify-content: center; padding: 3cqh 2cqw 0; }
.page--matted .print { flex: 0 1 auto; }
.page--matted .print__frame { flex: 0 0 auto; }
.page--matted.page--portrait .print__frame { aspect-ratio: 760 / 980; }
.page--matted.page--landscape .print__frame { aspect-ratio: 3 / 2; }
.page--matted .print__caption { padding-top: 4cqh; }

/* Two-up and collage layouts */
.page--grid .page__body { display: grid; gap: 5cqh 4cqw; padding: 1.4cqw; }
.page--two-up .page__body { grid-template-rows: 1fr 1fr; }
.page--collage .page__body {
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1.3fr 1fr;
}
.page--collage .print:first-child { grid-column: 1 / -1; }
.page--grid .print__caption { padding-top: 3.2cqh; }

.page__note {
  margin: 6cqh 2cqw 0;
  font: italic 400 clamp(.8rem, 3.8cqw, 1.1rem)/1.55 var(--lb-serif);
  color: var(--lb-muted);
  text-align: center;
}

/* --------------------------------------------------------------------------
   Front and back cover (hard boards)
   -------------------------------------------------------------------------- */
.lifebook .page--cover {
  background-color: var(--lb-sage-deep);
  background-image: var(--lb-linen), var(--lb-grain);
  color: var(--lb-ivory);
}

.lifebook .page--cover.--right { border-radius: 2px 6px 6px 2px; }
.lifebook .page--cover.--left { border-radius: 6px 2px 2px 6px; }

/* The cloth hinge groove next to the spine */
.lifebook .page--cover.--right::before,
.lifebook .page--cover.--left::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 3.5cqw;
  pointer-events: none;
}
.lifebook .page--cover.--right::before {
  left: 5.5%;
  background: linear-gradient(to right, rgba(0, 0, 0, .3), rgba(0, 0, 0, 0) 45%, rgba(255, 255, 255, .09) 62%, rgba(0, 0, 0, .1));
}
.lifebook .page--cover.--left::before {
  right: 5.5%;
  background: linear-gradient(to left, rgba(0, 0, 0, .3), rgba(0, 0, 0, 0) 45%, rgba(255, 255, 255, .09) 62%, rgba(0, 0, 0, .1));
}

.lifebook .page--cover::after { display: none; }

.cover__frame {
  position: absolute;
  inset: 5cqh 6cqw 5cqh 13cqw;
  border: 1px solid rgba(245, 240, 228, .38);
  outline: 1px solid rgba(245, 240, 228, .16);
  outline-offset: 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 7cqh 6cqw 6cqh;
  text-align: center;
}

.lifebook .page--cover.--left .cover__frame { inset: 5cqh 13cqw 5cqh 6cqw; }

.cover__logo {
  display: block;
  width: 34cqw;
  height: auto;
  opacity: .92;
}

.cover__eyebrow {
  margin: 0 0 2.5cqh;
  font: 600 clamp(9px, 2.4cqw, 12px)/1 var(--lb-sans);
  letter-spacing: .24em;
  text-transform: uppercase;
  color: rgba(245, 240, 228, .78);
}

.cover__title {
  margin: 0;
  font: 400 clamp(1.6rem, 11cqw, 3.1rem)/1.08 var(--lb-serif);
  letter-spacing: -.005em;
  color: var(--lb-ivory);
  /* letterpress: a faint highlight below, a faint shadow above */
  text-shadow: 0 1px 0 rgba(255, 255, 255, .18), 0 -1px 0 rgba(0, 0, 0, .4);
}

.cover__rule {
  width: 12cqw;
  height: 1px;
  margin: 4cqh auto 0;
  border: 0;
  background: rgba(245, 240, 228, .55);
}

.cover__hint {
  margin: 0;
  font: italic 400 clamp(.72rem, 3cqw, .9rem)/1.3 var(--lb-serif);
  color: rgba(245, 240, 228, .7);
}

.cover__thanks {
  margin: auto;
  font: italic 400 clamp(1rem, 5.5cqw, 1.5rem)/1.3 var(--lb-serif);
  color: rgba(245, 240, 228, .8);
  text-shadow: 0 1px 0 rgba(255, 255, 255, .15), 0 -1px 0 rgba(0, 0, 0, .35);
}

/* --------------------------------------------------------------------------
   Closing page and call to action
   -------------------------------------------------------------------------- */
.page--closing .page__body { justify-content: center; align-items: flex-start; }

.lifebook__cta {
  display: inline-block;
  margin-top: 6cqh;
  padding: .85em 1.6em;
  border-radius: 3px;
  background: var(--lb-sage-deep);
  color: var(--lb-ivory);
  font: 600 clamp(.82rem, 3.4cqw, 1rem)/1.2 var(--lb-sans);
  letter-spacing: .04em;
  text-decoration: none;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .15) inset, 0 2px 5px rgba(34, 26, 14, .3);
  transition: background-color .2s;
  user-select: auto;
  -webkit-user-select: auto;
}

.lifebook__cta:hover { background: #3a5042; }

.lifebook__cta:focus-visible,
.lifebook__btn:focus-visible {
  outline: 3px solid var(--lb-ink);
  outline-offset: 3px;
}

.lifebook__cta:focus-visible { box-shadow: 0 0 0 3px var(--lb-paper), 0 0 0 6px var(--lb-ink); outline: 0; }

/* --------------------------------------------------------------------------
   Controls
   -------------------------------------------------------------------------- */
.lifebook__controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: clamp(20px, 3vw, 32px);
}

.lifebook__btn {
  display: inline-grid;
  place-items: center;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 1px solid rgba(44, 49, 46, .28);
  border-radius: 50%;
  background: var(--lb-paper);
  color: var(--lb-ink);
  cursor: pointer;
  transition: background-color .2s, opacity .2s, transform .2s;
}

.lifebook__btn:hover { background: #fff; }
.lifebook__btn:active { transform: scale(.96); }
.lifebook__btn[aria-disabled="true"] { opacity: .35; cursor: default; }
.lifebook__btn[aria-disabled="true"]:hover { background: var(--lb-paper); }
.lifebook__btn svg { display: block; width: 20px; height: 20px; }

.lifebook__counter {
  min-width: 9.5rem;
  margin: 0;
  text-align: center;
  font: 500 .9rem/1.2 var(--lb-sans);
  letter-spacing: .02em;
  font-variant-numeric: tabular-nums;
  color: var(--lb-muted);
}

/* --------------------------------------------------------------------------
   Reduced motion
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .lifebook__shift,
  .lifebook__board,
  .lifebook__stack,
  .lifebook__btn {
    transition: none;
  }
}
