/* ===== Theme ===== */
:root{
    --bg: #0b0d12;
    --bg2:#101624;
    --card:#121a2b;
    --text:#e7ecff;
    --muted:#aab6e6;
    --border: rgba(255,255,255,.10);
    --shadow: 0 10px 30px rgba(0,0,0,.35);

    --accent:#f4c542;    /* gold */
    --accent2:#7dd3fc;   /* sky */
    --good:#34d399;
    --bad:#fb7185;

    --radius: 18px;
    --radius2: 14px;
}

:root[data-theme="light"]{
    --bg:#f7f8ff;
    --bg2:#eef1ff;
    --card:#ffffff;
    --text:#0d1324;
    --muted:#51607a;
    --border: rgba(17, 24, 39, .12);
    --shadow: 0 12px 28px rgba(17, 24, 39, .12);

    --accent:#b88700;
    --accent2:#2563eb;
}

/* ===== Base ===== */
*{ box-sizing:border-box; }
html,body{ margin:0; padding:0; }
body{
    font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji","Segoe UI Emoji";
    background: radial-gradient(1000px 600px at 20% 0%, rgba(244,197,66,.18), transparent 60%),
    radial-gradient(900px 500px at 85% 10%, rgba(125,211,252,.18), transparent 55%),
    linear-gradient(180deg, var(--bg), var(--bg2));
    color: var(--text);
}

body{
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

main{
    flex: 1;
}

a{ color:inherit; text-decoration:none; }
code, .mono{ font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; }

.container{ width:min(1100px, 92%); margin:0 auto; }
.muted{ color: var(--muted); }
.accent{ color: var(--accent); }

.section{ padding: 56px 0; }
.section.alt{ background: linear-gradient(180deg, transparent, rgba(255,255,255,.03), transparent); }
.section-head{ margin-bottom: 18px; }
.section-foot{ margin-top: 22px; display:flex; justify-content:flex-end; }

h1,h2,h3{ margin:0 0 10px 0; letter-spacing: -0.02em; }
h1{ font-size: clamp(28px, 4vw, 46px); line-height:1.05; }
.h2{ font-size: clamp(24px, 3vw, 34px); }
.lead{ font-size: 1.05rem; line-height:1.6; color: var(--muted); max-width: 58ch; }

/* ===== Header ===== */
.site-header{
    position: sticky; top:0;
    backdrop-filter: blur(14px);
    background: rgba(0,0,0,.22);
    border-bottom: 1px solid var(--border);
    z-index: 10;
}
:root[data-theme="light"] .site-header{ background: rgba(255,255,255,.7); }

.header-row{
    height: 68px;
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:14px;
}

.brand{ display:flex; align-items:center; gap:10px; }
.brand-mark{ font-size: 22px; }
.brand-title{ display:block; font-weight: 800; }
.brand-subtitle{ display:block; font-size: 12px; color: var(--muted); margin-top: 2px; }

.nav{ display:flex; gap:10px; align-items:center; }
.nav-link{
    padding: 10px 12px;
    border-radius: 999px;
    color: var(--muted);
}
.nav-link:hover{ background: rgba(255,255,255,.06); color: var(--text); }
.nav-link.active{ background: rgba(244,197,66,.16); color: var(--text); border: 1px solid rgba(244,197,66,.25); }

.icon-btn{
    width: 40px; height: 40px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: rgba(255,255,255,.04);
    color: var(--text);
    cursor:pointer;
}
.icon-btn:hover{ transform: translateY(-1px); }

.brand-logo{
    width: 28px;
    height: 28px;
    object-fit: contain;
    display: block;
    filter: drop-shadow(0 6px 10px rgba(0,0,0,.25));
}

/* ===== Hero ===== */
.hero{ padding: 54px 0 24px; }
.hero-grid{
    display:grid;
    grid-template-columns: 1.2fr .8fr;
    gap: 18px;
    align-items: start;
}
@media (max-width: 900px){
    .hero-grid{ grid-template-columns: 1fr; }
}

.hero-actions{ display:flex; gap:10px; margin-top: 18px; flex-wrap: wrap; }
.pill-row{ display:flex; gap:8px; margin-top: 16px; flex-wrap:wrap; }
.pill{
    font-size: 12px;
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: rgba(255,255,255,.03);
}

.hero-card{
    border:1px solid var(--border);
    background: linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.02));
    border-radius: var(--radius);
    padding: 18px;
    box-shadow: var(--shadow);
}
.hero-card-top{ display:flex; align-items:center; justify-content:space-between; gap:10px; }
.kicker{ font-size: 12px; color: var(--muted); }
.hero-card-title{ font-weight: 750; margin-top: 4px; }

