@layer reset, base, layout, components, motion;

@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  html { scroll-behavior: smooth; }
  body, h1, h2, p, figure, blockquote { margin: 0; }
  img { display: block; max-width: 100%; }
  button, a { font: inherit; }
}

@layer base {
  :root {
    --ink: #f4ead8;
    --muted: #c8bca8;
    --sand: #d4b680;
    --turquoise: #4da6a0;
    --night: #17130f;
    --glass: rgba(21, 17, 13, .72);
    --line: rgba(244, 234, 216, .24);
    --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
    --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  }
  body { min-width: 320px; color: var(--ink); background: var(--night); font-family: var(--sans); -webkit-font-smoothing: antialiased; }
  a { color: inherit; text-decoration: none; }
  ::selection { color: #17130f; background: var(--sand); }
}

@layer layout {
  .scene-stack { position: fixed; inset: 0; z-index: -2; overflow: hidden; background: #15110e; }
  .scene { position: absolute; inset: -4%; opacity: 0; transition: opacity .7s ease; will-change: opacity, transform; }
  .scene.is-active { opacity: 1; }
  .scene img { width: 100%; height: 100%; object-fit: cover; filter: saturate(.83) contrast(1.03); transform: scale(1.04); will-change: transform; }
  .scene-shade { position: absolute; inset: 0; background: linear-gradient(90deg, rgba(10,8,6,.76) 0%, rgba(10,8,6,.22) 48%, rgba(10,8,6,.48) 100%), linear-gradient(0deg, rgba(9,7,5,.7), transparent 45%, rgba(9,7,5,.25)); }
  .grain { position: absolute; inset: 0; opacity: .07; pointer-events: none; background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.75'/%3E%3C/svg%3E"); mix-blend-mode: soft-light; }
  .chapter { min-height: 135vh; padding: 18vh 8vw 20vh; display: flex; align-items: center; position: relative; }
  .hero { min-height: 110vh; align-items: flex-end; }
  .hero-inner { width: min(1180px, 100%); padding-bottom: 12vh; }
  .profile-hero { min-height: 100svh; padding: 84px 8vw 0; align-items: stretch; overflow: hidden; color: #211b15; background: #e7dac4; z-index: 3; }
  .profile-hero-grid { width: min(1180px, 100%); min-height: calc(100svh - 84px); margin: 0 auto; display: grid; grid-template-columns: minmax(320px, .88fr) minmax(520px, 1.12fr); gap: clamp(42px, 7vw, 110px); align-items: center; }
  .profile-portrait { align-self: end; height: calc(100svh - 84px); display: flex; flex-direction: column; justify-content: flex-end; }
  .profile-portrait img { width: 100%; max-height: calc(100svh - 115px); object-fit: contain; object-position: center bottom; }
  .profile-portrait figcaption { padding: 8px 0 18px; color: #746653; font-size: 9px; letter-spacing: .14em; text-transform: uppercase; }
  .profile-hero-copy { padding: 40px 0 60px; }
  .epilogue { position: relative; z-index: 2; background: #e7dac4; color: #201b16; padding: clamp(72px, 10vw, 150px) 8vw; }
  .epilogue-grid { width: min(1180px, 100%); margin: auto; display: grid; grid-template-columns: minmax(280px, .85fr) 1.15fr; gap: clamp(45px, 8vw, 120px); align-items: center; }
  .epilogue-solo { width: min(900px, 100%); grid-template-columns: 1fr; }
  footer { position: relative; z-index: 2; min-height: 100px; padding: 34px 8vw; display: flex; align-items: center; justify-content: space-between; gap: 20px; color: #a89a86; background: #17130f; border-top: 1px solid rgba(255,255,255,.06); font-size: 12px; letter-spacing: .11em; text-transform: uppercase; }
}

@layer components {
  .progress { position: fixed; inset: 0 0 auto; height: 2px; z-index: 30; background: rgba(255,255,255,.08); }
  .progress span { display: block; width: 0; height: 100%; background: linear-gradient(90deg, var(--sand), var(--turquoise)); }
  .topbar { position: fixed; inset: 0 0 auto; z-index: 20; padding: 24px clamp(22px, 4vw, 64px); display: flex; justify-content: space-between; align-items: center; background: linear-gradient(rgba(12,9,7,.55), transparent); }
  .brand { display: flex; align-items: center; gap: 12px; font-size: 12px; font-weight: 650; letter-spacing: .12em; text-transform: uppercase; }
  .brand-mark { width: 36px; height: 36px; display: grid; place-items: center; border: 1px solid rgba(255,255,255,.35); border-radius: 50%; color: var(--sand); font-family: var(--serif); letter-spacing: 0; }
  .chapters-nav { display: flex; align-items: center; gap: clamp(16px, 2.2vw, 32px); font-size: 12px; color: #e2d8c8; }
  .chapters-nav a { position: relative; padding: 8px 0; }
  .chapters-nav a::after { content: ""; position: absolute; left: 0; right: 100%; bottom: 2px; height: 1px; background: var(--sand); transition: right .3s ease; }
  .chapters-nav a:hover::after, .chapters-nav a:focus-visible::after { right: 0; }
  .chapters-toggle { display: none; border: 0; color: inherit; background: transparent; }
  .rail { position: fixed; z-index: 15; right: clamp(20px, 3vw, 48px); top: 50%; transform: translateY(-50%); display: flex; flex-direction: column; gap: 17px; }
  .rail-line { position: absolute; top: 5px; bottom: 5px; left: 4px; width: 1px; background: rgba(255,255,255,.2); }
  .rail a { position: relative; width: 9px; height: 9px; border-radius: 50%; border: 1px solid rgba(255,255,255,.55); background: rgba(18,14,11,.7); transition: .3s ease; }
  .rail a::before { content: attr(data-label); position: absolute; right: 18px; top: 50%; transform: translate(8px,-50%); white-space: nowrap; opacity: 0; color: #e9ddca; font-size: 10px; letter-spacing: .09em; transition: .25s ease; }
  .rail a:hover::before, .rail a.is-active::before { opacity: 1; transform: translate(0,-50%); }
  .rail a.is-active { background: var(--sand); border-color: var(--sand); box-shadow: 0 0 0 5px rgba(212,182,128,.16); }
  .kicker, .chapter-no { color: var(--sand); font-size: 11px; font-weight: 700; letter-spacing: .22em; text-transform: uppercase; }
  .hero h1 { margin-top: 18px; font-family: var(--serif); font-size: clamp(68px, 10vw, 156px); font-weight: 400; line-height: .76; letter-spacing: -.055em; text-shadow: 0 8px 36px rgba(0,0,0,.45); }
  .hero h1 span { color: #f9efdd; }
  .hero-bottom { margin-top: clamp(34px, 6vh, 70px); display: grid; grid-template-columns: .8fr 1.2fr; gap: 30px; align-items: end; max-width: 900px; }
  .book-title { color: var(--sand); font-family: var(--serif); font-size: clamp(24px, 3.2vw, 44px); font-style: italic; }
  .hero-lead { max-width: 490px; color: #eee3d2; font-size: clamp(17px, 2vw, 23px); line-height: 1.55; }
  .profile-hero .kicker { color: #8c5e2b; }
  .profile-hero h1 { margin-top: 16px; color: #201b16; font-size: clamp(66px, 7.5vw, 118px); line-height: .78; text-shadow: none; }
  .profile-hero h1 span { color: #201b16; }
  .profile-role { max-width: 610px; margin-top: 28px; color: #6d604f; font-size: 11px; font-weight: 700; line-height: 1.6; letter-spacing: .11em; text-transform: uppercase; }
  .profile-hero .hero-bottom { margin-top: clamp(25px, 4vh, 42px); grid-template-columns: .75fr 1.25fr; max-width: 690px; padding-top: 24px; border-top: 1px solid rgba(52,40,27,.2); }
  .profile-hero .book-title { color: #8c5e2b; }
  .profile-hero .hero-lead { color: #4e4234; font-size: clamp(16px, 1.55vw, 20px); }
  .begin-story { display: inline-flex; align-items: center; gap: 22px; margin-top: 34px; padding-bottom: 8px; border-bottom: 1px solid #7f6849; color: #4b3a28; font-size: 11px; font-weight: 750; letter-spacing: .13em; text-transform: uppercase; }
  .begin-story span { font-size: 18px; transition: transform .25s ease; }
  .begin-story:hover span { transform: translateY(4px); }
  .profile-mode .topbar { color: #30271e; background: linear-gradient(#e7dac4 55%, rgba(231,218,196,0)); }
  .profile-mode .brand-mark { color: #8c5e2b; border-color: rgba(48,39,30,.35); }
  .profile-mode .chapters-nav { color: #4d4135; }
  .profile-mode .rail-line { background: rgba(48,39,30,.2); }
  .profile-mode .rail a { border-color: rgba(48,39,30,.55); background: #e7dac4; }
  .profile-mode .rail a::before { color: #4d4135; }
  .profile-mode .rail a.is-active { background: #9b6d34; border-color: #9b6d34; }
  .scroll-cue { position: absolute; left: 50%; bottom: 6vh; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 12px; color: #d8cbb8; font-size: 10px; letter-spacing: .17em; text-transform: uppercase; }
  .scroll-cue i { width: 1px; height: 46px; background: linear-gradient(var(--sand), transparent); animation: cue 2s ease-in-out infinite; }
  .story-card { width: min(650px, calc(100vw - 48px)); padding: clamp(30px, 5vw, 60px); border: 1px solid rgba(255,255,255,.17); border-radius: 2px; background: linear-gradient(145deg, rgba(27,21,16,.86), rgba(18,15,12,.68)); box-shadow: 0 30px 100px rgba(0,0,0,.36); backdrop-filter: blur(13px) saturate(.8); }
  .align-left { margin-right: auto; }
  .align-right { margin-left: auto; }
  .story-card h2 { margin: 13px 0 22px; font-family: var(--serif); font-size: clamp(46px, 6vw, 78px); font-weight: 400; line-height: .94; letter-spacing: -.04em; }
  .story-card p { color: #d5c9b7; font-size: 15px; line-height: 1.75; }
  .story-card .lead { margin-bottom: 19px; color: #fff7e9; font-family: var(--serif); font-size: clamp(20px, 2.5vw, 27px); line-height: 1.42; }
  blockquote { margin: 28px 0 0; padding: 3px 0 3px 22px; border-left: 2px solid var(--sand); color: #f0dfc5; font-family: var(--serif); font-size: 20px; font-style: italic; line-height: 1.45; }
  .facts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 28px; }
  .facts span { padding: 8px 11px; border: 1px solid rgba(212,182,128,.35); border-radius: 999px; color: #e7d6bb; font-size: 10px; letter-spacing: .08em; text-transform: uppercase; }
  .milestones { margin-top: 30px; border-top: 1px solid var(--line); }
  .milestones div { display: grid; grid-template-columns: 64px 1fr; gap: 18px; padding: 15px 0; border-bottom: 1px solid var(--line); }
  .milestones strong { color: var(--sand); font-family: var(--serif); font-size: 20px; font-weight: 400; }
  .milestones span { color: #d5c9b7; font-size: 13px; line-height: 1.5; }
  .intimate { background: linear-gradient(145deg, rgba(50,28,19,.84), rgba(24,17,13,.72)); }
  .awards { display: grid; grid-template-columns: repeat(3, 1fr); margin-top: 34px; border-top: 1px solid var(--line); }
  .awards div { padding: 20px 14px 0 0; }
  .awards strong { display: block; color: var(--sand); font-family: var(--serif); font-size: 30px; font-weight: 400; }
  .awards span { display: block; margin-top: 7px; color: #cfc2af; font-size: 11px; line-height: 1.45; }
  .portrait-wrap { position: relative; }
  .portrait-wrap::before { content: ""; position: absolute; inset: -18px 18px 18px -18px; border: 1px solid rgba(80,62,42,.32); }
  .portrait-wrap img { position: relative; width: 100%; aspect-ratio: 4/5; object-fit: cover; object-position: 52% center; filter: sepia(.12) saturate(.8) contrast(1.02); }
  .portrait-wrap figcaption { margin-top: 12px; color: #746653; font-size: 10px; letter-spacing: .08em; text-transform: uppercase; }
  .epilogue-copy .kicker { color: #8c5e2b; }
  .epilogue-copy h2 { margin: 15px 0 34px; font-family: var(--serif); font-size: clamp(48px, 7vw, 90px); font-weight: 400; line-height: .92; letter-spacing: -.05em; }
  .epilogue-copy ul { margin: 0; padding: 0; list-style: none; border-top: 1px solid rgba(52,40,27,.2); }
  .epilogue-copy li { position: relative; padding: 17px 0 17px 26px; border-bottom: 1px solid rgba(52,40,27,.2); font-family: var(--serif); font-size: 18px; line-height: 1.4; }
  .epilogue-copy li::before { content: "✦"; position: absolute; left: 0; top: 20px; color: #9b6d34; font-size: 10px; }
  .source { margin-top: 28px; color: #6d604f; font-size: 12px; line-height: 1.65; }
  .to-top { display: inline-flex; align-items: center; gap: 22px; margin-top: 34px; padding-bottom: 7px; border-bottom: 1px solid #7f6849; color: #4b3a28; font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
  .to-top span { font-size: 17px; transition: transform .25s ease; }
  .to-top:hover span { transform: translateY(-4px); }
}

@layer motion {
  .story-card { opacity: .25; transform: translateY(70px) scale(.98); transition: opacity .75s ease, transform .75s cubic-bezier(.2,.7,.2,1); }
  .chapter.is-current .story-card { opacity: 1; transform: translateY(0) scale(1); }
  .reveal { opacity: 0; transform: translateY(24px); animation: reveal .9s cubic-bezier(.2,.7,.2,1) forwards; }
  .hero h1.reveal { animation-delay: .15s; }
  .hero-bottom.reveal { animation-delay: .3s; }
  @keyframes reveal { to { opacity: 1; transform: none; } }
  @keyframes cue { 0%,100% { opacity:.25; transform:scaleY(.55); transform-origin:top; } 50% { opacity:1; transform:scaleY(1); } }
}

@media (max-width: 820px) {
  .topbar { padding: 18px 20px; }
  .brand > span:last-child { display: none; }
  .chapters-toggle { display: block; padding: 10px; font-size: 12px; }
  .chapters-nav { position: absolute; right: 18px; top: 62px; display: none; min-width: 180px; padding: 14px; flex-direction: column; align-items: stretch; gap: 2px; border: 1px solid rgba(255,255,255,.15); background: rgba(20,16,12,.95); backdrop-filter: blur(12px); }
  .chapters-nav.is-open { display: flex; }
  .chapters-nav a { padding: 10px 12px; }
  .rail { right: 12px; gap: 14px; }
  .rail a::before { display: none; }
  .chapter { min-height: 125vh; padding: 16vh 34px 16vh 20px; align-items: flex-end; }
  .hero { min-height: 100svh; padding-top: 90px; padding-bottom: 68px; align-items: flex-end; }
  .hero-inner { padding-bottom: 0; }
  .hero h1 { font-size: clamp(60px, 19vw, 105px); line-height: .81; }
  .hero-bottom { display: block; }
  .hero-lead { margin-top: 18px; }
  .profile-hero { min-height: 100svh; padding: 64px 20px 18px; align-items: stretch; }
  .profile-hero-grid { min-height: calc(100svh - 82px); grid-template-columns: 1fr; grid-template-rows: minmax(300px, 43svh) auto; gap: 0; align-items: start; }
  .profile-portrait { width: 100%; height: 43svh; align-self: start; align-items: center; overflow: hidden; }
  .profile-portrait img { width: auto; height: 100%; max-height: none; object-fit: contain; object-position: center bottom; }
  .profile-portrait figcaption { display: none; }
  .profile-hero-copy { position: relative; z-index: 2; padding: 10px 0 0; }
  .profile-hero h1 { margin-top: 8px; font-size: clamp(52px, 15.3vw, 70px); line-height: .79; }
  .profile-role { margin-top: 16px; font-size: 9px; line-height: 1.5; }
  .profile-hero .hero-bottom { display: grid; grid-template-columns: .8fr 1.2fr; gap: 14px; margin-top: 16px; padding-top: 14px; }
  .profile-hero .book-title { font-size: 24px; }
  .profile-hero .hero-lead { margin-top: 0; font-size: 13px; line-height: 1.45; }
  .begin-story { margin-top: 18px; font-size: 9px; }
  .profile-mode .chapters-nav.is-open { color: #e2d8c8; }
  .scroll-cue { display: none; }
  .story-card { padding: 28px 24px; width: 100%; backdrop-filter: blur(10px); }
  .story-card h2 { font-size: 48px; }
  .scene-shade { background: linear-gradient(0deg, rgba(8,6,5,.9) 0%, rgba(8,6,5,.15) 67%, rgba(8,6,5,.4) 100%); }
  .scene { inset: -2%; }
  .scene img { object-position: center; }
  .epilogue { padding: 90px 24px; }
  .epilogue-grid { grid-template-columns: 1fr; }
  .portrait-wrap { max-width: 480px; }
  .awards { grid-template-columns: 1fr; }
  .awards div { padding: 15px 0; border-bottom: 1px solid var(--line); }
  footer { padding: 30px 24px; flex-direction: column; align-items: flex-start; }
}

@media (max-width: 430px) {
  .hero h1 { font-size: 17vw; }
  .book-title { font-size: 27px; }
  .hero-lead { font-size: 17px; }
  .scroll-cue { left: 20px; transform: none; align-items: flex-start; }
  .story-card p { font-size: 14px; }
  .story-card .lead { font-size: 21px; }
  blockquote { font-size: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .scene img { transform: none !important; }
  .story-card { opacity: 1; transform: none; }
}
