/* ==========================================================================
   Cranium — catalogo publico
   Sistema de diseno: fondo oscuro, acento rojo sangre, tipografia display
   solo para titulos grandes. Elemento distintivo: textura de ruido de
   fondo (una sola vez, en <body>) + grieta en el borde de las tarjetas
   de producto al hacer hover (una sola vez, no se repite en otros
   componentes).
   ========================================================================== */

:root {
    --bg-primary: #0d0b0c;
    --bg-secondary: #1a1516;
    --accent: #6b0f1a;
    --accent-hover: #a11d2e;
    --text-primary: #e8e2df;
    --text-muted: #8a8180;

    --border-color: #2a2223;
    --font-display: 'Eater', 'Nosifer', system-ui, serif;
    --font-body: 'Work Sans', 'Inter', system-ui, -apple-system, sans-serif;

    --header-height: 76px;
    --radius: 3px;
    --max-width: 1180px;
}

/* ---- reset ---- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.5;
    min-height: 100vh;
    position: relative;
}
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; }
ul { list-style: none; margin: 0; padding: 0; }
h1, h2, h3, p { margin: 0; }

body.no-scroll { overflow: hidden; }

/* ---- elemento distintivo: ruido de fondo (una unica vez) ---- */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    opacity: 0.05;
    mix-blend-mode: overlay;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='260' height='260'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='260' height='260' filter='url(%23n)'/%3E%3C/svg%3E");
}

#app {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.container {
    width: 100%;
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 20px;
}

:focus-visible {
    outline: 2px solid var(--accent-hover);
    outline-offset: 2px;
}

/* ==========================================================================
   Header
   ========================================================================== */

.site-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    z-index: 100;
}

.site-header__inner {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.site-header__brand {
    font-family: var(--font-display);
    font-size: clamp(1.6rem, 4vw, 2.1rem);
    letter-spacing: 0.03em;
    color: var(--text-primary);
    white-space: nowrap;
}
.site-header__brand:hover,
.site-header__brand:focus-visible { color: var(--accent-hover); }

.site-header__nav {
    display: flex;
    align-items: center;
    gap: 8px;
}

.icon-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    padding: 5px;
    border-radius: var(--radius);
    transition: transform .15s ease, background-color .15s ease;
}
.icon-btn img { width: 60px; height: 60px; object-fit: contain; }
.icon-btn:hover, .icon-btn:focus-visible {
    background: rgba(161, 29, 46, 0.12);
    transform: translateY(-1px);
}

.icon-btn--menu { display: none; }

.cart-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    border-radius: 999px;
    background: var(--accent-hover);
    color: var(--text-primary);
    font-size: 0.68rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}
.cart-badge[hidden] { display: none; }

/* ---- dropdown de categorias (desktop) ---- */
.category-dropdown { position: relative; }
.category-dropdown__panel {
    position: absolute;
    top: calc(100% + 10px);
    left: 0;
    min-width: 200px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 8px;
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.45);
    display: none;
    flex-direction: column;
    gap: 2px;
}
.category-dropdown.is-open .category-dropdown__panel { display: flex; }
.category-dropdown__panel a {
    padding: 8px 10px;
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 0.92rem;
}
.category-dropdown__panel a:hover,
.category-dropdown__panel a:focus-visible { background: var(--accent); }
.category-dropdown__empty { color: var(--text-muted); font-size: 0.85rem; padding: 8px 10px; }

/* ---- drawer mobile ---- */
.drawer-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 150;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease;
}
.drawer-backdrop.is-open { opacity: 1; pointer-events: auto; }

.drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(84vw, 320px);
    background: var(--bg-secondary);
    border-left: 1px solid var(--border-color);
    z-index: 151;
    transform: translateX(100%);
    transition: transform .25s ease;
    display: flex;
    flex-direction: column;
    padding: 20px;
    gap: 20px;
}
.drawer.is-open { transform: translateX(0); }

.drawer__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.drawer__title {
    font-family: var(--font-display);
    font-size: 1.3rem;
}
.drawer__close {
    display: inline-flex;
    background: transparent;
    border: none;
    padding: 6px;
    border-radius: var(--radius);
    transition: background-color .15s ease;
}
.drawer__close:hover, .drawer__close:focus-visible {
    background: rgba(161, 29, 46, 0.12);
}
.drawer__close img { width: 48px; height: 48px; }