.copy-row{
    display:flex; gap:10px; align-items:center;
    margin: 14px 0 10px;
}
.copy-code{
    flex:1;
    padding: 12px 12px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: rgba(0,0,0,.15);
    overflow:auto;
}

/* ===== Buttons / inputs ===== */
.btn{
    display:inline-flex;
    align-items:center;
    justify-content:center;
    gap:8px;
    padding: 12px 14px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: rgba(255,255,255,.04);
    color: var(--text);
    cursor:pointer;
    transition: transform .12s ease, background .12s ease;
}
.btn:hover{ transform: translateY(-1px); background: rgba(255,255,255,.07); }
.btn.primary{
    background: rgba(244,197,66,.18);
    border-color: rgba(244,197,66,.32);
}
.btn.small{ padding: 10px 12px; font-size: 14px; }

.input{
    width: min(560px, 100%);
    padding: 12px 12px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: rgba(255,255,255,.04);
    color: var(--text);
    outline: none;
}
.input:focus{ box-shadow: 0 0 0 4px rgba(125,211,252,.18); border-color: rgba(125,211,252,.35); }

/* ===== Cards / grid ===== */
.grid{
    display:grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}
@media (max-width: 640px){ .grid{ grid-template-columns: 1fr; } }

.card{
    border:1px solid var(--border);
    border-radius: var(--radius);
    background: rgba(255,255,255,.03);
    box-shadow: var(--shadow);
    padding: 16px;
}

.card-top{ display:flex; align-items:flex-start; justify-content:space-between; gap:12px; margin-bottom: 10px; }
.card-title a{
    text-decoration: none;
    transition: color .15s ease;
    font-weight: 700;
}

.card-title a:hover{
    color: var(--accent2);
    text-decoration: underline;
}
.card-meta{ font-size: 13px; color: var(--muted); margin-top: 4px; }

.badge{
    display:inline-flex; align-items:center; gap:6px;
    font-size: 12px;
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: rgba(255,255,255,.03);
    white-space: nowrap;
}
.badge.good{ border-color: rgba(52,211,153,.35); background: rgba(52,211,153,.12); }
.badge.bad{ border-color: rgba(251,113,133,.35); background: rgba(251,113,133,.12); }

.card-actions{ display:flex; gap:10px; flex-wrap: wrap; margin-top: 12px; }

/* ===== Downloads ===== */
.toolbar{
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

.chip-row{ display:flex; gap:8px; flex-wrap: wrap; }
.chip{
    padding: 8px 10px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: rgba(255,255,255,.03);
    color: var(--muted);
    cursor:pointer;
    font-size: 13px;
}
.chip:hover{ color: var(--text); }
.chip.active{
    color: var(--text);
    border-color: rgba(244,197,66,.35);
    background: rgba(244,197,66,.14);
}

.group{ margin-top: 24px; }
.group h2{ margin-bottom: 10px; }
.group .group-desc{ margin-top: -2px; margin-bottom: 14px; color: var(--muted); }

.dl-row{ display:flex; gap:10px; flex-wrap: wrap; margin-top: 10px; }
.tag{
    font-size: 12px;
    padding: 5px 8px;
    border-radius: 999px;
    border: 1px solid var(--border);
    color: var(--muted);
    background: rgba(255,255,255,.03);
}

/* ===== Footer ===== */
.site-footer{
    padding: 28px 0;
    border-top: 1px solid var(--border);
}
.footer-row{
    display:flex;
    align-items:flex-start;
    justify-content:space-between;
    gap: 16px;
    flex-wrap: wrap;
}
.footer-brand{ font-weight: 800; }
.footer-right{ display:flex; gap: 12px; flex-wrap: wrap; }
.footer-link{ color: var(--muted); }
.footer-link:hover{ color: var(--text); }

/* =======================================================================
   HATS (Gallery + Modal) — Single source of truth
   ======================================================================= */

/* ===== Hats grid ===== */
#hatsGrid.grid.cards{
    display: grid;
    gap: 14px;
}

