/* More Power — flip book experience */

@font-face {
  font-family: 'Feature Deck';
  src: url('../fonts/FeatureDeck-Regular-Web.woff2') format('woff2');
  font-weight: 400;
  font-display: block;
}
@font-face {
  font-family: 'Aeonik Pro';
  src: url('../fonts/aeonikpro-regular.otf') format('opentype');
  font-weight: 400;
  font-display: block;
}
@font-face {
  font-family: 'Aeonik Pro';
  src: url('../fonts/aeonikpro-medium.otf') format('opentype');
  font-weight: 500;
  font-display: block;
}
@font-face {
  font-family: 'ABC Social Mono';
  src: url('../fonts/ABCSocialMono-Regular.otf') format('opentype');
  font-weight: 400;
  font-display: block;
}

:root {
  --orange: #F66F00;
  --yellow: #FCCC3C;
  --beige: #FFF7E9;
  --black: #111111;
  --brown: #4C2806;
  --ink: #FFF7E9;
  --ink-soft: rgb(255 247 233 / 0.75);
  --hairline: rgb(255 247 233 / 0.25);
  --accent: #FFF7E9;
  --ease-reveal: cubic-bezier(0.16, 1.08, 0.38, 0.98);
  --ease-hover: cubic-bezier(0.4, 0, 0.2, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; }

body {
  font-family: 'Aeonik Pro', system-ui, sans-serif;
  letter-spacing: -0.02em;
  background-color: #F66F00;
  color: var(--ink);
  overflow: hidden;
}

/* the room: the orange motion gradient — the same mux grain clip as
   godaylight.com, played plain over flat #F66F00 (the low-power fallback) */
#motionBg {
  position: fixed;
  inset: 0;
  z-index: 0;
  background: #F66F00;
}
#motionBg video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* chrome */
#chrome-top {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 32px 48px 0;
}

.logo { display: block; color: var(--ink); }
.logo svg { height: 24px; width: auto; display: block; }
.logo svg path { fill: currentColor; }

/* stage */
#stage {
  position: relative;
  z-index: 10;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 76px 0 96px;
}

#bookWrap {
  position: relative;
  width: min(86vw, calc((100dvh - 280px) * 1.3333));
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 1000ms var(--ease-reveal), transform var(--cam-ms, 1000ms) var(--cam-ease, var(--ease-reveal));
}
body.reading #bookWrap { opacity: 1; transform: translateX(var(--book-shift, 0%)); }

/* layered cast shadow: one contact layer, two key layers, one wide ambient.
   It tracks the visible book — half-width when a lone cover parks on one side. */
#bookShadow {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: -1;
  border-radius: 2px;
  box-shadow:
    0 2px 6px rgb(17 17 17 / 0.16),
    0 12px 28px rgb(17 17 17 / 0.17),
    0 32px 72px rgb(17 17 17 / 0.2),
    0 64px 140px rgb(17 17 17 / 0.16);
  transition: left 1000ms var(--ease-reveal), right 1000ms var(--ease-reveal);
}
body.at-cover #bookShadow { left: 50%; }
body.at-back #bookShadow { right: 50%; }

#book { width: 100%; }

.page { overflow: hidden; }
.page img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
}

#hint {
  margin-top: 26px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink-soft);
  opacity: 0;
  transition: opacity 800ms var(--ease-reveal);
}
body.reading #hint.show { opacity: 1; }
.hint-touch { display: none; }

/* chapter rail */
#chapters {
  position: fixed;
  bottom: 88px;
  left: 0;
  right: 0;
  z-index: 20;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  column-gap: 32px;
  row-gap: 8px;
  padding: 0 32px;
  opacity: 0;
  transition: opacity 1000ms var(--ease-reveal);
}
body.reading #chapters { opacity: 1; }

