:root {
  --ink: #0a0807;
  --paper: #e3d3b0;
  --paper-dark: #c9b68e;
  --line: #d9c8a0;
  --red: #a3141b;
  --red-bright: #e11d26;
  --text-ink: #1b1510;

  /* Tamaños de texto relativos al ancho de la hoja (cqw) */
  --fs-caption: 1.75cqw;
  --fs-tag: 1.05cqw;
  --fs-name: 1.55cqw;
  --fs-size: 1.45cqw;
  --fs-price: 6.6cqw;
  --fs-btn: 1.55cqw;

  /* Texturas */
  --noise: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='3'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.55 -0.12'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)'/%3E%3C/svg%3E");
  --paper-noise: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3'/%3E%3CfeColorMatrix values='0 0 0 0 0.35 0 0 0 0 0.25 0 0 0 0 0.12 0 0 0 0.35 0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
  --skyline: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 100' preserveAspectRatio='none'%3E%3Cpath d='M0 100V62h7V48h5v14h5V34l3-9 3 9v28h7V46h9v16h5V28h3V16l2-8 2 8v12h3v34h7V54h7v-8h4v8h5v46h5V40l4-14 4 14v60h7V58h9v42h5V30h5V18l3-6 3 6v12h5v70h7V50h10v50h7V44l4-11 4 11v56h9V60h7v40z' fill='black'/%3E%3C/svg%3E");
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background: var(--ink);
  color: var(--paper);
  font-family: 'Montserrat', sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
  padding: 24px 16px 40px;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

/* ---------- Menú principal ---------- */
/* Logo (inicio) alineado al borde izquierdo de la hoja, secciones al derecho */
.main-menu {
  max-width: 1200px;
  margin: 0 auto 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.menu-home {
  flex: none;
  display: block;
  line-height: 0;
  transition: transform 0.15s ease, filter 0.15s ease;
  outline: none;
}

.menu-home img {
  height: 110px;
  width: auto;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.8));
}

.menu-home:hover,
.menu-home:focus-visible {
  transform: scale(1.05) rotate(-2deg);
  filter: brightness(1.12);
}