@media (min-width: 760px){
    #hatsGrid.grid.cards{
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* ===== Hat card ===== */
.hat-card{
    display: grid;
    grid-template-columns: 120px 1fr; /* big thumb left */
    gap: 14px;

    padding: 12px;
    border-radius: 16px;

    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.10);
    box-shadow: 0 10px 28px rgba(0,0,0,0.28);

    cursor: pointer;
    user-select: none;
    outline: none;

    transition: transform 140ms ease, border-color 140ms ease, background 140ms ease;
}

.hat-card:hover{
    transform: translateY(-1px);
    border-color: rgba(255,255,255,0.16);
    background: rgba(255,255,255,0.075);
}

.hat-card:focus-visible{
    box-shadow: 0 0 0 2px rgba(172, 134, 212, 0.45), 0 10px 28px rgba(0,0,0,0.28);
}

/* Left thumbnail */
.hat-thumb-big{
    width: 100%;
    height: 100%;
    min-height: 92px;

    border-radius: 14px;
    overflow: hidden;

    background: rgba(30, 42, 70, 0.45);
    border: 1px solid rgba(255,255,255,0.08);

    display: grid;
    place-items: center;
}

.hat-thumb-big img{
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
    image-rendering: pixelated;
}

/* placeholder */
.hat-thumb-skeleton{
    width: 70%;
    height: 70%;
    border-radius: 12px;
    background: rgba(255,255,255,0.06);
    border: 1px dashed rgba(255,255,255,0.12);
}

/* Right side content */
.hat-card-body{
    display: grid;
    gap: 8px;
    align-content: start;
}

.hat-card-top{
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}

.hat-name{
    font-weight: 750;
    font-size: 16px;
    line-height: 1.1;
}

.hat-meta{
    display: grid;
    gap: 6px;
    font-size: 13px;
}

/* Credits lines on card */
.hat-credit-line{
    display: flex;
    gap: 8px;
    align-items: baseline;
}

/* Mobile: thumb stacks on top */
@media (max-width: 520px){
    .hat-card{
        grid-template-columns: 1fr;
    }
    .hat-thumb-big{
        min-height: 160px;
    }
}

/* ===== Rarity pill (HATS ONLY) ===== */
.rarity-pill{
    --rarity-color: #ffffff;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    padding: 6px 12px;
    border-radius: 999px;

    font-size: 12px;
    font-weight: 700;
    line-height: 1;
    white-space: nowrap;

    color: #ffffff;

    /* muted “glass” tint */
    background: color-mix(in srgb, var(--rarity-color) 55%, rgba(0,0,0,0.55));
    border: 1px solid color-mix(in srgb, var(--rarity-color) 25%, rgba(255,255,255,0.10));

    box-shadow:
            inset 0 1px 0 rgba(255,255,255,0.10);
}

