/* ============================================================
   Material Design 3 Expressive — BoardGamesMx
   ============================================================ */

/* ---------- TOKENS ---------- */

:root {
    /* Color scheme: light by default. Palette colors come from palettes.css.
       Default palette is Lila (purple). Switch via [data-palette="..."]. */
    color-scheme: light;

    /* Shape tokens */
    --md-sys-shape-corner-none: 0;
    --md-sys-shape-corner-extra-small: 4px;
    --md-sys-shape-corner-small: 8px;
    --md-sys-shape-corner-medium: 12px;
    --md-sys-shape-corner-large: 16px;
    --md-sys-shape-corner-extra-large: 28px;
    --md-sys-shape-corner-full: 9999px;

    /* Elevation (MD3 shadows) */
    --md-sys-elevation-0: none;
    --md-sys-elevation-1: 0 1px 2px 0 rgb(0 0 0 / 0.30), 0 1px 3px 1px rgb(0 0 0 / 0.15);
    --md-sys-elevation-2: 0 1px 2px 0 rgb(0 0 0 / 0.30), 0 2px 6px 2px rgb(0 0 0 / 0.15);
    --md-sys-elevation-3: 0 4px 8px 3px rgb(0 0 0 / 0.15), 0 1px 3px rgb(0 0 0 / 0.30);
    --md-sys-elevation-4: 0 6px 10px 4px rgb(0 0 0 / 0.15), 0 2px 3px rgb(0 0 0 / 0.30);
    --md-sys-elevation-5: 0 8px 12px 6px rgb(0 0 0 / 0.15), 0 4px 4px rgb(0 0 0 / 0.30);

    /* Motion */
    --md-sys-motion-duration-short: 150ms;
    --md-sys-motion-duration-medium: 250ms;
    --md-sys-motion-duration-long: 400ms;
    --md-sys-motion-easing-standard: cubic-bezier(0.2, 0, 0, 1);
    --md-sys-motion-easing-emphasized: cubic-bezier(0.2, 0, 0, 1);
    --md-sys-motion-easing-emphasized-decelerate: cubic-bezier(0.05, 0.7, 0.1, 1);

    /* State layer opacities */
    --md-sys-state-hover-opacity: 0.08;
    --md-sys-state-focus-opacity: 0.10;
    --md-sys-state-pressed-opacity: 0.12;
}

[data-theme="dark"] { color-scheme: dark; }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) { color-scheme: dark; }
}

/* ---------- TYPOGRAPHY (Roboto Flex) ---------- */

* {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    overflow-x: hidden;
}

body {
    margin: 0;
    font-family: "Roboto Flex", "Roboto", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    font-variation-settings: "wdth" 100, "opsz" 14;
    background-color: var(--md-sys-color-background);
    color: var(--md-sys-color-on-background);
    line-height: 1.4;
    overflow-x: hidden;
    transition: background-color var(--md-sys-motion-duration-medium) var(--md-sys-motion-easing-standard),
                color var(--md-sys-motion-duration-medium) var(--md-sys-motion-easing-standard);
}

img, svg { max-width: 100%; }

.md-display-large   { font-size: 57px; line-height: 64px; letter-spacing: -0.25px; font-weight: 400; }
.md-display-medium  { font-size: 45px; line-height: 52px; letter-spacing: 0;       font-weight: 400; }
.md-display-small   { font-size: 36px; line-height: 44px; letter-spacing: 0;       font-weight: 400; }
.md-headline-large  { font-size: 32px; line-height: 40px; letter-spacing: 0;       font-weight: 400; }
.md-headline-medium { font-size: 28px; line-height: 36px; letter-spacing: 0;       font-weight: 400; }
.md-headline-small  { font-size: 24px; line-height: 32px; letter-spacing: 0;       font-weight: 400; }
.md-title-large     { font-size: 22px; line-height: 28px; letter-spacing: 0;       font-weight: 500; }
.md-title-medium    { font-size: 16px; line-height: 24px; letter-spacing: 0.15px;  font-weight: 500; }
.md-title-small     { font-size: 14px; line-height: 20px; letter-spacing: 0.1px;   font-weight: 500; }
.md-body-large      { font-size: 16px; line-height: 24px; letter-spacing: 0.5px;   font-weight: 400; }
.md-body-medium     { font-size: 14px; line-height: 20px; letter-spacing: 0.25px;  font-weight: 400; }
.md-body-small      { font-size: 12px; line-height: 16px; letter-spacing: 0.4px;   font-weight: 400; }
.md-label-large     { font-size: 14px; line-height: 20px; letter-spacing: 0.1px;   font-weight: 500; }
.md-label-medium    { font-size: 12px; line-height: 16px; letter-spacing: 0.5px;   font-weight: 500; }
.md-label-small     { font-size: 11px; line-height: 16px; letter-spacing: 0.5px;   font-weight: 500; }

