/* ==========================================================================
   book.css: the opened book (a native <dialog>).
   Desktop: two-page spread, bookmark tabs, page flipping.
   Phones: full screen, one long scrolling page.
   ========================================================================== */

.reader {
  border: 0; padding: 0; margin: auto; background: transparent; color: var(--ink);
  max-width: none; max-height: none; overflow: visible;
}
.reader::backdrop { background: rgba(58, 31, 43, .62); }
.reader[open] .book-wrap { animation: book-in .24s steps(4) both; }
@keyframes book-in { from { opacity: 0; transform: translateY(28px) scale(.94); } to { opacity: 1; transform: none; } }

.book-wrap { --gut: 72px; --closeOff: 12px; position: relative; width: min(calc(1008px + var(--gut)), calc(100vw - 48px)); height: min(672px, calc(100vh - 80px)); height: min(672px, calc(100dvh - 80px)); }
.book-wrap--tabs { --gut: 190px; --closeOff: 118px; }
.book-open {
  position: absolute; inset: 0 var(--gut) 0 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  background: var(--cover); border: 4px solid var(--ink); box-shadow: 12px 12px 0 rgba(0, 0, 0, .35); padding: 14px;
}
.book-open::after { content: ""; position: absolute; left: 14px; right: 14px; bottom: 6px; height: 4px; background: var(--line); }

