/* ---------- Flipbook (page-turning book at /book/…) ---------- */
.fb-page{background:#1b1c20}
.fb{display:flex;flex-direction:column;min-height:100vh;background:radial-gradient(120% 90% at 50% 40%,#34363d 0%,#1b1c20 70%);color:#fff;position:relative}
.fb--js{height:100vh;height:100dvh;overflow:hidden}
.fb [hidden]{display:none!important}
.fb img{-webkit-user-select:none;user-select:none;-webkit-touch-callout:none;-webkit-user-drag:none}
.fb__bar{display:flex;align-items:center;gap:16px;min-height:56px;padding:6px 20px;background:rgba(0,0,0,.35);border-bottom:1px solid rgba(255,255,255,.08);flex:none}
.fb__brand{font-family:'Inter','Noto Sans Thai',system-ui,sans-serif;font-size:22px;letter-spacing:.01em;white-space:nowrap}
.fb__title{flex:1;min-width:0;font-family:'Inter','Noto Sans Thai',system-ui,sans-serif;font-size:16px;font-weight:400;color:rgba(255,255,255,.82);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;padding-left:16px;border-left:1px solid rgba(255,255,255,.2)}
.fb__tools{display:flex;align-items:center;gap:4px;position:relative}
.fb__tool{display:grid;place-items:center;width:40px;height:40px;border:0;border-radius:50%;background:transparent;color:#fff;cursor:pointer;transition:background .15s}
.fb__tool:hover,.fb__tool[aria-pressed="true"]{background:rgba(255,255,255,.16)}
.fb__note{position:absolute;right:0;top:48px;z-index:6;background:#fff;color:#111;font-size:14px;padding:6px 12px;border-radius:4px;white-space:nowrap;box-shadow:0 6px 20px rgba(0,0,0,.35)}
.fb__stage{flex:1;min-height:0;position:relative;display:flex;overflow:hidden}
.fb__book{margin:auto}
.fb__empty{margin:auto;color:rgba(255,255,255,.7)}
.fb__list{list-style:none;margin:0 auto;padding:24px 16px;max-width:920px;display:grid;gap:16px}
.fb__list img{width:100%;height:auto;background:#fff;box-shadow:0 10px 30px rgba(0,0,0,.4)}
.fb__spread{position:relative;display:flex;perspective:2600px;transition:transform .7s cubic-bezier(.4,.1,.2,1)}
.fb__spread.is-first{transform:translateX(-25%)}
.fb__spread.is-last{transform:translateX(25%)}
.fb__half{position:relative;flex:1 1 0;min-width:0;height:100%;background:#fff;cursor:pointer;box-shadow:0 18px 50px rgba(0,0,0,.5)}
.fb__spread:not(.is-double) .fb__half--l{display:none}
.fb__half.is-empty{visibility:hidden}
.fb__half img,.fb__face img{width:100%;height:100%;object-fit:contain}
.fb__half--l::after,.fb__half--r::after{content:"";position:absolute;top:0;bottom:0;width:14%;pointer-events:none}
.is-double .fb__half--l::after{right:0;background:linear-gradient(to left,rgba(0,0,0,.20) 0,rgba(0,0,0,.10) 22%,rgba(0,0,0,.035) 55%,rgba(0,0,0,0) 100%)}
.is-double .fb__half--r::after{left:0;background:linear-gradient(to right,rgba(0,0,0,.24) 0,rgba(0,0,0,.11) 22%,rgba(0,0,0,.035) 55%,rgba(0,0,0,0) 100%)}
.fb__spine{display:none}
.fb__leaf{position:absolute;top:0;left:50%;width:50%;height:100%;z-index:3;transform-style:preserve-3d;transform-origin:left center;transition:transform .8s cubic-bezier(.45,.05,.25,1);pointer-events:none}
.fb__leaf--back{left:0;transform-origin:right center}
.fb__leaf--fwd.is-turning{transform:rotateY(-180deg)}
.fb__leaf--back.is-turning{transform:rotateY(180deg)}
.fb__leaf--single{left:0;width:100%;transform-origin:left center;transition:transform .6s cubic-bezier(.45,.05,.25,1),opacity .6s}
.fb__leaf--single.fb__leaf--fwd.is-turning{transform:rotateY(-105deg);opacity:.2}
.fb__leaf--single.fb__leaf--back{transform:rotateY(-105deg);opacity:.2}
.fb__leaf--single.fb__leaf--back.is-turning{transform:rotateY(0);opacity:1}
.fb__face{position:absolute;inset:0;background:#fff;-webkit-backface-visibility:hidden;backface-visibility:hidden;box-shadow:0 0 30px rgba(0,0,0,.25)}
.fb__face--back{transform:rotateY(180deg)}
.fb__nav{position:absolute;top:50%;z-index:5;transform:translateY(-50%);display:grid;place-items:center;width:52px;height:52px;border:0;border-radius:50%;background:rgba(255,255,255,.12);color:#fff;cursor:pointer;transition:background .15s,opacity .15s}
.fb__nav:hover{background:#ed1c24}
.fb__nav:disabled{opacity:.2;cursor:default;background:rgba(255,255,255,.12)}
.fb__nav--prev{left:14px}
.fb__nav--next{right:14px}
.is-zoomed .fb__stage{overflow:auto}
.is-zoomed .fb__nav{display:none}
.is-zoomed .fb__spread{transform:none;transition:none}
.is-zoomed .fb__half{cursor:default}
.fb__foot{display:flex;align-items:center;gap:16px;padding:8px 20px;background:rgba(0,0,0,.35);border-top:1px solid rgba(255,255,255,.08);flex:none}
.fb__range{flex:1;min-width:0;accent-color:#ed1c24;height:24px}
.fb__count{font-family:'Inter','Noto Sans Thai',system-ui,sans-serif;font-size:13px;letter-spacing:.08em;min-width:86px;text-align:right;white-space:nowrap}
.fb__thumbs{position:absolute;left:0;right:0;bottom:41px;z-index:6;display:flex;gap:10px;overflow-x:auto;padding:14px 20px;background:rgba(15,15,17,.96);border-top:1px solid rgba(255,255,255,.1)}
.fb__thumbs button{flex:none;border:2px solid transparent;border-radius:3px;background:none;padding:0;cursor:pointer;color:rgba(255,255,255,.7);font-size:12px}
.fb__thumbs img{height:110px;width:auto;background:#fff}
.fb__thumbs span{display:block;padding:3px 0 1px}
.fb__thumbs button.is-on{border-color:#ed1c24;color:#fff}
@media (max-width:820px){
  .fb__bar{padding:4px 10px;gap:8px}
  .fb__brand{font-size:18px}
  .fb__title{font-size:14px;padding-left:8px}
  .fb__tool{width:36px;height:36px}
  .fb__nav{width:38px;height:38px;background:rgba(0,0,0,.45)}
  .fb__nav--prev{left:4px}.fb__nav--next{right:4px}
  .fb__foot{padding:6px 12px;gap:10px}
  .fb__thumbs img{height:84px}}
@media (max-width:520px){.fb__brand{display:none}.fb__title{border-left:0;padding-left:4px}}
@media (prefers-reduced-motion:reduce){.fb__spread,.fb__leaf{transition:none}}
/* admin: pages of a book */
.fb-pages{display:grid;grid-template-columns:repeat(auto-fill,minmax(96px,1fr));gap:10px}
.fb-pages figure{margin:0;text-align:center}
.fb-pages img{width:100%;height:auto;border:1px solid #e5e7eb;background:#fff}
.fb-pages figcaption{font-size:12px;color:#6b7280;margin-top:2px}
/* page curl: hover / drag a page corner */
.fb__spread.is-curl-zone .fb__half{cursor:grab}
.fb__spread.is-curling,.fb__spread.is-curling .fb__half{cursor:grabbing}
.fb__spread.is-curling{-webkit-user-select:none;user-select:none}
.fb__curl{position:absolute;top:0;z-index:4;pointer-events:none}
.fb__c-under,.fb__c-keep{position:absolute;inset:0;background:#fff}
.fb__c-wrap{position:absolute;left:0;top:0;width:0;height:0;overflow:visible;filter:drop-shadow(-3px 5px 7px rgba(0,0,0,.38))}
.fb__c-flap{position:absolute;left:0;top:0;transform-origin:0 0;background:#fff}
.fb__cp{position:absolute;inset:0;overflow:hidden;background:#fff}
.fb__cp img{width:100%;height:100%;object-fit:contain;display:block}
.fb__c-shade{position:absolute;inset:0;background:linear-gradient(135deg,rgba(0,0,0,.2),rgba(0,0,0,0) 55%,rgba(255,255,255,.18));pointer-events:none}
@media (prefers-reduced-motion:reduce){.fb__c-wrap{filter:none}}
/* portfolio additions */
html,body{margin:0;height:100%}
body.fb-page{font-family:'Inter','Noto Sans Thai',system-ui,sans-serif;overflow:hidden;-webkit-tap-highlight-color:transparent}
.fb__brand{color:#fff;text-decoration:none;font-weight:800;letter-spacing:.04em;font-size:15px}
.fb__brand .red{color:#ed1c24}
.fb__title small{font-weight:400;color:#a9abb3;margin-left:8px;font-size:13px}
.fb__bar{padding-top:calc(6px + env(safe-area-inset-top));padding-left:calc(20px + env(safe-area-inset-left));padding-right:calc(20px + env(safe-area-inset-right))}
.fb__foot{padding-bottom:calc(8px + env(safe-area-inset-bottom))}
.fb .sr-only{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}
.fb__tool{text-decoration:none}
.fb__sl{position:relative;flex:1;display:flex;align-items:center;min-width:0}
.fb__sl .fb__range{width:100%}
.fb__tip{position:absolute;bottom:30px;left:0;transform:translateX(-50%);background:#1f2026;border:1px solid rgba(255,255,255,.18);border-radius:8px;padding:6px;text-align:center;font-size:12px;color:#e6e6ea;pointer-events:none;opacity:0;transition:opacity .12s;z-index:9;box-shadow:0 10px 30px rgba(0,0,0,.5)}
.fb__tip.on{opacity:1}
.fb__tip img{display:block;width:96px;height:auto;aspect-ratio:var(--par,.707);object-fit:cover;background:#2a2b31;border-radius:3px;margin:0 auto 4px}
.fb__pl{position:absolute;inset:0;display:grid;place-items:center;color:#9aa0aa;font-size:13px}

/* seamless spine: each page casts its shadow only OUTWARD, so the two shadows never smear over the neighbouring page */
.fb__half--l{clip-path:inset(-90px 0 -90px -90px)}
.fb__half--r{clip-path:inset(-90px -90px -90px 0)}
.fb__spread:not(.is-double) .fb__half--r,.fb__spread.is-first .fb__half--r{clip-path:inset(-90px)}
.fb__spread.is-last .fb__half--l{clip-path:inset(-90px)}
/* a hair-thin crease where the sheets meet */
.is-double:not(.is-first):not(.is-last)::after{content:"";position:absolute;top:0;bottom:0;left:50%;width:1px;margin-left:-.5px;background:rgba(0,0,0,.16);z-index:2;pointer-events:none}

/* the turning leaf wears the same spine shading as a resting page, so nothing "pops" when the leaf lands */
.is-double .fb__face::after{content:"";position:absolute;top:0;bottom:0;width:14%;pointer-events:none}
.is-double .fb__leaf--fwd .fb__face:not(.fb__face--back)::after,
.is-double .fb__leaf--back .fb__face--back::after{left:0;background:linear-gradient(to right,rgba(0,0,0,.24) 0,rgba(0,0,0,.11) 22%,rgba(0,0,0,.035) 55%,rgba(0,0,0,0) 100%)}
.is-double .fb__leaf--fwd .fb__face--back::after,
.is-double .fb__leaf--back .fb__face:not(.fb__face--back)::after{right:0;background:linear-gradient(to left,rgba(0,0,0,.20) 0,rgba(0,0,0,.10) 22%,rgba(0,0,0,.035) 55%,rgba(0,0,0,0) 100%)}
.fb__leaf--single .fb__face::after{display:none}

/* phone held sideways: slim bars so the two-page spread gets the height */
@media (orientation:landscape) and (max-height:520px){
  .fb__bar{min-height:40px;padding-top:calc(2px + env(safe-area-inset-top));padding-bottom:2px}
  .fb__tool{width:34px;height:34px}
  .fb__brand{font-size:13px}.fb__title{font-size:13px}
  .fb__foot{padding-top:2px;padding-bottom:calc(2px + env(safe-area-inset-bottom));padding-left:calc(14px + env(safe-area-inset-left));padding-right:calc(14px + env(safe-area-inset-right))}
  .fb__range{height:20px}
  .fb__nav{width:38px;height:38px;background:rgba(0,0,0,.45)}
  .fb__nav--prev{left:calc(6px + env(safe-area-inset-left))}.fb__nav--next{right:calc(6px + env(safe-area-inset-right))}
  .fb__thumbs{bottom:30px;padding:8px 14px}.fb__thumbs img{height:70px}
}

/* full screen / immersive view: only the book (and the arrows) remain */
.fb.is-immersive .fb__bar,.fb.is-immersive .fb__foot,.fb.is-immersive .fb__thumbs{display:none}
.fb__exit{position:absolute;top:calc(10px + env(safe-area-inset-top));right:calc(12px + env(safe-area-inset-right));z-index:9;width:40px;height:40px;border-radius:50%;border:0;background:rgba(0,0,0,.55);color:#fff;font-size:24px;line-height:1;cursor:pointer;display:grid;place-items:center;padding:0}
.fb__exit:hover{background:#ed1c24}
.fb.is-immersive .fb__stage{padding-left:env(safe-area-inset-left);padding-right:env(safe-area-inset-right)}

/* paper type button (soft / hard) */
.fb__tool--paper{display:flex;align-items:center;gap:7px;width:auto;border-radius:999px;padding:0 13px 0 11px;font:inherit;font-size:12.5px;font-weight:700;letter-spacing:.01em;border:1px solid rgba(255,255,255,.22)}
.fb__tool--paper .fb__paper-hard{display:none}
.fb__tool--paper.is-hard .fb__paper-soft{display:none}
.fb__tool--paper.is-hard .fb__paper-hard{display:block}
.fb__tool--paper.is-hard{background:rgba(237,28,36,.28);border-color:#ff5a66}
.fb__note{max-width:min(320px,86vw);white-space:normal;text-align:right}
@media (max-width:820px){.fb__paper-l{display:none}.fb__tool--paper{padding:0;width:36px;justify-content:center}}
/* hard paper: no corner-grab cursor */
.fb--hard .fb__spread.is-curl-zone .fb__half{cursor:pointer}

/* ── smoothness pass ── */
/* the curling layers carry the same spine shading as a resting page, so hovering a corner or finishing a turn changes nothing at the spine */
.fb__curl .fb__cp::after{content:"";position:absolute;top:0;bottom:0;width:14%;pointer-events:none}
.fb__curl--r .fb__cp::after{left:0;background:linear-gradient(to right,rgba(0,0,0,.24) 0,rgba(0,0,0,.11) 22%,rgba(0,0,0,.035) 55%,rgba(0,0,0,0) 100%)}
.fb__curl--l .fb__cp::after{right:0;background:linear-gradient(to left,rgba(0,0,0,.20) 0,rgba(0,0,0,.10) 22%,rgba(0,0,0,.035) 55%,rgba(0,0,0,0) 100%)}
/* let the compositor own the moving pieces */
.fb__c-flap{will-change:transform,clip-path;backface-visibility:hidden}
.fb__c-keep{will-change:clip-path}
.fb__leaf{will-change:transform}
.fb__curl{transition:opacity .08s linear}
