/* ==========================================================================
   v357 · THE OPENING, AS ONE PIECE OF FILM
   --------------------------------------------------------------------------
   One timeline, one tempo, one ending. The little book (Pip) drops, lands,
   blinks, looks around, hops, opens, and then settles above the name while
   the full wordmark sets beneath it in the same serif as the brand. The
   frame is held, then the yellow field lifts and the app is underneath.

   Rules kept from v353:
   - only transform, opacity and clip-path are animated, so the compositor
     does the work while the app boots behind the field;
   - nothing is removed by a promise from the app, only by the timeline or
     by the reader touching the screen;
   - reduced motion gets a short, still version of the same frame.
   ========================================================================== */

#tsbSplash {
  position: fixed; inset: 0; z-index: 2147483600;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  overflow: hidden;
  background:
    radial-gradient(120% 78% at 50% 14%, #FFE07A 0%, #FFC800 44%, #E8AD00 100%);
  transform: translateZ(0);
  will-change: clip-path, opacity;
}
html.tsb-nosplash #tsbSplash { display: none !important; }

/* the field: a still grain and a soft vignette, no repaint per frame */
#tsbSplash .sp-grain {
  position: absolute; inset: -4%;
  pointer-events: none; opacity: .14;
  background-image:
    radial-gradient(rgba(22,19,15,.55) .6px, transparent .7px),
    radial-gradient(rgba(255,255,255,.55) .6px, transparent .7px);
  background-size: 7px 7px, 11px 11px;
  background-position: 0 0, 3px 5px;
}
#tsbSplash .sp-vig {
  position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(120% 90% at 50% 42%, transparent 52%, rgba(122,84,0,.20) 100%);
}

/* ---------- what will sit under the name ---------- */
#tsbSplash .sp-shelf {
  position: absolute; left: 0; right: 0; bottom: -12px;
  width: min(118%, 260px); height: 5px;
  margin: 0 auto;
  border-radius: 999px;
  /* a shelf, not a block: it tapers to nothing at both ends */
  background: linear-gradient(90deg, rgba(22,19,15,0) 0%, #16130F 14%, #16130F 86%, rgba(22,19,15,0) 100%);
  box-shadow: 0 14px 26px -12px rgba(22,19,15,.45);
  transform-origin: 50% 50%;
  opacity: 0;
  animation: spShelfIn .46s cubic-bezier(.22,.9,.24,1) var(--sp-shelf, .12s) both;
}
@keyframes spShelfIn {
  0%   { opacity: 0; transform: scaleX(.18) }
  62%  { opacity: 1; transform: scaleX(1.04) }
  100% { opacity: 1; transform: scaleX(1) }
}

/* the ground the book sits on: a soft contact shadow, so the field has depth */
#tsbSplash .sp-shadow {
  position: absolute; left: 0; right: 0; bottom: -10px;
  width: min(96%, 210px); height: 18px; margin: 0 auto;
  border-radius: 50%;
  background: radial-gradient(ellipse at 50% 50%, rgba(22,19,15,.16) 0%, rgba(22,19,15,.06) 46%, transparent 72%);
  opacity: 0;
  animation: spShadow .9s cubic-bezier(.2,.8,.3,1) var(--sp-shelf, .12s) both;
}
@keyframes spShadow { 0% { opacity: 0; transform: scale(.4) } 100% { opacity: 1; transform: scale(1) } }
#tsbSplash .sp-stage {
  position: relative; flex: none;
  width: min(52vw, 178px); height: min(66vw, 226px);
  perspective: 900px; transform-style: preserve-3d;
  margin-bottom: min(13vw, 46px);
}
#tsbSplash .sp-glow {
  position: absolute; left: 50%; top: 50%;
  width: min(104vw, 460px); height: min(104vw, 460px);
  margin: min(-52vw, -230px) 0 0 min(-52vw, -230px);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,.52) 0%, rgba(255,255,255,.14) 44%, transparent 70%);
  opacity: 0; pointer-events: none;
  animation: spGlowIn .8s cubic-bezier(.22,.8,.3,1) var(--sp-glow, 0s) both;
}
@keyframes spGlowIn { 0% { opacity: 0; transform: scale(.78) } 100% { opacity: 1; transform: none } }

