/* AP Stories 4.19 — Turn.js r3 integration authority.
   Gemini Page_flp-3 structure is the reference: one #flipbook, direct .page children,
   fixed center spine, and thin controls outside the page DOM. */

.ap-turn-v3-view{max-width:1060px!important;margin:10px auto 0!important;overflow:visible!important;}
.ap-turn-book-shell{
  --ap-turn-width:960px;
  --ap-turn-height:680px;
  position:relative;
  width:100%;
  min-height:var(--ap-turn-height)!important;
  height:var(--ap-turn-height)!important;
  max-height:none!important;
  display:flex;
  justify-content:center;
  align-items:flex-start;
  overflow:visible;
  perspective:2500px;
  isolation:isolate;
}

/* Kill every old safe-spread/PageFlip visibility rule. Turn.js owns visibility. */
.ap-turn-v3-view .ap-turn-story-page{
  display:block!important;
  max-width:none!important;
  margin:0!important;
}
.ap-turn-v3-view .ap-flipbook{
  position:relative!important;
  display:block!important;
  width:var(--ap-turn-width)!important;
  height:var(--ap-turn-height)!important;
  min-height:0!important;
  max-height:none!important;
  margin:0 auto!important;
  overflow:visible!important;
  filter:drop-shadow(0 20px 30px rgba(0,0,0,.28));
  transform-style:preserve-3d;
  background:transparent!important;
  touch-action:pan-y pinch-zoom;
}

#ap-turn-flipbook>.page,
#ap-turn-flipbook .turn-page{
  background:#fffdf8!important;
  color:#18202b!important;
  overflow:hidden!important;
  position:relative;
  padding:0!important;
  margin:0!important;
  border:0!important;
  border-radius:0!important;
  min-height:0!important;
  max-height:none!important;
  box-shadow:none!important;
  user-select:none;
  -webkit-user-select:none;
  box-sizing:border-box!important;
}
#ap-turn-flipbook .ap-turn-pad-page{background:transparent!important;box-shadow:none!important;border:0!important;padding:0!important;}
#ap-turn-flipbook .turn-page-wrapper{overflow:hidden!important;}
#ap-turn-flipbook .turn-page-wrapper,
#ap-turn-flipbook .turn-page{
  background-color:#fffdf8!important;
  backface-visibility:hidden;
  -webkit-backface-visibility:hidden;
  transform-style:preserve-3d;
}
.ap-turn-book-shell.is-turning #ap-turn-flipbook{
  filter:drop-shadow(0 18px 28px rgba(0,0,0,.24));
}
.ap-turn-book-shell [data-page-turn-sound]{display:none!important;}
#ap-turn-flipbook .turn-page-wrapper[page="2"],
#ap-turn-flipbook .turn-page-wrapper[page="4"],
#ap-turn-flipbook .turn-page-wrapper[page="6"],
#ap-turn-flipbook .turn-page-wrapper[page="8"]{box-shadow:inset -13px 0 18px -17px rgba(0,0,0,.75);}
#ap-turn-flipbook .turn-page-wrapper[page="3"],
#ap-turn-flipbook .turn-page-wrapper[page="5"],
#ap-turn-flipbook .turn-page-wrapper[page="7"],
#ap-turn-flipbook .turn-page-wrapper[page="9"]{box-shadow:inset 13px 0 18px -17px rgba(0,0,0,.75);}