/* ---------- LAYOUT ---------- */

.md-app-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: padding-left var(--md-sys-motion-duration-medium) var(--md-sys-motion-easing-emphasized);
}

.md-main {
    flex: 1;
    padding: 16px 12px;
}

@media (min-width: 600px) {
    .md-main { padding: 24px max(16px, calc((100% - 1400px) / 2)); }
}

@media (min-width: 840px) {
    .md-app-shell { padding-left: 80px; }
    [data-rail="collapsed"] .md-app-shell { padding-left: 0; }
    .md-main { padding: 24px 32px; }
}

/* ---------- TOP APP BAR ---------- */

.md-top-bar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    height: 64px;
    background-color: var(--md-sys-color-surface-container);
    color: var(--md-sys-color-on-surface);
    transition: background-color var(--md-sys-motion-duration-medium) var(--md-sys-motion-easing-standard);
}

@media (min-width: 600px) {
    .md-top-bar { gap: 16px; padding: 8px 16px; }
}

.md-top-bar__title {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 22px;
    line-height: 28px;
    font-weight: 500;
    color: var(--md-sys-color-on-surface);
    margin: 0;
    white-space: nowrap;
    text-decoration: none;
    flex-shrink: 0;
}

.md-top-bar__title a { color: inherit; text-decoration: none; }

/* Hide the brand text in narrow viewports — keep just the mark */
.md-top-bar__title-text { display: none; }
@media (min-width: 600px) {
    .md-top-bar__title-text { display: inline; }
}

.md-top-bar__search {
    flex: 1;
    min-width: 0;
    max-width: 720px;
    margin: 0 auto;
}

.md-top-bar__actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

/* ---------- NAV RAIL (desktop) ---------- */

.md-nav-rail {
    display: none;
    flex-direction: column;
    align-items: center;
    padding: 12px 0;
    gap: 4px;
    background-color: var(--md-sys-color-surface);
    border-right: 1px solid var(--md-sys-color-outline-variant);
    position: fixed;
    top: 0;
    left: 0;
    width: 80px;
    height: 100vh;
    height: 100dvh;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 20;
    transition: transform var(--md-sys-motion-duration-medium) var(--md-sys-motion-easing-emphasized);
}

@media (min-width: 840px) {
    .md-nav-rail { display: flex; }
}

[data-rail="collapsed"] .md-nav-rail {
    transform: translateX(-100%);
}

.md-nav-rail__item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px;
    width: 100%;
    text-decoration: none;
    color: var(--md-sys-color-on-surface-variant);
    font-size: 12px;
    font-weight: 500;
    position: relative;
    cursor: pointer;
    background: transparent;
    border: none;
}

.md-nav-rail__icon-wrap {
    display: grid;
    place-items: center;
    width: 56px;
    height: 32px;
    border-radius: var(--md-sys-shape-corner-large);
    transition: background-color var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard);
}

.md-nav-rail__item:hover .md-nav-rail__icon-wrap {
    background-color: color-mix(in srgb, var(--md-sys-color-on-surface) var(--md-sys-state-hover-opacity), transparent);
}

.md-nav-rail__item[aria-current="page"] {
    color: var(--md-sys-color-on-secondary-container);
}

.md-nav-rail__item[aria-current="page"] .md-nav-rail__icon-wrap {
    background-color: var(--md-sys-color-secondary-container);
}

/* ---------- BOTTOM NAV (mobile) ---------- */