#tsbSplash .sp-pip {
  position: absolute; inset: 0;
  transform-style: preserve-3d;
  animation:
    spPipIn   .86s cubic-bezier(.16,.86,.24,1) var(--sp-drop, .14s) both,
    spPipHop  .56s cubic-bezier(.3,.82,.3,1) var(--sp-hop, 1.28s) both,
    spPipRise .52s cubic-bezier(.32,.86,.26,1) var(--sp-rise, 1.62s) both;
}
@keyframes spPipIn {
  0%   { opacity: 0; transform: translate3d(-26%, -168%, 0) rotate(-20deg) scale(.74) }
  26%  { opacity: 1; transform: translate3d(-5%, 3%, 0) rotate(5deg) scale(1.02) }
  38%  { transform: translate3d(0, 5%, 0) rotate(-2deg) scale(1.15, .85) }
  52%  { transform: translate3d(0, -6%, 0) rotate(1deg) scale(.94, 1.07) }
  68%  { transform: translate3d(0, 2%, 0) rotate(-1deg) scale(1.05, .96) }
  84%  { transform: translate3d(0, -1%, 0) scale(.985, 1.015) }
  100% { opacity: 1; transform: none }
}
@keyframes spPipHop {
  0%   { transform: translateY(0) }
  20%  { transform: translateY(2px) scale(1.04,.96) }
  46%  { transform: translateY(-20px) scale(.975,1.025) }
  74%  { transform: translateY(1px) scale(1.045,.955) }
  100% { transform: translateY(0) }
}
/* Pip gives the frame to the name: it rises and shrinks, it does not vanish */
@keyframes spPipRise {
  0%   { transform: none }
  70%  { transform: translateY(-14px) scale(.88) }
  100% { transform: translateY(-18px) scale(.84) }
}

#tsbSplash .sp-body {
  position: absolute; inset: 0;
  transform-origin: 50% 100%; transform-style: preserve-3d;
  filter: drop-shadow(0 12px 14px rgba(22,19,15,.24));
}
#tsbSplash .sp-cover {
  position: absolute; inset: 0;
  border-radius: 3px 10px 10px 3px;
  background:
    linear-gradient(160deg, rgba(255,255,255,.14) 0 18%, transparent 42%),
    linear-gradient(175deg, #1E1A15 0%, #16130F 62%, #241F18 100%);
  box-shadow: inset 3px 0 0 #FFC800, inset 0 0 0 1.5px rgba(255,255,255,.08);
  overflow: hidden;
}
#tsbSplash .sp-cover::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background:
    linear-gradient(90deg, rgba(255,220,120,.30) 0%, transparent 22%),
    radial-gradient(120% 60% at 50% -10%, rgba(255,255,255,.16), transparent 60%);
}
#tsbSplash .sp-spine {
  position: absolute; left: 0; top: 0; bottom: 0; width: 7%;
  background: linear-gradient(90deg, #000 0%, #2A241C 60%, #16130F 100%);
  border-radius: 3px 0 0 3px;
}
#tsbSplash .sp-leaves {
  position: absolute; right: -5px; top: 3%; bottom: 2%; width: 9px;
  border-radius: 2px 6px 6px 2px;
  background: repeating-linear-gradient(90deg, #F7F1E2 0 1.6px, #E7DFCC 1.6px 3px);
  box-shadow: 2px 3px 8px rgba(22,19,15,.26);
  transform-origin: 0 50%;
  animation: spLeaves .68s cubic-bezier(.22,.9,.24,1) var(--sp-open, 1.34s) both;
}
@keyframes spLeaves {
  0%   { transform: rotateY(0) }
  62%  { transform: rotateY(-24deg) }
  100% { transform: rotateY(-13deg) }
}
#tsbSplash .sp-feet {
  position: absolute; left: 50%; bottom: -7px; width: 54%; height: 12px;
  margin-left: -27%; display: flex; justify-content: space-between;
  animation: spFeet .56s cubic-bezier(.3,.82,.3,1) var(--sp-hop, 1.28s) both;
}
#tsbSplash .sp-feet i {
  display: block; width: 34%; height: 100%;
  border-radius: 0 0 9px 9px; background: #16130F;
  box-shadow: inset 0 -3px 0 #2A241C;
}
@keyframes spFeet {
  0%, 100% { transform: none }
  28% { transform: translateY(-4px) scaleY(.7) }
  68% { transform: translateY(2px) scaleY(1.1) }
}

