/* Twelve Issues: the library edition
   Libre Caslon for headings and reading, Libre Franklin for interface.
   Library green, oxblood, navy and goldenrod, borrowed from cloth book spines. */
:root {
  --ink: #17221e;
  --ink-soft: #4b5751;
  --blue: #1f4d3f;        /* primary: library green */
  --blue-deep: #143529;
  --red: #7d2a35;         /* oxblood */
  --navy: #253a5e;
  --gold: #d9a521;
  --gold-deep: #b98a12;
  --paper: #ffffff;
  --envelope: #eef2ec;    /* pale sage band */
  --tint: #f3f6f1;
  --rule: #d6ddd6;
  --ok: #1f7a4d;
  --warn: #8a5a00;
  --ui: "Libre Franklin", "Segoe UI", system-ui, sans-serif;
  --read: "Libre Caslon Text", Georgia, serif;
  --r-sm: 4px;
  --r-md: 8px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--ui); font-size: 17px; line-height: 1.6; color: var(--ink); background: var(--paper); }
img { max-width: 100%; }
a { color: var(--blue); text-underline-offset: 3px; }
a:hover { color: var(--blue-deep); }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; border-radius: 3px; }
h1, h2, h3 { font-family: var(--read); font-weight: 700; line-height: 1.15; margin: 0 0 .55em; letter-spacing: -.01em; text-wrap: balance; }
h1 { font-size: clamp(2.4rem, 5vw, 3.75rem); line-height: 1.05; letter-spacing: -.02em; }
h2 { font-size: clamp(1.65rem, 3vw, 2.3rem); }
h3 { font-size: 1.2rem; }
p { margin: 0 0 1em; }
.wrap { width: min(1140px, 92%); margin: 0 auto; }
.narrow { width: min(760px, 92%); margin: 0 auto; }
.muted { color: var(--ink-soft); }
.small { font-size: .88rem; }
.hidden { display: none !important; }

/* Kept for older markup: a plain book-plate frame */
.airmail { border: 1px solid var(--rule); background: var(--paper); }