.drawer__section-title {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 8px;
}
.drawer__links { display: flex; flex-direction: column; gap: 2px; }
.drawer__links a {
    padding: 10px 8px;
    border-radius: var(--radius);
    font-size: 0.96rem;
}
.drawer__links a:hover, .drawer__links a:focus-visible { background: var(--accent); }

/* ==========================================================================
   Layout general de paginas
   ========================================================================== */

main {
    flex: 1;
    padding-top: calc(var(--header-height) + 32px);
    padding-bottom: 64px;
}

.page-title {
    font-family: var(--font-display);
    font-size: clamp(2rem, 6vw, 3rem);
    margin-bottom: 6px;
}
.page-subtitle {
    color: var(--text-muted);
    margin-bottom: 28px;
}

.breadcrumb {
    display: inline-block;
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 20px;
}
.breadcrumb:hover, .breadcrumb:focus-visible { color: var(--accent-hover); }

.site-footer {
    border-top: 1px solid var(--border-color);
    padding: 24px 0;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* ---- mensajes de estado (loading / vacio / error) ---- */
.state-message {
    padding: 40px 20px;
    text-align: center;
    color: var(--text-muted);
    border: 1px dashed var(--border-color);
    border-radius: var(--radius);
}
.state-message--error { color: var(--text-primary); border-color: var(--accent); background: rgba(107, 15, 26, 0.15); }

/* ---- alertas de formulario ---- */
.alert {
    padding: 14px 16px;
    border-radius: var(--radius);
    margin-bottom: 18px;
    font-size: 0.92rem;
    border: 1px solid transparent;
}
.alert--error {
    background: rgba(107, 15, 26, 0.18);
    border-color: var(--accent);
    color: var(--text-primary);
}
.alert--success {
    background: rgba(138, 129, 128, 0.12);
    border-color: var(--border-color);
    color: var(--text-primary);
}
.alert[hidden] { display: none; }

/* ==========================================================================
   Botones y formularios
   ========================================================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 22px;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 0.88rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border: 1px solid transparent;
    transition: background-color .15s ease, border-color .15s ease, color .15s ease, opacity .15s ease;
}
.btn img { width: 42px; height: 42px; object-fit: contain; }

.btn--primary {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--text-primary);
}
.btn--primary:hover, .btn--primary:focus-visible {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}
.btn--primary:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.btn--outline {
    background: transparent;
    border-color: var(--border-color);
    color: var(--text-primary);
}
.btn--outline:hover, .btn--outline:focus-visible {
    border-color: var(--accent-hover);
    color: var(--accent-hover);
}

.btn--block { width: 100%; }

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
}
.field label {
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}
.field input,
.field select,
.field textarea {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 11px 12px;
    color: var(--text-primary);
}
.field input:focus-visible,
.field select:focus-visible,
.field textarea:focus-visible {
    border-color: var(--accent-hover);
}
.field textarea { resize: vertical; min-height: 90px; }
.field-error {
    font-size: 0.78rem;
    color: var(--accent-hover);
    min-height: 1em;
}
.field-hint { font-size: 0.8rem; color: var(--text-muted); }

/* ==========================================================================
   catalogo.html
   ========================================================================== */

/* ---- carrusel decorativo (hero) ---- */
.hero-carousel {
    max-width: 480px;
    margin: 0 auto 32px;
}
.hero-carousel[hidden] { display: none; }

.hero-carousel__viewport {
    position: relative;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    touch-action: pan-y;
}

.hero-carousel__track {
    display: flex;
    height: 100%;
    transition: transform .5s ease;
}
.hero-carousel__slide {
    flex: 0 0 100%;
    height: 100%;
}
.hero-carousel__slide img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
}

.hero-carousel__arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(13, 11, 12, 0.55);
    border: 1px solid rgba(232, 226, 223, 0.25);
    color: var(--text-primary);
    font-size: 1.1rem;
    line-height: 1;
    transition: background-color .15s ease, border-color .15s ease;
}
.hero-carousel__arrow:hover, .hero-carousel__arrow:focus-visible {
    background: rgba(161, 29, 46, 0.75);
    border-color: var(--accent-hover);
}
.hero-carousel__arrow[hidden] { display: none; }
.hero-carousel__arrow--prev { left: 10px; }
.hero-carousel__arrow--next { right: 10px; }

.hero-carousel__dots {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: 14px;
}
.hero-carousel__dots[hidden] { display: none; }
.hero-carousel__dot {
    width: 9px;
    height: 9px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: var(--border-color);
    transition: background-color .2s ease, transform .2s ease;
}
.hero-carousel__dot:hover, .hero-carousel__dot:focus-visible {
    background: var(--text-muted);
}
.hero-carousel__dot.is-active {
    background: var(--accent-hover);
    transform: scale(1.25);
}