/* ---------- FLOATING TOOLBAR (mobile, MD3 Expressive) ---------- */

.md-bottom-nav {
    position: fixed;
    left: 8px;
    right: 8px;
    bottom: calc(4px + env(safe-area-inset-bottom, 0));
    z-index: 10;
    display: flex;
    justify-content: space-around;
    gap: 4px;
    background-color: var(--md-sys-color-surface-container-high);
    border-radius: 9999px;
    box-shadow: var(--md-sys-elevation-3);
    padding: 6px;
}

/* Reserve space at the bottom of the page so the floating bar
   doesn't cover content */
@media (max-width: 839px) {
    body { padding-bottom: calc(80px + env(safe-area-inset-bottom, 0)); }
}

@media (min-width: 840px) {
    .md-bottom-nav { display: none; }
}

.md-bottom-nav__item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 8px 12px;
    text-decoration: none;
    color: var(--md-sys-color-on-surface-variant);
    font-size: 11px;
    font-weight: 500;
    background: transparent;
    border: none;
    border-radius: 9999px;
    cursor: pointer;
    transition: background-color var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard),
                color var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard);
}

.md-bottom-nav__item:hover {
    background-color: color-mix(in srgb, var(--md-sys-color-on-surface) 8%, transparent);
}

.md-bottom-nav__icon-wrap {
    display: grid;
    place-items: center;
    width: auto;
    height: 24px;
}

.md-bottom-nav__item[aria-current="page"] {
    color: var(--md-sys-color-on-secondary-container);
    background-color: var(--md-sys-color-secondary-container);
}

/* ---------- BUTTONS ---------- */

.md-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 40px;
    padding: 0 24px;
    border: none;
    border-radius: var(--md-sys-shape-corner-full);
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0.1px;
    cursor: pointer;
    text-decoration: none;
    transition: background-color var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard),
                box-shadow var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard);
    user-select: none;
}

.md-btn--filled {
    background-color: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
}

.md-btn--filled:hover {
    background-color: color-mix(in srgb, var(--md-sys-color-primary) 92%, var(--md-sys-color-on-primary));
    box-shadow: var(--md-sys-elevation-1);
}

.md-btn--tonal {
    background-color: var(--md-sys-color-secondary-container);
    color: var(--md-sys-color-on-secondary-container);
}

.md-btn--tonal:hover {
    background-color: color-mix(in srgb, var(--md-sys-color-secondary-container) 92%, var(--md-sys-color-on-secondary-container));
}

.md-btn--outlined {
    background-color: transparent;
    color: var(--md-sys-color-primary);
    border: 1px solid var(--md-sys-color-outline);
}

.md-btn--outlined:hover {
    background-color: color-mix(in srgb, var(--md-sys-color-primary) var(--md-sys-state-hover-opacity), transparent);
}

.md-btn--text {
    background-color: transparent;
    color: var(--md-sys-color-primary);
    padding: 0 12px;
}

.md-btn--text:hover {
    background-color: color-mix(in srgb, var(--md-sys-color-primary) var(--md-sys-state-hover-opacity), transparent);
}

.md-btn--full { width: 100%; }

/* Icon button — circular, MD3 style */
.md-icon-btn {
    display: inline-grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    color: var(--md-sys-color-on-surface-variant);
    border-radius: 50%;
    cursor: pointer;
    transition: background-color var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard);
}

.md-icon-btn:hover {
    background-color: color-mix(in srgb, var(--md-sys-color-on-surface) var(--md-sys-state-hover-opacity), transparent);
}

.md-icon-btn--toggled {
    color: var(--md-sys-color-primary);
    background-color: var(--md-sys-color-primary-container);
}

.md-icon-btn svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
}

/* ---------- SEARCH BAR ---------- */

.md-search {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    height: 48px;
    padding: 0 12px 0 16px;
    background-color: var(--md-sys-color-surface-container-high);
    border-radius: var(--md-sys-shape-corner-full);
    transition: background-color var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard);
}

.md-search:focus-within {
    background-color: var(--md-sys-color-surface-container-highest);
}

.md-search__icon {
    color: var(--md-sys-color-on-surface-variant);
    flex-shrink: 0;
    display: grid;
    place-items: center;
}