/* ---------- the face ---------- */
#tsbSplash .sp-face {
  position: absolute; left: 13%; right: 13%; top: 20%; height: 40%;
  display: flex; align-items: center; justify-content: space-between;
  animation: spLook 1.05s cubic-bezier(.4,0,.3,1) var(--sp-look, .96s) both;
}
@keyframes spLook {
  0%   { transform: none }
  22%  { transform: translateX(-5px) rotate(-2.5deg) }
  56%  { transform: translateX(6px) rotate(2.5deg) }
  80%  { transform: translateY(-3px) rotate(0) }
  100% { transform: none }
}
#tsbSplash .sp-eye {
  position: relative; display: block; width: 44%; aspect-ratio: 1 / 1;
  border-radius: 50%;
  background: radial-gradient(circle at 42% 34%, #FFFFFF, #FBF8F1 62%, #EFE7D4 100%);
  box-shadow: inset 0 0 0 2px #16130F, inset 0 0 0 6px #FFC800, 0 3px 9px rgba(0,0,0,.4);
  overflow: hidden;
}
#tsbSplash .sp-eye b {
  position: absolute; left: 50%; top: 50%;
  width: 44%; aspect-ratio: 1/1; margin: -22% 0 0 -22%;
  border-radius: 50%; background: #16130F;
  animation: spPupil 1.4s ease-in-out var(--sp-pupil, .3s) both;
}
@keyframes spPupil {
  0%, 100% { transform: none }
  18% { transform: translate(-20%, 9%) }
  42% { transform: translate(18%, -11%) }
  62% { transform: translate(-4%, 4%) }
  80% { transform: translate(0, -5%) }
}
#tsbSplash .sp-eye b::after {
  content: ""; position: absolute; left: 12%; top: 8%;
  width: 46%; height: 46%; border-radius: 50%; background: rgba(255,255,255,.94);
}
#tsbSplash .sp-brow {
  position: absolute; top: -22%; width: 34%; height: 5px;
  border-radius: 99px; background: #FFC800;
  box-shadow: 0 1px 0 rgba(0,0,0,.32);
}
#tsbSplash .sp-brow--l { left: 0; transform: rotate(-7deg) }
#tsbSplash .sp-brow--r { right: 0; transform: rotate(7deg) }
#tsbSplash .sp-lid {
  position: absolute; inset: -2px; border-radius: 50%;
  background: #16130F; transform-origin: 50% 0; transform: scaleY(0);
  animation: spBlink 2.4s cubic-bezier(.5,0,.5,1) var(--sp-blink, .78s) both;
}
@keyframes spBlink {
  0%, 7%, 100% { transform: scaleY(0) }
  2.5%, 4.5% { transform: scaleY(1) }
  46%, 52% { transform: scaleY(0) }
  48.5%, 50% { transform: scaleY(1) }
}
#tsbSplash .sp-mouth {
  position: absolute; left: 50%; bottom: 8%;
  width: 30%; height: 11px; margin-left: -15%;
  border-radius: 0 0 40px 40px; background: #FFC800;
  box-shadow: inset 0 -4px 0 #F0B400;
  opacity: 0;
  animation: spSmile .44s cubic-bezier(.3,1.4,.4,1) var(--sp-smile, 1.42s) both;
}
@keyframes spSmile { 0% { opacity: .3; transform: scale(.6,.45) } 100% { opacity: 1; transform: none } }
#tsbSplash .sp-bm {
  position: absolute; left: 62%; top: -2%; width: 12%; height: 26%;
  background: #FFC800;
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 74%, 0 100%);
  transform-origin: 50% 0; opacity: 0;
  animation: spBM .62s cubic-bezier(.3,1.3,.4,1) var(--sp-hop, 1.28s) both;
}
@keyframes spBM {
  0%   { opacity: 0; transform: translateY(-40%) rotate(-13deg) }
  55%  { opacity: 1; transform: translateY(0) rotate(5deg) }
  100% { opacity: 1; transform: none }
}