/* Compact page identity. Do not spend vertical room on a demo title card. */
.ap-turn-v3-view .ap-reader-page-meta{
  height:34px!important;
  min-height:34px!important;
  margin:0!important;
  padding:8px 18px!important;
  display:flex!important;
  align-items:center!important;
  gap:10px!important;
  border:0!important;
  border-bottom:1px solid rgba(208,166,67,.34)!important;
  border-radius:0!important;
  background:#fffdf8!important;
  color:#263449!important;
  font:700 10px/1.15 Inter,system-ui,sans-serif!important;
  letter-spacing:.025em!important;
  white-space:nowrap!important;
  overflow:hidden!important;
}
.ap-turn-v3-view .ap-reader-page-meta span{overflow:hidden;text-overflow:ellipsis;}
.ap-turn-v3-view .ap-reader-page-meta span:first-child{flex:1 1 auto;}
.ap-turn-v3-view .ap-reader-page-meta b{color:#d7ad48!important;font-weight:900!important;}
.ap-turn-v3-view .ap-flip-content{
  height:calc(100% - 34px)!important;
  max-height:calc(100% - 34px)!important;
  padding:9px 11px 12px!important;
  box-sizing:border-box!important;
  overflow:hidden!important;
  white-space:normal!important;
  background:#fffdf8!important;
}
.ap-turn-v3-view .ap-flip-content>.ap-story-canvas{
  width:100%!important;
  height:100%!important;
  min-height:0!important;
  max-height:100%!important;
  margin:0!important;
}
.ap-turn-v3-view .ap-story-canvas .ap-story-art img{width:100%!important;height:100%!important;object-fit:cover!important;}

/* Fixed 3D center spine, copied in spirit from the known-good Gemini HTML. */
.ap-turn-center-spine{
  position:absolute;
  z-index:10000;
  pointer-events:none;
  top:0!important;
  bottom:auto!important;
  left:50%;
  width:68px!important;
  height:var(--ap-turn-height)!important;
  transform:translateX(-50%);
  background:linear-gradient(to right,
    rgba(0,0,0,0) 0%,
    rgba(0,0,0,.20) 34%,
    rgba(0,0,0,.48) 46%,
    rgba(0,0,0,.67) 50%,
    rgba(0,0,0,.48) 54%,
    rgba(0,0,0,.20) 66%,
    rgba(0,0,0,0) 100%);
  opacity:.72;
}
.ap-turn-book-shell.is-single .ap-turn-center-spine{display:none!important;}

/* FlipHTML5-inspired edge controls: exactly centered on the paper edges. */
.ap-turn-edge{
  position:absolute;
  z-index:10020;
  border:1px solid #d9d0c2;
  background:rgba(255,253,248,.96);
  color:#263449;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:0;
  cursor:pointer;
  box-shadow:0 7px 20px rgba(0,0,0,.30);
  backdrop-filter:blur(6px);
  transition:opacity .16s ease,transform .16s ease,background .16s ease,border-color .16s ease;
  -webkit-tap-highlight-color:transparent;
}
.ap-turn-edge:hover{background:#f7f2e9;border-color:rgba(185,138,35,.68);transform:translateY(-50%) scale(1.05);}
.ap-turn-edge:focus-visible{outline:2px solid #e4ba58;outline-offset:2px;}
.ap-turn-edge:disabled,.ap-turn-edge.is-disabled{opacity:.22;cursor:default;pointer-events:none;}
.ap-turn-edge-main{
  top:50%;
  width:44px;
  height:62px;
  border-radius:11px;
  transform:translateY(-50%);
  font:300 42px/1 Arial,sans-serif;
}
.ap-turn-edge-small{
  top:calc(50% + 49px);
  width:38px;
  height:30px;
  border-radius:8px;
  transform:translateY(-50%);
  font:800 14px/1 Arial,sans-serif;
  opacity:.72;
}
.ap-turn-edge-prev,.ap-turn-edge-first{left:calc(50% - (var(--ap-turn-width) / 2) - 25px);}
.ap-turn-edge-next,.ap-turn-edge-last{right:calc(50% - (var(--ap-turn-width) / 2) - 25px);}
.ap-turn-edge-small:hover{transform:translateY(-50%) scale(1.05);opacity:1;}
.ap-turn-book-shell.is-turning .ap-turn-edge-main{opacity:.48;}

.ap-turn-v3-view .ap-pageflip-status{
  display:block!important;
  margin:8px auto 0!important;
  text-align:center!important;
  color:#8d98aa!important;
  font:800 9px/1.2 Inter,system-ui,sans-serif!important;
  letter-spacing:.08em!important;
  opacity:.8!important;
}

/* If vendor fails, fail visibly instead of rendering two empty black pages. */
.ap-turn-book-shell.is-turn-missing{display:block;min-height:0;}
.ap-turn-book-shell.is-turn-missing #ap-turn-flipbook{width:min(100%,560px)!important;height:auto!important;filter:none!important;}
.ap-turn-book-shell.is-turn-missing #ap-turn-flipbook>.page{display:none!important;position:relative!important;width:100%!important;height:auto!important;min-height:620px!important;}
.ap-turn-book-shell.is-turn-missing #ap-turn-flipbook>[data-flip-page]:first-of-type{display:block!important;}
.ap-turn-book-shell.is-turn-missing .ap-turn-edge,.ap-turn-book-shell.is-turn-missing .ap-turn-center-spine{display:none!important;}



/* 4.34 — 6 × 8.5 physical-page authority + premium opening/ending spreads. */
.ap-turn-v3-view .ap-turn-story-page.ap-turn-left-leaf .ap-flip-content{padding-right:16px!important;}
.ap-turn-v3-view .ap-turn-story-page.ap-turn-right-leaf .ap-flip-content{padding-left:16px!important;}
.ap-turn-design-page{position:relative!important;isolation:isolate!important;background:#132a4b!important;overflow:hidden!important;color:#fff!important;}
.ap-turn-design-page::before{content:"";position:absolute;inset:0;z-index:0;background-image:var(--ap-spread-bg);background-repeat:no-repeat;background-size:200% 100%;filter:saturate(1.08) contrast(1.03);transform:scale(1.004);}
.ap-turn-opening-left::before,.ap-turn-ending-left::before{background-position:left center;}
.ap-turn-opening-right::before,.ap-turn-ending-right::before{background-position:right center;}
.ap-spread-shade{position:absolute;inset:0;z-index:1;background:linear-gradient(180deg,rgba(6,18,40,.08),rgba(6,18,40,.18) 48%,rgba(6,18,40,.70));}
.ap-turn-opening-left .ap-spread-shade{background:linear-gradient(90deg,rgba(5,18,38,.12),rgba(5,18,38,.02) 58%,rgba(5,18,38,.36));}
.ap-turn-opening-right .ap-spread-shade{background:linear-gradient(90deg,rgba(5,18,38,.44),rgba(5,18,38,.15) 42%,rgba(5,18,38,.54));}
.ap-spread-shade-end{background:linear-gradient(180deg,rgba(7,17,34,.30),rgba(7,17,34,.72));backdrop-filter:saturate(.88);}
.ap-spread-copy{position:absolute;z-index:2;display:flex;flex-direction:column;max-width:84%;text-shadow:0 3px 16px rgba(0,0,0,.48);}
.ap-spread-copy-left{left:30px;right:46px;bottom:34px;align-items:flex-start;}
.ap-spread-copy-right{left:46px;right:30px;bottom:34px;align-items:flex-start;}
.ap-spread-kicker{display:inline-flex;padding:5px 9px;border:1px solid rgba(255,255,255,.48);border-radius:999px;background:rgba(10,34,72,.48);font:900 9px/1.1 Inter,system-ui,sans-serif;letter-spacing:.12em;text-transform:uppercase;box-shadow:0 5px 16px rgba(0,0,0,.20);}
.ap-spread-copy strong{margin-top:12px;font:950 clamp(30px,4vw,52px)/.94 Inter,system-ui,sans-serif;letter-spacing:-.055em;color:#fff;}
.ap-spread-copy small{margin-top:8px;font:800 12px/1.35 Inter,system-ui,sans-serif;color:#e0f2fe;letter-spacing:.01em;}
.ap-spread-series{font:950 13px/1 Inter,system-ui,sans-serif;letter-spacing:.11em;text-transform:uppercase;color:#fde047;text-shadow:0 2px 0 rgba(180,83,9,.72),0 5px 15px rgba(0,0,0,.34);}
.ap-spread-copy h2{margin:9px 0 0;font:950 clamp(28px,3.4vw,46px)/.98 Inter,system-ui,sans-serif;letter-spacing:-.04em;color:#fff;}
.ap-spread-copy p{margin:8px 0 0;font:800 14px/1.35 Inter,system-ui,sans-serif;color:#e0f2fe;font-style:italic;}
.ap-spread-copy em{margin-top:12px;padding-top:10px;border-top:2px solid rgba(253,224,71,.72);font:900 9px/1.25 Inter,system-ui,sans-serif;letter-spacing:.16em;color:#fde047;font-style:normal;}
.ap-spread-end-copy strong{font-size:clamp(27px,3.1vw,42px);}
#ap-turn-flipbook .ap-turn-end-pad{background:linear-gradient(180deg,#fffdf8,#f6efe3)!important;}

@media(max-width:760px){
  .ap-turn-v3-view{width:100%!important;margin-top:6px!important;}
  .ap-turn-book-shell{min-height:var(--ap-turn-height)!important;height:var(--ap-turn-height)!important;padding:0 2px;}
  .ap-turn-v3-view .ap-flipbook{filter:drop-shadow(0 12px 18px rgba(0,0,0,.22));}
  .ap-turn-edge-main{width:38px;height:56px;border-radius:10px;font-size:36px;}
  .ap-turn-edge-prev{left:4px;}
  .ap-turn-edge-next{right:4px;}
  .ap-turn-edge-small{display:none!important;}
  .ap-turn-v3-view .ap-reader-page-meta{height:31px!important;min-height:31px!important;padding:7px 8px!important;font-size:9px!important;gap:7px!important;}
  .ap-turn-v3-view .ap-flip-content{height:calc(100% - 31px)!important;max-height:calc(100% - 31px)!important;padding:7px 7px 10px!important;}
  .ap-spread-copy-left,.ap-spread-copy-right{left:22px;right:22px;bottom:26px}.ap-spread-copy strong{font-size:34px}.ap-spread-copy h2{font-size:30px}
  .ap-turn-v3-view .ap-flip-content>.ap-story-canvas{height:100%!important;overflow:auto!important;overscroll-behavior:contain!important;}
}
