/* Film grain over the whole page. One fixed layer of SVG fractal noise,
   multiplied over the warm ground so it reads as paper tooth rather than
   a grey wash. It never intercepts clicks. */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  opacity: 0.082;
  /* No mix-blend-mode: a blended full-viewport layer forces the browser to
     re-composite the entire page underneath it on every single frame, which
     is what made scrolling feel heavy. Instead the turbulence is reduced to
     pure black at a sparse alpha (feColorMatrix zeroes RGB and keeps the
     shaped alpha), so painting it normally darkens exactly the way multiply
     did - measured to within a pixel level on cream, card and honey, and
     still invisible over the dark footer. */
  background-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/><feComponentTransfer><funcA type='linear' slope='6' intercept='-3.4'/></feComponentTransfer><feColorMatrix type='matrix' values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0'/></filter><rect width='180' height='180' filter='url(%23n)'/></svg>");
  /* One tile, rasterised once and repeated, instead of one rect stretched
     over four viewports' worth of area. Own layer, so it never repaints. */
  background-size: 180px 180px;
  transform: translateZ(0);
}

/* ---- Page container ---------------------------------------------------
   One gutter and one content rail for the whole page. Section bands stay
   full-bleed so their colour still runs edge to edge; everything *inside*
   a band sits on `.shell`, and that is what makes the copy and card edges
   line up from the nav all the way down to the footer. Change --rail here
   and the whole page follows. */
:root { --rail: 1280px; }
.shell { width: 100%; max-width: var(--rail); margin-inline: auto; }

/* Lucide icons are stroke-drawn: without these they render as black fills. */
.icon { fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; }
.icon-brand { fill: currentColor; stroke: none; }

/* Hero doodles - the pen marks in the notebook margin around the headline.
   Three jobs, three wrappers, so no two of them ever fight over `transform`:
   the pointer drift lives on the outer [data-drift], the entry tween on the
   [data-enter] inside it, and the idle float on the innermost `.prop`. Each
   drift layer travels its own distance; that difference is the depth. */
.prop-layer { transition: transform 0.7s cubic-bezier(0.2, 0.8, 0.2, 1); }
@keyframes prop-float {
  0%, 100% { transform: translate3d(0, 0, 0); }
  50%      { transform: translate3d(0, var(--rise, -12px), 0); }
}
@media (prefers-reduced-motion: no-preference) {
  .prop { animation: prop-float var(--dur, 8s) ease-in-out var(--delay, 0s) infinite; }
}

/* A CSS animation set to `infinite` keeps asking the compositor for frames
   even after it has scrolled out of view, so the hero's doodles and the team
   wall's drifting columns go on costing the whole page for their entire
   life. `.is-still` is switched on by an observer once a section is off
   screen, and off again before it comes back. */
.is-still .prop,
.is-still .bee-wing, .is-still .hero-bee svg { animation-play-state: paused; }

/* The marked word. The honey block sits behind the glyphs on its own span,
   so the motion layer can wipe it in while the letters flick up on top.
   Sized in em off the headline, so it tracks the type at every width. */
