/* ══════════════════════════════════════════
   GARIX.IO — hats.css
   ══════════════════════════════════════════
   Hats (ui/react/HatsModal.jsx#HatsPage, backend-api-hats.md). Ya no es un
   modal: es una página del menú principal — el shell (encabezado,
   navegación lateral, scale to fit) vive en pages.css. Acá: la grilla de
   cards (un hat necesita mostrar nombre + precio/estado, no solo la
   imagen como .skins-item) y el bloque "Equipped" de la barra lateral. */

/* 6 columnas fijas: el contenido de la página mide ~800px (ver
   .menu-page__inner/.page-layout en pages.css) → cards de ~125px, así
   entran dos filas completas sin scrollear. minmax(0, 1fr), no solo 1fr: sin
   el mínimo en 0, el texto de .hat-card__name (overflow:hidden/ellipsis)
   puede forzar a la columna a crecer más allá de 1fr en algunos motores. */
.hats-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 12px;
}

.hat-card {
    position: relative;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border-light);
    border-radius: 12px;
    overflow: hidden;
    background: var(--bg-row);
    transition: var(--transition);
}

.hat-card:hover {
    border-color: var(--accent-border);
}

/* Mismo tratamiento que .skins-item.selected (skins.css): el borde solo no
   alcanza para que "es el hat equipado" se note de un vistazo en una
   grilla larga. */
.hat-card--equipped {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-glow);
}

.hat-card__badge {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 1;
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 2px 5px;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
}

/* Featured — update de backend (orden de tienda, HATS-CLIENT-API.md §1):
   esquina OPUESTA a .hat-card__badge (arriba) — mismo patrón de dos badges
   independientes que .skins-item__badge/__slot-badge (skins.css), para que
   un hat featured Y equipado a la vez no choque sus dos indicadores. Solo
   el glyph (sin la palabra "Featured"): con 6 columnas por fila la card
   mide ~125px (ver .hats-grid arriba) y un texto más largo ahí arriba a la
   izquierda se pisaría con "Equipped" a la derecha en el caso borde de un
   hat featured+equipado. Ámbar — mismo tono que
   .badge--gold (modals.css, Starter Pack/BEST VALUE), ningún color nuevo. */
.hat-card__featured-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 1;
    font-size: 11px;
    line-height: 1;
    padding: 2px 4px;
    border-radius: 4px;
    background: rgba(255, 204, 0, 0.85);
    color: #2b1900;
}

.hat-card__image {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: 16px;
}

.hat-card__image img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    display: block;
}

.hat-card__body {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 10px 8px 12px;
    border-top: 1px solid var(--border);
    text-align: center;
}

.hat-card__name {
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.hat-card__meta {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
}

.hat-card__coin {
    width: 13px;
    height: 13px;
    object-fit: contain;
}

.hat-card__owned {
    text-transform: uppercase;
    letter-spacing: 0.03em;
    font-size: 11px;
}

/* Franja de acción — mismo lenguaje que .skins-item__use-btn (skins.css):
   plana, uppercase, letter-spacing, ghost por default. BUY/EQUIP comparten
   este mismo estilo ghost (la diferencia entre los dos ya la dice el texto
   del botón + la fila de arriba, precio vs. "Owned") — solo EQUIPPED se
   distingue con relleno sólido, igual que la skin puesta en
   .skins-item__use-btn--active. */
.hat-card__action {
    width: 100%;
    padding: 10px 0;
    border: none;
    border-top: 1px solid var(--border);
    background: transparent;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 700;
    font-family: var(--font);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    cursor: pointer;
    transition: var(--transition);
}

.hat-card__action:hover:not(:disabled) {
    background: var(--accent-dim);
    color: var(--accent);
}

/* Bug real reportado ("le presiono al que tengo equipado y no se
   desequipa"): EQUIPPED ya NO se deshabilita — solo `pending` (una compra
   de OTRO hat en vuelo) lo hace, mismo criterio que SkinsModal.jsx
   (clickear la skin ya equipada la saca). El :not(--equipped) queda igual
   por robustez, aunque en la práctica un botón equipped nunca llega
   disabled ahora. */
.hat-card__action:disabled:not(.hat-card__action--equipped) {
    opacity: 0.6;
    cursor: not-allowed;
}

.hat-card__action--equipped {
    background: var(--accent);
    color: #001824;
    cursor: pointer;
}

/* Hover del botón EQUIPPED — ahora togglea (clickearlo saca el hat), así
   que necesita su propio hint de hover en vez del ghost genérico de
   BUY/EQUIP: tinte de acción destructiva, mismo rojo que
   .skins-item__delete-btn (skins.css). Doble clase (más específico que
   .hat-card__action:hover:not(:disabled) de arriba) para no perder contra
   esa regla. */
.hat-card__action.hat-card__action--equipped:hover {
    background: rgba(255, 77, 109, 0.85);
    color: #fff;
}

/* ── Bloque "Equipped" de la barra lateral (HatsPage) — el hat puesto
   ahora mismo, con atajo para sacárselo sin buscarlo en la grilla. ── */
.hats-equipped__heading {
    margin-top: 20px;
}

.hats-equipped {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg-row);
}

