/* ==========================================================================
   Ecuacultura — Storefront
   Dirección visual: "biblioteca nocturna" — fondo cálido oscuro, lomos de
   libro de colores como navegación principal, acentos dorados tipo hoja de
   oro. Nada de plantilla genérica: la estantería ES el hero.
   ========================================================================== */

:root {
    --ink: #1D1712;
    --surface: #271F18;
    --surface-2: #332920;
    --paper: #F2EAD9;
    --muted: #A89785;
    --gold: #C9972E;
    --gold-dim: #8A6A26;
    --border: #3A2F24;
    --radius: 6px;
    --shadow: 0 16px 32px -12px rgba(0, 0, 0, 0.55);

    --font-display: 'Fraunces', Georgia, serif;
    --font-body: 'Public Sans', -apple-system, sans-serif;
    --font-mono: 'IBM Plex Mono', Menlo, monospace;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    margin: 0;
    background: var(--ink);
    color: var(--paper);
    font-family: var(--font-body);
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }

h1, h2, h3 { font-family: var(--font-display); font-weight: 600; margin: 0 0 .4em; }

.container { max-width: 1180px; margin: 0 auto; padding: 0 20px; }

:focus-visible {
    outline: 2px solid var(--gold);
    outline-offset: 3px;
}

/* ---------- Header ---------- */
.site-header {
    position: sticky; top: 0; z-index: 40;
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px;
    background: rgba(29, 23, 18, 0.92);
    backdrop-filter: blur(6px);
    border-bottom: 1px solid var(--border);
}
.brand { font-family: var(--font-display); font-size: 22px; font-weight: 600; letter-spacing: .02em; color: var(--paper); }
.brand span { color: var(--gold); }
.header-actions { display: flex; align-items: center; gap: 18px; }
.cart-btn {
    position: relative; background: none; border: 1px solid var(--border);
    color: var(--paper); font-family: var(--font-body); font-size: 14px;
    padding: 9px 16px; border-radius: 999px; cursor: pointer;
    display: flex; align-items: center; gap: 8px;
    transition: border-color .15s ease;
}
.cart-btn:hover { border-color: var(--gold); }
.cart-count {
    background: var(--gold); color: var(--ink); font-family: var(--font-mono);
    font-size: 12px; font-weight: 700; min-width: 20px; height: 20px;
    border-radius: 999px; display: flex; align-items: center; justify-content: center;
}

/* ---------- Hero: la estantería ---------- */
.shelf-hero { padding: 56px 0 40px; }
.shelf-intro { max-width: 560px; margin-bottom: 40px; }
.eyebrow {
    font-family: var(--font-mono); text-transform: uppercase; letter-spacing: .14em;
    font-size: 12px; color: var(--gold); margin: 0 0 12px;
}
.shelf-intro h1 { font-size: clamp(28px, 4.5vw, 44px); color: var(--paper); line-height: 1.1; }
.shelf-intro p { color: var(--muted); font-size: 16px; margin: 0; }

.shelf {
    display: flex; align-items: flex-end; gap: 6px;
    overflow-x: auto; padding: 12px 4px 20px;
    scrollbar-width: thin; scrollbar-color: var(--gold-dim) transparent;
}
.spine {
    flex: 0 0 auto;
    width: 58px; height: 260px;
    background: var(--spine-color, var(--gold));
    border-radius: 5px 5px 3px 3px;
    display: flex; align-items: flex-start; justify-content: center;
    padding: 18px 0;
    box-shadow: inset -3px 0 8px rgba(0,0,0,.25), 0 6px 14px rgba(0,0,0,.35);
    cursor: pointer;
    transition: transform .2s ease, box-shadow .2s ease;
}
.spine:nth-child(3n) { height: 288px; }
.spine:nth-child(4n) { height: 240px; width: 52px; }
.spine:nth-child(5n) { height: 272px; }
.spine:hover, .spine:focus-visible {
    transform: translateY(-16px) rotate(-2deg);
    box-shadow: inset -3px 0 8px rgba(0,0,0,.25), 0 20px 28px rgba(0,0,0,.5);
}
.spine.active { outline: 2px solid var(--gold); outline-offset: 2px; }
.spine-label {
    writing-mode: vertical-rl;
    font-family: var(--font-display); font-weight: 600; font-size: 13.5px;
    color: rgba(255,255,255,.94); letter-spacing: .02em;
    text-shadow: 0 1px 2px rgba(0,0,0,.3);
}

@media (prefers-reduced-motion: reduce) {
    .spine, .book-cover, .drawer, .modal-panel { transition: none !important; }
}

