/* Metagana Publication · tokens from DESIGN.md */
:root {
  --paper: #EDE6DA;
  --white: #FFFDF8;
  --tray: #D8C3A5;
  --tray-light: #E6D8C3;
  --cocoa: #5C4433;
  --espresso: #3B2E28;
  --muted: #8B6B50;
  --footer: #382D29;
  --gold: #C9B597;
  --on-accent: #F6F1E8;
  --hairline: #D9CDBB;
  --wash: #F3ECE1;

  --page-width: 1400px;
  --gutter: 50px;
  --section-gap: 50px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --dur: 200ms;
  --font: "Manrope", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { font-size: 62.5%; -webkit-text-size-adjust: 100%; scrollbar-color: var(--muted) var(--paper); }
body {
  margin: 0;
  font: 400 1.6rem/1.8 var(--font);
  letter-spacing: 0.03rem;
  color: var(--cocoa);
  caret-color: var(--espresso);
  background-color: var(--paper);
  /* paper grain */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .23 0 0 0 0 .18 0 0 0 0 .14 0 0 0 .09 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  -webkit-font-smoothing: antialiased;
}
::selection { background: var(--tray); color: var(--espresso); }
::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-track { background: var(--paper); }
::-webkit-scrollbar-thumb { background: var(--muted); border-radius: 9999px; border: 2px solid var(--paper); }
img, svg { display: block; max-width: 100%; }
a { color: inherit; }
ul { list-style: none; margin: 0; padding: 0; }
h1, h2, p { margin: 0; }
:focus-visible { outline: 2px solid var(--espresso); outline-offset: 3px; border-radius: 4px; }

.page-width { max-width: var(--page-width); margin: 0 auto; padding: 0 var(--gutter); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 16px; top: -60px; z-index: 20; padding: 10px 18px; border-radius: 9999px; background: var(--espresso); color: var(--on-accent); font-weight: 700; text-decoration: none; }
.skip:focus { top: 16px; }

/* ---------- Header ---------- */
.header { position: sticky; top: 0; z-index: 10; background: var(--white); border-bottom: 1px solid var(--hairline); transition: transform 300ms var(--ease); }
.header.is-hidden { transform: translateY(-100%); }
.header__top { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 32px; padding-top: 20px; padding-bottom: 12px; }
.header__menu-btn.icon-btn, .nav__mobile-only { display: none; }
.header__logo img { width: 160px; height: auto; }
.icon-btn { position: relative; display: inline-flex; align-items: center; gap: 8px; min-width: 44px; min-height: 44px; justify-content: center; padding: 0 6px; border: 0; background: none; color: var(--muted); font: 600 1.4rem var(--font); text-decoration: none; cursor: pointer; border-radius: 9999px; transition: color var(--dur) var(--ease); }
.icon-btn:hover { color: var(--espresso); }
.icon-btn svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.header__actions { display: flex; gap: 8px; }
.cart-count { position: absolute; top: 4px; right: 0; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9999px; background: var(--espresso); color: var(--on-accent); font: 700 1.1rem/18px var(--font); text-align: center; font-variant-numeric: tabular-nums; }

.search { position: relative; justify-self: center; width: min(380px, 100%); }
.search__icon { position: absolute; left: 16px; top: 50%; width: 18px; height: 18px; transform: translateY(-50%); fill: none; stroke: var(--muted); stroke-width: 1.75; stroke-linecap: round; pointer-events: none; }
.search__input { width: 100%; height: 40px; padding: 0 20px 0 44px; border: 0; border-radius: 9999px; background: var(--white); color: var(--espresso); font: 500 1.4rem var(--font); box-shadow: 0 0 0 1px var(--muted), inset 0 2px 3px rgba(59,46,40,.06); transition: box-shadow var(--dur) var(--ease); }
.search__input::placeholder { color: var(--cocoa); opacity: 1; }
.search__input:focus { outline: none; box-shadow: 0 0 0 2px var(--espresso); }

.nav__list { display: flex; gap: 32px; }
.nav__list a { display: inline-flex; align-items: center; min-height: 42px; color: var(--muted); font: 600 1.4rem/1.3 var(--font); letter-spacing: .06rem; text-decoration: none; text-underline-offset: 4px; transition: color var(--dur) var(--ease); }
.nav__list a:hover, .nav__list a[aria-current="page"] { color: var(--espresso); text-decoration: underline; text-decoration-thickness: 1px; }

/* ---------- Hero ---------- */
.hero { margin-bottom: var(--section-gap); background: var(--footer); }
.hero__img { width: 100%; height: auto; animation: hero-in 1.2s var(--ease) both; }
@keyframes hero-in { from { filter: blur(8px) brightness(.85); } to { filter: none; } }

/* ---------- Statement ---------- */
.statement { max-width: 1100px; margin-bottom: var(--section-gap); text-align: center; }
.statement > * { max-width: 780px; margin-inline: auto; }
.statement__title { color: var(--espresso); font: 700 4rem/1.3 var(--font); letter-spacing: .06rem; text-wrap: balance; }
.statement__sub { margin-top: 8px; color: var(--muted); font: 500 2.2rem/1.45 var(--font); }
.statement__body { margin-top: 20px; max-width: 64ch; text-wrap: pretty; }

/* ---------- Shelf ---------- */
.shelf { margin-bottom: var(--section-gap); }
.shelf__head { display: flex; justify-content: center; }
.shelf__title { color: var(--espresso); font: 700 2.4rem/1.3 var(--font); letter-spacing: .06rem; }
.shelf__link { display: none; }
.shelf__note { max-width: 60ch; margin: 8px auto 28px; text-align: center; font-size: 1.4rem; line-height: 1.6; }
.shelf__grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 20px 30px; }
.shelf__counter { display: none; }
.shelf__cta { display: flex; justify-content: center; margin-top: 30px; }