.hats-equipped__image {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: var(--bg-card-inner);
}

.hats-equipped__image img {
    max-width: 36px;
    max-height: 36px;
    object-fit: contain;
}

.hats-equipped__info {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.hats-equipped__name {
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.hats-equipped__remove {
    align-self: flex-start;
    padding: 0;
    border: none;
    background: none;
    color: var(--text-muted);
    font-family: var(--font);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.hats-equipped__remove:hover {
    color: #ff4d6d;
}

.hats-equipped__none {
    font-size: 12px;
    color: var(--text-muted);
}

/* ══════════════════════════════════════════
   COSMETICS — Cell shapes + Border style
   (CELL-SHAPES-CLIENT-API.md, ui/react/HatsModal.jsx#CosmeticsPage)
   ══════════════════════════════════════════ */

/* Card de shape: mismas clases que .hat-card — solo la preview SVG en vez
   de <img>, centrada sobre un fondo un poco más oscuro (se lee como "la
   célula sobre el mapa"). */
.shape-card .hat-card__image {
    background: var(--bg-card-inner);
}

.cell-shape-preview {
    display: block;
    overflow: visible;
}

/* Estudio de borde (dentro de "Cell shapes"): preview grande de tu célula a
   la izquierda — sobre la grilla tenue del mapa, así se juzga como en
   partida — y los controles a la derecha. */
.shape-studio {
    display: grid;
    grid-template-columns: 200px minmax(0, 1fr);
    gap: 18px;
    margin-bottom: 16px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg-card-inner);
}

.shape-studio__preview {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 196px;
    padding: 8px 0;
    border: 1px solid var(--border);
    border-radius: 10px;
    background-color: #0b0c0e;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.045) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.045) 1px, transparent 1px);
    background-size: 22px 22px;
}

.shape-studio__caption {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.shape-studio__controls {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 14px;
    padding: 4px 8px 4px 0;
}

.shape-studio__row {
    display: flex;
    align-items: center;
    gap: 16px;
    min-height: 30px;
    transition: var(--transition);
}

.shape-studio__row--off {
    opacity: 0.4;
}

/* Separa los controles de borde de los de glow. */
.shape-studio__divider {
    height: 1px;
    background: var(--border);
}

.shape-studio__label {
    width: 58px;
    flex-shrink: 0;
    margin: 0;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
}

/* Muestra de color: abre el picker propio de la app (ColorPicker.jsx). */
.shape-studio__swatch {
    width: 30px;
    height: 30px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.25);
    transition: var(--transition);
}

.shape-studio__swatch:hover:not(:disabled) {
    border-color: rgba(255, 255, 255, 0.4);
}

.shape-studio__swatch:disabled {
    cursor: not-allowed;
}

.shape-studio__footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.shape-studio__note {
    font-size: 12px;
    color: var(--text-muted);
}

.shape-studio__reset {
    padding: 6px 14px;
    font-size: 12px;
}

/* ── Auto / Custom (color y tamaño del borde) — dos segmentos, el activo
   resaltado con el acento (antes un "Auto" suelto que no dejaba claro si
   estaba activo). ── */
.auto-custom {
    display: inline-flex;
    flex-shrink: 0;
    padding: 2px;
    border: 1px solid var(--border-light);
    border-radius: 8px;
    background: #0b0c0e;
}

.auto-custom__btn {
    min-width: 64px;
    padding: 5px 10px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text-muted);
    font-family: var(--font);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
}

.auto-custom__btn:hover:not(:disabled):not(.auto-custom__btn--active) {
    color: var(--text);
}

.auto-custom__btn--active {
    background: var(--accent);
    color: #001824;
    box-shadow: 0 1px 6px rgba(0, 180, 255, 0.35);
}

.auto-custom__btn:disabled {
    cursor: not-allowed;
}

/* Muestra "bloqueada" (en Auto): se ve el color automático, pero atenuada y
   sin cursor de acción — solo se elige color en Custom. */
.shape-studio__swatch--locked {
    opacity: 0.45;
    filter: saturate(0.6);
}

/* ── Barra de tamaño: pista fina con relleno de acento hasta el valor
   (--fill, inline), pulgar blanco con aro de acento, extremos Thin/Thick y
   el valor en una pastilla. ── */
.size-slider {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
    transition: var(--transition);
}

.size-slider--locked {
    opacity: 0.4;
}

.size-slider__end {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
}

.size-slider__input {
    -webkit-appearance: none;
    appearance: none;
    flex: 1;
    min-width: 80px;
    max-width: 240px;
    height: 20px;
    margin: 0;
    background: transparent;
    cursor: pointer;
}

.size-slider__input:disabled {
    cursor: not-allowed;
}

.size-slider__input:focus {
    outline: none;
}

.size-slider__input::-webkit-slider-runnable-track {
    height: 4px;
    border-radius: 2px;
    background: linear-gradient(to right, var(--accent) var(--fill, 50%), rgba(255, 255, 255, 0.12) var(--fill, 50%));
}

.size-slider__input::-moz-range-track {
    height: 4px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.12);
}