/* ---------- Secciones ---------- */
.section { padding: 36px 0; }
.section-head {
    display: flex; align-items: baseline; justify-content: space-between;
    margin-bottom: 20px; gap: 16px; flex-wrap: wrap;
}
.section-head h2 { font-size: 24px; color: var(--paper); }
.section-head .hint { color: var(--muted); font-size: 13px; font-family: var(--font-mono); }

.rail {
    display: flex; gap: 18px; overflow-x: auto; padding-bottom: 10px;
    scrollbar-width: thin; scrollbar-color: var(--gold-dim) transparent;
}

.pills { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 24px; }
.pill {
    font-family: var(--font-mono); font-size: 12.5px; padding: 7px 14px;
    border-radius: 999px; border: 1px solid var(--border); color: var(--muted);
    background: var(--surface); cursor: pointer; transition: all .15s ease;
    display: flex; align-items: center; gap: 7px;
}
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--pill-color, var(--gold)); }
.pill:hover { border-color: var(--gold-dim); color: var(--paper); }
.pill.active { background: var(--pill-color, var(--gold)); border-color: transparent; color: var(--ink); font-weight: 600; }
.pill.active .dot { background: var(--ink); }

.grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 20px;
}

/* ---------- Tarjeta de libro ---------- */
.book-card { cursor: pointer; }
.book-card, .rail .book-card { flex: 0 0 160px; }
.book-cover {
    position: relative; aspect-ratio: 2 / 3; border-radius: var(--radius);
    background: linear-gradient(155deg, var(--cat-color, var(--gold)) 0%, color-mix(in srgb, var(--cat-color, var(--gold)) 60%, #000) 100%);
    display: flex; align-items: center; justify-content: center; text-align: center;
    padding: 16px; box-shadow: var(--shadow);
    transition: transform .18s ease;
    overflow: hidden;
}
.book-card:hover .book-cover { transform: translateY(-5px); }
.book-cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.book-cover-title {
    font-family: var(--font-display); font-weight: 600; color: #fff;
    font-size: 15px; line-height: 1.25; text-shadow: 0 1px 3px rgba(0,0,0,.35);
    position: relative; z-index: 1;
}
.badge {
    position: absolute; top: 8px; left: 8px; z-index: 2;
    font-family: var(--font-mono); font-size: 10px; text-transform: uppercase;
    letter-spacing: .05em; background: var(--gold); color: var(--ink);
    padding: 3px 8px; border-radius: 3px; font-weight: 700;
}
.book-meta { padding: 10px 2px 0; }
.book-meta .autor { font-size: 12.5px; color: var(--muted); margin: 0 0 4px; }
.book-meta .precio { font-family: var(--font-mono); font-size: 14.5px; color: var(--paper); }
.book-meta .precio .antes { color: var(--muted); text-decoration: line-through; margin-right: 6px; font-size: 12.5px; }
.book-meta .precio .ahora { color: var(--gold); font-weight: 700; }

.load-more { display: block; margin: 28px auto 0; }

/* ---------- Botones ---------- */
.btn {
    font-family: var(--font-body); font-weight: 600; font-size: 14.5px;
    padding: 12px 22px; border-radius: 999px; border: none; cursor: pointer;
    transition: opacity .15s ease, transform .1s ease;
}
.btn:active { transform: scale(.98); }
.btn-gold { background: var(--gold); color: var(--ink); }
.btn-gold:hover { opacity: .9; }
.btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--paper); }
.btn-ghost:hover { border-color: var(--gold); }
.btn-block { width: 100%; text-align: center; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ---------- Modal (ficha de libro) ---------- */
.overlay {
    position: fixed; inset: 0; background: rgba(10, 8, 6, .72);
    display: none; align-items: center; justify-content: center; z-index: 80;
    padding: 20px;
}
.overlay.open { display: flex; }
.modal-panel {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 10px; max-width: 640px; width: 100%; max-height: 88vh;
    overflow-y: auto; padding: 28px;
}
.modal-close { float: right; background: none; border: none; color: var(--muted); font-size: 22px; cursor: pointer; line-height: 1; }
.modal-grid { display: grid; grid-template-columns: 140px 1fr; gap: 22px; margin-top: 6px; }
.modal-grid .book-cover { width: 140px; }
.modal-body h3 { font-size: 20px; }
.modal-body .autor { color: var(--muted); margin: 0 0 12px; font-size: 14px; }
.modal-body .descripcion { color: var(--muted); font-size: 14.5px; margin-bottom: 16px; }
.ficha-datos { font-family: var(--font-mono); font-size: 12px; color: var(--muted); margin-bottom: 16px; display: flex; gap: 14px; flex-wrap: wrap; }

.variantes { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.variante-opt {
    font-family: var(--font-mono); font-size: 12.5px; padding: 8px 13px;
    border: 1px solid var(--border); border-radius: 6px; cursor: pointer; color: var(--paper);
    background: var(--surface-2);
}
.variante-opt.selected { border-color: var(--gold); color: var(--gold); }
.variante-opt[disabled] { opacity: .4; cursor: not-allowed; text-decoration: line-through; }

.modal-precio { font-family: var(--font-mono); font-size: 22px; color: var(--gold); font-weight: 700; margin-bottom: 16px; }

/* ---------- Carrito (drawer) ---------- */
.drawer {
    position: fixed; top: 0; right: 0; height: 100%; width: min(400px, 100%);
    background: var(--surface); border-left: 1px solid var(--border);
    transform: translateX(100%); transition: transform .25s ease;
    z-index: 90; display: flex; flex-direction: column;
}
.drawer.open { transform: translateX(0); }
.drawer-head { padding: 20px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.drawer-items { flex: 1; overflow-y: auto; padding: 16px 20px; }
.cart-item { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.cart-item .cart-cover { width: 46px; height: 66px; border-radius: 4px; flex-shrink: 0; }
.cart-item .info { flex: 1; }
.cart-item .info .titulo { font-size: 13.5px; margin: 0 0 3px; }
.cart-item .info .variante { font-size: 11.5px; color: var(--muted); font-family: var(--font-mono); }
.cart-item .qty { display: flex; align-items: center; gap: 8px; font-family: var(--font-mono); font-size: 13px; margin-top: 6px; }
.cart-item .qty button { background: var(--surface-2); border: 1px solid var(--border); color: var(--paper); width: 22px; height: 22px; border-radius: 4px; cursor: pointer; }
.cart-item .remove { color: var(--muted); font-size: 11px; cursor: pointer; background:none; border:none; text-decoration: underline; padding: 0; margin-top: 4px; }
.drawer-foot { padding: 20px; border-top: 1px solid var(--border); }
.drawer-total { display: flex; justify-content: space-between; font-family: var(--font-mono); font-size: 16px; margin-bottom: 14px; }
.empty-msg { color: var(--muted); text-align: center; padding: 40px 0; font-size: 14px; }

/* ---------- Checkout ---------- */
.checkout-body { padding: 4px 0; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; font-family: var(--font-mono); }
.field input, .field textarea {
    width: 100%; background: var(--surface-2); border: 1px solid var(--border);
    color: var(--paper); padding: 11px 12px; border-radius: 6px; font-family: var(--font-body); font-size: 14.5px;
}
.field input:focus, .field textarea:focus { border-color: var(--gold); outline: none; }
.option-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
.option-btn {
    flex: 1; min-width: 130px; text-align: left; padding: 12px 14px; border-radius: 8px;
    border: 1px solid var(--border); background: var(--surface-2); color: var(--paper); cursor: pointer;
    font-family: var(--font-body); font-size: 13.5px;
}
.option-btn.selected { border-color: var(--gold); background: rgba(201,151,46,.12); }
.panel-extra { background: var(--surface-2); border: 1px dashed var(--border); border-radius: 8px; padding: 14px; margin: 10px 0 16px; font-size: 13.5px; }
.cuenta-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); gap: 10px; }
.cuenta-row:last-child { border-bottom: none; }
.copy-btn { font-family: var(--font-mono); font-size: 11px; background: var(--surface); border: 1px solid var(--border); color: var(--gold); padding: 5px 10px; border-radius: 5px; cursor: pointer; white-space: nowrap; }

.footer { border-top: 1px solid var(--border); padding: 32px 0; color: var(--muted); font-size: 13px; text-align: center; }
.footer .credito { margin-top: 8px; }
.footer .credito a {
    color: var(--gold); text-decoration: none; font-family: var(--font-mono);
    font-size: 12.5px; display: inline-flex; align-items: center; gap: 6px;
    transition: opacity .15s ease;
}
.footer .credito a:hover { opacity: .8; text-decoration: underline; }
.footer .credito svg { width: 15px; height: 15px; }

.whatsapp-fab {
    position: fixed; bottom: 22px; right: 22px; z-index: 60;
    background: #25D366; color: #fff; width: 56px; height: 56px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center; box-shadow: var(--shadow);
    transition: transform .15s ease;
}
.whatsapp-fab:hover { transform: scale(1.06); }
.whatsapp-fab svg { width: 30px; height: 30px; fill: #fff; }

@media (max-width: 640px) {
    .modal-grid { grid-template-columns: 1fr; }
    .modal-grid .book-cover { width: 120px; margin: 0 auto; }
}