.card { position: relative; height: 100%; }
.card__link { display: flex; flex-direction: column; height: 100%; padding: 20px; border-radius: 10px; background: var(--tray); color: var(--espresso); text-decoration: none; transition: background-color var(--dur) var(--ease); }
.card__link:hover { background: color-mix(in srgb, var(--tray), var(--espresso) 8%); }
.card__link:hover .card__title { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.card__media { display: grid; place-items: center; aspect-ratio: 1; margin-bottom: 14px; }
.cover { position: relative; display: flex; flex-direction: column; justify-content: space-between; width: 64%; aspect-ratio: 2 / 3; padding: 12% 8% 10% 14%; border-radius: 2px; background: var(--c, var(--espresso)); color: var(--t, var(--gold)); box-shadow: 0 8px 16px -6px rgba(59,46,40,.35); overflow: hidden; }
.cover--img { padding: 0; }
.cover__img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cover::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 6%; background: rgba(0,0,0,.18); }
.cover__title { font: 700 clamp(.9rem, .9vw, 1.2rem)/1.2 var(--font); letter-spacing: .03em; text-transform: uppercase; overflow-wrap: anywhere; }
.cover__rule { width: 40%; height: 1px; background: currentColor; opacity: .6; }
.cover__author { font: 500 clamp(.8rem, .7vw, 1rem)/1.2 var(--font); letter-spacing: .12em; text-transform: uppercase; }
.card__title { font: 600 1.4rem/1.6 var(--font); letter-spacing: .06rem; text-transform: uppercase; }
.card__author { margin-top: 2px; color: var(--cocoa); font-size: 1.3rem; line-height: 1.5; }
.card__price { margin-top: auto; padding-top: 10px; font: 700 1.4rem var(--font); font-variant-numeric: tabular-nums; }
.card__add { display: none; position: absolute; top: 8px; right: 8px; width: 34px; height: 34px; place-items: center; border: 0; border-radius: 50%; background: var(--espresso); color: var(--on-accent); cursor: pointer; transition: background-color var(--dur) var(--ease); }
.card__add:hover { background: var(--cocoa); }
.card__add svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }

.btn { display: inline-flex; align-items: center; height: 40px; padding: 0 28px; border-radius: 9999px; background: var(--espresso); color: var(--on-accent); font: 700 1.5rem/1 var(--font); letter-spacing: .06rem; text-decoration: none; transition: background-color var(--dur) var(--ease); }
.btn:hover { background: var(--cocoa); }

