:root {
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --green: #087f5b;
  --ink: #101828;
  --muted: #667085;
  --line: #e4e7ec;
  --soft: #f7f9fc;
  --ritual-night: #120a20;
  --ritual-card: #201332;
  --ritual-violet: #9b78ee;
  --ritual-gold: #e8c66d;
  --ritual-cream: #fff8e8;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; min-width: 320px; color: var(--ink); background: #fff; font-family: Arial, sans-serif; transition: color .35s ease, background-color .35s ease; }
a { color: inherit; text-decoration: none; }
button, input { font: inherit; }
button { cursor: pointer; }

header { height: 68px; padding: 0 clamp(20px, 5vw, 64px); display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
header nav, .site-footer div { display: flex; gap: 22px; font-size: 13px; }
.logo { font-size: 25px; font-weight: 800; letter-spacing: -1.5px; }
.logo span, .catalog-head small, .product small { color: var(--blue); }

.catalog { position: relative; width: min(1180px, calc(100% - 40px)); min-height: 75vh; margin: 0 auto; padding: 56px 0 72px; }
.catalog-head { display: flex; align-items: end; justify-content: space-between; gap: 30px; }
.catalog-head h1 { margin: 9px 0; font-size: clamp(34px, 4vw, 46px); line-height: 1.05; letter-spacing: -1.5px; }
.catalog-head p { margin-bottom: 0; color: var(--muted); }
.catalog-head input { width: min(300px, 100%); min-height: 44px; padding: 11px 14px; border: 1px solid var(--line); border-radius: 10px; outline: none; }
.catalog-head input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px #2563eb20; }

.filters { display: flex; gap: 8px; margin: 30px 0 22px; overflow-x: auto; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.filters button { flex: 0 0 auto; padding: 9px 14px; border: 1px solid var(--line); border-radius: 999px; background: #fff; }
.filters .active { color: #fff; background: var(--ink); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); align-items: start; gap: 20px; }
.product { min-width: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 14px; background: #fff; box-shadow: 0 4px 16px #1018280a; }
.product > img { display: block; width: 100%; aspect-ratio: 16 / 9; height: auto; object-fit: contain; background: var(--soft); }
.product > div { padding: 16px; }
.product h2 { margin: 7px 0 9px; font-size: 18px; line-height: 1.25; letter-spacing: -.25px; }
.product p { display: -webkit-box; margin: 0; overflow: hidden; color: var(--muted); font-size: 13px; line-height: 1.45; -webkit-box-orient: vertical; -webkit-line-clamp: 3; }
.product footer { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-top: 16px; }
.product footer b { white-space: nowrap; }
.product-actions { display: flex; align-items: center; gap: 8px; }
.details-button { min-height: 42px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 9px; color: var(--ink); background: #fff; font-weight: 700; }
.details-button:hover { border-color: #98a2b3; background: var(--soft); }
.buy { min-height: 42px; padding: 10px 15px; border: 0; border-radius: 9px; color: #fff; background: var(--blue); font-weight: 700; }
.buy:hover { background: var(--blue-dark); }
.buy.download { background: var(--green); }
.buy:disabled { opacity: .65; cursor: wait; }
.empty { padding: 80px 20px; color: var(--muted); text-align: center; }
.filter-empty { margin: 18px 0 0; padding: 70px 22px; border: 1px dashed var(--line); border-radius: 18px; color: var(--muted); text-align: center; }
.filter-empty[hidden] { display: none; }
.filter-empty > span { display: block; margin-bottom: 14px; color: var(--ritual-gold); font-size: 36px; }
.filter-empty b { display: block; color: inherit; font-size: 18px; }
.filter-empty p { margin: 8px 0 0; }
.ritual-sigil { display: none; }
.tarot-entry { display: none; }

.site-footer { padding: 28px clamp(20px, 5vw, 64px); border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 20px; color: var(--muted); font-size: 12px; }

dialog { width: min(480px, calc(100vw - 28px)); max-height: calc(100dvh - 28px); overflow-y: auto; padding: 34px; border: 0; border-radius: 16px; box-shadow: 0 25px 70px #0005; }
dialog::backdrop { background: #101828b5; }
.close { float: right; width: 38px; height: 38px; border: 0; border-radius: 50%; background: #f2f4f7; font-size: 20px; }
.details-close { position: absolute; top: 14px; right: 14px; z-index: 1; width: 38px; height: 38px; border: 0; border-radius: 50%; background: #fff; box-shadow: 0 3px 12px #10182826; font-size: 20px; }
.details-dialog { width: min(620px, calc(100vw - 28px)); padding: 0 0 26px; }
.details-dialog > img { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: contain; border-radius: 16px 16px 0 0; background: var(--soft); }
.details-dialog > small, .details-dialog > h2, .details-dialog > p, .details-dialog > footer { display: block; margin-right: 26px; margin-left: 26px; }
.details-dialog > small { margin-top: 22px; color: var(--blue); }
.details-dialog > h2 { margin-top: 7px; margin-bottom: 12px; font-size: 25px; line-height: 1.2; }
.details-dialog .full-description { max-height: 34vh; overflow-y: auto; white-space: pre-line; font-size: 15px; line-height: 1.6; }
.details-dialog > footer { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-top: 8px; }
.details-actions { display: flex; align-items: center; gap: 8px; }
.share-button { min-height: 42px; padding: 9px 13px; border: 1px solid var(--line); border-radius: 9px; color: var(--ink); background: #fff; font-weight: 700; }
.share-button:hover { border-color: #98a2b3; background: var(--soft); }
dialog p, #paymentMessage { color: var(--muted); line-height: 1.5; }
#paymentMessage { margin-top: 15px; }
#paymentMessage a { color: var(--blue); font-weight: 700; }

.cookie-banner { position: fixed; z-index: 20; right: 18px; bottom: 18px; left: 18px; width: min(900px, calc(100% - 36px)); margin: auto; padding: 17px 19px; border: 1px solid var(--line); border-radius: 14px; display: flex; align-items: center; justify-content: space-between; gap: 24px; background: #fff; box-shadow: 0 18px 55px #1018282e; }
.cookie-banner[hidden] { display: none; }
.cookie-banner p { margin: 5px 0; color: var(--muted); font-size: 13px; line-height: 1.4; }
.cookie-banner a { color: var(--blue); font-size: 13px; }
.cookie-actions { display: flex; gap: 8px; flex-shrink: 0; }
.cookie-actions button { min-height: 42px; padding: 9px 13px; border-radius: 8px; font-weight: 700; }
.cookie-secondary { border: 1px solid var(--line); background: #fff; }
.cookie-primary { border: 1px solid var(--blue); color: #fff; background: var(--blue); }

/* Colección Rituales: una identidad especial sin alterar el resto de Mercaci. */
body.ritual-theme {
  color: var(--ritual-cream);
  background-color: var(--ritual-night);
  background-image:
    radial-gradient(circle at 12% 18%, #ad7cff24 0 2px, transparent 3px),
    radial-gradient(circle at 87% 12%, #f2d98a2e 0 1px, transparent 2px),
    radial-gradient(circle at 78% 62%, #ad7cff1f 0 2px, transparent 3px),
    radial-gradient(circle at 24% 78%, #f2d98a24 0 1px, transparent 2px),
    radial-gradient(ellipse at 50% 0%, #4b287566 0, transparent 52%),
    linear-gradient(155deg, #0b0712 0%, #160b26 48%, #0d0917 100%);
  background-attachment: fixed;
}
body.ritual-theme header { border-color: #d6b75d38; background: #10091bd9; backdrop-filter: blur(16px); }
body.ritual-theme header nav a { color: #d9cbea; }
body.ritual-theme .logo { color: var(--ritual-cream); }
body.ritual-theme .logo span { color: var(--ritual-gold); }
body.ritual-theme .catalog-head { min-height: 185px; padding-right: 190px; align-items: center; }
body.ritual-theme .catalog-head small { color: var(--ritual-gold); letter-spacing: 2.2px; }
body.ritual-theme .catalog-head h1 { max-width: 650px; color: var(--ritual-cream); font-family: Georgia, 'Times New Roman', serif; font-size: clamp(40px, 5vw, 60px); font-weight: 600; letter-spacing: -.8px; text-shadow: 0 6px 30px #0008; }
body.ritual-theme .catalog-head p { max-width: 650px; color: #cfc1df; font-size: 16px; line-height: 1.6; }
body.ritual-theme .catalog-head input { color: #fff8e8; border-color: #c7aee14a; background: #ffffff0d; box-shadow: inset 0 1px 0 #ffffff0d; }
body.ritual-theme .catalog-head input::placeholder { color: #b5a6c6; }
body.ritual-theme .catalog-head input:focus { border-color: var(--ritual-gold); box-shadow: 0 0 0 3px #e8c66d20; }
body.ritual-theme .ritual-sigil { position: absolute; top: 55px; right: 34px; display: flex; width: 126px; height: 126px; align-items: center; justify-content: center; gap: 8px; border: 1px solid #e8c66d5c; border-radius: 50%; color: var(--ritual-gold); background: radial-gradient(circle, #7f52bc35, #1d102e 65%); box-shadow: 0 0 0 10px #e8c66d09, 0 18px 55px #0008; }
body.ritual-theme .ritual-sigil::before, body.ritual-theme .ritual-sigil::after { position: absolute; inset: 10px; border: 1px dashed #e8c66d35; border-radius: inherit; content: ''; }
body.ritual-theme .ritual-sigil::after { inset: 23px; border-style: solid; }
body.ritual-theme .ritual-sigil b { z-index: 1; font-size: 40px; font-weight: 400; }
body.ritual-theme .ritual-sigil span { z-index: 1; font-size: 12px; }
body.ritual-theme .filters button { color: #d9cbea; border-color: #a58ac23d; background: #ffffff08; }
body.ritual-theme .filters button:hover { border-color: #d8bb6e7d; }
body.ritual-theme .filters .active { color: #20142d; border-color: var(--ritual-gold); background: linear-gradient(135deg, #f4dda0, #d7ae4f); box-shadow: 0 5px 20px #d9b65324; }
body.ritual-theme .site-footer { color: #b4a4c8; border-color: #d6b75d2e; background: #0b0712b8; }
body.ritual-theme .filter-empty { color: #cbbdda; border-color: #e8c66d52; background: #ffffff08; }
body.ritual-theme .tarot-entry { position: relative; min-height: 260px; margin: 8px 0 24px; padding: 38px 42px; display: flex; align-items: center; overflow: hidden; border: 1px solid #e8c66d55; border-radius: 20px; background: radial-gradient(circle at 14% 50%, #9d6ec73d, transparent 27%), linear-gradient(125deg, #211231, #100918); box-shadow: 0 20px 60px #0005; }
body.ritual-theme .tarot-entry > div:last-child { position: relative; z-index: 1; width: min(560px, 62%); margin-left: auto; }
body.ritual-theme .tarot-entry small { color: var(--ritual-gold); font-weight: 900; letter-spacing: 2px; }
body.ritual-theme .tarot-entry h2 { margin: 10px 0; font-family: Georgia,serif; font-size: clamp(28px,4vw,42px); font-weight: 500; }
body.ritual-theme .tarot-entry p { color: #cbbdda; line-height: 1.6; }
body.ritual-theme .tarot-entry a { display: inline-flex; margin-top: 7px; padding: 12px 16px; gap: 16px; border-radius: 9px; color: #21142d; background: linear-gradient(135deg,#f2dda0,#d0a33f); font-weight: 900; }
.tarot-entry-art { position: absolute; left: 6%; width: 220px; height: 190px; }
.tarot-entry-art span { position: absolute; top: 12px; left: 55px; width: 105px; height: 168px; border: 2px solid #e8c66d99; border-radius: 10px; background: url('/tarot-card.php?id=back') center/cover; box-shadow: 0 18px 40px #0008; }
.tarot-entry-art span:first-child { transform: translateX(-58px) rotate(-13deg); opacity: .7; }
.tarot-entry-art span:last-child { transform: translateX(58px) rotate(13deg); opacity: .7; }

.product[data-category="Rituales"] { color: var(--ritual-cream); border-color: #d7b96759; background: linear-gradient(155deg, #27173b, #180f26); box-shadow: 0 14px 34px #1b0c2d38; }
.product[data-category="Rituales"] > img { background: #140c20; }
.product[data-category="Rituales"] > div { position: relative; }
.product[data-category="Rituales"] > div::before { position: absolute; top: 0; right: 16px; left: 16px; height: 1px; background: linear-gradient(90deg, transparent, #e8c66d87, transparent); content: ''; }
.product[data-category="Rituales"] small { color: var(--ritual-gold); letter-spacing: .8px; text-transform: uppercase; }
.product[data-category="Rituales"] small::before { margin-right: 6px; content: '☾'; }
.product[data-category="Rituales"] p { color: #cbbdda; }
.product[data-category="Rituales"] footer > b { color: #f3d98f; }
.product[data-category="Rituales"] .details-button { color: #f4ead4; border-color: #d7b96759; background: #ffffff08; }
.product[data-category="Rituales"] .details-button:hover { background: #ffffff12; }
.product[data-category="Rituales"] .buy { color: #1f142a; background: linear-gradient(135deg, #f1d993, #d3a844); box-shadow: 0 8px 22px #d6ad4d26; }
.product[data-category="Rituales"] .buy:hover { background: linear-gradient(135deg, #f9e7af, #dfb957); }

dialog.ritual-dialog { color: var(--ritual-cream); border: 1px solid #d9ba6859; background: linear-gradient(160deg, #261638, #130c1f); box-shadow: 0 28px 90px #000b, 0 0 45px #8c5ec52b; }
dialog.ritual-dialog::backdrop { background: #09050dcc; backdrop-filter: blur(3px); }
dialog.ritual-dialog .close, dialog.ritual-dialog .details-close { color: #f7e8bd; background: #ffffff12; }
dialog.ritual-dialog p, dialog.ritual-dialog #paymentMessage { color: #cbbdda; }
dialog.ritual-dialog .details-dialog { color: inherit; }
dialog.ritual-dialog .details-button, dialog.ritual-dialog .share-button { color: #f4ead4; border-color: #d7b96759; background: #ffffff08; }
dialog.ritual-dialog .buy { color: #1f142a; background: linear-gradient(135deg, #f1d993, #d3a844); }
dialog.ritual-dialog #detailsCategory { color: var(--ritual-gold); letter-spacing: 1px; text-transform: uppercase; }
dialog.ritual-dialog #detailsPrice { color: #f3d98f; }
dialog.ritual-dialog #paymentMessage a { color: var(--ritual-gold); }

@media (min-width: 1180px) {
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  header { height: 60px; padding: 0 18px; }
  header nav { display: none; }
  .catalog { width: min(100% - 28px, 560px); padding: 32px 0 50px; }
  .catalog-head { display: block; }
  .catalog-head h1 { margin-top: 7px; font-size: 32px; letter-spacing: -1px; }
  .catalog-head p { margin-top: 10px; font-size: 14px; line-height: 1.45; }
  .catalog-head input { width: 100%; margin-top: 20px; font-size: 16px; }
  .filters { margin: 22px -14px 18px; padding: 0 14px; }
  .grid { grid-template-columns: 1fr; gap: 16px; }
  .product { border-radius: 13px; }
  .product > div { padding: 15px; }
  .product h2 { font-size: 18px; }
  .product p { -webkit-line-clamp: 3; }
  .product footer { margin-top: 14px; }
  .product-actions { gap: 7px; }
  .details-button { min-height: 44px; }
  .buy { min-width: 112px; min-height: 44px; }
  .site-footer { padding: 26px 18px; display: grid; justify-items: start; }
  .site-footer div { gap: 12px 18px; flex-wrap: wrap; }
  dialog { width: calc(100vw - 20px); max-height: calc(100dvh - 20px); padding: 22px 18px; border-radius: 14px; }
  dialog h2 { margin-top: 9px; padding-right: 42px; font-size: 22px; line-height: 1.2; }
  dialog p { font-size: 14px; }
  .details-dialog { width: calc(100vw - 20px); padding-bottom: 20px; }
  .details-dialog > small, .details-dialog > h2, .details-dialog > p, .details-dialog > footer { margin-right: 18px; margin-left: 18px; }
  .details-dialog > small { margin-top: 18px; }
  .details-dialog > h2 { padding-right: 0; }
  .details-dialog .full-description { max-height: 30vh; }
  .details-dialog > footer { align-items: stretch; flex-direction: column; }
  .details-actions { width: 100%; }
  .details-actions button { flex: 1; }
  .cookie-banner { right: 10px; bottom: 10px; left: 10px; width: calc(100% - 20px); padding: 15px; align-items: stretch; flex-direction: column; gap: 14px; }
  .cookie-actions button { flex: 1; }
  body.ritual-theme .catalog { padding-top: 24px; }
  body.ritual-theme .ritual-sigil { position: relative; top: auto; right: auto; width: 82px; height: 82px; margin: 0 0 18px; box-shadow: 0 0 0 7px #e8c66d09, 0 15px 40px #0007; }
  body.ritual-theme .ritual-sigil::after { inset: 17px; }
  body.ritual-theme .ritual-sigil b { font-size: 28px; }
  body.ritual-theme .catalog-head { min-height: 0; padding-right: 0; }
  body.ritual-theme .catalog-head h1 { font-size: 39px; line-height: 1; }
  body.ritual-theme .catalog-head p { font-size: 14px; line-height: 1.55; }
  .filter-empty { padding: 54px 18px; }
  body.ritual-theme .tarot-entry { min-height: 430px; padding: 26px 22px; align-items: flex-end; }
  body.ritual-theme .tarot-entry > div:last-child { width: 100%; }
  .tarot-entry-art { top: 20px; left: 50%; width: 180px; height: 190px; transform: translateX(-50%) scale(.82); }
}

.coupon-box{margin:18px 0;padding:14px;border:1px solid var(--line);border-radius:11px;background:var(--soft)}.coupon-box label{display:block;margin-bottom:8px;font-size:12px;font-weight:800}.coupon-box>div{display:flex;gap:7px}.coupon-box input{min-width:0;flex:1;padding:11px;border:1px solid var(--line);border-radius:8px;text-transform:uppercase}.coupon-box button{padding:0 14px;border:0;border-radius:8px;color:#fff;background:var(--blue);font-weight:800}.coupon-box small{display:block;margin-top:8px;line-height:1.4}.coupon-success{color:#067647!important}.coupon-error{color:#b42318!important}.ritual-dialog .coupon-box{border-color:#d9ba6847;background:#ffffff08}.ritual-dialog .coupon-box input{color:#fff;background:#ffffff0b}.ritual-dialog .coupon-box button{color:#21142d;background:linear-gradient(135deg,#f1d993,#d3a844)}
@media (max-width: 380px) {
  .catalog { width: calc(100% - 20px); }
  .catalog-head h1 { font-size: 29px; }
  .product footer { align-items: stretch; flex-direction: column; }
  .product-actions { width: 100%; }
  .product-actions button { flex: 1; }
  .buy { width: 100%; }
  .cookie-actions { flex-direction: column; }
}
