/* ============================================================
   BOOK SHOP — storefront styles
   ------------------------------------------------------------
   Built ON core/tokens.css (loaded first in both pages): every
   colour, font and radius here comes from a design-system token,
   so the shop reads as the same product as the landing page and
   the in-app UI, and switches to dark automatically.
   ============================================================ */

/* OS dark-preference support, mirroring the landing page. The
   explicit data-theme toggle below always wins. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink:#F1F5F9; --ink-2:#94A3B8; --ink-3:#64748B;
    --surface:#1E293B; --surface-2:#0F172A; --surface-3:#334155;
    --rule:#334155; --rule-2:#475569;
    --chrome:#0B1220; --chrome-2:#1E293B; --chrome-line:#334155;
    --input:#38BDF8; --input-bg:#0C2A3D; --input-line:#155E75;
    --process:#60A5FA; --process-bg:#152A56; --process-line:#1E3A6E;
    --output:#FBBF24; --output-bg:#3A2A0C; --output-line:#5B4212;
    --ok:#2DD4BF; --ok-bg:#0F2C29; --ok-line:#115E59;
    --no:#F87171; --no-bg:#3A1414; --no-line:#7F1D1D;
    --warn:#FBBF24; --warn-bg:#332708; --warn-line:#5B4212;
  }
}

body { padding: 0; }

.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
main.wrap { padding-bottom: 72px; }

/* ---------------- nav ---------------- */
.site-nav {
  position: sticky; top: 0; z-index: 20; background: var(--surface);
  border-bottom: 1px solid var(--rule);
}
.nav-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 16px 0; }
.brand { display: flex; align-items: center; gap: 14px; text-decoration: none; color: var(--ink); }
.brand-logo { height: 40px; width: auto; display: block; }
.brand-logo.dark { display: none; }
[data-theme="dark"] .brand-logo.light { display: none; }
[data-theme="dark"] .brand-logo.dark { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .brand-logo.light { display: none; }
  :root:not([data-theme="light"]) .brand-logo.dark { display: block; }
}
.brand-tagline {
  font-family: var(--f-mono); font-size: 10px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink-3); border-left: 1px solid var(--rule); padding-left: 12px; white-space: nowrap;
}
.nav-links { display: flex; align-items: center; gap: 22px; font-size: 14px; font-weight: 500; }
.nav-links a { text-decoration: none; color: var(--ink-2); }
.nav-links a:hover { color: var(--ink); }
.nav-links a.on { color: var(--process); font-weight: 700; }
.nav-links .btn { white-space: nowrap; }
.theme-btn {
  background: var(--surface-3); border: 1px solid var(--rule); color: var(--ink-2);
  border-radius: var(--r-full); padding: 6px 12px; font-size: 12px; font-family: var(--f-mono);
}
.theme-btn:hover { color: var(--ink); border-color: var(--rule-2); }
@media (max-width: 720px) { .nav-links a.hide-sm { display: none; } }
@media (max-width: 560px) { .brand-tagline { display: none; } }

/* ---------------- shop head / hero ---------------- */
.shop-head { padding: 56px 0 28px; }
.shop-head .eyebrow { display: inline-block; margin-bottom: 12px; }
.shop-head h1 { font-size: clamp(30px, 4.6vw, 44px); letter-spacing: -.02em; }
.lede { margin-top: 16px; font-size: 18px; color: var(--ink-2); max-width: 60ch; }

/* ---------------- offer banner ---------------- */
.offer-banner {
  display: flex; flex-direction: column; gap: 4px; margin: 8px 0 32px;
  border: 1px solid var(--process-line); border-left: 4px solid var(--process);
  background: var(--process-bg); border-radius: var(--r-m); padding: 18px 20px;
}
.offer-banner.live { border-color: var(--ok-line); border-left-color: var(--ok); background: var(--ok-bg); }
.offer-kicker {
  font-family: var(--f-mono); font-size: 10px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--process); font-weight: 700;
}
.offer-banner.live .offer-kicker { color: var(--ok); }
.offer-title { font-family: var(--f-display); font-size: 18px; color: var(--ink); }
.offer-desc { font-size: 14px; color: var(--ink-2); }