/* ---------- Footer ---------- */
.footer { background: var(--footer); color: var(--on-accent); font-size: 1.5rem; font-weight: 500; }
.footer__top { display: grid; grid-template-columns: repeat(3, 1fr); gap: 30px; padding-top: 50px; padding-bottom: 50px; }
.footer__heading { margin-bottom: 12px; color: var(--gold); font: 700 1.6rem/1.3 var(--font); letter-spacing: .06rem; }
.footer__col p + p { margin-top: 6px; }
.footer__links a, .footer__legal a { text-decoration: none; text-underline-offset: 4px; }
.footer__links a:hover, .footer__legal a:hover { color: var(--gold); text-decoration: underline; }
.footer__bottom { display: flex; flex-direction: column; align-items: center; gap: 6px; padding-top: 28px; padding-bottom: 32px; border-top: 1px solid rgba(201,181,151,.25); font-size: 1.3rem; text-align: center; }
.footer__legal { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 0; }
.footer__legal li + li::before { content: "|"; margin: 0 10px; color: var(--gold); }
.footer :focus-visible { outline-color: var(--gold); }

/* ---------- Tablet ---------- */
@media (max-width: 989px) {
  .shelf__grid { grid-template-columns: repeat(3, 1fr); }
  .header__action-label { display: none; }
}

/* ---------- Mobile ---------- */
@media (max-width: 749px) {
  :root { --gutter: 15px; }
  body { font-size: 1.5rem; }
  .header__top { grid-template-columns: 44px 1fr 44px; gap: 8px; padding-top: 12px; padding-bottom: 12px; }
  .header__menu-btn.icon-btn { display: inline-flex; }
  .header__logo { justify-self: center; }
  .header__logo img { width: 110px; }
  .header__account { display: none; }
  .search { grid-column: 1 / -1; grid-row: 2; width: 100%; }
  .nav__mobile-only { display: list-item; }
  .nav { position: absolute; left: 0; right: 0; top: 100%; padding: 0; background: var(--white); box-shadow: 0 4px 12px rgba(59,46,40,.15); display: none; }
  .nav.is-open { display: block; }
  .nav__list { flex-direction: column; gap: 0; padding: 8px 0; }
  .nav__list a { display: flex; min-height: 48px; padding: 0 var(--gutter); font-size: 1.5rem; }
  .nav__list a:hover { background: var(--wash); }

  .statement__title { font-size: 3rem; }
  .statement__sub { font-size: 1.8rem; }

  .shelf__head { justify-content: space-between; align-items: baseline; gap: 16px; }
  .shelf__title { font-size: 2rem; }
  .shelf__link { display: inline; flex-shrink: 0; color: var(--espresso); font: 600 1.4rem var(--font); text-underline-offset: 4px; }
  .shelf__note { margin: 6px 0 16px; text-align: left; }
  .shelf__grid { display: flex; gap: 10px; margin: 0 calc(var(--gutter) * -1); padding: 0 var(--gutter); overflow-x: auto; scroll-snap-type: x mandatory; scroll-padding-inline: var(--gutter); scrollbar-width: none; }
  .shelf__grid::-webkit-scrollbar { display: none; }
  .shelf__grid > li { flex: 0 0 calc((100% - 10px) / 2); scroll-snap-align: start; }
  .card__link { padding: 0 0 12px; }
  .card__media { margin-bottom: 10px; }
  .card__title, .card__author, .card__price { padding-inline: 10px; }
  .card__title { font-size: 1.3rem; }
  .card__add { display: grid; }
  .shelf__counter { display: block; margin-top: 14px; text-align: center; font: 600 1.3rem var(--font); font-variant-numeric: tabular-nums; }
  .shelf__cta { display: none; }

  .footer__top { grid-template-columns: 1fr; gap: 28px; padding: 40px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Catalog Filters & Empty State ---------- */
.shelf__filters { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-bottom: 28px; }
.filter-pill { height: 36px; padding: 0 18px; border: 1px solid var(--hairline); border-radius: 9999px; background: var(--white); color: var(--muted); font: 600 1.3rem/1 var(--font); letter-spacing: .04rem; cursor: pointer; transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease), border-color var(--dur) var(--ease); }
.filter-pill:hover { color: var(--espresso); border-color: var(--muted); }
.filter-pill.is-active { background: var(--espresso); border-color: var(--espresso); color: var(--on-accent); }
.shelf__empty { padding: 48px 20px; text-align: center; border-radius: 10px; background: var(--white); border: 1px solid var(--hairline); }
.shelf__empty p { margin-bottom: 16px; color: var(--espresso); font-weight: 600; }

/* ---------- Shared Button Variants & Badges ---------- */
.btn { border: 0; cursor: pointer; justify-content: center; }
.btn--full { width: 100%; }
.btn--outline { background: transparent; color: var(--espresso); border: 1px solid var(--espresso); }
.btn--outline:hover { background: var(--wash); color: var(--espresso); }
.btn--ghost { background: var(--wash); color: var(--espresso); }
.btn--ghost:hover { background: var(--tray); }
.badge { display: inline-block; padding: 3px 10px; border-radius: 9999px; background: var(--tray-light); color: var(--espresso); font: 700 1.1rem/1.4 var(--font); letter-spacing: .05em; text-transform: uppercase; }
.badge--espresso { background: var(--espresso); color: var(--on-accent); }
.tabular { font-variant-numeric: tabular-nums; }

/* ---------- Slide-Over Drawers (PDP & Troli) ---------- */
.drawer-backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(59,46,40,.42); }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; z-index: 50; width: min(520px, 100%); display: flex; flex-direction: column; background: var(--white); color: var(--cocoa); box-shadow: 0 4px 24px rgba(59,46,40,.18); transform: translateX(100%); transition: transform 260ms var(--ease); }
.drawer.is-open { transform: translateX(0); }
.drawer__head { display: flex; align-items: center; justify-content: space-between; padding: 18px 24px; border-bottom: 1px solid var(--hairline); background: var(--white); }
.drawer__kicker, .drawer__title { color: var(--espresso); font: 700 1.8rem/1.3 var(--font); letter-spacing: .04rem; }
.drawer__body { flex: 1; overflow-y: auto; padding: 24px; display: flex; flex-direction: column; gap: 20px; }

