/* The landing page's hero film (app/views/pages/_hero_film.html.erb), a live animation.
   How it works, how to edit it: app/views/pages/HERO_FILM.md.

   The film is drawn on a 1440 × 960 stage in plain pixels and scaled to its box
   (--k = box width / 1440). Every moment is a CSS animation whose delay is its time in the
   33-second film, so the timeline reads in seconds right here; hero_animation_controller.js
   pauses, seeks and loops them all together. Entrances fill "both", exits only "forwards". */

@property --mx { syntax: "<length>"; inherits: true; initial-value: 0px; }
@property --my { syntax: "<length>"; inherits: true; initial-value: 0px; }

.anim-box { container-type: inline-size; overflow: hidden; }

.hf-film {
  --ink: #16213A;
  --text: #2A2F3A;
  --muted: #6A6458;
  --brown: #7A4B2C;
  --brown-soft: #8B5A36;
  --card: #FFFDF8;
  --line: #E6DAC6;
  --hand: "Cedarville Cursive", cursive;
  --script: "Pinyon Script", cursive;
  --clerk: "Petit Formal Script", cursive;
  --print: "IM Fell Double Pica", "Newsreader", Georgia, serif;
  --k: tan(atan2(100cqw, 1440px));

  position: absolute;
  left: 0;
  top: 0;
  width: 1440px;
  height: 960px;
  transform: scale(var(--k));
  transform-origin: 0 0;
  font-family: "Newsreader", Georgia, serif;
  color: var(--text);
  animation: hf-clock 33s linear both;
}

.hf-film * { box-sizing: border-box; }
.hf-film img { display: block; max-width: none; }
.hf-abs { position: absolute; }

/* ---------- Motion vocabulary ---------- */
@keyframes hf-clock { from { --hf-clock: 0; } to { --hf-clock: 1; } }
@keyframes hf-fade-in { from { opacity: 0; } }
@keyframes hf-fade-out { to { opacity: 0; } }
@keyframes hf-rise { from { opacity: 0; translate: 0 18px; } }
@keyframes hf-drop { from { opacity: 0; translate: 0 -26px; rotate: 6deg; } }
@keyframes hf-slide-in { from { opacity: 0; translate: 40px 0; } }
@keyframes hf-leave { to { opacity: 0; translate: -40px 0; } }
@keyframes hf-pop { from { opacity: 0; scale: 0.6; } 70% { scale: 1.06; } }
@keyframes hf-write { from { clip-path: inset(-30% 100% -30% 0); } to { clip-path: inset(-30% -2% -30% 0); } }
@keyframes hf-draw { from { stroke-dashoffset: 1; } }
@keyframes hf-mark { from { background-color: transparent; border-color: transparent; } }
@keyframes hf-spin { to { rotate: 720deg; } }
@keyframes hf-flip-out { to { rotate: y 90deg; } }
@keyframes hf-flip-in { from { rotate: y -90deg; } }
@keyframes hf-glow { from { border-color: var(--brown-soft); box-shadow: 0 0 0 1px var(--brown-soft), 0 10px 26px rgba(70, 45, 20, 0.16); } }
@keyframes hf-zoom { from { scale: 1; } to { scale: 1.12; } }
@keyframes hf-fill { from { width: 0; } }
@keyframes hf-shrink { to { scale: 0.62; translate: 8px 178px; } }