@media (max-width: 520px) {
    .hero-carousel { max-width: 100%; }
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 28px;
}
.toolbar__search {
    flex: 1 1 240px;
    display: flex;
}
.toolbar__search input {
    flex: 1;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-right: none;
    border-radius: var(--radius) 0 0 var(--radius);
    padding: 11px 14px;
}
.toolbar__search input:focus-visible { border-color: var(--accent-hover); }
.toolbar__search button {
    border-radius: 0 var(--radius) var(--radius) 0;
    padding: 0 16px;
}

.toolbar__filter {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 0 6px 0 12px;
}
.toolbar__filter img { width: 36px; height: 36px; }
.toolbar__filter select {
    background: transparent;
    border: none;
    padding: 11px 8px;
    min-width: 160px;
}

.product-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 18px;
}
@media (min-width: 640px) {
    .product-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 960px) {
    .product-grid { grid-template-columns: repeat(4, 1fr); gap: 24px; }
}

.product-card {
    position: relative;
    display: block;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    overflow: hidden;
    transition: border-color .2s ease, transform .2s ease;
}
.product-card:hover, .product-card:focus-visible {
    border-color: var(--accent-hover);
    transform: translateY(-2px);
}

/* ---- elemento distintivo: grieta en el borde, solo en hover de la card ---- */
.product-card::after {
    content: "";
    position: absolute;
    top: 0;
    left: 6%;
    width: 88%;
    height: 3px;
    background: var(--accent-hover);
    clip-path: polygon(0% 60%, 5% 10%, 11% 70%, 18% 0%, 26% 65%, 33% 15%, 41% 55%, 49% 5%, 57% 60%,
        65% 10%, 73% 68%, 81% 20%, 89% 58%, 100% 15%, 100% 100%, 0% 100%);
    opacity: 0;
    transform: translateY(-3px);
    transition: opacity .3s ease, transform .3s ease;
    box-shadow: 0 0 10px 1px rgba(161, 29, 46, 0.65);
    pointer-events: none;
}
.product-card:hover::after,
.product-card:focus-visible::after {
    opacity: 1;
    transform: translateY(0);
}

.product-card__image-wrap {
    aspect-ratio: 3 / 4;
    background: #100d0e;
    overflow: hidden;
}
.product-card__image-wrap img { width: 100%; height: 100%; object-fit: cover; }
.product-card__no-image {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 0.8rem;
    text-align: center;
    padding: 12px;
}