/* PDP Content */
.pdp__hero { display: grid; grid-template-columns: 132px 1fr; gap: 20px; align-items: start; padding: 18px; border-radius: 10px; background: var(--tray-light); }
.pdp__hero .cover { width: 100%; }
.pdp__title { color: var(--espresso); font: 700 2rem/1.3 var(--font); text-transform: uppercase; letter-spacing: .04rem; }
.pdp__author { margin-top: 4px; color: var(--cocoa); font: 500 1.4rem/1.4 var(--font); }
.pdp__price { margin-top: 12px; color: var(--espresso); font: 700 2rem/1 var(--font); font-variant-numeric: tabular-nums; }
.pdp__specs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; padding: 14px 16px; border-radius: 10px; background: var(--paper); font-size: 1.3rem; }
.pdp__specs span { display: block; color: var(--muted); font-size: 1.1rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.pdp__specs strong { color: var(--espresso); font-weight: 700; }
.pdp__label { display: block; margin-bottom: 8px; color: var(--espresso); font: 700 1.3rem/1.3 var(--font); text-transform: uppercase; letter-spacing: .05em; }
.editions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.edition-btn { padding: 10px 8px; border: 1px solid var(--hairline); border-radius: 10px; background: var(--white); color: var(--espresso); text-align: left; cursor: pointer; font: 600 1.25rem/1.3 var(--font); transition: border-color var(--dur) var(--ease), background-color var(--dur) var(--ease); }
.edition-btn span { display: block; margin-top: 4px; color: var(--muted); font: 700 1.3rem var(--font); font-variant-numeric: tabular-nums; }
.edition-btn.is-selected { border-color: var(--espresso); background: var(--tray-light); }
.pdp__excerpt { border-top: 1px solid var(--hairline); padding-top: 16px; }
.pdp__excerpt-toggle { display: inline-flex; align-items: center; gap: 8px; padding: 0; border: 0; background: none; color: var(--espresso); font: 700 1.4rem var(--font); text-decoration: underline; text-underline-offset: 4px; cursor: pointer; }
.pdp__excerpt-box { margin-top: 12px; padding: 16px; border-radius: 10px; background: var(--paper); color: var(--espresso); font: 400 1.5rem/1.8 var(--font); font-style: italic; }

/* Cart & Checkout */
.cart-empty { margin: auto 0; text-align: center; padding: 40px 16px; }
.cart-empty p { margin-bottom: 18px; color: var(--espresso); font-weight: 600; }
.cart-list { display: flex; flex-direction: column; gap: 14px; }
.cart-item { display: grid; grid-template-columns: 56px 1fr auto; gap: 14px; align-items: center; padding: 14px; border-radius: 10px; background: var(--paper); }
.cart-item .cover { width: 100%; }
.cart-item__title { color: var(--espresso); font: 700 1.35rem/1.35 var(--font); text-transform: uppercase; }
.cart-item__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 4px; }
.cart-item__price { color: var(--espresso); font: 700 1.4rem var(--font); font-variant-numeric: tabular-nums; }
.qty-stepper { display: inline-flex; align-items: center; gap: 8px; margin-top: 8px; }
.qty-stepper button { width: 28px; height: 28px; border: 1px solid var(--hairline); border-radius: 50%; background: var(--white); color: var(--espresso); font: 700 1.4rem/1 var(--font); cursor: pointer; }
.qty-stepper button:hover { background: var(--tray); }
.qty-stepper span { min-width: 18px; text-align: center; font: 700 1.3rem var(--font); color: var(--espresso); font-variant-numeric: tabular-nums; }
.cart-item__remove { border: 0; background: none; color: var(--muted); font: 600 1.2rem var(--font); text-decoration: underline; cursor: pointer; }
.cart-summary { margin-top: auto; padding-top: 18px; border-top: 1px solid var(--hairline); display: flex; flex-direction: column; gap: 12px; }
.cart-summary__row { display: flex; justify-content: space-between; align-items: baseline; color: var(--espresso); font: 700 1.7rem var(--font); }
.checkout-form { display: flex; flex-direction: column; gap: 14px; }
.field label { display: block; margin-bottom: 5px; color: var(--espresso); font: 600 1.3rem var(--font); }
.field input, .field textarea { width: 100%; padding: 10px 14px; border: 1px solid var(--muted); border-radius: 10px; background: var(--white); color: var(--espresso); font: 500 1.4rem/1.5 var(--font); }
.field input:focus, .field textarea:focus { outline: none; border-color: var(--espresso); box-shadow: 0 0 0 1px var(--espresso); }
.form-error { padding: 10px 14px; border-radius: 10px; background: var(--tray); color: var(--espresso); font: 600 1.3rem var(--font); }
.checkout-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 6px; }