/* ---------------- book grid / cards ---------------- */
.book-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 22px; }
@media (max-width: 720px) { .book-grid { grid-template-columns: 1fr; } }

.book-card { display: grid; grid-template-columns: 190px 1fr; gap: 20px; padding: 20px; align-items: start; }
@media (max-width: 520px) { .book-card { grid-template-columns: 1fr; } }
.book-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lift); border-color: var(--process-line); }
.book-card-cover { display: block; text-decoration: none; }
.book-card-title { font-size: 20px; line-height: 1.2; }
.book-card-title a { color: inherit; text-decoration: none; }
.book-card-title a:hover { color: var(--process); }
.book-card-sub { font-size: 13px; color: var(--ink-3); margin: 4px 0 10px; }
.book-card-blurb { font-size: 14px; color: var(--ink-2); margin: 12px 0 14px; }
.book-card-prices { display: flex; flex-direction: column; gap: 4px; margin-bottom: 16px; font-size: 14px; }
.pc-line { display: flex; align-items: baseline; gap: 8px; }
.pc-line b { font-family: var(--f-mono); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); min-width: 58px; }

.tag-row { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---------------- generated cover ---------------- */
.book-cover-img { width: 100%; height: auto; border-radius: var(--r-s); display: block; }
.book-cover-gen {
  position: relative; aspect-ratio: 2 / 3; border-radius: 6px; overflow: hidden;
  background: linear-gradient(145deg, var(--c1), var(--c2));
  color: #fff; padding: 20px 16px 16px 26px; display: flex; flex-direction: column;
  box-shadow: var(--shadow); isolation: isolate;
}
.book-cover-gen::after {
  content: ''; position: absolute; inset: 0; z-index: -1;
  background: radial-gradient(120px 120px at 80% 12%, rgba(255,255,255,.22), transparent 70%);
}
.bc-spine { position: absolute; left: 12px; top: 0; bottom: 0; width: 3px; background: rgba(255,255,255,.35); border-radius: 2px; }
.bc-brand { font-family: var(--f-mono); font-size: 8.5px; letter-spacing: .16em; text-transform: uppercase; opacity: .85; }
.bc-title { font-family: var(--f-display); font-weight: 700; font-size: 17px; line-height: 1.22; margin-top: auto; letter-spacing: -.01em; }
.bc-author { font-family: var(--f-mono); font-size: 9.5px; letter-spacing: .06em; margin-top: 8px; opacity: .9; }

/* ---------------- price chips ---------------- */
.price-free {
  font-family: var(--f-display); font-weight: 700; color: var(--ok);
  background: var(--ok-bg); border: 1px solid var(--ok-line); border-radius: var(--r-full);
  padding: 1px 9px; font-size: 13px;
}
.price-old { color: var(--ink-3); text-decoration: line-through; font-size: 13px; }
.price-now { font-family: var(--f-display); font-weight: 700; color: var(--ink); }

.shop-foot { margin-top: 28px; font-size: 13px; color: var(--ink-3); }

/* ---------------- detail page ---------------- */
.crumbs { padding: 28px 0 8px; font-size: 13px; color: var(--ink-3); }
.crumbs a { color: var(--ink-2); text-decoration: none; }
.crumbs a:hover { color: var(--process); }
.crumbs span { margin: 0 6px; }

.detail { display: grid; grid-template-columns: 300px 1fr; gap: 40px; align-items: start; padding: 12px 0 0; }
@media (max-width: 780px) { .detail { grid-template-columns: 1fr; gap: 26px; } }
.detail-cover { position: sticky; top: 90px; display: flex; flex-direction: column; gap: 14px; }
@media (max-width: 780px) { .detail-cover { position: static; max-width: 260px; } }
.detail-info h1 { font-size: clamp(26px, 3.6vw, 36px); letter-spacing: -.02em; margin-top: 6px; }
.byline { margin-top: 10px; color: var(--ink-2); font-size: 15px; }
.detail-desc { margin-top: 16px; color: var(--ink-2); max-width: 68ch; }

.tick-list { list-style: none; padding: 0; margin: 16px 0; display: flex; flex-direction: column; gap: 8px; }
.tick-list li { position: relative; padding-left: 26px; font-size: 14.5px; color: var(--ink-2); max-width: 68ch; }
.tick-list li::before {
  content: '✓'; position: absolute; left: 0; top: 0; color: var(--ok); font-weight: 700;
}

.sec-title { font-size: 18px; margin: 30px 0 12px; }
.spec-table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-m); overflow: hidden; max-width: 520px; }
.spec-table th, .spec-table td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--rule); font-size: 14px; }
.spec-table tr:last-child th, .spec-table tr:last-child td { border-bottom: 0; }
.spec-table th { font-family: var(--f-mono); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); width: 40%; background: var(--surface-3); }
.back-link { margin-top: 28px; }
.back-link a { color: var(--ink-2); text-decoration: none; }
.back-link a:hover { color: var(--process); }