/* Buttons and fields */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .5em; font: 600 1rem/1 var(--ui); padding: .85em 1.35em; border-radius: var(--r-sm); border: 2px solid var(--blue); background: var(--blue); color: #fff; cursor: pointer; text-decoration: none; transition: background .15s, border-color .15s; }
.btn:hover { background: var(--blue-deep); border-color: var(--blue-deep); color: #fff; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-ghost { background: transparent; color: var(--blue); }
.btn-ghost:hover { background: var(--envelope); color: var(--blue-deep); }
.btn-red { background: var(--red); border-color: var(--red); }
.btn-red:hover { background: #61202a; border-color: #61202a; }
.btn-gold { background: var(--gold); border-color: var(--gold); color: var(--ink); }
.btn-gold:hover { background: var(--gold-deep); border-color: var(--gold-deep); color: var(--ink); }
.btn-sm { font-size: .88rem; padding: .55em .9em; }
.btn-lg { font-size: 1.08rem; padding: 1em 1.6em; }
label { display: block; font-weight: 600; font-size: .95rem; margin: 0 0 .35em; }
.hint { display: block; font-weight: 400; color: var(--ink-soft); font-size: .86rem; margin-top: .15em; }
input[type=text], input[type=email], input[type=password], input[type=url], select, textarea {
  width: 100%; font: 400 1rem/1.4 var(--ui); color: var(--ink); padding: .72em .85em; border: 1.5px solid var(--rule); border-radius: var(--r-sm); background: #fff;
}
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); outline: none; box-shadow: 0 0 0 3px rgba(31, 77, 63, .16); }
.field { margin-bottom: 1.1rem; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.alert { padding: .8em 1em; border-radius: var(--r-sm); margin: 0 0 1rem; font-size: .95rem; }
.alert-error { background: #f8eaec; color: #7d1f2c; }
.alert-ok { background: #e7f5ee; color: var(--ok); }
.alert-info { background: var(--envelope); color: var(--ink); }

/* Top bar */
.top { border-bottom: 1px solid var(--rule); background: #fff; position: sticky; top: 0; z-index: 20; }
.top-in { display: flex; align-items: center; justify-content: space-between; height: 66px; gap: 1rem; }
.brand { display: flex; align-items: center; gap: .6rem; text-decoration: none; color: var(--ink); font-family: var(--read); font-weight: 700; font-size: 1.22rem; }
.brand-mark { width: 32px; height: 38px; border-radius: 2px 4px 4px 2px; background: var(--blue); color: #fff; display: grid; place-items: center; font: 700 .9rem/1 var(--ui); position: relative; box-shadow: inset 4px 0 0 rgba(0,0,0,.18); }
.brand-mark::after { content: ""; position: absolute; right: 6px; top: 0; width: 6px; height: 13px; background: var(--gold); clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 78%, 0 100%); }
.nav { display: flex; align-items: center; gap: 1.2rem; }
.nav a { text-decoration: none; color: var(--ink); font-weight: 500; font-size: .96rem; }
.nav a:hover { color: var(--blue); }
.nav .btn { color: #fff; }
.brand, .nav a { white-space: nowrap; }

/* ---------- Landing ---------- */
.hero { padding: 64px 0 80px; }
.hero-grid { display: grid; grid-template-columns: 1fr 1.05fr; gap: 64px; align-items: center; }
.hero .lede { font-size: 1.2rem; color: var(--ink-soft); max-width: 31em; }
.hero-actions { display: flex; flex-wrap: wrap; gap: .9rem 1.1rem; align-items: center; margin-top: 1.8rem; }
.price-note { font-size: .98rem; color: var(--ink-soft); }
.price-note strong { color: var(--red); font-size: 1.1em; }

/* The stack: twelve months as twelve books */
.shelf { margin: 0; }
.toggle { display: inline-flex; flex-wrap: wrap; gap: 4px; background: var(--envelope); border-radius: 999px; padding: 4px; margin-bottom: 18px; }
.toggle button { white-space: nowrap; font: 600 .86rem/1 var(--ui); border: 0; background: transparent; padding: .6em 1em; border-radius: 999px; cursor: pointer; color: var(--ink-soft); }
.toggle button:hover { color: var(--ink); }
.toggle button[aria-pressed="true"] { background: var(--ink); color: #fff; }
.stack { list-style: none; margin: 0; padding: 0 0 0 0; display: grid; gap: 3px; border-bottom: 6px solid #6b4f2e; padding-bottom: 3px; }
.book { --c: var(--blue); position: relative; display: flex; align-items: baseline; gap: 14px; margin-left: var(--x); padding: 9px 18px 9px 22px; min-height: 42px; background: var(--c); color: #fff; border-radius: 3px 5px 5px 3px; box-shadow: inset 0 -2px 0 rgba(0,0,0,.14); }
.book::before, .book::after { content: ""; position: absolute; top: 0; bottom: 0; width: 3px; background: rgba(255,255,255,.28); }
.book::before { left: 8px; }
.book::after { right: 10px; }
.book b { flex: none; width: 5.4em; font: 600 .74rem/1.2 var(--ui); opacity: .78; letter-spacing: .02em; }
.book span { font-family: var(--read); font-size: 1rem; line-height: 1.3; }
.b0 { --c: var(--blue); }
.b1 { --c: var(--red); }
.b2 { --c: var(--navy); }
.b3 { --c: var(--gold); color: var(--ink); }
.b4 { --c: #4f5d55; }
.b5 { --c: #8c5a2b; }
.b3::before, .b3::after { background: rgba(0,0,0,.18); }
.shelf figcaption { margin-top: 12px; font-size: .9rem; color: var(--ink-soft); }
.stack.restack .book { animation: drop .5s cubic-bezier(.2,.8,.3,1) both; animation-delay: calc((11 - var(--i)) * 45ms); }
@keyframes drop { from { opacity: 0; transform: translateY(-18px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .stack.restack .book { animation: none; } }

.band { padding: 84px 0; }
.band-alt { background: var(--envelope); }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 56px; align-items: start; }
.split h2 { margin: 0; }
.split-body p { font-family: var(--read); font-size: 1.12rem; line-height: 1.7; }
.split-body p:last-child { margin-bottom: 0; }

.steps { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 40px; margin: 2rem 0 0; counter-reset: step; }
.steps li { counter-increment: step; border-top: 3px solid var(--ink); padding-top: 18px; }
.steps li::before { content: counter(step); display: block; font: 700 2.4rem/1 var(--read); color: var(--gold-deep); margin-bottom: 12px; }
.steps p { color: var(--ink-soft); margin: 0; }

.sample { display: grid; grid-template-columns: 1fr 1.1fr; gap: 56px; align-items: start; }
.letter { background: #fff; border: 1px solid var(--rule); border-radius: var(--r-md); overflow: hidden; box-shadow: 0 18px 40px -24px rgba(23, 34, 30, .35); }
.letter-meta { margin: 0; padding: 14px 22px; border-bottom: 1px solid var(--rule); font-size: .9rem; background: var(--tint); }
.letter-meta div { display: flex; gap: .6em; }
.letter-meta dt { color: var(--ink-soft); width: 70px; flex: none; }
.letter-meta dd { margin: 0; font-weight: 600; }
.letter-body { padding: 26px 28px 30px; font-family: var(--read); font-size: 1.06rem; line-height: 1.75; }
.letter-body h3 { font-size: 1.5rem; }

.offer { display: grid; grid-template-columns: 1.2fr 1fr; gap: 56px; align-items: center; }
.ticket { background: var(--ink); color: #fff; border-radius: var(--r-md); padding: 34px 32px; text-align: center; }
.ticket .muted { color: #b9c4bd; }
.ticket .amount { font: 700 5rem/1 var(--read); letter-spacing: -.03em; color: var(--gold); }
.ticket .amount sup { font-size: .42em; vertical-align: 1em; margin-right: 2px; }
.ticket ul { text-align: left; margin: 1.3rem auto 1.6rem; padding-left: 1.1em; max-width: 310px; }
.ticket li { margin: .35em 0; }

.faq details { border-bottom: 1px solid var(--rule); padding: 1.05rem 0; }
.faq summary { font-family: var(--read); font-weight: 700; cursor: pointer; font-size: 1.1rem; }
.faq details p { margin: .6rem 0 0; color: var(--ink-soft); }

.closer { background: var(--blue); color: #fff; padding: 72px 0; }
.closer-in { display: flex; align-items: center; justify-content: space-between; gap: 2rem; flex-wrap: wrap; }
.closer h2 { margin: 0; max-width: 18em; }

.foot { background: var(--ink); color: #c7d0ca; font-size: .93rem; padding: 64px 0 0; }
.foot a { color: #e9eee9; text-decoration: none; }
.foot a:hover { color: var(--gold); text-decoration: underline; }
.foot-grid { display: grid; grid-template-columns: 1.6fr 1fr 1fr 1fr; gap: 40px; padding-bottom: 48px; }
.foot-brand .brand { color: #fff; margin-bottom: 14px; }
.foot-brand .brand-mark { box-shadow: inset 4px 0 0 rgba(0,0,0,.25), 0 0 0 1px rgba(255,255,255,.18); }
.foot-brand p { max-width: 24em; margin-bottom: 1.2rem; }
.foot-brand .btn { color: var(--ink); }
.foot-brand .btn:hover { color: var(--ink); text-decoration: none; }
.foot-col { display: flex; flex-direction: column; gap: .55rem; }
.foot-col h4 { margin: 0 0 .35rem; font: 700 1rem/1.2 var(--read); color: #fff; }
.foot-base { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; border-top: 1px solid rgba(255,255,255,.14); padding: 20px 0 32px; font-size: .85rem; color: #9aa79f; }

/* ---------- Contact ---------- */
.contact { display: grid; grid-template-columns: 1fr 1.25fr; gap: 56px; align-items: start; }
.contact .lede { font-size: 1.15rem; color: var(--ink-soft); }
.contact-facts { margin: 2rem 0 0; display: grid; gap: 1.2rem; }
.contact-facts div { border-left: 3px solid var(--gold); padding-left: 14px; }
.contact-facts dt { font-family: var(--read); font-weight: 700; }
.contact-facts dd { margin: .2rem 0 0; color: var(--ink-soft); }
.contact-form .btn { width: 100%; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* ---------- Auth ---------- */
.auth { min-height: calc(100vh - 66px); display: grid; place-items: center; background: var(--envelope); padding: 40px 0; }
.auth-card { width: min(440px, 92%); background: #fff; border-radius: var(--r-md); padding: 34px 32px; border: 1px solid var(--rule); }
.auth-card h1 { font-size: 1.9rem; }
.auth-card .btn { width: 100%; margin-top: .3rem; }
.auth-alt { text-align: center; margin-top: 1.2rem; font-size: .95rem; }

/* ---------- App ---------- */
.page { padding: 40px 0 80px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.6rem; }
.page-head h1 { font-size: clamp(1.8rem, 3.4vw, 2.4rem); margin: 0; }
.panel { border: 1px solid var(--rule); border-radius: var(--r-md); background: #fff; padding: 26px; margin-bottom: 1.4rem; }
.empty { text-align: center; padding: 56px 24px; border: 2px dashed var(--rule); border-radius: var(--r-md); }
.list { border: 1px solid var(--rule); border-radius: var(--r-md); overflow: hidden; }
.list a.item { display: grid; grid-template-columns: 1fr auto auto; gap: 1rem; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--rule); text-decoration: none; color: var(--ink); }
.list a.item:last-child { border-bottom: 0; }
.list a.item:hover { background: var(--envelope); }
.item-title { font-weight: 650; }
.pill { display: inline-block; font-size: .8rem; font-weight: 650; padding: .3em .7em; border-radius: 999px; background: var(--envelope); color: var(--ink); white-space: nowrap; }
.pill-complete { background: #e7f5ee; color: var(--ok); }
.pill-generating, .pill-paid { background: #e3eee8; color: var(--blue); }
.pill-failed { background: #fdecee; color: #8f1525; }
.pill-awaiting_payment { background: #fff4e0; color: var(--warn); }

/* Wizard */
.steps-bar { display: flex; gap: 6px; margin-bottom: 1.6rem; }
.steps-bar span { flex: 1; height: 5px; border-radius: 3px; background: var(--rule); }
.steps-bar span.on { background: var(--blue); }
.choice-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.choice { display: block; border: 2px solid var(--rule); border-radius: var(--r-md); padding: 22px; cursor: pointer; font-weight: 400; }
.choice:hover { border-color: var(--blue); }
.choice input { position: absolute; opacity: 0; }
.choice strong { display: block; font-size: 1.1rem; margin-bottom: .3em; }
.choice:has(input:checked) { border-color: var(--blue); background: var(--tint); }
.choice:has(input:focus-visible) { outline: 3px solid var(--blue); outline-offset: 2px; }
.drop { border: 2px dashed var(--rule); border-radius: var(--r-md); padding: 30px; text-align: center; cursor: pointer; transition: border-color .15s, background .15s; }
.drop:hover, .drop.over { border-color: var(--blue); background: var(--tint); }
.files { list-style: none; padding: 0; margin: 1rem 0 0; }
.files li { display: flex; justify-content: space-between; gap: 1rem; padding: .55em .8em; background: var(--envelope); border-radius: var(--r-sm); margin-bottom: 6px; font-size: .93rem; }
.files button { border: 0; background: none; color: #8f1525; cursor: pointer; font: inherit; }
.wiz-nav { display: flex; justify-content: space-between; gap: 1rem; margin-top: 1.6rem; }
.summary-table { width: 100%; border-collapse: collapse; }
.summary-table td { padding: .55em 0; border-bottom: 1px solid var(--rule); vertical-align: top; }
.summary-table td:first-child { color: var(--ink-soft); width: 38%; }

/* Progress */
.progress { height: 12px; border-radius: 6px; background: var(--envelope); overflow: hidden; margin: 1rem 0 .6rem; }
.progress > div { height: 100%; width: 0; background: var(--blue); transition: width .6s ease; }
.progress.working > div { background-image: linear-gradient(-45deg, rgba(255,255,255,.22) 25%, transparent 25% 50%, rgba(255,255,255,.22) 50% 75%, transparent 75%); background-size: 28px 28px; animation: slide 1s linear infinite; }
@keyframes slide { to { background-position: 28px 0; } }
@media (prefers-reduced-motion: reduce) { .progress.working > div { animation: none; } }

/* Issue viewer */
.viewer { display: grid; grid-template-columns: 260px 1fr; gap: 28px; align-items: start; }
.issue-nav { position: sticky; top: 86px; border: 1px solid var(--rule); border-radius: var(--r-md); overflow: hidden; }
.issue-nav button { display: block; width: 100%; text-align: left; border: 0; border-bottom: 1px solid var(--rule); background: #fff; padding: 11px 14px; cursor: pointer; font: 400 .9rem/1.3 var(--ui); color: var(--ink); }
.issue-nav button:last-child { border-bottom: 0; }
.issue-nav button b { display: block; font-size: .76rem; color: var(--blue); }
.issue-nav button[aria-current="true"] { background: var(--ink); color: #fff; }
.issue-nav button[aria-current="true"] b { color: #e9c869; }
.issue-tools { display: flex; flex-wrap: wrap; gap: .5rem; margin: 0 0 1rem; }
.prose { font-family: var(--read); font-size: 1.12rem; line-height: 1.7; }
.prose h2 { font-family: var(--read); font-weight: 600; font-size: 1.8rem; letter-spacing: 0; }
.prose h3, .prose h4 { font-family: var(--read); font-weight: 600; }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose a.cta-line, .prose a.cta-line:hover { color: #fff; }
.cta-line { text-decoration: none; display: inline-block; margin-top: .4rem; padding: .7em 1.1em; border-radius: var(--r-sm); background: var(--red); color: #fff; font-family: var(--ui); font-weight: 650; font-size: .98rem; }
.stars { display: inline-flex; gap: 4px; }
.stars button { border: 0; background: none; font-size: 1.7rem; cursor: pointer; color: var(--rule); padding: 0 2px; }
.stars button.on { color: var(--gold); }

/* Admin */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; margin-bottom: 1.6rem; }
.stat { border: 1px solid var(--rule); border-radius: var(--r-md); padding: 16px; }
.stat span { display: block; color: var(--ink-soft); font-size: .86rem; }
.stat strong { font-size: 1.7rem; letter-spacing: -.02em; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--rule); margin-bottom: 1rem; flex-wrap: wrap; }
.tabs button { border: 0; background: none; padding: .8em 1em; font: 600 .95rem var(--ui); cursor: pointer; color: var(--ink-soft); border-bottom: 3px solid transparent; margin-bottom: -1px; }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--blue); }
.table-wrap { overflow-x: auto; border: 1px solid var(--rule); border-radius: var(--r-md); }
table.data { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.data th { text-align: left; font-weight: 650; background: var(--envelope); padding: 10px 12px; white-space: nowrap; }
table.data td { padding: 10px 12px; border-top: 1px solid var(--rule); vertical-align: top; }
table.data tr.click { cursor: pointer; }
table.data tr.click:hover td { background: var(--tint); }
.drawer { position: fixed; inset: 0 0 0 auto; width: min(760px, 100%); background: #fff; box-shadow: -12px 0 40px rgba(23,34,30,.18); z-index: 50; overflow-y: auto; padding: 28px; transform: translateX(100%); transition: transform .25s ease; }
.drawer.open { transform: none; }
.drawer pre { white-space: pre-wrap; background: var(--envelope); padding: 12px; border-radius: var(--r-sm); font-size: .82rem; max-height: 320px; overflow: auto; }
.scrim { position: fixed; inset: 0; background: rgba(23,34,30,.35); z-index: 40; }

@media (max-width: 900px) {
  .hero-grid, .sample, .offer, .viewer, .split, .contact { grid-template-columns: 1fr; }
  .foot-grid { grid-template-columns: 1fr 1fr; }
  .foot-brand { grid-column: 1 / -1; }
  .contact { gap: 28px; }
  .hero-grid { gap: 40px; }
  .split { gap: 20px; }
  .issue-nav { position: static; display: grid; grid-template-columns: repeat(2, 1fr); }
  .issue-nav button { border-right: 1px solid var(--rule); }
}
@media (max-width: 640px) {
  .book { margin-left: calc(var(--x) / 3); padding-left: 18px; }
  .book b { width: 4.6em; }
  .steps, .choice-grid, .row2 { grid-template-columns: 1fr; }
  .band { padding: 60px 0; }
  .nav a.hide-sm { display: none; }
  .nav { gap: .8rem; }
  .brand { font-size: 1.08rem; }
  .list a.item { grid-template-columns: 1fr auto; }
  .list a.item .item-date { display: none; }
  .hero { padding: 40px 0 52px; }
}
