/* Stax Planner — the open paper planner in the home page's hero
   (includes/planner-book.php, assets/js/planner-book.js). Loaded
   after the design's own stylesheet, which sets the colours and fonts. A
   design re-colours the book with the --book-* properties below.

   The book is drawn once, 594 units wide, and scales as one piece with the
   room it has: inside it, one --u is one pixel at full width. Sizes are
   written calc(N * var(--u)); hairlines and the page-edge steps stay in
   pixels so they never thin away. */

/* ---------- The open planner ---------- */
.p-book {
  --book-tilt-x: 13deg;
  --book-tilt-z: -4deg;
  --book-cover: linear-gradient(135deg, #24493c, #17352b 55%, #10271f);
  --book-stitch: rgba(214, 173, 98, 0.6);
  --book-ribbon: linear-gradient(90deg, #174a37, #2a7356 35%, #2a7356 65%, #174a37);
  --book-edge: 0 0 0 0 transparent;
  --book-shadow: drop-shadow(0 50px 50px rgba(60, 40, 10, 0.3)) drop-shadow(0 8px 10px rgba(60, 40, 10, 0.18));
  --book-stamp: var(--gold);
  position: relative; aspect-ratio: 594 / 620; container-type: inline-size; perspective: 1800px;
  animation: p-book-in 1.3s var(--ease) both;
}
@keyframes p-book-in { from { opacity: 0; transform: translateY(28px); } }
/* The lean toward the pointer (--book-lean-*) is set by planner-book.js. */
.p-spread {
  --u: calc(100cqw / 594);
  position: absolute; inset: calc(40 * var(--u)) calc(34 * var(--u)) calc(46 * var(--u)) calc(14 * var(--u));
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  transform: rotateX(calc(var(--book-tilt-x) + var(--book-lean-x, 0deg))) rotateY(var(--book-lean-y, 0deg)) rotateZ(var(--book-tilt-z));
  filter: var(--book-shadow);
}
/* The leather cover the pages lie in: stitched edge, and a dip at the spine. */
.p-cover {
  position: absolute; inset: calc(-13 * var(--u)) calc(-15 * var(--u)) calc(-16 * var(--u)); z-index: -2; border-radius: calc(11 * var(--u));
  background: var(--book-cover);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14), inset 0 0 0 1px rgba(255, 255, 255, 0.05), inset 0 -3px 0 rgba(0, 0, 0, 0.3);
}
.p-cover::before { content: ""; position: absolute; inset: 5px; border-radius: calc(7 * var(--u)); border: 1.5px dashed var(--book-stitch); }
.p-cover::after { content: ""; position: absolute; top: 0; bottom: 0; left: 50%; width: calc(30 * var(--u)); margin-left: calc(-15 * var(--u)); background: linear-gradient(90deg, transparent, rgba(0, 0, 0, 0.4), transparent); }
.p-page {
  position: relative; padding: calc(44 * var(--u)) calc(31 * var(--u)) calc(30 * var(--u));
  background-color: var(--paper-hi);
  background-image: repeating-linear-gradient(transparent 0 calc(34 * var(--u) - 1px), rgba(31, 90, 67, 0.12) calc(34 * var(--u) - 1px) calc(34 * var(--u)));
  background-position: 0 calc(68 * var(--u));
  color: var(--ink);
}
/* Each page: the shade of the gutter, the design's edge line, and the cut
   edges of the pages stacked under it. */
.p-left {
  border-radius: calc(6 * var(--u)) 0 0 calc(6 * var(--u));
  box-shadow: inset -1px 0 0 rgba(0, 0, 0, 0.1), inset calc(-30 * var(--u)) 0 calc(34 * var(--u)) calc(-22 * var(--u)) rgba(0, 0, 0, 0.26), inset var(--book-edge),
    -1px 1px 0 #e4dcc8, -2px 2px 0 #fcf8ee, -3px 3px 0 #ddd4be, -4px 4px 0 #f6f0e2, -5px 5px 0 #d3c9b1;
}
.p-right {
  border-radius: 0 calc(6 * var(--u)) calc(6 * var(--u)) 0;
  box-shadow: inset 1px 0 0 rgba(0, 0, 0, 0.1), inset calc(30 * var(--u)) 0 calc(34 * var(--u)) calc(-22 * var(--u)) rgba(0, 0, 0, 0.26), inset var(--book-edge),
    1px 1px 0 #e4dcc8, 2px 2px 0 #fcf8ee, 3px 3px 0 #ddd4be, 4px 4px 0 #f6f0e2, 5px 5px 0 #d3c9b1;
}
.p-day { display: flex; justify-content: space-between; align-items: baseline; border-bottom: 1px solid var(--ink); padding-bottom: calc(8 * var(--u)); }
.p-day b { font-family: var(--serif); font-weight: 400; font-size: calc(48 * var(--u)); line-height: 1; }
.p-day > span { font-size: calc(10.5 * var(--u)); letter-spacing: 0.25em; text-transform: uppercase; color: var(--muted); white-space: nowrap; padding-left: calc(8 * var(--u)); }
/* A word in place of the day's number is set smaller, to fit the page. */
.p-day-word b { font-size: calc(32 * var(--u)); line-height: calc(48 * var(--u)); }
.p-day-word > span { letter-spacing: 0.1em; }
.p-slot { display: flex; gap: calc(16 * var(--u)); height: calc(34 * var(--u)); align-items: center; }
.p-slot time { width: calc(40 * var(--u)); color: var(--muted); font-size: calc(12 * var(--u)); font-variant-numeric: tabular-nums; }
.p-slot em { font-family: var(--hand); font-style: normal; font-size: calc(22 * var(--u)); color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.p-mark { width: calc(6 * var(--u)); height: calc(22 * var(--u)); border-radius: 2px; }
.p-emerald { background: var(--emerald-2); }
.p-gold { background: var(--gold-soft); }
.p-sage { background: var(--sage); }
.p-ink { background: var(--ink); }
.p-cream { background: var(--cream); }
.p-right h3 { font-family: var(--serif); font-size: calc(25 * var(--u)); letter-spacing: -0.01em; height: calc(34 * var(--u)); line-height: calc(34 * var(--u)); margin-top: calc(-6 * var(--u)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.p-written { font-family: var(--hand); font-size: calc(22 * var(--u)); line-height: calc(34 * var(--u)); color: var(--ink-2); }
.p-check { display: flex; gap: calc(12 * var(--u)); align-items: center; font-family: var(--hand); font-size: calc(22 * var(--u)); height: calc(34 * var(--u)); white-space: nowrap; overflow: hidden; }
.p-check i { width: calc(16 * var(--u)); height: calc(16 * var(--u)); border: 1.5px solid var(--ink); border-radius: 3px; position: relative; flex: none; }
.p-done { color: var(--faint); text-decoration: line-through; }
.p-done i::after { content: ""; position: absolute; left: 19%; top: -19%; width: 38%; height: 75%; border: solid var(--emerald); border-width: 0 calc(2.5 * var(--u)) calc(2.5 * var(--u)) 0; transform: rotate(40deg); }
.p-check small { margin-left: auto; padding-left: calc(10 * var(--u)); font-family: var(--sans); font-size: calc(11 * var(--u)); font-weight: 600; color: var(--muted); }
.p-sub { padding-left: calc(26 * var(--u)); }
.p-urgent i { border-color: var(--gold); }
.p-urgent small { color: var(--gold); }
.p-aside { font-size: calc(19 * var(--u)) !important; color: var(--muted) !important; transform: rotate(-2deg); }
.p-sealed { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: calc(12.5 * var(--u)); line-height: calc(34 * var(--u)); letter-spacing: 0.06em; color: var(--emerald); word-break: break-all; }
.p-month { display: grid; grid-template-columns: repeat(7, 1fr); row-gap: calc(6 * var(--u)); margin-top: calc(14 * var(--u)); text-align: center; }
.p-month > span { font-size: calc(10 * var(--u)); letter-spacing: 0.1em; color: var(--muted); }
.p-month i { position: relative; font-style: normal; font-family: var(--hand); font-size: calc(20 * var(--u)); line-height: calc(28 * var(--u)); color: var(--ink-2); }
.p-month i.d::after { content: ""; position: absolute; left: 50%; bottom: 0; width: calc(5 * var(--u)); height: calc(5 * var(--u)); margin-left: calc(-2.5 * var(--u)); border-radius: 50%; background: var(--gold-soft); }
.p-month i.t { color: #fffdf7; z-index: 0; }
.p-month i.t::before { content: ""; position: absolute; left: 50%; top: 50%; width: calc(30 * var(--u)); height: calc(30 * var(--u)); margin: calc(-15 * var(--u)) 0 0 calc(-15 * var(--u)); border-radius: 50%; background: var(--emerald-2); z-index: -1; }
.p-stamp {
  position: absolute; right: calc(18 * var(--u)); bottom: calc(10 * var(--u)); width: calc(108 * var(--u)); height: calc(108 * var(--u)); border-radius: 50%;
  display: grid; place-items: center; text-align: center; line-height: 1.2;
  font-family: var(--serif); font-style: italic; font-size: calc(14 * var(--u)); color: var(--book-stamp);
  border: 1px solid currentColor; outline: 1px solid currentColor; outline-offset: calc(-6 * var(--u));
  transform: rotate(-12deg); background: rgba(255, 253, 247, 0.75);
}
/* The ribbon lies in the gutter and hangs out below the cover. It stays
   above a turning leaf: at the spine the leaf is flat against the book. */
.p-ribbon {
  position: absolute; left: 50%; top: -4px; z-index: 60; width: calc(12 * var(--u)); height: calc(100% + calc(70 * var(--u))); margin-left: calc(-6 * var(--u));
  background: var(--book-ribbon);
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% calc(100% - calc(16 * var(--u))), 0 100%);
  transform-origin: 50% 0; transform: rotate(0.7deg);
}

/* ---------- Sheets and tabs (planner-book.js) ---------- */
.p-sheet { display: none; }
.p-sheet.is-on { display: block; }
/* Tucked under the page's edge, so every tab stays attached to it. */
.p-tabs { position: absolute; left: calc(100% - calc(6 * var(--u))); top: calc(54 * var(--u)); z-index: -1; display: grid; gap: calc(6 * var(--u)); justify-items: start; }
.p-tab {
  display: grid; place-items: center; width: calc(32 * var(--u)); height: calc(80 * var(--u)); padding: 0 0 0 calc(9 * var(--u)); border: 0; cursor: pointer;
  border-radius: 0 calc(8 * var(--u)) calc(8 * var(--u)) 0; box-shadow: 2px 2px calc(6 * var(--u)) rgba(0, 0, 0, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.25);
  color: #17231d; font-family: var(--sans); font-size: calc(9.5 * var(--u)); font-weight: 600; letter-spacing: 0.16em; text-transform: uppercase;
  transition: width 0.35s var(--ease), box-shadow 0.35s;
}
.p-tab.p-emerald { color: #f3ecd9; }
.p-tab > span { writing-mode: vertical-rl; white-space: nowrap; }
.p-tab:hover { width: calc(37 * var(--u)); }
.p-tab.is-on { width: calc(43 * var(--u)); box-shadow: 4px 3px calc(10 * var(--u)) rgba(0, 0, 0, 0.26), inset 0 1px 0 rgba(255, 255, 255, 0.25); }
.p-tab:focus-visible { outline: 2px solid var(--gold-soft); outline-offset: 2px; }

/* ---------- The turning leaf (planner-book.js) ----------
   A leaf is a row of strips, each hinged on the one before it, so the paper
   bends as it turns. Every strip shows its slice of the page leaving on the
   front and of the page arriving on the back. */
.p-leaf { position: absolute; pointer-events: none; perspective: calc(2400 * var(--u)); }
.p-leaf-fwd { perspective-origin: 0 50%; }
.p-leaf-rev { perspective-origin: 100% 50%; }
.p-strip { position: absolute; top: 0; height: 100%; transform-style: preserve-3d; }
.p-leaf-fwd .p-strip { transform-origin: 0 50%; }
.p-leaf-rev .p-strip { transform-origin: 100% 50%; }
/* Half a pixel wider each side, so no gap shows between strips. */
.p-face { position: absolute; top: 0; bottom: 0; left: -0.5px; right: -0.5px; overflow: hidden; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.p-face-back { transform: rotateY(180deg); }
.p-face .p-page { position: absolute; top: 0; height: 100%; }
/* The paper darkens as it turns away from the light. Each strip is given
   the shade at its spine edge (-a) and its free edge (-b), so the shading
   runs smoothly across the bend. */
.p-face::after { content: ""; position: absolute; inset: 0; background: linear-gradient(var(--book-shade-to), rgba(26, 18, 6, var(--book-shade-a, 0)), rgba(26, 18, 6, var(--book-shade-b, 0))); }
.p-leaf-fwd .p-face-front, .p-leaf-rev .p-face-back { --book-shade-to: 90deg; }
.p-leaf-fwd .p-face-back, .p-leaf-rev .p-face-front { --book-shade-to: 270deg; }
/* The shadow a lifted leaf throws on the page under it, darkest at the spine. */
.p-cast { position: absolute; z-index: 3; pointer-events: none; opacity: 0; }
.p-cast-left { border-radius: calc(6 * var(--u)) 0 0 calc(6 * var(--u)); background: linear-gradient(270deg, rgba(20, 14, 4, 0.55), rgba(20, 14, 4, 0.12) 55%, transparent 90%); }
.p-cast-right { border-radius: 0 calc(6 * var(--u)) calc(6 * var(--u)) 0; background: linear-gradient(90deg, rgba(20, 14, 4, 0.55), rgba(20, 14, 4, 0.12) 55%, transparent 90%); }

/* ---------- Opening sealed (planner-book-cipher.js) ----------
   Each piece of writing keeps its place and width; while sealed it is
   hidden and small cipher characters show on top of it. */
.p-text { position: relative; }
.p-text.is-cipher, .p-text.is-blank { color: transparent; }
.p-text.is-cipher::before {
  content: attr(data-g); position: absolute; left: 0; top: 50%; max-width: 100%; overflow: hidden; transform: translateY(-50%);
  font: 500 calc(11 * var(--u))/1.2 ui-monospace, "SF Mono", Menlo, Consolas, monospace; letter-spacing: 0.04em; text-transform: none; white-space: nowrap;
  color: var(--emerald);
}
/* The band that sweeps down the spread; above it the pages are readable. */
.p-band {
  position: absolute; left: 0; right: 0; bottom: 100%; z-index: 4; height: calc(96 * var(--u)); pointer-events: none; opacity: 0; transition: opacity 0.4s;
  background: linear-gradient(180deg, transparent, rgba(214, 173, 98, 0.16) 55%, rgba(214, 173, 98, 0.42)); border-bottom: 1px solid var(--gold-soft);
}
/* Under the book: what the pages are right now, and Replay. */
.p-book-state { position: absolute; right: 30px; bottom: 0; margin: 0; display: flex; align-items: center; gap: 14px; font: 500 11px/1.4 ui-monospace, "SF Mono", Menlo, Consolas, monospace; letter-spacing: 0.08em; color: var(--book-caption, var(--muted)); }
.p-book-state button { font: inherit; letter-spacing: inherit; color: inherit; background: transparent; border: 0; border-bottom: 1px solid currentColor; padding: 0 0 1px; cursor: pointer; }
.p-book-state button:hover { color: var(--gold-soft); }

@media (max-width: 960px) {
  .p-book { max-width: 620px; width: 100%; margin: 10px auto 0; }
}
@media (max-width: 560px) {
  .p-book { margin-bottom: 22px; }
  .p-book-state { right: 14px; bottom: -22px; font-size: 10px; }
}