/* Mythic: rainbow but muted */
.rarity-pill.mythic{
    background: linear-gradient(
            90deg,
            color-mix(in srgb, #ff5f6d 70%, #111 30%),
            color-mix(in srgb, #ffc371 70%, #111 30%),
            color-mix(in srgb, #47e891 70%, #111 30%),
            color-mix(in srgb, #5f9cff 70%, #111 30%),
            color-mix(in srgb, #c471ed 70%, #111 30%)
    );

    background-size: 200% 200%;
    animation: mythicShift 6s ease infinite;

    border: 1px solid rgba(255,255,255,0.18);
}

@keyframes mythicShift{
    0%{ background-position: 0% 50%; }
    50%{ background-position: 100% 50%; }
    100%{ background-position: 0% 50%; }
}

/* Common optional: don’t look like a loading bar */
.rarity-pill.common{
    background: rgba(255,255,255,0.10);
    border: 1px solid rgba(255,255,255,0.12);
    color: rgba(255,255,255,0.92);
}

/* ===== Modal (required) ===== */
.modal{
    position: fixed;
    inset: 0;
    display: none;
    z-index: 50;
}
.modal.open{ display:block; }

.modal-backdrop{
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,.55);
    backdrop-filter: blur(4px);
}

/* Modal panel */
.modal-panel{
    position: relative;
    width: min(1040px, 94vw);
    margin: 8vh auto;
    border-radius: var(--radius);
    border: 1px solid rgba(255,255,255,.12);
    background: rgba(18, 22, 30, .92);
    box-shadow: 0 24px 80px rgba(0,0,0,.55);
    overflow: hidden;
}

.modal-panel::before{
    content:"";
    position:absolute;
    inset:0;
    pointer-events:none;
    background: radial-gradient(1200px 700px at 20% 10%, rgba(255,255,255,.05), transparent 60%);
}

.modal-head{
    display:flex;
    align-items:flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 16px 10px;
    border-bottom: 1px solid var(--border);
}

.modal-head-left{
    display:flex;
    align-items:center;
    gap: 12px;
}

.hat-thumb{
    width: 36px;
    height: 36px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: rgba(255,255,255,.04);
    overflow: hidden;
    flex: 0 0 auto;
}
.hat-thumb img{
    width: 100%;
    height: 100%;
    display:block;
    object-fit: cover;
    image-rendering: pixelated;
}

.modal-body{ padding: 14px 16px 16px; }

.modal-layout{
    display: grid;
    grid-template-columns: 1.35fr 0.65fr;
    gap: 14px;
    align-items: start;
}

.modal-left{ min-width: 0; display:flex; }
.modal-right{
    min-width: 0;
    display:flex;
    flex-direction: column;
    gap: 12px;
}

.viewer{
    height: clamp(320px, 56vh, 560px);
    border-radius: var(--radius2);
    border: 1px solid rgba(255,255,255,.10);
    background: rgba(255,255,255,.03);
    overflow: hidden;
    width: 100%;
    flex: 1;
}

.hat-panels{
    display:flex;
    flex-direction: column;
    gap: 12px;
}

.hat-panel{
    border: 1px solid rgba(255,255,255,.10);
    background: rgba(255,255,255,.04);
    border-radius: 18px;
    padding: 14px;
    box-shadow: 0 10px 24px rgba(0,0,0,.18);
}

.hat-panel-title{
    font-weight: 850;
    margin-bottom: 12px;
    letter-spacing: -0.01em;
}

.pill-grid{
    display:grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

.pill-card,
.credit-row{
    border: 1px solid rgba(255,255,255,.10);
    background: rgba(255,255,255,.03);
    border-radius: 16px;
    padding: 12px;
}

.pill-label{
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 6px;
}
.pill-value{ font-weight: 750; }

.credit-grid{ display:grid; gap: 10px; }
.credit-role{ color: var(--muted); font-size: 12px; }
.credit-who{ font-weight: 750; text-align: right; }

.modal-actions{
    display:flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

@media (max-width: 900px){
    .modal-panel{ margin: 4vh auto; }
    .modal-layout{ grid-template-columns: 1fr; }
    .viewer{ height: clamp(260px, 42vh, 420px); }
    .modal-actions{ justify-content: stretch; }
    .modal-actions .btn{ flex: 1; }
    .brand-subtitle { display: none; }
}