.size-slider__input::-moz-range-progress {
    height: 4px;
    border-radius: 2px;
    background: var(--accent);
}

.size-slider__input::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    margin-top: -6px;
    border: 3px solid var(--accent);
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
    transition: transform 0.08s var(--ease);
}

.size-slider__input::-moz-range-thumb {
    width: 10px;
    height: 10px;
    border: 3px solid var(--accent);
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

.size-slider__input:not(:disabled):hover::-webkit-slider-thumb,
.size-slider__input:focus-visible::-webkit-slider-thumb {
    transform: scale(1.15);
}

.size-slider__value {
    min-width: 28px;
    padding: 3px 0;
    border: 1px solid var(--border-light);
    border-radius: 6px;
    background: #0b0c0e;
    color: var(--text);
    font-size: 12px;
    font-weight: 700;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

/* ── Preview de un shape no equipado (clic en una card). ── */
.shape-studio__preview {
    position: relative;
}

.shape-studio__badge {
    position: absolute;
    top: 8px;
    left: 8px;
    padding: 2px 7px;
    border-radius: 4px;
    background: var(--accent-dim);
    border: 1px solid var(--accent-border);
    color: var(--accent);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

/* La imagen de la card de shape es un botón (clic = previsualizar). */
.shape-card__preview-btn {
    position: relative;
    width: 100%;
    border: none;
    font-family: var(--font);
    cursor: pointer;
}

.shape-card__preview-hint {
    position: absolute;
    left: 50%;
    bottom: 6px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 7px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.65);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    opacity: 0;
    transform: translate(-50%, 3px);
    transition: opacity 0.12s var(--ease), transform 0.12s var(--ease);
    pointer-events: none;
}

.shape-card__preview-btn:hover .shape-card__preview-hint,
.shape-card__preview-btn:focus-visible .shape-card__preview-hint {
    opacity: 1;
    transform: translate(-50%, 0);
}

.shape-card--previewing {
    border-color: var(--accent-border);
    box-shadow: 0 0 0 1px var(--accent-border);
}

/* Sin shape (ni equipado ni en preview): la célula lisa + esta ayuda. */
.shape-studio__hint {
    font-size: 11px;
    color: var(--text-muted);
}

/* ── Estudio de Hats (HatsModal.jsx#HatStudio) — misma tarjeta que el de
   shapes; el escenario pone la célula abajo-centro con lugar arriba para el
   hat, que se ubica con la misma regla que en partida (ancho = diámetro de
   la célula, centro a alto/verticalOffset por encima del centro de la
   célula — el translateY lo arma el componente). ── */
.hat-studio__stage {
    position: relative;
    width: 150px;
    height: 174px;
    flex-shrink: 0;
}

.hat-studio__cell {
    position: absolute;
    left: 20px;
    top: 64px;
}

.hat-studio__hat {
    position: absolute;
    left: 75px;
    top: 119px;
    width: 110px;
    height: auto;
    pointer-events: none;
}

.hat-studio__note {
    margin: -6px 0 0;
    padding-left: 74px;
    font-size: 12px;
    color: var(--text-muted);
}

.size-slider__value--wide {
    min-width: 42px;
}

/* La imagen de las cards de HAT también es un botón (previsualizar) — sin
   el fondo gris por defecto de <button> (las de shape tienen su propio
   fondo, ver .shape-card .hat-card__image). */
.hat-card:not(.shape-card) .shape-card__preview-btn {
    background: transparent;
}