/* ---------- Subpages (/mock-billplz & /payment/return) ---------- */
.subpage { padding-top: 50px; padding-bottom: 50px; }
.subpage__card { max-width: 720px; margin: 0 auto; padding: 36px; border-radius: 16px; background: var(--white); border: 1px solid var(--hairline); }
.subpage__head { margin-bottom: 24px; }
.subpage__title { margin-top: 10px; color: var(--espresso); font: 700 2.8rem/1.3 var(--font); }
.subpage__sub { margin-top: 8px; color: var(--cocoa); font-size: 1.5rem; }
.receipt__meta { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; padding: 18px; border-radius: 10px; background: var(--paper); margin-bottom: 20px; }
.receipt__meta span { display: block; color: var(--muted); font: 600 1.15rem var(--font); text-transform: uppercase; letter-spacing: .05em; }
.receipt__meta strong { color: var(--espresso); font: 700 1.45rem var(--font); }
.receipt__address { grid-column: 1 / -1; }
.receipt__list { border-top: 1px solid var(--hairline); margin-bottom: 24px; }
.receipt__item { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--hairline); color: var(--espresso); font-size: 1.45rem; }
.mock-actions, .subpage__actions { display: flex; flex-wrap: wrap; gap: 12px; }
.receipt__downloads { margin: 0 0 24px; padding: 20px; border-radius: 10px; background: var(--tray-light); }
.receipt__downloads-title { color: var(--espresso); font: 700 1.6rem/1.3 var(--font); }
.receipt__downloads-note { margin-top: 4px; color: var(--cocoa); font-size: 1.35rem; }
.receipt__downloads-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }

/* ---------- Admin Orders Dashboard ---------- */
.subpage__card--wide { max-width: 100%; }
.btn--sm { height: 32px; padding: 0 14px; font-size: 1.25rem; }
.admin__table-wrap { overflow-x: auto; }
.admin__table { width: 100%; border-collapse: collapse; font-size: 1.35rem; }
.admin__table th { padding: 12px 10px; border-bottom: 2px solid var(--hairline); color: var(--muted); font: 700 1.15rem/1.3 var(--font); text-align: left; text-transform: uppercase; letter-spacing: .05em; }
.admin__table td { padding: 14px 10px; border-bottom: 1px solid var(--hairline); vertical-align: top; color: var(--espresso); }
.admin__muted { color: var(--muted); font-size: 1.25rem; }

@media (max-width: 749px) {
  .pdp__hero { grid-template-columns: 100px 1fr; gap: 14px; }
  .pdp__specs, .editions, .receipt__meta { grid-template-columns: 1fr; }
  .subpage__card { padding: 22px; }
}
