/* Chinar legacy book — adapted from the interactive 3D book prototype. */
.legacy .legacy-grid{grid-template-columns:minmax(320px,.8fr) minmax(520px,1.2fr);gap:72px 64px;align-items:center}
.legacy-timeline{grid-column:1/-1;margin-top:10px}

.legacy-book-shell{--book-paper:#fffdf7;--book-paper-warm:#f5eddf;--book-green:#173d28;--book-green-deep:#092016;--book-gold:#c9a24b;--book-shadow:rgba(18,31,23,.25);min-width:0;position:relative;outline:none}
.legacy-book-shell:focus-visible{outline:2px solid var(--gold);outline-offset:8px;border-radius:18px}
.legacy-book-heading{display:flex;align-items:baseline;justify-content:space-between;gap:20px;margin:0 5% -18px;position:relative;z-index:4}
.legacy-book-heading span{font-size:9px;letter-spacing:.24em;text-transform:uppercase;color:var(--gold);font-weight:700}
.legacy-book-heading strong{font-family:var(--serif);font-size:18px;font-style:italic;color:var(--green-800);font-weight:600}

.legacy-book-stage{min-height:500px;position:relative;display:flex;justify-content:center;align-items:center;perspective:1800px;isolation:isolate}
.legacy-book-glow{position:absolute;border-radius:50%;pointer-events:none;opacity:.58;filter:blur(1px);z-index:-1}
.legacy-book-glow--one{width:210px;height:210px;left:2%;top:12%;background:radial-gradient(circle,rgba(201,162,75,.2),transparent 68%)}
.legacy-book-glow--two{width:250px;height:250px;right:0;bottom:0;background:radial-gradient(circle,rgba(42,93,63,.17),transparent 68%)}

.legacy-book-wrap{--tilt-x:0deg;--tilt-y:0deg;width:min(94%,720px);aspect-ratio:1.64/1;position:relative;transform-style:preserve-3d;transform:rotateX(calc(8deg + var(--tilt-y))) rotateY(var(--tilt-x)) rotateZ(-.7deg);transition:transform .55s ease;will-change:transform}
.legacy-book-wrap:hover{transform:rotateX(calc(6deg + var(--tilt-y))) rotateY(var(--tilt-x)) rotateZ(-.3deg) translateY(-3px)}
.legacy-book-wrap.is-closed{transform:translateX(-25%) rotateX(calc(8deg + var(--tilt-y))) rotateY(var(--tilt-x)) rotateZ(-1.5deg);cursor:pointer}
.legacy-book-wrap.is-closed:hover{transform:translateX(-25%) rotateX(calc(6deg + var(--tilt-y))) rotateY(var(--tilt-x)) rotateZ(-.7deg) translateY(-6px) scale(1.01)}
.legacy-book-wrap.is-closed .legacy-book-back-cover,.legacy-book-wrap.is-closed .legacy-book-paper-stack{width:100%;left:0}
.legacy-book-wrap.is-closed .legacy-book-spread--base{opacity:0;pointer-events:none}
.legacy-book-wrap.is-opening{animation:legacyBookOpen .8s ease both}
@keyframes legacyBookOpen{0%{filter:brightness(.92)}45%{filter:brightness(1.08)}100%{filter:brightness(1)}}

.legacy-book{width:50%;height:100%;position:absolute;left:50%;transform-style:preserve-3d}
.legacy-book-back-cover{position:absolute;width:202%;height:104%;left:-101%;top:-2%;border-radius:9px 15px 15px 9px;background:linear-gradient(145deg,#123522,#082017);box-shadow:0 30px 46px var(--book-shadow),0 8px 12px rgba(10,25,16,.18);transform:translateZ(-10px);transition:width .75s ease,left .75s ease}
.legacy-book-back-cover:after{content:"";position:absolute;inset:7px;border:1px solid rgba(227,198,126,.3);border-radius:5px 11px 11px 5px}
.legacy-book-paper-stack{position:absolute;width:199%;height:98%;left:-99.5%;top:1%;border-radius:6px 12px 12px 6px;background:repeating-linear-gradient(to bottom,#d7cdbd 0,#fffaf0 1px,#fffaf0 3px);transform:translateZ(-3px);transition:width .75s ease,left .75s ease}
.legacy-book-spread{position:absolute;width:200%;height:96%;left:-100%;top:2%;display:flex;transform-style:preserve-3d;transition:opacity .3s}
.legacy-book-static-page{position:relative;width:50%;height:100%;background:var(--book-paper);overflow:hidden}
.legacy-book-static-page--left{border-radius:6px 0 0 6px;box-shadow:inset -18px 0 23px -20px rgba(30,35,27,.46)}
.legacy-book-static-page--right{border-radius:0 8px 8px 0;box-shadow:inset 18px 0 23px -20px rgba(30,35,27,.42)}

.legacy-book-sheet{position:absolute;width:100%;height:96%;top:2%;left:0;transform-origin:left center;transform-style:preserve-3d;transition:transform 1s cubic-bezier(.65,.05,.36,1),z-index .2s step-end;cursor:grab;touch-action:pan-y}
.legacy-book-wrap.is-open .legacy-book-sheet:not(.is-turned):hover{filter:brightness(1.015)}
.legacy-book-sheet:active{cursor:grabbing}
.legacy-book-sheet.is-turned{transform:rotateY(-180deg)}
.legacy-book-sheet-face{position:absolute;inset:0;background:var(--book-paper);backface-visibility:hidden;-webkit-backface-visibility:hidden;overflow:hidden;border-radius:0 8px 8px 0;box-shadow:inset 18px 0 24px -22px rgba(32,38,29,.5),2px 1px 2px rgba(35,48,38,.14)}
.legacy-book-sheet-back{transform:rotateY(180deg);border-radius:8px 0 0 8px;box-shadow:inset -18px 0 24px -22px rgba(32,38,29,.5),-2px 1px 2px rgba(35,48,38,.12)}

.legacy-book-front-cover{background:linear-gradient(140deg,#1f5035,#0a2518 72%);color:#f4ead7;padding:17px;box-shadow:inset 7px 0 16px rgba(255,255,255,.055),inset -5px 0 13px rgba(0,0,0,.16),3px 3px 5px rgba(20,35,24,.22)}
.legacy-book-front-cover:before{content:"";position:absolute;inset:0;opacity:.12;background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='90' height='90'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.42'/%3E%3C/svg%3E")}
.legacy-book-wrap.is-closed .legacy-book-front-cover:after{content:"Click to open";position:absolute;left:50%;bottom:7%;transform:translateX(-50%);font:600 8px var(--sans);text-transform:uppercase;letter-spacing:.2em;color:rgba(244,234,215,.68);animation:legacyBookPulse 2s ease-in-out infinite;white-space:nowrap}
@keyframes legacyBookPulse{50%{opacity:.42;transform:translateX(-50%) translateY(-2px)}}
.legacy-book-cover-border{position:relative;height:100%;border:1px solid rgba(227,198,126,.5);display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center}
.legacy-book-cover-leaf{width:42px;height:48px;object-fit:contain;margin-bottom:7px;filter:drop-shadow(0 4px 8px rgba(0,0,0,.2))}
.legacy-book-cover-kicker{font-size:7px;letter-spacing:.26em;color:rgba(244,234,215,.78)}
.legacy-book-cover-border h3{font-family:var(--serif);font-size:clamp(24px,2.5vw,38px);line-height:.92;margin:12px 0;font-weight:600}
.legacy-book-cover-border h3 em{color:var(--gold-light);font-weight:500}
.legacy-book-cover-rule{width:44px;height:1px;background:var(--book-gold);margin-bottom:9px}
.legacy-book-cover-border p{margin:0;font-family:var(--serif);font-style:italic;font-size:12px;color:rgba(244,234,215,.8)}

.legacy-book-page{position:absolute;inset:0;padding:9%;display:flex;flex-direction:column;align-items:center;justify-content:center}
.legacy-book-photo{width:100%;flex:1;min-height:0;background:var(--book-paper-warm);overflow:hidden;position:relative;border:1px solid rgba(201,162,75,.25)}
.legacy-book-photo:after{content:"";position:absolute;inset:5px;border:1px solid rgba(255,255,255,.48);pointer-events:none}
.legacy-book-photo img{width:100%;height:100%;object-fit:cover;display:block;filter:saturate(.9) contrast(1.02)}
.legacy-book-caption{font-family:var(--serif);font-style:italic;font-size:13px;margin:11px 0 2px;color:#4e5f54;text-align:center}
.legacy-book-page-number{position:absolute;bottom:3.5%;font-size:8px;color:#918f86}
.legacy-book-sheet-front .legacy-book-page-number,.legacy-book-static-page--right .legacy-book-page-number{right:6%}
.legacy-book-sheet-back .legacy-book-page-number,.legacy-book-static-page--left .legacy-book-page-number{left:6%}
.legacy-book-title-page{text-align:center;background:radial-gradient(circle at center,#fff 0,#faf4e8 82%)}
.legacy-book-tiny-label{font-size:7px;letter-spacing:.22em;color:#8b9c90;font-weight:700}
.legacy-book-title-page h3{font-family:var(--serif);font-size:clamp(20px,2vw,30px);line-height:1.02;color:var(--green-900);margin:16px 0 12px}
.legacy-book-title-rule{width:45%;height:1px;background:linear-gradient(to right,transparent,var(--book-gold),transparent)}
.legacy-book-title-page p{max-width:190px;color:#778179;font-size:9px;line-height:1.65;margin-top:14px}
.legacy-book-ending-page{text-align:center;background:radial-gradient(circle,#fff,#f7efe1)}
.legacy-book-flourish{color:var(--book-gold);font-size:17px}
.legacy-book-ending-page h3{font-family:var(--serif);font-size:clamp(22px,2.3vw,34px);line-height:.98;color:var(--green-900);margin:13px 0}
.legacy-book-ending-page p{max-width:185px;color:#788179;font-size:9px;line-height:1.65}

.legacy-book-nav{position:absolute;z-index:20;width:44px;height:44px;border:1px solid rgba(20,55,35,.16);border-radius:50%;background:rgba(255,253,247,.86);backdrop-filter:blur(9px);-webkit-backdrop-filter:blur(9px);color:var(--green-800);box-shadow:0 9px 24px rgba(24,45,32,.12);cursor:pointer;transition:transform .25s,background .25s,color .25s,border-color .25s;font-size:19px}
.legacy-book-nav:hover:not(:disabled){background:var(--green-800);color:var(--cream);border-color:var(--green-800);transform:scale(1.06)}
.legacy-book-nav:focus-visible{outline:2px solid var(--gold);outline-offset:3px}
.legacy-book-nav:disabled{opacity:.28;cursor:not-allowed}
.legacy-book-nav--prev{left:0}.legacy-book-nav--next{right:0}
.legacy-book-controls{display:flex;align-items:center;justify-content:center;gap:13px;color:var(--muted);font-size:10px;margin-top:-22px;min-height:20px}
.legacy-book-progress{width:100px;height:3px;background:rgba(24,36,32,.12);border-radius:3px;overflow:hidden}
.legacy-book-progress span{display:block;width:0;height:100%;background:var(--gold);transition:width .5s ease}
.legacy-book-hint{color:rgba(93,107,98,.7)}

@media(max-width:1080px){
  .legacy .legacy-grid{grid-template-columns:1fr;gap:54px}
  .legacy-book-shell{width:min(100%,800px);margin-inline:auto}
  .legacy-timeline{grid-column:1;margin-top:0}
}
@media(max-width:640px){
  .legacy .legacy-grid{gap:42px}
  .legacy-book-heading{margin:0 0 2px;align-items:flex-end}
  .legacy-book-heading strong{font-size:16px}
  .legacy-book-stage{min-height:340px}
  .legacy-book-wrap{width:94vw;max-width:100%;aspect-ratio:1.58/1}
  .legacy-book-nav{width:39px;height:39px;bottom:0}
  .legacy-book-nav--prev{left:24%}.legacy-book-nav--next{right:24%}
  .legacy-book-controls{margin-top:2px;flex-wrap:wrap;gap:9px}
  .legacy-book-hint{display:none}
  .legacy-book-cover-leaf{width:30px;height:34px;margin-bottom:4px}
  .legacy-book-cover-border h3{font-size:23px;margin:8px 0}
  .legacy-book-caption{font-size:10px;margin-top:7px}
  .legacy-book-title-page p,.legacy-book-ending-page p{font-size:8px}
}
@media(prefers-reduced-motion:reduce){
  .legacy-book-shell *,.legacy-book-shell *:before,.legacy-book-shell *:after{animation-duration:.01ms!important;transition-duration:.01ms!important}
  .legacy-book-wrap{--tilt-x:0deg!important;--tilt-y:0deg!important}
}