/* ---------- pages thrown, sparks ---------- */
#tsbSplash .sp-page {
  position: absolute; left: 50%; top: 60%;
  width: 40px; height: 54px;
  background: linear-gradient(180deg, #FFFDF7, #EFE7D4);
  border-radius: 2px;
  box-shadow: 0 8px 16px -6px rgba(22,19,15,.38);
  opacity: 0;
  animation: spPage .92s cubic-bezier(.2,.7,.3,1) var(--sp-hop, 1.28s) both;
}
#tsbSplash .sp-page::after {
  content: ""; position: absolute; inset: 10px 8px auto 8px; height: 21px;
  background: repeating-linear-gradient(180deg, #D8CFBA 0 1.5px, transparent 1.5px 6px);
}
#tsbSplash .sp-page:nth-child(1) { --dx: -70px; --rot: -32deg; --dy: -56px }
#tsbSplash .sp-page:nth-child(2) { --dx: 4px;   --rot: 11deg;  --dy: -82px }
#tsbSplash .sp-page:nth-child(3) { --dx: 74px;  --rot: 38deg;  --dy: -50px }
@keyframes spPage {
  0%   { opacity: 0; transform: translate(0,0) rotate(0) scale(.62) }
  24%  { opacity: 1 }
  100% { opacity: 0; transform: translate(var(--dx), var(--dy)) rotate(var(--rot)) scale(1) }
}
#tsbSplash .sp-spark {
  position: absolute; left: 50%; top: 46%;
  width: 7px; height: 7px; margin: -3px 0 0 -3px;
  border-radius: 50%; background: #16130F; opacity: 0;
  animation: spSpark .72s cubic-bezier(.2,.8,.3,1) var(--sp-open, 1.34s) both;
}
#tsbSplash .sp-spark:nth-child(1) { --sx: -92px; --sy: -16px }
#tsbSplash .sp-spark:nth-child(2) { --sx: 88px;  --sy: -28px }
#tsbSplash .sp-spark:nth-child(3) { --sx: -48px; --sy: 24px }
#tsbSplash .sp-spark:nth-child(4) { --sx: 54px;  --sy: 20px }
#tsbSplash .sp-spark:nth-child(5) { --sx: 0;     --sy: -98px }
@keyframes spSpark {
  0%   { opacity: 0; transform: translate(0,0) scale(.2) }
  34%  { opacity: 1 }
  100% { opacity: 0; transform: translate(var(--sx), var(--sy)) scale(.6) }
}

/* ==========================================================================
   THE NAME
   The frame the whole opening is built for: TheSmallBook, set in the same
   serif as the brand, Small in italic, tracking tightening as it lands.
   ========================================================================== */
#tsbSplash .sp-name {
  position: relative; flex: none;
  text-align: center; pointer-events: none;
  font: 400 clamp(38px, 11.4vw, 54px)/1.06 "Newsreader", Georgia, "Times New Roman", serif;
  color: #16130F;
  letter-spacing: -.015em;
  animation: spNameTrack .9s cubic-bezier(.2,.7,.2,1) var(--sp-name, 1.86s) both;
}
#tsbSplash .sp-name span {
  display: inline-block; opacity: 0;
  animation: spLetter .52s cubic-bezier(.16,1.02,.3,1) both;
  animation-delay: calc(var(--sp-name, 1.86s) + var(--i) * 26ms);
}
#tsbSplash .sp-name i {
  font-style: italic;
  font-family: "Newsreader", Georgia, "Times New Roman", serif;
  letter-spacing: 0;
  /* a light optical nudge, so Small reads as the same word set apart */
  padding: 0 .01em;
}
@keyframes spNameTrack {
  0%   { letter-spacing: .05em }
  100% { letter-spacing: -.015em }
}
@keyframes spLetter {
  0%   { opacity: 0; transform: translateY(16px); filter: blur(3px) }
  60%  { opacity: 1 }
  100% { opacity: 1; transform: none; filter: blur(0) }
}
#tsbSplash .sp-rule {
  position: relative; flex: none; margin-top: min(6vw, 20px);
  width: min(52vw, 220px); height: 1.5px;
  background: linear-gradient(90deg, transparent, rgba(22,19,15,.55) 18%, rgba(22,19,15,.55) 82%, transparent);
  transform: scaleX(0); transform-origin: 50% 50%;
  animation: spRule .62s cubic-bezier(.22,.9,.24,1) var(--sp-rule, 2.28s) both;
}
@keyframes spRule { 0% { transform: scaleX(0); opacity: 0 } 40% { opacity: 1 } 100% { transform: scaleX(1); opacity: 1 } }
#tsbSplash .sp-tag {
  position: relative; flex: none; margin-top: min(4.4vw, 14px);
  text-align: center; opacity: 0;
  font: 700 9.5px/1 "Space Grotesk", system-ui, sans-serif;
  letter-spacing: .30em; text-transform: uppercase;
  color: rgba(22,19,15,.60);
  animation: spTag .5s ease var(--sp-tag, 2.42s) both;
}
@keyframes spTag { 0% { opacity: 0; transform: translateY(6px) } 100% { opacity: 1; transform: none } }

/* the hold, then the field lifts away */
#tsbSplash.sp-lift {
  animation: spLift .62s cubic-bezier(.4,0,.6,1) both;
  pointer-events: none;
}
@keyframes spLift {
  0%   { opacity: 1; clip-path: inset(0 0 0 0) }
  100% { opacity: 1; clip-path: inset(0 0 100% 0) }
}
#tsbSplash.sp-lift .sp-stage,
#tsbSplash.sp-lift .sp-name,
#tsbSplash.sp-lift .sp-rule,
#tsbSplash.sp-lift .sp-tag,
#tsbSplash.sp-lift .sp-shelf {
  animation: spGive .62s cubic-bezier(.4,0,.6,1) both;
}
@keyframes spGive {
  0%   { transform: scale(1); opacity: 1 }
  100% { transform: scale(1.045) translateY(-8px); opacity: 0 }
}