/* ---------------- buy box ---------------- */
.buybox { margin: 22px 0; padding: 20px; }
.buybox-offer {
  margin-bottom: 14px; border: 1px solid var(--ok-line); background: var(--ok-bg);
  color: var(--ink); border-radius: var(--r-s); padding: 10px 14px; font-size: 14px;
}
.format-picker { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 520px) { .format-picker { grid-template-columns: 1fr; } }
.format-opt {
  display: flex; flex-direction: column; gap: 6px; cursor: pointer;
  border: 1px solid var(--rule-2); border-radius: var(--r-s); padding: 14px 16px;
  transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
}
.format-opt:hover { border-color: var(--process-line); }
.format-opt:has(input:checked) { border-color: var(--process); background: var(--process-bg); box-shadow: 0 0 0 1px var(--process) inset; }
.format-opt input { position: absolute; opacity: 0; width: 0; height: 0; }
.fo-name { font-weight: 600; font-size: 14.5px; }
.fo-price { font-size: 14px; }

.buy-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-top: 18px; }
.buy-price { font-size: 22px; display: flex; align-items: baseline; gap: 10px; }
.buy-result { margin-top: 16px; border-top: 1px dashed var(--rule); padding-top: 14px; font-size: 14px; }
.buy-result p { margin: 6px 0 0; color: var(--ink-2); max-width: 60ch; }

.includes { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin: 24px 0; align-items: start; }
.includes .card { margin-top: 0; }
.includes .card h3 { font-size: 15px; margin-bottom: 8px; }
.includes .tick-list { margin: 0; }

.empty { padding: 32px; color: var(--ink-2); text-align: center; }

/* ---------------- order page ---------------- */
.order-head { padding: 44px 0 22px; }
.order-wrap { display: grid; grid-template-columns: 1fr 360px; gap: 28px; align-items: start; }
@media (max-width: 860px) { .order-wrap { grid-template-columns: 1fr; } }
.order-main { min-width: 0; }
.order-side { position: sticky; top: 90px; }
@media (max-width: 860px) { .order-side { position: static; order: -1; } }

.order-form .sec-title { margin-top: 0; }
.order-form .btn { margin-top: 6px; }