.md-search__input {
    flex: 1;
    border: none;
    background: transparent;
    font: inherit;
    color: var(--md-sys-color-on-surface);
    outline: none;
    padding: 0;
    min-width: 0;
}

.md-search__input::placeholder {
    color: var(--md-sys-color-on-surface-variant);
}

/* ---------- CHIPS ---------- */

.md-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.md-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 32px;
    padding: 0 16px;
    background-color: transparent;
    color: var(--md-sys-color-on-surface-variant);
    border: 1px solid var(--md-sys-color-outline);
    border-radius: var(--md-sys-shape-corner-small);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    user-select: none;
    transition: background-color var(--md-sys-motion-duration-short),
                border-color var(--md-sys-motion-duration-short);
}

.md-chip:hover {
    background-color: color-mix(in srgb, var(--md-sys-color-on-surface) var(--md-sys-state-hover-opacity), transparent);
}

.md-chip--selected {
    background-color: var(--md-sys-color-secondary-container);
    color: var(--md-sys-color-on-secondary-container);
    border-color: transparent;
    padding-left: 8px;
}

.md-chip--selected::before {
    content: "";
    width: 18px;
    height: 18px;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%23000"><path d="M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"/></svg>');
    background-size: contain;
}

/* ---------- CARDS ---------- */

.md-card {
    background-color: var(--md-sys-color-surface-container-low);
    color: var(--md-sys-color-on-surface);
    border-radius: var(--md-sys-shape-corner-medium);
    overflow: hidden;
    box-shadow: var(--md-sys-elevation-1);
    display: flex;
    flex-direction: column;
    transition: box-shadow var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard),
                transform var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard);
    position: relative;
}

.md-card:hover {
    box-shadow: var(--md-sys-elevation-2);
}

.md-card--filled {
    background-color: var(--md-sys-color-surface-container-highest);
    box-shadow: none;
}

.md-card--outlined {
    background-color: var(--md-sys-color-surface);
    box-shadow: none;
    border: 1px solid var(--md-sys-color-outline-variant);
}

/* ---------- GRID ---------- */

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

/* ---------- FOOTER ---------- */

.md-footer {
    background-color: var(--md-sys-color-surface-container);
    color: var(--md-sys-color-on-surface-variant);
    padding: 32px 24px;
    text-align: center;
    font-size: 12px;
    line-height: 1.6;
    border-top: 1px solid var(--md-sys-color-outline-variant);
}

.md-footer a {
    color: var(--md-sys-color-primary);
    text-decoration: none;
}

.md-footer a:hover { text-decoration: underline; }

/* ---------- UTILITIES ---------- */

.md-divider {
    height: 1px;
    background-color: var(--md-sys-color-outline-variant);
    border: none;
    margin: 16px 0;
}

.md-stack { display: flex; flex-direction: column; gap: 8px; }
.md-row { display: flex; align-items: center; gap: 8px; }

/* Visually hidden but accessible */
.md-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Avatar */
.md-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    background-color: var(--md-sys-color-surface-container-high);
}

/* ---------- LEGACY CLASS BRIDGES (used by server.js) ---------- */

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

.card {
    background-color: var(--md-sys-color-surface-container-low);
    color: var(--md-sys-color-on-surface);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: var(--md-sys-elevation-1);
    display: flex;
    flex-direction: column;
    position: relative;
    transition: box-shadow var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard),
                transform var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard);
}

.card:hover {
    box-shadow: var(--md-sys-elevation-2);
    transform: translateY(-2px);
}

.card > img {
    width: 100%;
    height: 200px;
    object-fit: contain;
    padding: 16px;
    background: #ffffff;
}