/* ---------- Chapter 1: the order form (0 – 6 s) ---------- */
.hf-form {
  left: 296px; top: 96px; width: 842px; height: 742px;
  rotate: -0.7deg;
  background: var(--card);
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(60, 40, 20, 0.08), 0 18px 40px rgba(60, 40, 20, 0.14);
  padding: 46px 54px;
  animation: hf-rise 0.7s cubic-bezier(.16,1,.3,1) 0.1s both, hf-leave 0.5s ease-in 5.7s forwards;
}
.hf-form h3 { margin: 0; font-weight: 500; font-size: 47px; letter-spacing: -0.6px; color: var(--ink); line-height: 1.1; }
.hf-form .hf-sub { margin: 12px 0 0; font-size: 23px; color: #555A63; }
.hf-form .hf-rule { height: 2px; background: var(--brown-soft); opacity: 0.7; margin: 24px -54px 22px; }
.hf-sides { margin-top: -4px; display: grid; grid-template-columns: 272px 272px; gap: 0; }
.hf-side h4 { margin: 0 0 12px; font-weight: 400; font-style: italic; font-size: 21px; color: var(--brown); }
.hf-field { height: 86px; }
.hf-field small { display: block; font-size: 19px; line-height: 1; color: #5A5E68; }
.hf-field .hf-line { position: relative; width: 240px; height: 54px; border-bottom: 2px solid #C9D1E3; }
.hf-hand { font-family: var(--hand); color: #1F2E66; white-space: nowrap; }
.hf-field .hf-hand { position: absolute; left: -2px; bottom: 2px; font-size: 31px; }
.hf-write { animation: hf-write 0.6s linear both; }
.hf-notes { margin-top: 22px; }
.hf-note { position: relative; width: 732px; height: 70px; border-bottom: 2px solid #D7DDEA; }
.hf-note .hf-hand { position: absolute; left: 2px; bottom: 8px; font-size: 25px; }
.hf-handoff { margin-top: 40px; font-size: 28px; color: var(--ink); display: flex; align-items: center; gap: 16px; animation: hf-fade-in 0.4s ease 5.1s both; }
.hf-handoff svg { stroke: var(--brown); }

.hf-snapshot {
  left: 604px; top: 164px; width: 196px;
  background: #F8F4EA; padding: 9px 9px 30px;
  rotate: 2deg;
  box-shadow: 0 6px 16px rgba(50, 30, 15, 0.22);
  animation: hf-drop 0.55s cubic-bezier(.2,1.2,.4,1) 3.0s both;
}
.hf-snapshot .hf-photo { width: 178px; height: 188px; background-size: 215%; background-position: 100% 28%; filter: grayscale(1) contrast(1.05); }
.hf-snapshot .hf-hand { position: absolute; left: 0; right: 0; bottom: 4px; text-align: center; font-size: 15.5px; }
.hf-clip { position: absolute; left: 40px; top: -26px; width: 24px; height: 70px; }

/* ---------- Chapter 2: searching the archives (6 – 23.3 s) ---------- */
.hf-status {
  left: 548px; top: 812px; width: 880px;
  display: flex; align-items: center; justify-content: space-between;
  font-size: 26px; color: #5A5E68; white-space: nowrap;
  animation: hf-fade-in 0.5s ease 6.2s both, hf-fade-out 0.4s ease 22.9s forwards;
}
.hf-searching { display: flex; gap: 12px; align-items: baseline; }
.hf-kinds { position: relative; display: inline-block; min-width: 330px; height: 36px; }
.hf-kind { position: absolute; left: 0; bottom: -6px; white-space: nowrap; font-style: italic; color: var(--ink); }
.hf-research { display: flex; align-items: center; gap: 16px; color: var(--ink); }
.hf-clock { width: 42px; height: 42px; }
.hf-clock .hf-hand-line { transform-origin: 21px 21px; transform-box: view-box; animation: hf-spin 16.8s linear 6.2s both; }

.hf-cards { left: 40px; top: 92px; width: 462px; }
.hf-card {
  position: absolute; left: 0; width: 462px; min-height: 160px;
  background: var(--card); border: 1px solid #EFE5D4; border-radius: 12px;
  box-shadow: 0 6px 18px rgba(70, 45, 20, 0.1);
  padding: 18px 22px;
  display: flex; gap: 18px; align-items: flex-start;
}
.hf-card .hf-kicker { display: block; font-style: italic; font-size: 19.5px; color: var(--brown); }
.hf-card strong { display: block; font-weight: 400; font-size: 27px; line-height: 1.18; color: var(--ink); margin-top: 2px; }
.hf-card .hf-source { display: block; font-style: italic; font-size: 16.5px; color: #6A6E78; margin-top: 8px; }
.hf-card .hf-thumb { flex: none; width: 104px; height: 128px; border-radius: 4px; background-size: 420%; background-position: 46% 18%; filter: sepia(0.25); }

.hf-doc { position: absolute; }
.hf-page { position: absolute; inset: 0; overflow: hidden; }
.hf-magnifier { position: absolute; inset: 0; pointer-events: none; }
.hf-lens {
  position: absolute; left: calc(var(--mx) - 116px); top: calc(var(--my) - 116px);
  width: 232px; height: 232px; border-radius: 50%; overflow: hidden;
  box-shadow: 0 0 0 11px #3A2A1C, 0 0 0 13px #B8925A, 0 14px 30px rgba(30, 18, 8, 0.4), inset 0 0 22px rgba(255, 250, 235, 0.55);
}
.hf-zoom { position: absolute; left: 0; top: 0; transform-origin: 0 0; transform: translate(calc(116px - var(--mx) * 1.8), calc(116px - var(--my) * 1.8)) scale(1.8); }
.hf-lens::after { content: ""; position: absolute; inset: 0; border-radius: 50%; background: radial-gradient(circle at 34% 28%, rgba(255, 255, 255, 0.45), transparent 42%); }
.hf-handle {
  position: absolute; left: calc(var(--mx) + 78px); top: calc(var(--my) + 78px);
  width: 22px; height: 108px; border-radius: 11px; background: linear-gradient(90deg, #2A1D12, #4A3524 55%, #2A1D12);
  rotate: -45deg; transform-origin: 11px 0;
}

/* Where the magnifying glass goes, in the document's own pixels. */
@keyframes hf-lens-register-en { 0% { --mx: 150px; --my: 520px; } 35% { --mx: 300px; --my: 290px; } 70% { --mx: 600px; --my: 470px; } 100% { --mx: 520px; --my: 390px; } }
@keyframes hf-lens-register-fr { 0% { --mx: 170px; --my: 470px; } 35% { --mx: 420px; --my: 520px; } 70% { --mx: 600px; --my: 300px; } 100% { --mx: 520px; --my: 140px; } }
@keyframes hf-lens-military { 0% { --mx: 190px; --my: 540px; } 40% { --mx: 250px; --my: 420px; } 75% { --mx: 520px; --my: 470px; } 100% { --mx: 600px; --my: 380px; } }
@keyframes hf-lens-news { 0% { --mx: 150px; --my: 620px; } 40% { --mx: 330px; --my: 470px; } 75% { --mx: 420px; --my: 360px; } 100% { --mx: 300px; --my: 300px; } }
@keyframes hf-lens-portrait { 0% { --mx: 260px; --my: 300px; } 45% { --mx: 180px; --my: 420px; } 100% { --mx: 220px; --my: 560px; } }

.hf-film mark { color: inherit; }

/* Highlighted words: a box in the brown ink, filled blue for names, brown for details. */
.hf-mark { border: 2.5px solid var(--brown-soft); border-radius: 6px; padding: 0 3px; margin: 0 -3px; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
.hf-mark--name { background-color: rgba(46, 74, 120, 0.2); }
.hf-mark--detail { background-color: rgba(139, 90, 54, 0.2); }
.hf-spot { position: absolute; border: 3px solid var(--brown-soft); border-radius: 6px; background-color: rgba(139, 90, 54, 0.16); }

.hf-links { left: 0; top: 0; width: 1440px; height: 960px; overflow: visible; pointer-events: none; }
.hf-links path { fill: none; stroke: var(--brown-soft); stroke-width: 2.5; stroke-dasharray: 1; stroke-dashoffset: 0; }

/* The parish register */
.hf-register {
  left: 560px; top: 84px; width: 842px; height: 646px; rotate: 0.5deg;
  box-shadow: 0 16px 34px rgba(50, 30, 15, 0.26);
  animation: hf-slide-in 0.7s cubic-bezier(.16,1,.3,1) 6.25s both, hf-fade-out 0.4s ease 10.7s forwards;
}
.hf-parchment {
  width: 842px; height: 646px;
  background-color: #E4D3B4;
  background-image: radial-gradient(ellipse at 50% 45%, rgba(255, 248, 230, 0.55), transparent 70%), radial-gradient(ellipse at 50% 50%, transparent 60%, rgba(110, 75, 35, 0.35)), url("/assets/landing/paper-texture-e06de356.webp");
  background-blend-mode: normal, multiply, multiply;
  color: #2A1E12;
}
.hf-register .hf-parchment { padding: 24px 28px; font-family: var(--script); font-size: 27.5px; line-height: 37px; }
.hf-register .hf-margin { position: absolute; left: 28px; top: 24px; }
.hf-register p { margin: 0 0 0 128px; }
.hf-register .hf-parchment { position: relative; }
.hf-register .hf-signs { display: flex; justify-content: space-between; margin-top: 6px; padding-left: 50px; font-size: 25px; }
.hf-register .hf-signs span:last-child { font-size: 31px; }
.hf-form-table { width: 100%; border-collapse: collapse; font-family: var(--script); }
.hf-form-table th { font-family: var(--print); font-weight: 400; font-size: 17px; line-height: 1.2; padding: 6px 6px; border: 1.5px solid rgba(70, 45, 20, 0.55); color: #3A2A1A; vertical-align: bottom; }
.hf-form-table td { border: 1.5px solid rgba(70, 45, 20, 0.45); padding: 10px 8px; font-size: 28px; line-height: 36px; vertical-align: top; }
.hf-form-table td.hf-no { font-family: var(--print); font-size: 18px; text-align: center; color: #3A2A1A; }
.hf-print-head { font-family: var(--print); text-align: center; color: #2E2216; }
.hf-print-head b { display: block; font-weight: 400; font-size: 34px; letter-spacing: 3px; }
.hf-print-head > span { display: block; font-size: 19px; margin: 4px 0 14px; }
.hf-print-head .hf-fill { font-family: var(--script); font-size: 27px; padding: 0 6px; }

/* The military register */
.hf-military {
  left: 530px; top: 80px; width: 862px; height: 646px; rotate: -0.5deg;
  box-shadow: 0 16px 34px rgba(50, 30, 15, 0.24);
  animation: hf-slide-in 0.7s cubic-bezier(.16,1,.3,1) 10.95s both, hf-fade-out 0.4s ease 14.45s forwards;
}
.hf-military .hf-parchment { width: 862px; padding: 28px 24px; background-color: #E9D9B6; }
.hf-military .hf-form-table td { font-family: var(--clerk); font-size: 23px; line-height: 31px; height: 146px; }
.hf-military .hf-print-head b { font-size: 21px; letter-spacing: 4px; }
.hf-military .hf-print-head i { display: block; font-size: 32px; margin-top: 4px; }

/* The newspaper clipping */
.hf-news {
  left: 712px; top: 40px; width: 572px; height: 600px; rotate: 0.9deg;
  animation: hf-slide-in 0.7s cubic-bezier(.16,1,.3,1) 14.55s both, hf-fade-out 0.4s ease 18.05s forwards;
}
.hf-clipping { width: 572px; background: #EFE6D2; padding: 16px 18px; box-shadow: 0 16px 34px rgba(50, 30, 15, 0.26); clip-path: polygon(0 0.6%, 4% 0, 30% 0.8%, 61% 0.1%, 100% 0.7%, 99.6% 38%, 100% 71%, 99.3% 100%, 62% 99.2%, 27% 100%, 0.5% 99.4%, 0 62%); }
.hf-clipping img { width: 100%; }
.hf-clipping .hf-head { margin-bottom: 10px; mix-blend-mode: multiply; }
.hf-clipping .hf-column { position: relative; mix-blend-mode: multiply; }
.hf-credit { position: absolute; left: 712px; top: 604px; margin: 0; width: 572px; font-size: 13.5px; color: #8A8478; text-align: right; animation: hf-fade-in 0.4s ease 14.9s both, hf-fade-out 0.4s ease 18.05s forwards; }

/* The studio portrait, front then back */
.hf-cdv { left: 800px; top: 88px; width: 422px; height: 648px; rotate: 1deg; perspective: 1600px; animation: hf-slide-in 0.7s cubic-bezier(.16,1,.3,1) 18.15s both, hf-fade-out 0.45s ease 22.8s forwards; }
/* The card turns over: the front swings edge-on, then the back swings in from edge-on. */
.hf-cdv-front { position: absolute; inset: 0; animation: hf-flip-out 0.35s ease-in 20.0s forwards; }
.hf-portrait { inset: 0; }
.hf-cdv-face { position: relative; width: 422px; height: 648px; border-radius: 6px; background: #2E2219; padding: 24px 24px 0; box-shadow: 0 16px 34px rgba(30, 20, 10, 0.3); }
.hf-cdv-face .hf-print { height: 478px; background-size: cover; background-position: 50% 30%; filter: sepia(0.15); }
.hf-cdv-face .hf-studio { position: absolute; left: 0; right: 0; bottom: 34px; text-align: center; color: #CDB27A; font-family: var(--print); }
.hf-cdv-face .hf-studio b { display: block; font-family: var(--clerk); font-weight: 400; font-size: 42px; line-height: 1.2; }
.hf-cdv-face .hf-studio span { font-size: 15px; letter-spacing: 4px; }
.hf-cdv-back { position: absolute; inset: 0; border-radius: 6px; box-shadow: 0 16px 34px rgba(30, 20, 10, 0.3); background: #E8DABB url("/assets/landing/paper-texture-e06de356.webp"); background-blend-mode: multiply; border: 1px solid #CDB98F; animation: hf-flip-in 0.35s ease-out 20.35s both; }
.hf-cdv-back .hf-frame { position: absolute; inset: 16px; border: 1.5px solid rgba(80, 55, 25, 0.5); outline: 1px solid rgba(80, 55, 25, 0.35); outline-offset: -6px; }
.hf-cdv-back .hf-print-head { margin-top: 46px; }
.hf-cdv-back .hf-print-head b { font-size: 32px; letter-spacing: 5px; }
.hf-cdv-back .hf-print-head i { display: block; font-size: 22px; }
.hf-cdv-back .hf-print-head > span { font-size: 16px; margin-top: 6px; }
.hf-cdv-back .hf-print-head hr { width: 120px; border: 0; border-top: 1.5px solid rgba(80, 55, 25, 0.5); margin: 12px auto 0; }
.hf-cdv-back .hf-inscription { position: absolute; left: 0; right: 0; top: 262px; text-align: center; font-family: var(--clerk); font-size: 38px; line-height: 58px; color: #1F2440; }
.hf-cdv-back .hf-inscription span { display: block; }

/* ---------- Chapter 3: your family story (23.3 – 33 s) ---------- */
.hf-story { left: 0; top: 0; width: 1440px; height: 960px; animation: hf-fade-out 0.5s ease 32.45s forwards; }
.hf-tree-wrap { position: absolute; left: 0; top: 0; width: 1440px; height: 960px; transform-origin: 0 0; animation: hf-shrink 0.9s cubic-bezier(.65,0,.35,1) 28.0s forwards; }
.hf-tree-title { left: 40px; top: 32px; width: 270px; animation: hf-fade-in 0.5s ease 23.4s both; }
.hf-tree-title b { display: block; font-weight: 400; font-size: 37px; line-height: 1.1; color: var(--ink); }
.hf-tree-title i { display: block; font-size: 20px; color: #6A6E78; }
.hf-row { position: absolute; left: 328px; width: 680px; height: 100px; }
.hf-person { position: absolute; top: 0; display: flex; align-items: center; gap: 16px; }
.hf-person--spouse { left: 370px; }
.hf-avatar { flex: none; width: 100px; height: 100px; border-radius: 50%; border: 4px solid #FBF6EC; box-shadow: 0 4px 10px rgba(50, 30, 15, 0.22); display: grid; place-items: center; font-size: 30px; background: #EADCC6 center / cover; color: var(--ink); }
.hf-avatar--living { background: var(--ink); color: #FFFDF8; }
.hf-person b { display: block; font-weight: 400; font-size: 26px; color: var(--ink); line-height: 1.1; }
.hf-person small { display: block; font-size: 18px; color: #6A6E78; }
.hf-row svg { position: absolute; left: 0; top: 0; overflow: visible; }
.hf-row path { fill: none; stroke: #B79A72; stroke-width: 2; }
.hf-fact { position: absolute; left: 1050px; width: 340px; font-size: 22px; line-height: 1.3; color: var(--ink); padding-left: 22px; }
.hf-fact::before { content: ""; position: absolute; left: 0; top: 12px; width: 9px; height: 9px; border-radius: 50%; background: var(--brown-soft); }
.hf-fact--who { font-style: italic; font-size: 19px; color: #6A6E78; padding-left: 0; }
.hf-fact--who::before { display: none; }
.hf-fan { left: 0; top: 440px; width: 270px; animation: hf-fade-in 0.8s ease 26.9s both; }
.hf-fan i { display: block; margin: 50px 0 0 40px; font-size: 19px; color: #6A6E78; line-height: 1.15; }

.hf-film-card {
  left: 898px; top: 104px; width: 506px; padding: 16px 16px 20px;
  background: #FBF7EF; rotate: 1.6deg;
  box-shadow: 0 4px 8px rgba(50, 30, 15, 0.1), 0 22px 44px rgba(50, 30, 15, 0.22);
  animation: hf-rise 0.8s cubic-bezier(.16,1,.3,1) 28.45s both;
}
.hf-screen { position: relative; height: 300px; overflow: hidden; }
.hf-screen img { width: 100%; height: 100%; object-fit: cover; transform-origin: 60% 45%; animation: hf-zoom 4.6s linear 28.45s both; }
.hf-screen::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 45%, rgba(20, 14, 8, 0.6)); }
.hf-screen .hf-title { position: absolute; z-index: 1; left: 22px; bottom: 34px; color: #FFFDF8; text-shadow: 0 2px 8px rgba(0, 0, 0, 0.45); }
.hf-screen .hf-title b { display: block; font-weight: 400; font-style: italic; font-size: 42px; line-height: 1.05; }
.hf-screen .hf-title span { font-size: 20px; }
.hf-progress { position: absolute; z-index: 1; left: 22px; right: 22px; bottom: 16px; height: 4px; border-radius: 2px; background: rgba(255, 253, 248, 0.35); }
.hf-progress i { display: block; height: 100%; width: 100%; border-radius: 2px; background: #FFFDF8; animation: hf-fill 3.8s linear 29.0s both; }
.hf-film-card .hf-hand { display: block; margin-top: 12px; text-align: center; font-size: 34px; color: #1F2440; }

.hf-share {
  left: 940px; top: 530px; width: 420px; height: 76px; border-radius: 38px;
  display: flex; align-items: center; justify-content: center; gap: 16px;
  font-family: var(--print); font-size: 30px; color: #FFFDF8;
  background-color: #6A2E22;
  background-image: radial-gradient(120% 140% at 50% 0%, rgba(255, 200, 170, 0.35), transparent 55%), linear-gradient(180deg, #7D3A2B, #5A251B);
  box-shadow: inset 0 2px 2px rgba(255, 215, 185, 0.28), inset 0 -3px 4px rgba(30, 8, 4, 0.45), 0 8px 18px rgba(60, 25, 10, 0.3);
  text-shadow: 0 -1px 0 rgba(30, 10, 4, 0.5);
  animation: hf-pop 0.5s cubic-bezier(.2,1.2,.4,1) 29.6s both;
}
.hf-share svg { stroke: #FFFDF8; }
.hf-sent {
  left: 940px; top: 636px; width: 420px; padding: 18px 24px 16px;
  background: var(--card); border: 1px solid #EFE5D4; border-radius: 14px; box-shadow: 0 6px 18px rgba(70, 45, 20, 0.1);
  animation: hf-rise 0.6s cubic-bezier(.16,1,.3,1) 30.2s both;
}
.hf-sent b { display: flex; align-items: center; gap: 12px; font-weight: 400; font-size: 27px; color: var(--ink); }
.hf-sent b svg { stroke: var(--brown-soft); }
.hf-family { display: flex; gap: 14px; margin-top: 14px; }
.hf-family span { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 18px; color: #6A6E78; }
.hf-family i { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; font-style: normal; font-size: 25px; color: var(--ink); background: #EADCC6; }
.hf-family span:nth-child(2) i { background: #DDE2EA; }
.hf-family span:nth-child(3) i { background: #E8D7CC; }
.hf-family span:nth-child(4) i { background: #E2E3D3; }
.hf-family span:nth-child(5) i { background: #E6DDE8; }

/* A still frame, readable, for people who prefer less motion: the controller seeks there and stays. */
@media (prefers-reduced-motion: reduce) {
  .hf-film, .hf-film * { animation-play-state: paused !important; }
}