.hl-pill {
  position: relative;
  isolation: isolate;
  display: inline-block;
  padding-inline: 0.16em 0.2em;
}
.hl-pill-bg {
  position: absolute;
  inset: 0.06em 0 -0.1em;
  z-index: -1;
  border-radius: 0.2em;
  background-image: linear-gradient(135deg, #FFC24D 0%, #F5A521 62%, #E8931A 100%);
  box-shadow: 0 0.16em 0.4em -0.2em rgba(138, 101, 8, 0.55);
}

/* Its wingbeat. Each wing sits in its own <g> so the flap doesn't
   overwrite the rotate() already on the ellipse, and pivots on its root,
   which is just inside the body so the joint never shows. One cycle holds
   seven beats of uneven height, so the loop reads as a live buzz rather
   than a metronome, and the front wing trails the back by a hair. The
   body gets a quicker, smaller hover on top of the slow `.prop` float
   the other doodles share - a couple of pixels, no more. */
.bee-wing { transform-box: view-box; }
.bee-wing--back  { --tilt: -13deg; transform-origin: 49px 56px; }
.bee-wing--front { --tilt: 10deg;  transform-origin: 56px 53px; }
@keyframes bee-flap {
  0%, 14%, 28.5%, 42.5%, 57%, 71.5%, 86%, 100% { transform: rotate(0deg) scaleY(1); }
  7%    { transform: rotate(var(--tilt)) scaleY(0.82); }
  21.5% { transform: rotate(calc(var(--tilt) * 0.75)) scaleY(0.87); }
  35.5% { transform: rotate(calc(var(--tilt) * 0.95)) scaleY(0.83); }
  50%   { transform: rotate(calc(var(--tilt) * 0.6)) scaleY(0.9); }
  64%   { transform: rotate(var(--tilt)) scaleY(0.8); }
  78.5% { transform: rotate(calc(var(--tilt) * 0.8)) scaleY(0.86); }
  93%   { transform: rotate(calc(var(--tilt) * 0.9)) scaleY(0.84); }
}
@keyframes bee-hover {
  0%, 100% { transform: translate3d(0, 0, 0); }
  28%      { transform: translate3d(0, -2.4%, 0); }
  52%      { transform: translate3d(0, 0.6%, 0); }
  76%      { transform: translate3d(0, -1.4%, 0); }
}
@media (prefers-reduced-motion: no-preference) {
  .bee-wing { animation: bee-flap 1.05s ease-in-out infinite; }
  .bee-wing--front { animation-delay: -0.03s; }
  .hero-bee svg { animation: bee-hover 1.7s ease-in-out infinite; }
}

/* ---- Motion layer (js/motion.js) --------------------------------------
   Nothing here animates on its own. These are the states the page holds
   *before* the motion layer boots, plus the two pieces of structure GSAP
   cannot express in a tween: the word clipping box and the wipe panels.
   `html.motion-ready` is added the moment motion.js has built its tweens
   (or decided not to), and every pre-state below is scoped to its absence,
   so a blocked CDN or reduced-motion preference leaves a plain page. */

html:not(.motion-ready) [data-reveal],
html:not(.motion-ready) [data-enter],
html:not(.motion-ready) [data-reveal-group] > * { opacity: 0; }
html:not(.motion-ready) [data-reveal="clip"] { opacity: 1; clip-path: inset(46% 8% 46% 8% round 36px); }

/* Type splitting. A word stays one unit so lines still break on spaces,
   and the characters inside it are what actually move. No clipping box:
   each glyph rotates as it rises, and a mask would shear the corners. */
.rv-w { display: inline-block; white-space: nowrap; }

/* One clipping box per word, split further into characters. Each glyph
   pivots about a point near its own baseline (50% 90%) as it rises, which
   is what gives the reveal its flick rather than a flat slide. */
.rv-c { display: inline-block; transform-origin: 50% 90%; }
/* will-change only while a heading is actually typing. Left on permanently
   it hands every single glyph on the page its own compositor layer, which
   costs memory and slows every frame for motion that has already finished.
   motion.js adds .is-typing for the length of the tween and takes it off. */
.is-typing .rv-c { will-change: transform, opacity; }

/* The curtain covers the viewport from first paint. Its path is drawn at
   the covered position so there is no flash of page before motion.js
   takes over; the failsafe below hides the whole layer if it never does. */
#curtain { display: block; }

/* Sticker eyebrows - the rotated, offset-shadowed label CRAV uses to tag a
   section. Kept to honey on ink so it reads as a label, not a callout. */
.sticker {
  display: inline-block;
  transform: rotate(-2.5deg);
  border-radius: 999px;
  background: #FFFFFF;
  padding: 0.3rem 0.85rem;
  box-shadow: 2px 2px 0 rgba(20, 20, 15, 0.82);
}


/* Footer. Links sit at cream on the ink sheet and warm to honey on hover;
   keyboard focus gets its own honey ring, since the hover shift alone is
   too quiet to find on a dark ground. */
.footer-link {
  color: rgba(253, 252, 247, 0.78);
  text-decoration: none;
  width: fit-content;
  border-radius: 6px;
  transition: color 0.2s ease;
}
.footer-link:hover { color: #FFC24D; }
.footer-link:focus-visible { outline: 2px solid #FFC24D; outline-offset: 3px; }
/* The comb only shows at the top-right corner and thins out across the
   sheet, so it reads as texture behind the columns, never under the copy. */
.footer-comb {
  -webkit-mask-image: radial-gradient(75% 110% at 100% 0%, #000 0%, rgba(0, 0, 0, 0.35) 45%, transparent 75%);
  mask-image: radial-gradient(75% 110% at 100% 0%, #000 0%, rgba(0, 0, 0, 0.35) 45%, transparent 75%);
}

/* ---- Nav dropdowns ----------------------------------------------------
   Courses and Resources each gather their links behind one button.
   From `menu` up the list drops as a card under the button; below that,
   inside the Menu sheet, it opens in place as an indented group. The
   button's aria-expanded is the only state - the script flips it and
   everything here reads it. */
.nav-dd { position: relative; }
.nav-dd-link {
  display: block;
  white-space: nowrap;
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 14.5px;
  font-weight: 500;
  color: #55554B;
  text-decoration: none;
  transition: background-color .15s ease, color .15s ease;
}
.nav-dd-link:hover,
.nav-dd-link[aria-current="page"] { background: #F2EEE3; color: #14140F; }
/* Current page in the main nav: ink text over a honey bar the width of the label, rather
   than the grey chip that hover already uses. The mobile menu stacks the
   links, so there the bar moves to the left edge over a honey wash. */
#navLinks > li > a[aria-current="page"],
#navLinks > li > button[data-current] { position: relative; color: #14140F; }
#navLinks > li > a[aria-current="page"]::after,
#navLinks > li > button[data-current]::after {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 0;
  height: 3px;
  border-radius: 999px;
  background: #F5A521;
}
@media (max-width: 1023.98px) {
  #navLinks > li > a[aria-current="page"],
  #navLinks > li > button[data-current] {
    background: linear-gradient(135deg, rgba(255,194,77,0.26) 0%, rgba(245,165,33,0.17) 62%, rgba(232,147,26,0.14) 100%);
  }
  #navLinks > li > a[aria-current="page"]::after,
  #navLinks > li > button[data-current]::after {
    left: 0; right: auto; top: 50%; bottom: auto;
    width: 3px; height: 60%;
    transform: translateY(-50%);
  }
}
@media (min-width: 1024px) {
  .nav-dd-panel {
    position: absolute;
    top: calc(100% + 10px);
    left: 50%;
    min-width: 180px;
    padding: 6px;
    border-radius: 16px;
    background: #FFFFFF;
    box-shadow: 0 2px 6px rgba(20, 20, 15, 0.05), 0 18px 44px rgba(138, 101, 8, 0.14);
    opacity: 0;
    visibility: hidden;
    transform: translate(-50%, -6px);
    transition: opacity .18s ease, transform .18s ease, visibility 0s linear .18s;
  }
  /* bridges the gap under the button, so the pointer can cross to the card
     without the group closing on the way */
  .nav-dd-panel::before { content: ''; position: absolute; inset: -10px 0 auto; height: 10px; }
  [aria-expanded="true"] + .nav-dd-panel {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, 0);
    transition: opacity .18s ease, transform .18s ease, visibility 0s;
  }
}
@media (max-width: 1023.98px) {
  .nav-dd-panel { margin: 2px 0 4px 14px; padding-left: 10px; border-left: 2px solid #E9E3D3; }
  [aria-expanded="false"] + .nav-dd-panel { display: none; }
  .nav-dd-link { padding: 10px 14px; font-size: 15px; }
}
@media (prefers-reduced-motion: reduce) {
  .nav-dd-panel { transition: none !important; }
}

/* ---- Menu sheet (below `menu`) ----------------------------------------
   Stays laid out while closed so it can animate: it unrolls downward from
   the bar and the rows follow one after another. On close it rolls back
   up quicker than it came down. The script only toggles .is-open. */
@media (max-width: 1023.98px) {
  #navLinks {
    display: flex;
    visibility: hidden;
    opacity: 0;
    transform: translateY(-10px);
    clip-path: inset(0 0 100% 0);
    transition: clip-path .32s cubic-bezier(.4,0,.2,1), transform .32s cubic-bezier(.4,0,.2,1), opacity .24s ease .06s, visibility 0s linear .32s;
  }
  #navLinks.is-open {
    visibility: visible;
    opacity: 1;
    transform: none;
    clip-path: inset(0 -60px -60px -60px);
    transition: clip-path .5s cubic-bezier(.22,1,.36,1), transform .5s cubic-bezier(.22,1,.36,1), opacity .2s ease, visibility 0s;
  }
  #navLinks > li { opacity: 0; transform: translateY(-8px); transition: opacity .15s ease, transform .15s ease; }
  #navLinks.is-open > li {
    opacity: 1;
    transform: none;
    transition: opacity .35s ease var(--d, 0s), transform .5s cubic-bezier(.22,1,.36,1) var(--d, 0s);
  }
  #navLinks.is-open > li:nth-child(1) { --d: .06s; }
  #navLinks.is-open > li:nth-child(2) { --d: .1s; }
  #navLinks.is-open > li:nth-child(3) { --d: .14s; }
  #navLinks.is-open > li:nth-child(4) { --d: .18s; }
  #navLinks.is-open > li:nth-child(5) { --d: .22s; }
  #navLinks.is-open > li:nth-child(6) { --d: .26s; }
  #navLinks.is-open > li:nth-child(7) { --d: .3s; }
  #navLinks.is-open > li:nth-child(8) { --d: .34s; }
}
@media (max-width: 1023.98px) and (prefers-reduced-motion: reduce) {
  #navLinks, #navLinks > li { transform: none !important; transition: none !important; }
}