/* auth box */
.auth-box { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-bottom: 18px; }
.auth-box.signed-in { gap: 10px; }
.auth-box p { flex: 1 1 100%; margin: 0; font-size: 14px; }
.auth-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px var(--ok-bg); flex: none; }
.auth-box .btn.ghost { margin-left: auto; }
.auth-tabs { display: flex; gap: 6px; flex: 1 1 100%; margin: 4px 0 16px; }
.auth-tab {
  background: var(--surface-3); border: 1px solid var(--rule); color: var(--ink-2);
  border-radius: var(--r-full); padding: 7px 16px; font-size: 13px; font-weight: 600;
}
.auth-tab:hover { color: var(--ink); border-color: var(--rule-2); }
.auth-tab.on { background: var(--process); border-color: var(--process); color: #fff; }
.auth-form { flex: 1 1 100%; max-width: 460px; }
.auth-msg { flex: 1 1 100%; font-size: 13.5px; margin-top: 4px; }
.auth-msg.err { color: var(--no); }

/* summary card */
.order-summary .order-cover { max-width: 190px; margin-bottom: 16px; }
.order-summary .book-cover-img { box-shadow: var(--shadow); }
.order-book-title { font-family: var(--f-display); font-size: 18px; line-height: 1.25; }
.order-book-sub { font-size: 13px; color: var(--ink-3); margin: 4px 0 16px; }
.order-summary .format-picker { grid-template-columns: 1fr; }
.order-summary .buybox-offer { margin-bottom: 16px; }
.qty-ctrl { margin-top: 18px; }
.qty-ctrl input { max-width: 120px; }

.order-totals { margin-top: 18px; border-top: 1px dashed var(--rule); padding-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.ot-line { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; font-size: 14px; color: var(--ink-2); }
.ot-total { font-size: 16px; color: var(--ink); border-top: 1px solid var(--rule); padding-top: 10px; margin-top: 2px; }
.ot-total > span:first-child { font-family: var(--f-display); font-weight: 700; }

.order-msg { margin-top: 16px; border-radius: var(--r-s); padding: 12px 14px; font-size: 14px; border: 1px solid var(--rule-2); background: var(--surface-3); }
.order-msg.ok { border-color: var(--ok-line); background: var(--ok-bg); color: var(--ink); }
.order-msg.err { border-color: var(--no-line); background: var(--no-bg); color: var(--ink); }
.order-msg.warn { border-color: var(--warn-line); background: var(--warn-bg); color: var(--ink); }
.order-msg p { margin: 6px 0 0; color: var(--ink-2); max-width: 60ch; }
.order-msg .buy-row { margin-top: 12px; }
.order-copy {
  white-space: pre-wrap; word-break: break-word; font-family: var(--f-mono); font-size: 12.5px;
  line-height: 1.55; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-s);
  padding: 12px 14px; margin: 10px 0 0; color: var(--ink); max-height: 320px; overflow: auto;
}

/* payment + slip */
#paymentSection { margin-top: 22px; }
#paymentSection:empty { display: none; }
.pay-picker { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin-bottom: 14px; }
.pay-note {
  border-radius: var(--r-s); padding: 11px 14px; font-size: 14px;
  border: 1px solid var(--rule-2); background: var(--surface-3); color: var(--ink-2);
}
.pay-note.ok { border-color: var(--ok-line); background: var(--ok-bg); color: var(--ink); }
.pay-note.warn { border-color: var(--warn-line); background: var(--warn-bg); color: var(--ink); }
.pay-instr { margin: 0 0 12px; max-width: 62ch; }
.pay-details {
  border: 1px solid var(--rule); border-radius: var(--r-s); background: var(--surface-3);
  padding: 6px 14px; margin-bottom: 14px;
}
.pd-row { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; padding: 8px 0; border-bottom: 1px solid var(--rule); font-size: 14px; }
.pd-row:last-child { border-bottom: 0; }
.pd-row span { color: var(--ink-3); }
.pd-row b { font-family: var(--f-mono); font-size: 13.5px; }
.slip-ctrl input[type="file"] { padding: 9px 10px; background: var(--surface); cursor: pointer; }
.slip-ctrl .hint { margin-top: 6px; }

/* order history */
.orders-list { display: flex; flex-direction: column; gap: 0; padding: 6px 20px; }
.order-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--rule); }
.order-row:last-child { border-bottom: 0; }
.order-row-main { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.order-row-main b { font-size: 14.5px; }
.order-row-main .muted { font-size: 12.5px; }
.order-row-note { font-size: 12.5px; }
.order-row-side { display: flex; align-items: center; gap: 12px; flex: none; }
.order-row-price { font-family: var(--f-display); font-weight: 700; font-size: 14.5px; }
.order-dl { font-size: 13px; padding: 7px 14px; }

/* ---------------- footer ---------------- */
.site-foot { border-top: 1px solid var(--rule); margin-top: 40px; }
.site-foot .wrap { display: flex; flex-wrap: wrap; gap: 14px; justify-content: space-between; align-items: center; padding: 26px 16px; font-size: 13px; color: var(--ink-3); }
.site-foot .foot-logo { height: 16px; width: auto; display: block; }
.site-foot .foot-logo.dark { display: none; }
[data-theme="dark"] .site-foot .foot-logo.light { display: none; }
[data-theme="dark"] .site-foot .foot-logo.dark { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .site-foot .foot-logo.light { display: none; }
  :root:not([data-theme="light"]) .site-foot .foot-logo.dark { display: block; }
}