.chapter {
  font-family: 'Aeonik Pro', system-ui, sans-serif;
  font-size: 13px;
  font-weight: 400;
  letter-spacing: -0.02em;
  color: var(--ink);
  opacity: 0.7;
  background: none;
  border: none;
  cursor: pointer;
  transition: opacity 150ms var(--ease-hover);
}
.chapter:hover { opacity: 1; }
.chapter.active { font-weight: 500; opacity: 1; }
.chapter .num { opacity: 0.7; margin-right: 7px; }

/* end actions */
#endRow {
  position: fixed;
  bottom: 132px;
  left: 0;
  right: 0;
  z-index: 21;
  display: flex;
  justify-content: center;
  gap: 12px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 800ms var(--ease-reveal), visibility 0s 800ms;
}
#endRow.show { opacity: 1; visibility: visible; transition: opacity 800ms var(--ease-reveal); }

/* when the lone back cover sits centered, the closing actions stand 48px off
   its right edge, centered on the book's height (app.js sets --book-right and
   --book-mid). Embedded, Read again stands alone and hugs its label; the
   standalone pair keeps one width */
body.at-back #endRow.show {
  bottom: auto;
  right: auto;
  left: calc(var(--book-right, 75vw) + 48px);
  top: var(--book-mid, 50%);
  transform: translateY(-50%);
  flex-direction: column;
  align-items: stretch;
}
body.at-back:not(.embed) #endRow.show .btn { min-width: 200px; }

/* Read again (app.js): the button leaves first and the closed book fades out,
   so the jump back to the front cover happens out of sight, then the cover
   rises in on the #bookWrap reveal above */
body.restarting #endRow {
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms var(--ease-hover);
}
body.restarting #bookWrap {
  opacity: 0;
  transform: translateX(var(--book-shift, 0%)) translateY(10px);
  transition: opacity 450ms var(--ease-hover), transform 450ms var(--ease-hover);
}
body.no-anim #bookWrap,
body.no-anim #bookShadow,
body.no-anim #endRow { transition: none; }

/* bottom footer — the book's own leader-line motif */
#chrome-bottom {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 20px;
  padding: 0 32px 26px;
}

.mono {
  font-family: 'ABC Social Mono', 'SF Mono', monospace;
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  line-height: 1.35;
  color: var(--ink);
}
#chrome-bottom .mono { opacity: 0.78; }

#leader {
  position: relative;
  height: 3px;
  color: var(--ink);
}
#leader::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle at 1.5px 1.5px, currentColor 1.2px, transparent 1.7px);
  background-size: 10px 3px;
  background-repeat: repeat-x;
  opacity: 0.32;
}
#leaderFill {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 0%;
  color: var(--accent);
  background-image: radial-gradient(circle at 1.5px 1.5px, currentColor 1.2px, transparent 1.7px);
  background-size: 10px 3px;
  background-repeat: repeat-x;
}

/* embedded on godaylight.com (?embed=1): the host page supplies the chrome,
   so the book's own logo and site link stay out of the room */
body.embed #chrome-top { display: none; }
body.embed #endRow .btn-yellow { display: none; }
body.embed #chapters {
  top: 112px;
  bottom: auto;
}
body.embed #stage { padding: 132px 0 48px; }

/* buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 50px;
  padding: 0 24px;
  border-radius: 4px;
  border: 1px solid rgb(255 247 233 / 0.25);
  font-family: 'Aeonik Pro', system-ui, sans-serif;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -0.02em;
  text-decoration: none;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgb(17 17 17 / 0.07);
  opacity: 0;
  transition: opacity 300ms var(--ease-reveal);
}
.btn:hover::after { opacity: 1; }

.btn-yellow { background: var(--yellow); color: #111111; }
.btn-beige { background: var(--beige); color: #111111; }

/* the homepage hero CTA hover (Intro.tsx): a #111111 block sweeps up from below,
   tilting from 15 to 8 degrees, and the label turns white and lifts 1px. No
   border, so the black reaches the edge like the hero's */