.card-content {
    padding: 16px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.card h3 {
    margin: 0 0 4px 0;
    font-size: 16px;
    font-weight: 500;
    line-height: 1.3;
    height: 42px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    color: var(--md-sys-color-on-surface);
}

.card-slug {
    font-size: 11px;
    color: var(--md-sys-color-outline);
    margin-bottom: 12px;
    font-family: monospace;
    display: none;
}

body.dev-mode .card-slug {
    display: inline-block;
    background: var(--md-sys-color-surface-variant);
    color: var(--md-sys-color-on-surface-variant);
    padding: 2px 6px;
    border-radius: 4px;
}

.wishlist-btn, .share-card-btn {
    position: absolute;
    background: var(--md-sys-color-surface-container-high);
    color: var(--md-sys-color-on-surface-variant);
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    cursor: pointer;
    display: grid;
    place-items: center;
    box-shadow: var(--md-sys-elevation-1);
    transition: background-color var(--md-sys-motion-duration-short),
                transform var(--md-sys-motion-duration-short);
}

.wishlist-btn { top: 8px; right: 8px; }
.share-card-btn { top: 56px; right: 8px; }
.wishlist-btn:hover, .share-card-btn:hover { transform: scale(1.08); }

.icon-heart, .icon-share { font-size: 22px; line-height: 1; }
.icon-heart { font-variation-settings: 'FILL' 0, 'wght' 500, 'GRAD' 0, 'opsz' 24; }
.icon-share { font-variation-settings: 'FILL' 0, 'wght' 500, 'GRAD' 0, 'opsz' 24; }
.wishlist-btn.active { background: var(--md-sys-color-error-container); color: var(--md-sys-color-error); }
.wishlist-btn.active .icon-heart { font-variation-settings: 'FILL' 1, 'wght' 600, 'GRAD' 0, 'opsz' 24; }

.offers-container {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.offer-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 30px 70px;
    gap: 8px;
    align-items: center;
    padding: 6px 8px;
    background: var(--md-sys-color-surface-container);
    border-radius: 8px;
}

.offer-row.is-out {
    opacity: 0.6;
    filter: grayscale(70%);
}

.price {
    font-weight: 700;
    color: var(--md-sys-color-tertiary);
    font-size: 14px;
    text-align: right;
    white-space: nowrap;
    line-height: 1.2;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.price-strike {
    text-decoration: line-through;
    color: var(--md-sys-color-outline);
    font-size: 11px;
    font-weight: 500;
}

.price-out {
    color: var(--md-sys-color-error);
    font-size: 11px;
    font-weight: 700;
}

.lang-tag {
    font-size: 11px;
    font-weight: 700;
    padding: 2px 4px;
    border: 1px solid transparent;
    border-radius: 4px;
    text-align: center;
    display: inline-block;
    width: 100%;
    box-sizing: border-box;
    background: var(--md-sys-color-surface-container-high);
    color: var(--md-sys-color-on-surface-variant);
}

/* Semantic colors per language, derived from MD3 tokens so they
   stay consistent across palettes and adapt to dark mode. */
.lang-tag--es { color: var(--md-sys-color-on-tertiary-container); background: var(--md-sys-color-tertiary-container); }
.lang-tag--en { color: var(--md-sys-color-on-secondary-container); background: var(--md-sys-color-secondary-container); }
.lang-tag--multi { color: var(--md-sys-color-on-primary-container); background: var(--md-sys-color-primary-container); }

/* Tienda buttons — híbrido MD3 tonal + acento de marca como borde izquierdo */
.tienda-btn {
    text-decoration: none;
    background-color: var(--md-sys-color-secondary-container);
    color: var(--md-sys-color-on-secondary-container);
    padding: 6px 8px 6px 10px;
    border-radius: 8px;
    border-left: 4px solid var(--brand, var(--md-sys-color-primary));
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
    text-align: left;
    transition: background-color var(--md-sys-motion-duration-short);
}

.tienda-btn:hover {
    filter: brightness(0.96);
}

.btn-el-duende         { --brand: #28a745; }
.btn-t-de-tlacuache    { --brand: #8b4513; }
.btn-geeky-stuff       { --brand: #6f42c1; }
.btn-quantum-boardgames{ --brand: #00bcd4; }
.btn-chocita-juegos    { --brand: #dcba4f; }
.btn-roll-games        { --brand: #e53e3e; }
.btn-malditos-dados    { --brand: #1a202c; }
.btn-gamesmart         { --brand: #4c51bf; }
.btn-art-hobbies       { --brand: #e3000f; }
.btn-mundo-meeple      { --brand: #f59e0b; }
.btn-vonkraken         { --brand: #334fb4; }
.btn-redqueen          { --brand: #e32619; }
.btn-juego-de-belugas  { --brand: #9b046f; }
.btn-geim              { --brand: #FFFC00; }
.btn-eurojuegos        { --brand: #0f64af; }
.btn-juegos-patolli    { --brand: #ffcb70; }
.btn-alfa-y-delta      { --brand: #480080; }
.btn-juega-mas         { --brand: #d76b14; }
.btn-hobbiton-games    { --brand: #9e833b; }
.btn-bundaba           { --brand: #f2a649; }
.btn-juegate-este      { --brand: #ff6b35; }
.btn-yego-games        { --brand: #31434d; }
.btn-hobby-guild       { --brand: #121212; }
.btn-2tomatoes         { --brand: #911f1f; }
.btn-caravana-gameslab { --brand: #155984; }
.btn-cantera-ludica    { --brand: #ec7603; }
.btn-el-comodin        { --brand: #00CD34; }
.btn-infinite-skill    { --brand: #e9b539; }
.btn-geeky-mania       { --brand: #0865f1; }

/* Amazon promo card */
.amazon-promo-card {
    border: 2px dashed var(--md-sys-color-outline-variant) !important;
    background: transparent !important;
    box-shadow: none !important;
}

.btn-amazon-cta {
    display: inline-block;
    background: #ff9900;
    color: #111;
    font-weight: 700;
    padding: 10px 16px;
    border-radius: 20px;
    text-decoration: none;
    font-size: 14px;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    gap: 4px;
    margin: 32px 0;
    flex-wrap: wrap;
}

.page-link {
    padding: 8px 14px;
    background-color: transparent;
    color: var(--md-sys-color-on-surface);
    border-radius: 9999px;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    border: 1px solid transparent;
    transition: background-color var(--md-sys-motion-duration-short);
}

.page-link:hover {
    background-color: color-mix(in srgb, var(--md-sys-color-on-surface) 8%, transparent);
}

.page-link.active {
    background-color: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
}

/* Section title alignment in /tiendas */
.section-title { color: var(--md-sys-color-primary); }

/* Store cards (in /tiendas page) */
.store-card .card-content {
    flex-grow: 1;
}

.store-card__logo {
    height: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--md-sys-color-surface);
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
    padding: 20px;
}

.store-card__logo {
    background: #ffffff;
}

.store-card__logo img {
    max-height: 100%;
    max-width: 100%;
    object-fit: contain;
    /* Don't apply padding/height from the generic .card img rule */
    padding: 0 !important;
    height: auto !important;
    background: transparent !important;
}

/* Material Symbols Rounded base */
.material-symbols-rounded {
    font-family: "Material Symbols Rounded";
    font-weight: normal;
    font-style: normal;
    font-size: 24px;
    line-height: 1;
    letter-spacing: normal;
    text-transform: none;
    display: inline-block;
    white-space: nowrap;
    word-wrap: normal;
    direction: ltr;
    -webkit-font-feature-settings: 'liga';
    -webkit-font-smoothing: antialiased;
    font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

/* Tiendas sheet */
.md-overlay {
    position: fixed;
    inset: 0;
    background-color: color-mix(in srgb, var(--md-sys-color-scrim) 32%, transparent);
    z-index: 100;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    animation: md-fade var(--md-sys-motion-duration-medium) var(--md-sys-motion-easing-emphasized-decelerate);
}
.md-overlay[hidden] { display: none; }

@keyframes md-fade { from { opacity: 0; } to { opacity: 1; } }

.md-sheet {
    background-color: var(--md-sys-color-surface-container-high);
    color: var(--md-sys-color-on-surface);
    border-radius: 28px 28px 0 0;
    width: 100%;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    animation: md-slide-up var(--md-sys-motion-duration-medium) var(--md-sys-motion-easing-emphasized-decelerate);
}

@keyframes md-slide-up { from { transform: translateY(20%); } to { transform: translateY(0); } }

@media (min-width: 600px) {
    .md-overlay { align-items: center; }
    .md-sheet { max-width: 560px; border-radius: 28px; max-height: 70vh; }
}

.md-sheet__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
}

.md-sheet__body {
    padding: 16px 24px;
    overflow-y: auto;
    flex: 1;
}

.md-sheet__footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 16px 24px;
    border-top: 1px solid var(--md-sys-color-outline-variant);
}

/* Login/account dialog */
.md-dialog-overlay {
    position: fixed;
    inset: 0;
    background-color: color-mix(in srgb, var(--md-sys-color-scrim) 32%, transparent);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 200;
}

.md-dialog-overlay.show { display: flex; }

.md-dialog {
    background: var(--md-sys-color-surface-container-high);
    color: var(--md-sys-color-on-surface);
    border-radius: 28px;
    padding: 24px;
    max-width: 360px;
    width: calc(100% - 32px);
    box-shadow: var(--md-sys-elevation-3);
}

.md-dialog__title { margin: 0 0 12px; }
.md-dialog__body { color: var(--md-sys-color-on-surface-variant); margin-bottom: 24px; }
.md-dialog__actions { display: flex; justify-content: flex-end; gap: 8px; }

.btn-google {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: #fff;
    color: #1f1f1f;
    padding: 0 16px;
    height: 40px;
    border-radius: 9999px;
    text-decoration: none;
    font-weight: 500;
    font-size: 14px;
    border: 1px solid #dadce0;
    box-shadow: var(--md-sys-elevation-1);
}

/* ---------- FILTERS BAR ---------- */
.filters-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.filter-badge {
    display: inline-grid;
    place-items: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    background: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
    border-radius: 9999px;
    font-size: 11px;
    font-weight: 700;
    margin-left: 4px;
}

/* ---------- TOP BAR MENU BUTTON ---------- */
.md-top-bar__menu { display: none; }
@media (min-width: 840px) {
    .md-top-bar__menu { display: inline-grid; }
}

/* ---------- BRAND LOGO (dark vs light variants) ---------- */
.brand-logo { width: 32px; height: 32px; border-radius: 8px; flex-shrink: 0; }
/* The original white logo is meant for dark surfaces. In light mode
   we swap to a darker version so it stays visible. */
.brand-logo--light { display: none; }
[data-theme="light"] .brand-logo--dark  { display: none; }
[data-theme="light"] .brand-logo--light { display: block; }
@media (prefers-color-scheme: light) {
    :root:not([data-theme="dark"]) .brand-logo--dark  { display: none; }
    :root:not([data-theme="dark"]) .brand-logo--light { display: block; }
}

/* ---------- SECTION TITLE WITH ICON ---------- */
.md-section-title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 16px;
    color: var(--md-sys-color-primary);
}

.md-section-title .material-symbols-rounded {
    font-size: 28px;
    font-variation-settings: 'FILL' 1, 'wght' 500, 'GRAD' 0, 'opsz' 24;
}

/* ---------- COLOR PICKER ---------- */
.color-swatches {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

@media (min-width: 480px) {
    .color-swatches { grid-template-columns: repeat(6, 1fr); }
}

.color-swatch {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    background: transparent;
    border: none;
    padding: 4px;
    cursor: pointer;
    font: inherit;
    color: var(--md-sys-color-on-surface-variant);
    border-radius: 12px;
    transition: background-color var(--md-sys-motion-duration-short);
}

.color-swatch:hover {
    background-color: color-mix(in srgb, var(--md-sys-color-on-surface) 8%, transparent);
}

.color-swatch__dot {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--swatch);
    border: 2px solid transparent;
    box-shadow: inset 0 0 0 2px var(--md-sys-color-surface-container-high);
    transition: border-color var(--md-sys-motion-duration-short);
    position: relative;
}

.color-swatch.is-selected .color-swatch__dot {
    border-color: var(--md-sys-color-on-surface);
}

.color-swatch.is-selected .color-swatch__dot::after {
    content: "";
    position: absolute;
    inset: 0;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="white"><path d="M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"/></svg>');
    background-size: 24px;
    background-position: center;
    background-repeat: no-repeat;
}

.color-swatch__label {
    font-size: 12px;
    font-weight: 500;
}

.color-swatch.is-selected { color: var(--md-sys-color-on-surface); }