.page { min-width: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; padding: 32px 40px 24px 36px; background: var(--cream); box-shadow: inset -12px 0 0 #EADCC2; }
.page--r { padding: 32px 36px 24px 44px; background: var(--paper2); box-shadow: inset 12px 0 0 #EADCC2; }
.spread { display: contents; }
.spread .page[data-p] { display: none; }
.spread[data-page="1"] .page[data-p="1"], .spread[data-page="2"] .page[data-p="2"] { display: flex; }

.reader h1, .reader h2, .reader h3 { text-wrap: balance; }
.b-title { font-family: var(--pixel); font-size: 32px; line-height: 1.1; font-weight: 600; margin: 0; }
.b-h2 { font-family: var(--pixel); font-size: 21px; font-weight: 600; margin: 0; display: flex; align-items: baseline; gap: 10px; }
.b-h2 .num { font-size: 14px; color: var(--blue); }
.b-body { margin: 0; font-size: 16px; line-height: 1.6; max-width: 62ch; }
.b-sec { display: flex; flex-direction: column; gap: 8px; scroll-margin-top: 120px; }
.tile { display: flex; align-items: center; justify-content: center; text-align: center; background: #E8DCC6; border: 2px dashed #A8907E; color: var(--muted); font-size: 14px; overflow: hidden; }
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.hero-tile { flex: none; height: 196px; }
.facts-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.facts-grid .fact { padding: 10px 12px; gap: 2px; }
.facts-grid .fact span { font-size: 15px; }
.decision { display: flex; gap: 10px; align-items: flex-start; }
.decision .sq { flex: none; width: 10px; height: 10px; margin-top: 7px; border: 2px solid var(--ink); }
.stats { display: flex; gap: 10px; flex-wrap: wrap; }
.stat { display: flex; flex-direction: column; gap: 4px; padding: 14px; background: #FFFFFF; border: 2px solid var(--line); flex: 1 1 140px; }
.stat b { font-family: var(--pixel); font-size: 30px; color: var(--blue); line-height: 1; font-variant-numeric: tabular-nums; }
.stat span { font-size: 14px; color: var(--muted); }
.gallery { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.gallery .tile { height: 78px; }
.cta { font-family: var(--pixel); font-size: 17px; text-decoration: none; color: var(--ink); background: var(--pink); border: 3px solid var(--ink); box-shadow: 4px 4px 0 var(--ink); min-height: 46px; padding: 0 18px; display: inline-flex; align-items: center; gap: 8px; align-self: flex-start; }
.cta:hover { background: var(--pink-deep); color: var(--ink); }
.cta--teal { background: var(--teal); }
.cta--teal:hover { background: var(--gold); }
.cta[aria-disabled="true"] { opacity: .5; pointer-events: none; }
.next-link { font-weight: 700; }

.pager { margin-top: auto; padding-top: 8px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.pager span { font-family: var(--pixel); font-size: 15px; }
.navbtn { font-family: var(--pixel); font-size: 16px; background: var(--cream); color: var(--ink); border: 2px solid var(--ink); box-shadow: 3px 3px 0 var(--ink); min-height: 44px; padding: 0 14px; cursor: pointer; }
.navbtn:hover { background: var(--gold); }
.navbtn:disabled { opacity: .4; cursor: default; box-shadow: none; }

.tabs { position: absolute; left: calc(100% - var(--gut)); top: 64px; display: flex; flex-direction: column; gap: 6px; }
.tab { width: 104px; height: 42px; border: 2px solid var(--ink); border-left: 0; padding: 0 10px 0 14px; text-align: left; font-family: var(--pixel); font-size: 14px; color: var(--ink); background: var(--cream); cursor: pointer; box-shadow: 3px 3px 0 rgba(0, 0, 0, .25); }
.tab[aria-current="true"] { background: var(--gold); }
.tab:hover, .tab:focus-visible { transform: translateX(6px); }

.closer { position: absolute; left: calc(100% - var(--gut) + var(--closeOff)); top: 0; display: flex; align-items: center; gap: 10px; }
.closer .esc { font-family: var(--pixel); font-size: 13px; color: var(--cream); }
.xbig { width: 48px; height: 48px; border: 3px solid var(--ink); background: var(--pink); color: var(--ink); font-family: var(--pixel); font-size: 20px; font-weight: 600; cursor: pointer; box-shadow: 4px 4px 0 var(--ink); }
.xbig:hover { background: var(--pink-deep); }
.mbar { display: none; }

/* About / resume / contact bits */
.photo { flex: none; width: 150px; height: 150px; background: #E8DCC6; border: 4px solid var(--ink); box-shadow: 6px 6px 0 var(--pink); display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 14px; overflow: hidden; }
.photo img { width: 100%; height: 100%; object-fit: cover; }
.bullets { display: flex; flex-direction: column; gap: 10px; padding: 16px; background: #FFFFFF; border: 2px solid var(--line); }
.bullet { display: flex; align-items: center; gap: 10px; }
.bullet .sq { flex: none; width: 10px; height: 10px; border: 2px solid var(--ink); }
.job h3 { margin: 0; font-size: 17px; }
.job .meta { font-family: var(--pixel); color: var(--blue); }
.job ul { margin: 6px 0 0; padding-left: 18px; display: flex; flex-direction: column; gap: 3px; }
.job li { font-size: 15px; line-height: 1.45; }
.r-h2 { font-family: var(--pixel); font-size: 20px; font-weight: 600; margin: 0; border-bottom: 3px solid var(--ink); padding-bottom: 4px; }
.copyrow { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 14px; background: #FFFFFF; border: 2px solid var(--line); }
.copyrow .addr { font-size: 18px; font-weight: 700; user-select: all; word-break: break-all; }
.draft-note { font-family: var(--pixel); font-size: 12px; background: var(--gold); padding: 2px 8px; align-self: flex-start; }

@media (prefers-reduced-motion: reduce) {
  .reader[open] .book-wrap { animation: fade .15s linear both; }
  .tab:hover, .tab:focus-visible { transform: none; }
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ---------- Phones: full-screen, single scroll ---------- */
@media (max-width: 860px) {
  .reader { width: 100vw; height: 100vh; height: 100dvh; margin: 0; }
  .book-wrap { width: 100%; height: 100%; display: flex; flex-direction: column; background: var(--cream); }
  .mbar {
    display: flex; flex: none; align-items: center; justify-content: space-between; gap: 10px;
    background: var(--cover); border-bottom: 4px solid var(--ink);
    padding-block: calc(10px + env(safe-area-inset-top, 0px)) 10px;
    padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
  }
  .mbar .kind { font-family: var(--pixel); font-size: 14px; color: var(--onCover); }
  .mbtn { min-height: 44px; min-width: 44px; border: 3px solid var(--ink); background: var(--cream); font-family: var(--pixel); font-size: 15px; color: var(--ink); box-shadow: 3px 3px 0 var(--ink); padding: 0 10px; cursor: pointer; }
  .mbtn--x { background: var(--pink); font-weight: 600; }
  .closer { display: none; }
  .tabs { position: static; flex-direction: row; overflow-x: auto; gap: 6px; flex: none; padding: 10px 16px; background: var(--paper2); border-bottom: 2px solid var(--line); }
  .tab { flex: none; width: auto; height: 36px; border: 2px solid var(--ink); box-shadow: none; }
  .tab:hover, .tab:focus-visible { transform: none; }
  .book-open { position: static; flex: 1; display: block; overflow-y: auto; border: 0; box-shadow: none; padding: 0; background: var(--cream); }
  .book-open::after { display: none; }
  .spread .page[data-p] { display: flex; }
  .page, .page--r { padding: 20px max(18px, env(safe-area-inset-right, 0px)) 8px max(18px, env(safe-area-inset-left, 0px)); box-shadow: none; background: var(--cream); overflow: visible; }
  .page:last-child { padding-bottom: calc(28px + env(safe-area-inset-bottom, 0px)); }
  .pager { display: none; }
  .b-title { font-size: 28px; }
  .hero-tile { height: 190px; }
  .photo { width: 110px; height: 110px; }
}
