/* ============================================================
   BUNDLE NOTEBOOK — phone layout (v63)
   On phones the notebook is turned on its side: the spiral runs across the middle,
   the cover opens upward and each page flips from the bottom up (scroll back = it flips down).
   Every page is now as wide as the screen instead of half of it.
   The matching transforms are in js/notebooks.js (`vertical` flag, same 760px breakpoint).
   Desktop and tablet layouts are untouched.
   ============================================================ */
@media (max-width: 760px) {

  /* ---- stage: use the whole phone ---- */
  #bundles.bundle-section { padding-top: 70px; padding-bottom: 40px; }
  #bundles .bundle-lede { font-size: .9rem; line-height: 1.5; }
  .bundle-scroll-track {
    --bundle-step-distance: 58svh;
    height: calc(100svh + 58svh * 3);
    margin: 14px -20px 0;
  }
  .bundle-pin {
    top: var(--rg-header-height, 60px);
    height: calc(100svh - var(--rg-header-height, 60px) - 6px);
    min-height: 0;
  }
  .bundle-stage {
    width: 100%;
    height: min(calc(100svh - var(--rg-header-height, 60px) - 36px), 760px);
    min-height: 420px;
    perspective: 1900px;
    perspective-origin: 50% 50%;
  }
  .bundle-stage::before { inset: 40px 3% 40px; transform: translateY(14px) scale(.98); }
  .bundle-stage-meta { top: 6px; left: 12px; right: 12px; }
  .book-stage-caption { bottom: 6px; left: 12px; right: 12px; }
  .book-stage-caption span:last-child { display: none; }
  .bundle-book { inset: 34px 10px 32px; }

  /* ---- geometry: pages are full-width, stacked top to bottom, hinged at the top ---- */
  .page-block { left: 0; top: 25%; width: 100%; height: 50%; }
  .book-leaves { inset: 0; }
  .book-leaf,
  .front-cover {
    left: 0; top: 25%; width: 100%; height: 50%;
    transform-origin: 50% 0;
  }
  .page-block-edge {
    inset: 5px -4px -8px 4px;
    background: repeating-linear-gradient(90deg, #fffdf3 0 2px, #d4cdbb 2px 3px, #f3eddd 3px 5px);
    box-shadow: 6px 10px 14px rgba(26,31,21,.2), inset 0 -2px 3px rgba(65,55,39,.2);
  }
  .page-block-lines { background: repeating-linear-gradient(90deg, transparent 0 3px, rgba(107,98,78,.19) 3px 4px); }
  .page-block-bottom { left: 4px; right: -4px; bottom: -9px; }

  /* the back faces must be turned about the same (horizontal) axis */
  .leaf-back,
  .cover-inside { transform: rotateX(180deg); }
  .cover-face, .leaf-side { border-radius: 4px 4px 9px 9px; }
  .leaf-side::after { background: linear-gradient(180deg, rgba(24,31,22,.3), transparent 22%, transparent 78%, rgba(24,31,22,.1)); }
  .leaf-back::after { background: linear-gradient(0deg, rgba(24,31,22,.3), transparent 22%, transparent 78%, rgba(24,31,22,.1)); }

  /* ---- spiral: horizontal wire across the hinge ---- */
  .spiral-binding {
    left: 3%; right: 3%; top: calc(25% - 21px); bottom: auto;
    width: auto; height: 44px;
    flex-direction: row; align-items: flex-start; justify-content: space-around;
  }
  .spiral-binding::before {
    left: 0; right: 0; top: 19px; bottom: auto; width: auto; height: 5px;
    background: linear-gradient(180deg, #6e552f, #e5cc85 38%, #8d6e39 68%, #e6d195);
  }
  .spiral-binding i {
    width: 18px; height: 37px; margin: 0;
    border: 3px solid #c9a55e; border-top-color: transparent;
  }

  /* ---- closed cover ---- */
  .cover-brand { top: 6%; left: 6%; width: clamp(96px, 30%, 128px); }
  .cover-title-plate { width: 64%; padding: 0; height: 26%; min-height: 56px; }
  .cover-title-plate span { font-size: clamp(1.5rem, 8.4vw, 2.2rem); letter-spacing: .12em; }
  .cover-subtitle { margin-top: 3.5%; font-size: .62rem; letter-spacing: .26em; }
  .cover-emblem { margin-top: 3%; font-size: 1.1rem; }
  .cover-edition { left: 6%; right: 6%; bottom: 6%; font-size: .56rem; }
  .cover-border { inset: 9px; }

  /* ---- inside of the cover + the green left-hand pages (top half): title, drawing, small print.
         The hinge (wire) is at the BOTTOM of these pages, so they keep clear space there. ---- */
  .cover-inside,
  .leaf-back {
    display: flex; flex-direction: column; justify-content: flex-start;
    padding: 16px 20px 28px;
  }
  .inside-cover-border { inset: 8px; }
  .cover-inside .inside-kicker,
  .leaf-back .inside-kicker { font-size: .58rem; letter-spacing: .14em; }

  .cover-inside h3,
  .leaf-back .back-note-title {
    margin: 8px 0 0; font-size: clamp(1.45rem, 6.8vw, 1.9rem); line-height: 1.02; letter-spacing: -.02em;
    text-wrap: balance;
  }
  .cover-inside .inside-copy,
  .leaf-back .back-note-copy { display: none; }
  .cover-inside .inside-sketch,
  .leaf-back .back-sketch { flex: 1 1 0; min-height: 0; margin: 6px 0 4px; }
  .leaf-back .bk-fig,
  .cover-inside .bk-fig { font-size: .6rem; line-height: 1.15; text-align: center; margin-top: 1px; }

  .cover-inside .inside-index { display: grid; gap: 3px; margin: 0; padding-top: 6px; }
  .cover-inside .inside-index span { font-size: .52rem; letter-spacing: .06em; gap: 5px; min-width: 0; white-space: nowrap; }
  .cover-inside .inside-index i { min-width: 4px; }
  .cover-inside .inside-signature { display: block; margin: 5px 0 0; font-size: .9rem; align-self: flex-start; }
  .cover-inside .inside-page-mark { display: none; }
  .leaf-back .back-note-sign { position: relative; right: auto; bottom: auto; align-self: flex-start; margin: 2px 0 0; font-size: .54rem; letter-spacing: .1em; }
  /* closing note (no drawing): keep its text */
  .leaf-back:not(:has(.bk-sketch)) { justify-content: center; }
  .leaf-back:not(:has(.bk-sketch)) .back-note-copy { display: block; max-width: 92%; margin-top: 8px; font-size: .76rem; }

  /* ---- the bundle page (bottom half). The hinge is at the TOP of this page. ---- */
  .proposal-page {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-rows: auto auto minmax(0, 1fr) auto auto;
    column-gap: 12px;
    padding: 26px 20px 14px;
  }
  .proposal-topline { grid-column: 1 / -1; padding-bottom: 6px; font-size: .56rem; letter-spacing: .1em; }
  .proposal-heading { grid-column: 1 / -1; margin-top: 6px; }
  .proposal-kicker { font-size: 1rem; margin: 0; }
  .proposal-heading h3 { font-size: clamp(1.55rem, 7.4vw, 2.05rem); line-height: .98; letter-spacing: -.03em; }
  .bundle-page .proposal-description {
    margin-top: 6px; font-size: .78rem; line-height: 1.42;
    -webkit-line-clamp: 5;
  }
  .bundle-page .popular-stamp { display: none; }

  /* price block becomes a direct grid item; the module list stays on the detail page */
  .bundle-page .proposal-bottom { display: contents; }
  .bundle-page .proposal-includes { display: none; }
  .bundle-page .proposal-description { grid-column: 1 / -1; }

  .bundle-page .bundle-stats { grid-column: 1; grid-row: 4; align-self: end; margin: 8px 0 0; }
  .bundle-stats span { font-size: .52rem; padding: 4px 2px; letter-spacing: .06em; text-align: center; }
  .bundle-stats b { font-size: 1.05rem; }
  .bundle-page .proposal-investment { grid-column: 2; grid-row: 4; align-self: end; padding: 0 0 0 2px; border: 0; }
  .proposal-investment > span { font-size: .52rem; }
  .proposal-investment strong { font-size: 1.05rem; margin-top: 1px; }
  .proposal-investment strong.ask { font-size: 1.1rem; }
  .proposal-investment svg { height: 7px; }
  .proposal-page .book-cta {
    grid-column: 1 / -1; grid-row: 5; margin-top: 8px; padding: 9px 12px; font-size: .74rem;
  }
  .proposal-page .book-cta.bundle-purchase-cta:not([hidden]) { grid-row: 6; margin-top: 6px; }
  .proposal-page-no { display: none; }
}

/* Each page measures itself: a taller phone gives the text more lines, a shorter one trims the extras.
   (Container queries, so the result never changes while the browser's address bar slides in and out.) */
@media (max-width: 760px) {
  .leaf-side, .cover-face { container-type: size; }
}
@container (max-height: 319px) {
  .bundle-page .proposal-description { font-size: .72rem; -webkit-line-clamp: 3; }
  .cover-inside .inside-index { display: none; }
}
@container (max-height: 279px) {
  .bundle-page .proposal-description { -webkit-line-clamp: 2; }
  .proposal-kicker { font-size: .9rem; }
  .proposal-heading h3 { font-size: 1.45rem; }
  .cover-inside .inside-signature { display: none; }
  .cover-inside h3, .leaf-back .back-note-title { font-size: 1.3rem; }
}

/* very small phones */
@media (max-width: 360px) {
  .proposal-heading h3 { font-size: 1.4rem; }
  .bundle-stats span { font-size: .48rem; }
}

/* Lower-powered phones: never keep large layers alive longer than the section needs them. */
@media (max-width: 860px) {
  .work-rail { will-change: auto; }
}