.menu-home:focus-visible {
  filter: brightness(1.12) drop-shadow(0 0 10px #f5c518);
}

.menu-items {
  flex: 0 1 430px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.menu-item {
  display: block;
  line-height: 0;
  transition: transform 0.15s ease, filter 0.15s ease;
  outline: none;
}

.menu-item img {
  width: 100%;
  height: auto;
  /* Disuelve el borde del recorte sobre el fondo negro */
  -webkit-mask-image: radial-gradient(ellipse 52% 50% at 50% 50%, #000 70%, transparent 100%);
  mask-image: radial-gradient(ellipse 52% 50% at 50% 50%, #000 70%, transparent 100%);
}

.menu-item:hover,
.menu-item:focus-visible {
  transform: scale(1.06) rotate(-2deg);
  filter: brightness(1.15);
}

.menu-item:focus-visible {
  filter: brightness(1.15) drop-shadow(0 0 10px #f5c518);
}

.menu-item[aria-current='page'] {
  filter: drop-shadow(0 0 14px rgba(225, 29, 38, 0.55));
}

.menu-item[aria-current='page']:hover {
  filter: brightness(1.15) drop-shadow(0 0 14px rgba(225, 29, 38, 0.55));
}

.toast {
  position: fixed;
  z-index: 50;
  left: 50%;
  top: 24px;
  font-size: 1.1rem;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -12px) rotate(-2deg);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.visible {
  opacity: 1;
  transform: translate(-50%, 0) rotate(-2deg);
}

/* ---------- Hoja de cómic ---------- */
.comic-page {
  position: relative;
  max-width: 1200px;
  margin: 0 auto;
  aspect-ratio: 1139 / 1381;
  container-type: inline-size;
  background: var(--noise), #0d0a09;
}

.slots {
  display: contents;
}

/* Cada viñeta: caja posicionada (--x/--y/--w/--h) + forma recortada (--clip), calculadas en catalogo.js */
.slot {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: var(--w);
  height: var(--h);
  padding: 0;
  border: 0;
  background: none;
  outline: none;
}

.shape {
  position: absolute;
  inset: 0;
  display: block;
  overflow: hidden;
  clip-path: var(--clip);
}

/* Trazo crema alrededor de la forma recortada (el borde de la viñeta) */
.stroke {
  filter:
    drop-shadow(2px 0 0 var(--stroke-color, var(--line)))
    drop-shadow(-2px 0 0 var(--stroke-color, var(--line)))
    drop-shadow(0 2px 0 var(--stroke-color, var(--line)))
    drop-shadow(0 -2px 0 var(--stroke-color, var(--line)));
}

/* Papel envejecido reutilizable */
.caption-box {
  font-family: 'Permanent Marker', cursive;
  text-transform: uppercase;
  line-height: 1.15;
  padding: 0.5em 0.8em;
  color: var(--text-ink);
  background-color: var(--paper);
  background-image:
    radial-gradient(circle at 20% 30%, rgba(120, 90, 50, 0.2), transparent 45%),
    radial-gradient(circle at 80% 70%, rgba(120, 90, 50, 0.25), transparent 50%),
    var(--paper-noise);
  border: 2px solid var(--ink);
  box-shadow: 3px 3px 0 #000;
}

/* ---------- Viñetas de productos ---------- */
.slot-product .shape {
  background:
    var(--skyline) bottom / 100% 72% no-repeat,
    radial-gradient(ellipse at 50% 30%, transparent 25%, rgba(0, 0, 0, 0.6) 100%),
    var(--noise),
    var(--bg);
}

.slot-product img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 6%;
  filter: contrast(1.12) saturate(0.9) sepia(0.12) drop-shadow(0 0 12px rgba(0, 0, 0, 0.5));
  transition: transform 0.4s ease;
}

/* Grano de tinta y sombra de bordes sobre la foto */
.slot-product .shape::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    var(--noise),
    radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 0, 0.5));
  pointer-events: none;
}

.panel-caption {
  position: absolute;
  z-index: 1;
  left: 8%;
  bottom: 7%;
  max-width: 84%;
  padding: 0.25em 0.7em;
  font-family: 'Permanent Marker', cursive;
  font-size: var(--fs-tag);
  text-transform: uppercase;
  text-align: left;
  color: var(--text-ink);
  background: var(--paper);
  border: 2px solid var(--ink);
  box-shadow: 2px 2px 0 #000;
  transform: rotate(-2deg) translateY(6px);
  opacity: 0;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.slot-product:hover img,
.slot-product:focus-visible img {
  transform: scale(1.05);
}

.slot-product:hover .panel-caption,
.slot-product:focus-visible .panel-caption,
.slot-product.selected .panel-caption {
  opacity: 1;
  transform: rotate(-2deg);
}

.slot-product:focus-visible {
  --stroke-color: #f5c518;
}

.slot-product.selected {
  --stroke-color: var(--red-bright);
}

.slot-product.selected .panel-caption {
  background: var(--red-bright);
  color: #fff;
}

/* Viñetas del lateral derecho: el nombre va a la derecha para que no quede cortado */
.caption-der .panel-caption {
  left: auto;
  right: 8%;
  transform: rotate(2deg) translateY(6px);
}

.caption-der:hover .panel-caption,
.caption-der:focus-visible .panel-caption,
.caption-der.selected .panel-caption {
  transform: rotate(2deg);
}

/* Viñeta circular: borde crema + anillo negro que la separa de las de atrás */
.slot-circle {
  z-index: 3;
  filter: none;
}

.slot-circle .shape {
  clip-path: none;
  border-radius: 50%;
  border: 3px solid var(--line);
  box-shadow: 0 0 0 6px var(--ink);
}

.slot-circle.selected .shape {
  border-color: var(--red-bright);
}

.slot-circle:focus-visible .shape {
  border-color: #f5c518;
}

.slot-circle .panel-caption {
  left: 50%;
  bottom: 10%;
  translate: -50% 0;
}

/* ---------- Banner con el logo ---------- */
.banner {
  background:
    var(--skyline) bottom / 100% 85% no-repeat,
    radial-gradient(circle at 46% 22%, rgba(220, 212, 195, 0.35) 0 4.5%, transparent 5%),
    radial-gradient(ellipse at 50% 40%, #3a332c 0%, #120f0d 70%),
    #120f0d;
}

.banner::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--noise);
  pointer-events: none;
}

.banner-burst {
  position: absolute;
  left: 13%;
  top: 6%;
  width: 78%;
  height: 88%;
  fill: var(--red);
  opacity: 0.92;
}

.banner-logo {
  position: absolute;
  z-index: 1;
  left: 50%;
  top: 50%;
  height: 92%;
  line-height: 0;
  transform: translate(-46%, -50%) rotate(-3deg);
}

.banner-logo img {
  height: 100%;
  width: auto;
  filter: drop-shadow(0 6px 18px rgba(0, 0, 0, 0.85));
}

.caption-poder {
  position: absolute;
  z-index: 2;
  left: 3%;
  top: 14%;
  font-size: var(--fs-caption);
  text-align: center;
  transform: rotate(-5deg);
}

/* ---------- Panel de precio ---------- */
.price-panel {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  /* Nombre y talles a la derecha: la viñeta circular tapa la esquina superior izquierda */
  align-items: flex-end;
  text-align: right;
  padding: 6% 6% 7%;
  background:
    var(--noise),
    repeating-conic-gradient(from 0deg at 50% 52%, rgba(163, 20, 27, 0.55) 0 5deg, transparent 5deg 13deg),
    radial-gradient(ellipse at 50% 52%, #3a1612 0%, #120d0b 75%);
}

.detail-name {
  max-width: 58%;
  font-family: 'Permanent Marker', cursive;
  font-weight: 400;
  font-size: var(--fs-name);
  line-height: 1.1;
  text-transform: uppercase;
  color: var(--paper);
  text-shadow: 2px 2px 0 #000;
}

.sizes {
  display: flex;
  gap: 0.5em;
  font-size: var(--fs-size);
}

.size {
  width: 2.1em;
  height: 2.1em;
  background: var(--ink);
  color: var(--paper);
  border: 2px solid var(--line);
  font-family: 'Bangers', cursive;
  font-size: 1em;
  letter-spacing: 1px;
}

.size:hover {
  background: #2a221b;
}

.size.active {
  background: var(--red-bright);
  color: #fff;
}

.price {
  align-self: center;
  font-family: 'Bangers', cursive;
  font-size: var(--fs-price);
  line-height: 1;
  letter-spacing: 1px;
  color: var(--paper);
  padding: 0.08em 0.3em;
  background: var(--red);
  transform: rotate(-4deg);
  text-shadow: 0.05em 0.05em 0 #000;
  clip-path: polygon(0 12%, 7% 0, 22% 8%, 40% 0, 58% 7%, 76% 0, 94% 6%, 100% 20%, 96% 50%, 100% 84%, 92% 100%, 70% 92%, 50% 100%, 28% 93%, 8% 100%, 0 86%, 4% 50%);
}

.add-to-cart {
  align-self: flex-end;
  display: flex;
  align-items: center;
  gap: 0.6em;
  font-size: var(--fs-btn);
  transform: rotate(-2deg);
  transition: transform 0.1s ease, box-shadow 0.1s ease, background-color 0.15s ease;
}

.add-to-cart svg {
  width: 1.9em;
  height: 1.7em;
  fill: currentColor;
}

.add-to-cart:hover {
  transform: rotate(-2deg) translate(-1px, -1px);
  box-shadow: 5px 5px 0 #000;
}

.add-to-cart:active {
  transform: rotate(-2deg) translate(2px, 2px);
  box-shadow: 1px 1px 0 #000;
}

.add-to-cart.added {
  background: #1f8a3a;
  color: #fff;
}

.add-to-cart.needs-size {
  animation: shake 0.35s ease;
}

@keyframes shake {
  0%, 100% { translate: 0; }
  25% { translate: -6px 0; }
  75% { translate: 6px 0; }
}

/* ---------- Franja de ciudad ---------- */
.city-strip {
  background:
    var(--skyline) bottom / 100% 90% no-repeat,
    radial-gradient(circle at 64% 38%, #d8d1c0 0 7%, transparent 7.5%),
    linear-gradient(#3b3631, #161310);
}

.city-strip::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--noise);
}

/* Centrado sobre la viñeta central de abajo (franja de ciudad) */
.caption-heroe {
  position: absolute;
  z-index: 4;
  left: 46.6%;
  top: 95.4%;
  font-size: var(--fs-caption);
  text-align: center;
  white-space: nowrap;
  transform: translate(-50%, -50%) rotate(-3deg);
}

/* ---------- Ventana de detalle ---------- */
.product-modal {
  width: min(920px, calc(100vw - 32px));
  max-width: none;
  max-height: none;
  margin: auto;
  padding: 0;
  border: 0;
  background: none;
  overflow: visible;
  color: var(--text-ink);
}

.product-modal::backdrop {
  background: rgba(5, 4, 3, 0.82);
}

.product-modal[open] .modal-frame {
  animation: modal-in 0.22s ease-out;
}

@keyframes modal-in {
  from { transform: scale(0.92) rotate(-1.5deg); opacity: 0; }
  to { transform: none; opacity: 1; }
}

.modal-card {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
  max-height: calc(100dvh - 48px);
  overflow: auto;
  clip-path: polygon(0 18px, 100% 0, 100% calc(100% - 14px), 0 100%);
  background-color: var(--paper);
  background-image:
    radial-gradient(circle at 70% 20%, rgba(120, 90, 50, 0.18), transparent 45%),
    radial-gradient(circle at 85% 85%, rgba(120, 90, 50, 0.22), transparent 50%),
    var(--paper-noise);
}

.modal-close {
  position: absolute;
  z-index: 2;
  top: 26px;
  right: 16px;
  width: 38px;
  height: 38px;
  font-family: 'Bangers', cursive;
  font-size: 1.2rem;
  color: var(--paper);
  background: var(--ink);
  border: 2px solid var(--ink);
  box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.4);
}

.modal-close:hover {
  background: var(--red-bright);
}

.modal-art {
  position: relative;
  min-height: 460px;
  overflow: hidden;
  clip-path: polygon(0 0, 100% 0, calc(100% - 26px) 100%, 0 100%);
  background:
    var(--skyline) bottom / 100% 60% no-repeat,
    radial-gradient(ellipse at 50% 30%, transparent 25%, rgba(0, 0, 0, 0.6) 100%),
    var(--noise),
    var(--bg, #1b2232);
}

.modal-art img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 10%;
  filter: contrast(1.12) saturate(0.9) sepia(0.12);
}

.modal-info {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 40px 28px 30px 22px;
}

.modal-name {
  padding-right: 44px;
  font-family: 'Permanent Marker', cursive;
  font-weight: 400;
  font-size: 1.8rem;
  line-height: 1.05;
  text-transform: uppercase;
}

.modal-desc {
  font-size: 0.95rem;
  line-height: 1.45;
}

.features {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.features li {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.feat-icon {
  flex: none;
  width: 36px;
  height: 36px;
  border: 2px solid var(--text-ink);
  border-radius: 50%;
  display: grid;
  place-items: center;
}

.feat-icon svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: var(--text-ink);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.label-tag {
  align-self: flex-start;
  display: inline-block;
  margin-bottom: 4px;
  font-family: 'Permanent Marker', cursive;
  text-transform: uppercase;
  font-size: 0.95rem;
  padding: 3px 14px;
  background: var(--paper-dark);
  border: 2px solid var(--ink);
  box-shadow: 3px 3px 0 #000;
  transform: rotate(-2deg);
}

.colors {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.color {
  background: none;
  border: 2px solid transparent;
  padding: 4px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-family: 'Permanent Marker', cursive;
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--text-ink);
}

.color svg {
  width: 54px;
  height: 50px;
  filter: drop-shadow(2px 2px 0 rgba(0, 0, 0, 0.35));
}

.color.active {
  border-color: var(--ink);
  background: rgba(0, 0, 0, 0.08);
}

.buy-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

.product-modal .sizes {
  font-size: 17px;
  margin-top: 8px;
}

.product-modal .size {
  border-color: var(--ink);
}

.product-modal .price {
  font-size: 46px;
}

.modal-add {
  align-self: stretch;
  justify-content: center;
  margin-top: 4px;
  font-size: 18px;
  background-color: var(--red-bright);
  background-image: none;
  color: #fff;
}

/* ---------- Celular: las viñetas pasan a una grilla de 2 columnas ---------- */
@media (max-width: 720px) {
  :root {
    --fs-caption: 15px;
    --fs-tag: 11px;
    --fs-name: 16px;
    --fs-size: 15px;
    --fs-price: 48px;
    --fs-btn: 15px;
  }

  .main-menu {
    gap: 8px;
    margin-bottom: 12px;
  }

  .menu-home img {
    height: 64px;
  }

  .menu-items {
    gap: 2px;
  }

  .toast {
    font-size: 0.95rem;
    white-space: nowrap;
  }

  .comic-page {
    aspect-ratio: auto;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    padding: 6px;
  }

  .slot {
    position: relative;
    left: auto;
    top: auto;
    width: auto;
    height: auto;
    aspect-ratio: 4 / 5;
  }

  .slot .shape {
    clip-path: polygon(0 0, 100% 0, 100% calc(100% - 8px), 0 100%);
  }

  .slot-circle {
    aspect-ratio: 1;
  }

  .slot-circle .shape {
    clip-path: none;
  }

  .slot[data-shape='banner'] {
    grid-column: 1 / -1;
    aspect-ratio: 16 / 10;
  }

  .slot[data-shape='precio'] {
    grid-column: 1 / -1;
    aspect-ratio: auto;
    min-height: 240px;
  }

  .slot[data-shape='ciudad'] {
    grid-column: 1 / -1;
    aspect-ratio: auto;
    height: 70px;
  }

  .panel-caption {
    opacity: 1;
    transform: rotate(-2deg);
  }

  .caption-poder {
    top: 8%;
    left: 4%;
    font-size: 12px;
  }

  .detail-name {
    max-width: none;
  }

  .slot-product:nth-child(even):not(.slot-circle) .panel-caption {
    left: auto;
    right: 8%;
    transform: rotate(2deg);
  }

  .slot-product:nth-child(odd) .panel-caption {
    left: 8%;
    right: auto;
    transform: rotate(-2deg);
  }

  .modal-card {
    grid-template-columns: 1fr;
    clip-path: polygon(0 12px, 100% 0, 100% calc(100% - 10px), 0 100%);
  }

  .modal-art {
    min-height: 280px;
    clip-path: polygon(0 0, 100% 0, 100% calc(100% - 14px), 0 100%);
  }

  .modal-info {
    padding: 18px 18px 26px;
  }

  .modal-name {
    font-size: 1.45rem;
  }

  /* Se superpone a la franja de ciudad, que es el elemento anterior en la grilla */
  .caption-heroe {
    position: relative;
    left: auto;
    top: auto;
    grid-column: 1 / -1;
    justify-self: center;
    margin-top: -70px;
    transform: rotate(-3deg);
  }
}