.btn-sweep { border: 0; }
.btn-sweep::after { content: none; }
.btn-sweep .btn-label {
  position: relative;
  z-index: 2;
  transition: color 300ms var(--ease-reveal);
}
.btn-sweep .btn-fill {
  position: absolute;
  inset: 0;
  border-radius: 8px;
  background: var(--black);
  transform-origin: center;
  translate: 0 200%;
  rotate: 15deg;
  scale: 1.8;
  transition: translate 1000ms var(--ease-reveal), rotate 1000ms var(--ease-reveal);
}
@media (hover: hover) {
  .btn-sweep:hover .btn-label { color: #ffffff; translate: 0 -1px; }
  .btn-sweep:hover .btn-fill { translate: 0 0; rotate: 8deg; }
}

button:focus:not(:focus-visible), a:focus:not(:focus-visible) { outline: none; }
button:focus-visible, a:focus-visible { outline: 2px solid var(--beige); outline-offset: 2px; }

/* standalone desktop: the chapter rail rides the logo's line at the top, so
   the book takes the height the bottom rail used to hold */
@media (min-width: 761px) {
  body:not(.embed) #chapters { top: 36px; bottom: auto; padding: 0 240px; }
  body:not(.embed) #stage { padding: 80px 0; }
  body:not(.embed) #bookWrap { width: min(90vw, calc((100dvh - 196px) * 1.3333)); }
  /* hint floats under the book so it never pushes the book off the middle */
  body:not(.embed) #hint { position: absolute; left: 0; right: 0; margin: 0; text-align: center; top: calc(50% + min(33.75vw, (100dvh - 196px) / 2) + 16px); }
}
/* too narrow to share the line with the logo: the rail drops under it */
@media (min-width: 761px) and (max-width: 1100px) {
  body:not(.embed) #chapters { top: 76px; padding: 0 32px; }
  body:not(.embed) #stage { padding: 108px 0; }
  body:not(.embed) #bookWrap { width: min(90vw, calc((100dvh - 224px) * 1.3333)); }
  body:not(.embed) #hint { top: calc(50% + min(33.75vw, (100dvh - 224px) / 2) + 16px); }
}

@media (max-width: 760px) {
  #chrome-top { padding: 20px 20px 0; }
  #chrome-bottom { padding: 0 20px 18px; grid-template-columns: auto 1fr auto; gap: 12px; }
  /* the chapter rail sits at the top, under the logo, like the /about embed */
  #chapters { top: 72px; bottom: auto; column-gap: 18px; }
  .chapter .name { display: none; }
  .hint-desk { display: none; }
  .hint-touch { display: inline; }
  .chapter.active .name { display: inline; }
  /* the spread runs past the screen edges, so the stage clips it, or the page
     itself grows wider than the phone */
  #stage { padding: 104px 0 70px; touch-action: pan-y; overflow: hidden; }
  /* the open spread, wider than the screen: one page is the screen width less
     a 20px margin and a 50px peek of the facing page (app.js, phoneShift),
     inside the same height budget the single page had, so on a short phone
     (iPhone SE) the book shrinks and Read again fits under the back cover.
     Never under the engine's 2 x 160px minimum, or its pages outgrow this box. */
  #bookWrap { width: max(320px, min(calc((100vw - 70px) * 2), calc((100dvh - 260px) * 1.3333))); }
  /* sliding to the facing page answers the swipe right away; following a
     turning page takes the turn's own time */
  body { --cam-ms: 550ms; --cam-ease: cubic-bezier(0.22, 1, 0.36, 1); }
  body.cam-turn { --cam-ms: 850ms; --cam-ease: cubic-bezier(0.45, 0, 0.2, 1); }
  /* the closed back cover fills the screen width, so the closing actions sit
     under it where the hint was, kept clear of the footer (app.js sets
     --book-bottom) */
  body.at-back #endRow.show {
    top: min(calc(var(--book-bottom, 70dvh) + 26px), calc(100dvh - 100px));
    bottom: auto;
    left: 0;
    right: 0;
    transform: none;
    flex-direction: row;
  }
  body.at-back:not(.embed) #endRow.show .btn { min-width: 0; }
  body.embed #chapters {
    top: 84px;
    bottom: auto;
  }
  body.embed #stage { padding: 88px 0 40px; }
}