/* M4Edu "Read more". Below `nav` the copy is held to four lines with the
   last of them fading out; the script opens it to its full height. */
@media (max-width: 899.98px) {
  .m4edu-more {
    overflow: hidden;
    max-height: 6.8em;
    transition: max-height .5s cubic-bezier(.22,1,.36,1);
    -webkit-mask-image: linear-gradient(to bottom, #000 45%, transparent);
            mask-image: linear-gradient(to bottom, #000 45%, transparent);
  }
  .m4edu-more.is-open { -webkit-mask-image: none; mask-image: none; }
}
@media (prefers-reduced-motion: reduce) {
  .m4edu-more { transition: none !important; }
}

/* Back to top. Held out of sight until the reader is most of a screen down,
   then it rises into the corner. The honey ring fills with how far through
   the page they are - pathLength="1" on the circle makes its dash offset a
   plain 0-1 fraction. Visibility flips at the end of the fade, so a hidden
   button can be neither clicked nor tabbed to. */
.to-top {
  margin-bottom: env(safe-area-inset-bottom);
  opacity: 0;
  visibility: hidden;
  translate: 0 14px;
  scale: 0.9;
  transition: opacity 0.25s ease, translate 0.35s cubic-bezier(0.22, 1, 0.36, 1), scale 0.35s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.2s ease, visibility 0s linear 0.35s;
}
.to-top.is-shown { opacity: 1; visibility: visible; translate: 0 0; scale: 1; transition-delay: 0s; }
.to-top.is-shown:hover { translate: 0 -2px; box-shadow: 0 16px 34px -10px rgba(20,20,15,0.6); }
.to-top-ring { stroke-dasharray: 1; stroke-dashoffset: 1; }
@media (prefers-reduced-motion: reduce) {
  .to-top, .to-top.is-shown, .to-top.is-shown:hover { translate: none; scale: none; }
}

/* ---- Resources: anchors -----------------------------------------------
   The nav links straight into #study-material from every page.
   A jump lands the band's top edge just under the fixed 68px bar rather
   than behind it. (In-page links go through Lenis, which offsets by 80.) */
.res-anchor { scroll-margin-top: 68px; }

/* ---- Resources: hero desk -----------------------------------------------
   The right half of the hero is a desk top: a ruled contents card for
   this page, a classroom photo clipped behind it, a small comb in its
   corner and the bee's dotted flight across the top. The photo, the
   flight and the bee share one box sized in % so they keep their places
   at every width; on a phone they step out and the card sits flat. */
.res-photo, .res-sky, .res-arc { display: none; }
@media (min-width: 640px) {
  .res-desk { padding-top: clamp(78px, 9vw, 104px); }
  .res-photo { display: block; position: absolute; left: -3%; top: 0; z-index: 1; width: 43%; }
  .res-sky { display: block; position: absolute; left: 0; top: 0; z-index: 3; width: 100%; aspect-ratio: 520 / 200; pointer-events: none; }
  .res-arc { display: block; }
}
.res-polaroid {
  position: relative;
  margin: 0;
  padding: 8px 8px 28px;
  border-radius: 10px;
  background: #FFFFFF;
  transform: rotate(-6deg);
  box-shadow: 0 18px 34px -22px rgba(20, 20, 15, 0.55);
}
.res-polaroid img { display: block; width: 100%; aspect-ratio: 5 / 4; object-fit: cover; border-radius: 10px; }
.res-tape {
  position: absolute;
  left: 50%;
  top: -11px;
  width: 76px;
  height: 22px;
  translate: -50% 0;
  rotate: 5deg;
  border-radius: 3px;
  background: rgba(255, 194, 77, 0.78);
}
.res-bee { position: absolute; left: 86%; top: 0; width: 13%; }
@media (prefers-reduced-motion: no-preference) {
  .res-bee svg { animation: bee-hover 1.7s ease-in-out infinite; }
}
.is-still .res-bee svg { animation-play-state: paused; }

/* The contents card. A thin honey rule runs down it like the margin of
   a ruled page, with the section numbers set to its left. */
.res-index {
  --pl: 1.25rem;
  position: relative;
  border-radius: 21px;
  background: #FFFFFF;
  padding: 1.4rem 1.25rem 0.6rem var(--pl);
  box-shadow: 0 2px 6px rgba(20, 20, 15, 0.05), 0 30px 60px -30px rgba(138, 101, 8, 0.38);
}
.res-index::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: calc(var(--pl) + 3.1rem);
  width: 1px;
  background: rgba(245, 165, 33, 0.45);
}
@media (min-width: 640px) {
  .res-index { --pl: 1.6rem; margin-left: 13%; padding: 1.7rem 1.6rem 0.8rem var(--pl); transform: rotate(1.5deg); }
}
.res-index-row {
  display: grid;
  grid-template-columns: 2.6rem minmax(0, 1fr) auto;
  align-items: center;
  gap: 1.1rem;
  padding: 1rem 0;
  border-top: 1px solid rgba(20, 20, 15, 0.08);
  color: #14140F;
  text-decoration: none;
}
.res-index-row:focus-visible { outline: 2px solid #14140F; outline-offset: 4px; border-radius: 8px; }
.res-index-num {
  font-family: 'Sora', system-ui, sans-serif;
  font-size: 1.7rem;
  font-weight: 200;
  line-height: 1;
  letter-spacing: -0.03em;
  color: rgba(138, 101, 8, 0.38);
  transition: color 0.3s ease;
}
.res-index-row:hover .res-index-num { color: #8A6508; }
.res-index-title { display: block; font-family: 'Sora', system-ui, sans-serif; font-size: 1.08rem; font-weight: 600; letter-spacing: -0.02em; }
.res-index-meta { display: block; margin-top: 2px; font-size: 0.875rem; font-weight: 300; line-height: 1.45; color: #55554B; }
.res-index-go {
  display: flex;
  height: 2.25rem;
  width: 2.25rem;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: #F2EEE3;
  transition: transform 0.2s ease, background-color 0.2s ease;
}
.res-index-row:hover .res-index-go { background: #F5A521; transform: translateX(3px); }
.res-comb { position: absolute; right: -3%; bottom: -52px; z-index: 3; width: 84px; overflow: visible; }
@media (min-width: 640px) { .res-comb { right: -7%; bottom: -70px; width: 118px; } }
.res-comb-cell { fill: #FBE3AE; stroke: #FDF4DF; stroke-width: 4; stroke-linejoin: round; }
.res-comb-cell--white { fill: #FFFFFF; }
.res-comb-cell--honey { fill: #F5A521; }

/* ---- Resources: study material ------------------------------------------
   A bookshelf. One spine per class, 8 to 12, each a different binding and
   height so the row reads as books stood on a shelf rather than a grid of
   tiles. The syllabus switch swaps which shelf is out; each spine is a
   WhatsApp link with the request already written. The spines stay five
   across even on a phone, where they are narrow enough to look the part. */
.sm-tab {
  cursor: pointer;
  border-radius: 999px;
  padding: 0.6rem 1.1rem;
  font-size: 0.9rem;
  color: #55554B;
  white-space: nowrap;
  transition: color 0.2s ease, box-shadow 0.2s ease;
}
.sm-tab:hover { color: #14140F; }
.sm-tab[aria-selected="true"] {
  background-image: linear-gradient(135deg, #FFC24D 0%, #F5A521 62%, #E8931A 100%);
  color: #14140F;
  box-shadow: 0 6px 20px rgba(232, 147, 26, 0.38);
}
.sm-tab:focus-visible { outline: 2px solid #14140F; outline-offset: 2px; }

/* The shelf is a small 3D set. .sm-scene is the camera (perspective),
   .sm-stage the room it looks into - turned a few degrees off-square so
   every spine shows the same right-hand edge and the light, which sits
   front-top-left, falls the same way across all five. Each spine is a real
   slab: the <a> is its front face, two child planes are folded back to make
   the right side and the top, and a flattened ::after lies on the ground as
   its contact shadow. Depth is 8-18px - enough to read as an object, not an
   extrusion. The set does not move: no pointer parallax, no entrance -
   the depth is the whole effect. */
.sm-scene {
  perspective: 1500px;
  perspective-origin: 50% 36%;
  padding-top: 12px;
}
.sm-stage {
  transform-style: preserve-3d;
  transform: rotateX(4deg) rotateY(-9deg);
}
.sm-books {
  display: flex;
  align-items: flex-end;
  gap: clamp(6px, 1.4vw, 16px);
  height: clamp(250px, 34vw, 380px);
  padding-inline: clamp(2px, 2vw, 28px);
  transform-style: preserve-3d;
}
.sm-books > li {
  flex: 1 1 0;
  min-width: 0;
  height: var(--h, 100%);
  transform-style: preserve-3d;
}
/* The slabs do not all stand on the same line: a few millimetres of
   forward and backward placement, so the row has air in it. */
.sm-books > li:nth-child(1) { --z: 0px;  }
.sm-books > li:nth-child(2) { --z: 10px; }
.sm-books > li:nth-child(3) { --z: 4px;  }
.sm-books > li:nth-child(4) { --z: 14px; }
.sm-books > li:nth-child(5) { --z: 2px;  }
/* Each spine's own ink, used for the side and top faces so the depth is
   the object's own colour under light rather than a grey shadow. */
.sm-books > li:nth-child(1) .sm-book { --face: #F5A521; }
.sm-books > li:nth-child(2) .sm-book { --face: #F7E9C6; }
.sm-books > li:nth-child(3) .sm-book { --face: #14140F; }
.sm-books > li:nth-child(4) .sm-book { --face: #C2410C; }
.sm-books > li:nth-child(5) .sm-book { --face: #FFFFFF; }

.sm-book {
  --d: clamp(10px, 1.35vw, 20px);
  position: relative;
  display: flex;
  height: 100%;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  border-radius: 12px 12px 5px 5px;
  padding: 14px 2px 16px;
  text-decoration: none;
  transform-style: preserve-3d;
  transform: translateZ(var(--z, 0px));
  box-shadow: 0 26px 34px -26px rgba(20, 20, 15, 0.55);
  transition: transform 0.45s cubic-bezier(0.22, 1, 0.36, 1),
              box-shadow 0.45s ease, opacity 0.35s ease;
}
/* The two folded faces. Both sit behind the front plane, so they only ever
   read as thickness. */
.sm-book-side,
.sm-book-top {
  position: absolute;
  pointer-events: none;
  background: var(--face, #E9E3D3);
}
.sm-book-side {
  top: 0;
  right: 0;
  width: var(--d);
  height: 100%;
  transform-origin: 100% 50%;
  transform: rotateY(-90deg);
  border-radius: 0 3px 3px 0;
  /* Turned away from the light, so it darkens toward the back edge. */
  background-image: linear-gradient(to left, rgba(20, 20, 15, 0.38), rgba(20, 20, 15, 0.16));
}
.sm-book-top {
  top: 0;
  left: 0;
  width: 100%;
  height: var(--d);
  transform-origin: 50% 0;
  transform: rotateX(-90deg);
  border-radius: 3px 3px 0 0;
  /* Facing the light, so it lifts. */
  background-image: linear-gradient(to bottom, rgba(255, 255, 255, 0.34), rgba(255, 255, 255, 0.08));
}
/* The front face's own light: a soft highlight at the top-left shoulder
   falling to a faint shade at the bottom-right. */
.sm-book-lit {
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  background-image: linear-gradient(148deg, rgba(255, 255, 255, 0.26) 0%, rgba(255, 255, 255, 0.05) 38%, rgba(20, 20, 15, 0.06) 72%, rgba(20, 20, 15, 0.14) 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28), inset -1px 0 0 rgba(20, 20, 15, 0.1);
}
/* Contact shadow: laid flat on the ground at the slab's foot. */
.sm-book::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: -8%;
  width: 116%;
  height: 54px;
  transform-origin: 50% 100%;
  transform: rotateX(90deg);
  background-image: radial-gradient(52% 58% at 50% 6%, rgba(20, 20, 15, 0.4) 0%, rgba(20, 20, 15, 0.14) 46%, rgba(20, 20, 15, 0) 76%);
  pointer-events: none;
  transition: opacity 0.45s ease;
}
.sm-book:hover,
.sm-book:focus-visible {
  transform: translate3d(0, -10px, calc(var(--z, 0px) + 30px)) rotateY(-2deg);
  box-shadow: 0 40px 46px -28px rgba(20, 20, 15, 0.6);
}
.sm-book:focus-visible { outline: 3px solid #14140F; outline-offset: 5px; }
/* One spine forward means the other four step back. */
.sm-books:hover > li:not(:hover) .sm-book { opacity: 0.8; }

.sm-book-label,
.sm-book-foot { transform: translateZ(0.6px); }
.sm-book-label {
  min-height: 0;
  overflow: hidden;
  writing-mode: vertical-rl;
  transform: translateZ(0.6px) rotate(180deg);
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  white-space: nowrap;
  opacity: 0.72;
  -webkit-font-smoothing: antialiased;
}
/* A phone's spine is too narrow for the full name; it carries the short one. */
.sm-short { display: none; }
@media (max-width: 639.98px) { .sm-long { display: none; } .sm-short { display: inline; } }
.sm-book-foot { display: flex; flex-direction: column; align-items: center; line-height: 1; }
.sm-book-cls { font-size: 0.8125rem; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; opacity: 0.7; }
.sm-book-num {
  margin-top: 6px;
  font-family: 'Sora', system-ui, sans-serif;
  font-size: clamp(1.55rem, 3.4vw, 2.7rem);
  font-weight: 200;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
}

/* The shelf itself: a very shallow platform. Its front lip is the line the
   spines used to stand on; the plane behind it is the ground they sit on,
   fading out before it reaches the horizon. */
.sm-ground {
  position: relative;
  height: clamp(56px, 8vw, 96px);
  margin-top: -1px;
  transform-style: preserve-3d;
  transform-origin: 50% 0;
  transform: rotateX(90deg);
  background-image: linear-gradient(to bottom, rgba(226, 219, 201, 0.98) 0%, rgba(230, 223, 206, 0.6) 40%, rgba(233, 227, 211, 0) 100%);
}
.sm-ground::before {
  content: '';
  position: absolute;
  inset-inline: 0;
  top: 0;
  height: 12px;
  transform-origin: 50% 0;
  transform: rotateX(-90deg);
  border-radius: 0 0 6px 6px;
  background: #E9E3D3;
  box-shadow: 0 12px 22px -12px rgba(20, 20, 15, 0.45);
}

@keyframes sm-rise {
  from { opacity: 0; transform: translate3d(0, 26px, -60px); }
  to   { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: no-preference) {
  .sm-shelf.is-swap .sm-books > li { animation: sm-rise 0.5s cubic-bezier(0.2, 0.7, 0.3, 1) both; animation-delay: calc(var(--i, 0) * 55ms); }
}

/* Tablet: the same set, shot from further back with less turn. */
@media (max-width: 1023.98px) {
  .sm-scene { perspective: 1900px; }
  .sm-stage { transform: rotateX(2deg) rotateY(-4deg); }
}
/* Phone: five slabs across a phone would be slivers, so the shelf becomes
   a scrollable run of proper spines. The scroll lives on the camera, which
   keeps the stage's 3D space intact. */
@media (max-width: 639.98px) {
  .sm-scene {
    perspective: 1000px;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 4px;
    margin-inline: -5%;
    padding-inline: 5%;
  }
  .sm-scene::-webkit-scrollbar { display: none; }
  .sm-stage { transform: rotateX(2deg) rotateY(-3deg); min-width: max-content; }
  .sm-books { gap: 12px; padding-inline: 0; }
  .sm-books > li { flex: 0 0 auto; width: 92px; scroll-snap-align: center; }
  .sm-ground { height: 48px; }
}

@media (prefers-reduced-motion: reduce) {
  .sm-book, .res-index-go { transition: none !important; }
  /* Depth stays; the movement goes. */
  .sm-book:hover, .sm-book:focus-visible { transform: translate3d(0, 0, var(--z, 0px)); }
}