.product-card__body { padding: 14px; }
.product-card__category {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 4px;
}
.product-card__name {
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 6px;
}
.product-card__price {
    color: var(--text-primary);
    font-weight: 600;
}
.product-card__stock-warning {
    display: inline-block;
    margin-top: 6px;
    font-size: 0.72rem;
    color: var(--accent-hover);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* ==========================================================================
   producto.html
   ========================================================================== */

.product-detail {
    display: grid;
    grid-template-columns: 1fr;
    gap: 32px;
}
@media (min-width: 860px) {
    .product-detail { grid-template-columns: 1fr 1fr; align-items: start; }
}

.product-gallery__main {
    aspect-ratio: 4 / 5;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 12px;
}
.product-gallery__main-trigger {
    display: block;
    width: 100%;
    height: 100%;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
}
.product-gallery__main img { width: 100%; height: 100%; object-fit: cover; cursor: pointer; }
.product-gallery__thumbs {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}
.product-gallery__thumb {
    width: 68px;
    height: 68px;
    border-radius: var(--radius);
    overflow: hidden;
    border: 2px solid var(--border-color);
    background: var(--bg-secondary);
    padding: 0;
}
.product-gallery__thumb img { width: 100%; height: 100%; object-fit: cover; }
.product-gallery__thumb.is-active { border-color: var(--accent-hover); }

/* ---- lightbox de la galeria (click en imagen principal o miniatura) ----
   Se mantiene siempre en el DOM (nunca display:none via [hidden] salvo
   cuando esta cerrado) para que la transicion de opacity pueda animar
   correctamente: sacar el atributo hidden primero, y recien en el frame
   siguiente sumar is-open, es el mismo patron que .drawer-backdrop. */
.lightbox {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(13, 11, 12, 0.92);
    opacity: 0;
    transition: opacity .2s ease;
}
.lightbox[hidden] { display: none; }
.lightbox.is-open { opacity: 1; }

.lightbox__image {
    max-width: min(90vw, 900px);
    max-height: 85vh;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: var(--radius);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}

.lightbox__close,
.lightbox__arrow {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(26, 21, 22, 0.75);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    transition: background-color .15s ease, border-color .15s ease;
}
.lightbox__close:hover, .lightbox__close:focus-visible,
.lightbox__arrow:hover, .lightbox__arrow:focus-visible {
    background: rgba(161, 29, 46, 0.85);
    border-color: var(--accent-hover);
}
.lightbox__arrow[hidden] { display: none; }

.lightbox__close {
    top: 20px;
    right: 20px;
    width: 44px;
    height: 44px;
}
.lightbox__close img { width: 22px; height: 22px; }

.lightbox__arrow {
    top: 50%;
    transform: translateY(-50%);
    width: 48px;
    height: 48px;
    font-size: 1.6rem;
    line-height: 1;
}
.lightbox__arrow--prev { left: 16px; }
.lightbox__arrow--next { right: 16px; }

@media (max-width: 640px) {
    .lightbox__close { top: 12px; right: 12px; width: 38px; height: 38px; }
    .lightbox__close img { width: 18px; height: 18px; }
    .lightbox__arrow { width: 40px; height: 40px; font-size: 1.3rem; }
    .lightbox__arrow--prev { left: 8px; }
    .lightbox__arrow--next { right: 8px; }
}

.product-info__category {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 8px;
}
.product-info__name {
    font-family: var(--font-display);
    font-size: clamp(1.8rem, 4vw, 2.6rem);
    margin-bottom: 14px;
    line-height: 1.15;
}
.product-info__description {
    color: var(--text-muted);
    margin-bottom: 18px;
}
.product-info__price {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 24px;
}

.variant-selectors {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin-bottom: 8px;
}
.variant-selectors .field { margin-bottom: 0; }

.qty-row {
    display: flex;
    align-items: flex-end;
    gap: 14px;
    margin: 18px 0 22px;
}
.qty-row .field { margin-bottom: 0; width: 110px; }

.stock-info { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 18px; }

.add-feedback {
    margin-top: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
    font-size: 0.9rem;
}
.add-feedback img { width: 34px; height: 34px; }
.add-feedback[hidden] { display: none; }

/* ==========================================================================
   pedido.html
   ========================================================================== */

.cart-list { display: flex; flex-direction: column; gap: 14px; margin-bottom: 28px; }

.cart-row {
    display: grid;
    grid-template-columns: 72px 1fr auto;
    gap: 14px;
    align-items: center;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 12px;
}
.cart-row__image {
    width: 72px;
    height: 90px;
    border-radius: var(--radius);
    overflow: hidden;
    background: #100d0e;
}
.cart-row__image img { width: 100%; height: 100%; object-fit: cover; }
.cart-row__name { font-weight: 600; margin-bottom: 2px; }
.cart-row__variant { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 8px; }
.cart-row__controls { display: flex; align-items: center; gap: 10px; }
.cart-row__controls input {
    width: 58px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 7px;
    color: var(--text-primary);
    text-align: center;
}
.cart-row__remove {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 4px 0;
}
.cart-row__remove:hover, .cart-row__remove:focus-visible { color: var(--accent-hover); }
.cart-row__totals { text-align: right; font-weight: 600; white-space: nowrap; }

.cart-summary {
    display: flex;
    justify-content: flex-end;
    gap: 24px;
    padding: 18px 0;
    border-top: 1px solid var(--border-color);
    margin-bottom: 36px;
    font-size: 1.2rem;
}
.cart-summary__label { color: var(--text-muted); }
.cart-summary__value { font-weight: 700; }

.checkout-form {
    max-width: 480px;
}
.checkout-form__title {
    font-family: var(--font-display);
    font-size: 1.6rem;
    margin-bottom: 18px;
}

.confirmation {
    max-width: 520px;
    text-align: center;
    padding: 40px 24px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
}
.confirmation img { width: 72px; height: 72px; margin: 0 auto 16px; }
.confirmation__title {
    font-family: var(--font-display);
    font-size: 1.8rem;
    margin-bottom: 12px;
}
.confirmation__detail { color: var(--text-muted); margin-bottom: 6px; }
.confirmation__detail strong { color: var(--text-primary); }

/* ==========================================================================
   Responsive: header en mobile
   ========================================================================== */

@media (max-width: 720px) {
    .category-dropdown { display: none; }
    .icon-btn--menu { display: inline-flex; }
    .variant-selectors { grid-template-columns: 1fr; }
}