@media (prefers-reduced-motion: reduce) {
  #tsbSplash, #tsbSplash * {
    animation-duration: .01ms !important;
    animation-delay: 0s !important;
    animation-iteration-count: 1 !important;
  }
  #tsbSplash .sp-name span, #tsbSplash .sp-name, #tsbSplash .sp-rule,
  #tsbSplash .sp-tag, #tsbSplash .sp-shelf, #tsbSplash .sp-mouth { opacity: 1 !important }
  #tsbSplash .sp-grain, #tsbSplash .sp-vig { display: none }
}


/* ==========================================================================
   v391 · THE OPENING IS BACK
   v382 killed it with a display:none override and this is that override
   removed. It plays once per app open, on a cold start, and it covers the
   boot instead of the reader staring at an empty white screen. Any touch sends
   it away early, so nobody is held hostage by it. To retime it, edit SCORE at
   the top of js/splash.js, every delay is one number there.

/* ==========================================================================
   v391 · THE LOADING LINE
   The markup has carried <div class="sp-bar"><i></i></div> since the opening
   was written and no rule ever drew it, so the wait had nothing to show for
   itself. A hairline that fills while the app boots behind the field, gone the
   moment the field lifts. It is the quiet "we are nearly there", not a spinner.
   ========================================================================== */
#tsbSplash .sp-bar {
  position: relative;
  width: 148px; height: 2px;
  margin: 30px auto 0;
  border-radius: 2px;
  background: rgba(22, 19, 15, .16);
  overflow: hidden;
  opacity: 0;
  animation: spBarIn .5s ease var(--sp-name, 1.15s) both;
}
#tsbSplash .sp-bar i {
  position: absolute; top: 0; bottom: 0; left: 0;
  width: 0;
  border-radius: 2px;
  background: #16130F;
  animation: spBarFill 3.1s cubic-bezier(.32, .08, .24, 1) var(--sp-name, 1.15s) both;
}
@keyframes spBarIn { from { opacity: 0 } to { opacity: 1 } }
@keyframes spBarFill {
  0%   { width: 0 }
  55%  { width: 62% }
  100% { width: 100% }
}
@media (prefers-reduced-motion: reduce) {
  #tsbSplash .sp-bar { animation: none; opacity: 1 }
  #tsbSplash .sp-bar i { animation: none; width: 100% }
}

/* ==========================================================================
   v391 · THE QUIET OPENING
   The field, the name and the line. No character, nothing to watch twice.
   ========================================================================== */
#tsbSplash .spx {
  position: relative;
  display: flex; flex-direction: column; align-items: center;
  text-align: center;
  color: #16130F;
}
#tsbSplash .spx-mark {
  width: 46px; height: 46px;
  opacity: 0; transform: translateY(10px);
  animation: spxIn .8s cubic-bezier(.22,.9,.24,1) .06s both;
}
#tsbSplash .spx-name {
  margin-top: 22px;
  font: 400 clamp(31px, 9.4vw, 46px)/1 "Newsreader", Georgia, serif;
  letter-spacing: -.02em;
  opacity: 0; transform: translateY(12px);
  animation: spxIn .9s cubic-bezier(.22,.9,.24,1) .18s both;
}
#tsbSplash .spx-name i { font-style: italic }
#tsbSplash .spx-rule {
  height: 1px; width: 0; margin-top: 20px;
  background: rgba(22,19,15,.26);
  animation: spxRule .8s cubic-bezier(.3,.8,.3,1) .42s both;
}
#tsbSplash .spx-tag {
  margin-top: 15px;
  font: 600 10.5px/1 "Space Grotesk", system-ui, sans-serif;
  letter-spacing: .24em; text-transform: lowercase;
  color: rgba(22,19,15,.6);
  opacity: 0;
  animation: spxIn .7s ease .56s both;
}
@keyframes spxIn { from { opacity: 0; transform: translateY(12px) } to { opacity: 1; transform: none } }
@keyframes spxRule { from { width: 0; opacity: 0 } to { width: 104px; opacity: 1 } }
@media (prefers-reduced-motion: reduce) {
  #tsbSplash .spx-mark, #tsbSplash .spx-name, #tsbSplash .spx-tag {
    animation: none !important; opacity: 1 !important; transform: none !important;
  }
  #tsbSplash .spx-rule { animation: none !important; opacity: 1 !important; width: 104px }
}
