/* ===========================================================================
   CanAtlas — energy drinks of the world
   Two themes: clean-grey light (default) + electric dark. Toggle in the nav.
   The can artwork and the caffeine bar stay colourful in both themes;
   only the UI chrome goes monochrome in light.
   =========================================================================== */

:root {
    /* ── Light (clean grey) — default ─────────────────────────────────── */
    --bg: #f4f4f5;
    --bg-2: #eaeaec;
    --panel: #ffffff;
    --panel-2: #f1f1f4;
    --line: #e3e3e7;
    --line-soft: #ededf0;
    --ink: #18181b;
    --ink-dim: #52525b;
    --ink-faint: #9a9aa4;
    --accent: #18181b;          /* interactive chrome — monochrome in light */
    --accent-2: #00b4d8;        /* data-viz cyan */
    --accent-3: #ff2d78;        /* data-viz magenta */
    --caff-lime: #7cc400;       /* caffeine-bar middle */

    --body-bg:
        radial-gradient(900px 500px at 12% -8%, rgba(0,0,0,.035), transparent 60%),
        radial-gradient(800px 520px at 92% 2%, rgba(0,0,0,.03), transparent 60%),
        var(--bg);
    --nav-bg: rgba(244,244,245,.82);
    --h1-grad: linear-gradient(180deg, #18181b, #55555e);
    --chip-active-bg: #18181b;
    --chip-active-ink: #ffffff;
    --brand-accent: #18181b;
    --can-glow: 34%;
    --focus-border: #18181b;
    --focus-ring: rgba(0,0,0,.12);
    --shadow: 0 14px 34px -20px rgba(0,0,0,.28);

    --radius: 18px;
    --wrap: 1180px;
}

:root[data-theme="dark"] {
    --bg: #0a0a0f;
    --bg-2: #101017;
    --panel: #14141d;
    --panel-2: #1a1a25;
    --line: #262633;
    --line-soft: #1f1f2b;
    --ink: #f4f4f8;
    --ink-dim: #a9a9bd;
    --ink-faint: #6f6f86;
    --accent: #c6ff3a;          /* electric lime */
    --accent-2: #00e5ff;
    --accent-3: #ff2d78;
    --caff-lime: #c6ff3a;

    --body-bg:
        radial-gradient(900px 500px at 12% -8%, rgba(198,255,58,.10), transparent 60%),
        radial-gradient(800px 520px at 92% 2%, rgba(0,229,255,.10), transparent 60%),
        radial-gradient(700px 600px at 60% 110%, rgba(255,45,120,.08), transparent 60%),
        var(--bg);
    --nav-bg: rgba(10,10,15,.72);
    --h1-grad: linear-gradient(180deg, #ffffff, #c4c4d6);
    --chip-active-bg: var(--accent);
    --chip-active-ink: #10130a;
    --brand-accent: var(--accent);
    --can-glow: 55%;
    --focus-border: var(--accent-2);
    --focus-ring: rgba(0,229,255,.15);
    --shadow: 0 18px 40px -20px rgba(0,0,0,.8);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

body {
    margin: 0;
    background: var(--body-bg);
    color: var(--ink);
    font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    transition: background-color .2s ease, color .2s ease;
}

.wrap { max-width: var(--wrap); margin: 0 auto; padding-inline: 22px; }

h1, h2, h3, .brand { font-family: 'Space Grotesk', 'Inter', sans-serif; letter-spacing: -.01em; }

a { color: var(--accent-2); text-decoration: none; }
:root[data-theme="dark"] a { color: var(--accent-2); }
:root:not([data-theme="dark"]) a { color: #0369a1; }
a:hover { text-decoration: underline; }

/* ── Nav ──────────────────────────────────────────────────────────────── */
.nav {
    position: sticky; top: 0; z-index: 50;
    background: var(--nav-bg);
    backdrop-filter: saturate(140%) blur(12px);
    border-bottom: 1px solid var(--line-soft);
}
.nav-in { display: flex; align-items: center; justify-content: space-between; height: 62px; gap: 16px; }
.brand { font-size: 1.35rem; font-weight: 700; color: var(--ink); }
.brand span { color: var(--brand-accent); }
.brand:hover { text-decoration: none; }
.links { display: flex; gap: 22px; align-items: center; margin-left: auto; }
.links a { color: var(--ink-dim); font-weight: 500; font-size: .95rem; }
.links a:hover { color: var(--ink); text-decoration: none; }

.theme-toggle {
    display: inline-flex; align-items: center; justify-content: center;
    width: 38px; height: 38px; border-radius: 10px; cursor: pointer;
    background: var(--panel); border: 1px solid var(--line); color: var(--ink);
    font-size: 1.05rem; line-height: 1; padding: 0; transition: .15s;
}
.theme-toggle:hover { border-color: var(--ink-faint); }
.theme-toggle .i-dark { display: none; }
.theme-toggle .i-light { display: inline; }
:root[data-theme="dark"] .theme-toggle .i-dark { display: inline; }
:root[data-theme="dark"] .theme-toggle .i-light { display: none; }

/* ── Hero ─────────────────────────────────────────────────────────────── */
.hero { padding: 74px 0 40px; }
.eyebrow {
    text-transform: uppercase; letter-spacing: .22em; font-size: .72rem;
    font-weight: 700; color: var(--ink-faint); margin: 0 0 14px;
}
.hero h1 {
    font-size: clamp(2.6rem, 7vw, 5rem); line-height: .98; margin: 0 0 20px; font-weight: 700;
    background: var(--h1-grad);
    -webkit-background-clip: text; background-clip: text; color: transparent;
}
.lede { max-width: 640px; color: var(--ink-dim); font-size: 1.08rem; margin: 0 0 34px; }

.stats { display: flex; flex-wrap: wrap; gap: 14px; }
.stat {
    background: linear-gradient(180deg, var(--panel), var(--bg-2));
    border: 1px solid var(--line); border-radius: 14px;
    padding: 14px 20px; min-width: 116px;
}
.stat .n { display: block; font-family: 'Space Grotesk'; font-size: 1.9rem; font-weight: 700; line-height: 1; }
.stat .n small { font-size: .9rem; color: var(--ink-faint); font-weight: 500; }
.stat .l { display: block; font-size: .78rem; text-transform: uppercase; letter-spacing: .1em; color: var(--ink-faint); margin-top: 7px; }

/* ── Controls ─────────────────────────────────────────────────────────── */
.controls-wrap { padding-top: 26px; }
.controls {
    display: flex; flex-wrap: wrap; gap: 16px; align-items: center;
    background: var(--panel); border: 1px solid var(--line);
    border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow);
}
.search { flex: 1 1 260px; }
.search input {
    width: 100%; padding: 12px 16px; border-radius: 12px;
    background: var(--bg); border: 1px solid var(--line); color: var(--ink);
    font-size: .98rem; font-family: inherit;
}
.search input::placeholder { color: var(--ink-faint); }
.search input:focus { outline: none; border-color: var(--focus-border); box-shadow: 0 0 0 3px var(--focus-ring); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
    padding: 8px 14px; border-radius: 999px; cursor: pointer;
    background: var(--bg); color: var(--ink-dim);
    border: 1px solid var(--line); font-size: .86rem; font-weight: 500;
    font-family: inherit; transition: .15s;
}
.chip:hover { color: var(--ink); border-color: var(--ink-faint); }
.chip.is-active { background: var(--chip-active-bg); color: var(--chip-active-ink); border-color: var(--chip-active-bg); font-weight: 600; }

.right-controls { display: flex; gap: 18px; align-items: center; margin-left: auto; }
.toggle { display: flex; align-items: center; gap: 8px; font-size: .88rem; color: var(--ink-dim); cursor: pointer; user-select: none; }
.toggle input { accent-color: var(--accent); width: 16px; height: 16px; }
.sortlbl { font-size: .82rem; color: var(--ink-faint); display: flex; align-items: center; gap: 8px; }
.sortlbl select {
    background: var(--bg); color: var(--ink); border: 1px solid var(--line);
    border-radius: 10px; padding: 9px 12px; font-family: inherit; font-size: .9rem; cursor: pointer;
}
.sortlbl select:focus { outline: none; border-color: var(--focus-border); }

.resultline { color: var(--ink-faint); font-size: .84rem; margin: 14px 2px 4px; }
.resultline #count { color: var(--ink); font-weight: 600; }

/* ── Grid ─────────────────────────────────────────────────────────────── */
.grid {
    display: grid; gap: 20px; padding: 12px 0 60px;
    grid-template-columns: repeat(auto-fill, minmax(268px, 1fr));
}
.card {
    background: linear-gradient(180deg, var(--panel), var(--bg-2));
    border: 1px solid var(--line); border-radius: var(--radius);
    overflow: hidden; display: flex; flex-direction: column;
    transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.card:hover { transform: translateY(-4px); border-color: var(--ink-faint); box-shadow: var(--shadow); }

/* ── The CSS-rendered can ─────────────────────────────────────────────── */
.can-stage {
    position: relative; height: 210px; display: flex; align-items: center; justify-content: center;
    background:
        radial-gradient(120px 120px at 50% 46%, color-mix(in srgb, var(--c1, #333) var(--can-glow), transparent), transparent 70%),
        var(--panel-2);
    border-bottom: 1px solid var(--line-soft);
}
.can { width: 96px; height: 172px; position: relative; filter: drop-shadow(0 14px 18px rgba(0,0,0,.4)); }
.can-lid {
    position: absolute; top: 0; left: 6px; right: 6px; height: 12px;
    background: linear-gradient(90deg, #8f8f9c, #ececf3 40%, #ffffff 50%, #d6d6de 60%, #8a8a97);
    border-radius: 50% / 100%; z-index: 3;
}
.can-body {
    position: absolute; top: 6px; bottom: 0; left: 0; right: 0;
    border-radius: 12px / 26px; overflow: hidden;
    background: linear-gradient(180deg, var(--c1, #444), var(--c2, #222));
}
/* cylinder shading — brand-independent light wrap */
.can-body::before {
    content: ''; position: absolute; inset: 0;
    background: linear-gradient(90deg,
        rgba(0,0,0,.42) 0%, rgba(0,0,0,.12) 18%,
        rgba(255,255,255,.24) 42%, rgba(255,255,255,.06) 56%,
        rgba(0,0,0,.16) 82%, rgba(0,0,0,.45) 100%);
    mix-blend-mode: soft-light;
}
.can-shine {
    position: absolute; top: 8%; bottom: 8%; left: 26%; width: 8px;
    background: linear-gradient(180deg, transparent, rgba(255,255,255,.5), transparent);
    filter: blur(1px); border-radius: 8px; z-index: 2;
}
.can-label {
    position: absolute; inset: 0; z-index: 2; display: flex; flex-direction: column;
    align-items: center; justify-content: center; text-align: center; padding: 6px;
}
.can-brand {
    color: var(--tx, #fff); font-family: 'Space Grotesk'; font-weight: 700;
    font-size: .82rem; line-height: 1.02; letter-spacing: -.01em;
    text-shadow: 0 1px 2px rgba(0,0,0,.35); word-break: break-word;
}
.can-flavor { color: var(--tx, #fff); opacity: .78; font-size: .56rem; margin-top: 4px; letter-spacing: .04em; text-transform: uppercase; }

.strength {
    position: absolute; top: 12px; right: 12px; z-index: 4;
    font-size: .64rem; text-transform: uppercase; letter-spacing: .1em; font-weight: 700;
    padding: 4px 9px; border-radius: 999px; border: 1px solid transparent;
}
/* light-theme strength colours (readable on white) */
.strength-mild    { background: rgba(2,132,199,.12);  color: #0369a1; border-color: rgba(2,132,199,.3); }
.strength-medium  { background: rgba(101,163,13,.16); color: #4d7c0f; border-color: rgba(101,163,13,.34); }
.strength-strong  { background: rgba(217,119,6,.14);  color: #b45309; border-color: rgba(217,119,6,.34); }
.strength-extreme { background: rgba(219,39,119,.12); color: #be185d; border-color: rgba(219,39,119,.34); }
/* dark-theme strength colours (readable on near-black) */
:root[data-theme="dark"] .strength-mild    { background: rgba(0,229,255,.12);  color: #7fe9ff; border-color: rgba(0,229,255,.35); }
:root[data-theme="dark"] .strength-medium  { background: rgba(198,255,58,.14); color: #d6ff6b; border-color: rgba(198,255,58,.4); }
:root[data-theme="dark"] .strength-strong  { background: rgba(255,153,0,.15);  color: #ffbe5c; border-color: rgba(255,153,0,.4); }
:root[data-theme="dark"] .strength-extreme { background: rgba(255,45,120,.16); color: #ff85ac; border-color: rgba(255,45,120,.45); }

/* ── Card body ────────────────────────────────────────────────────────── */
.card-body { padding: 16px 18px 18px; display: flex; flex-direction: column; flex: 1; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.card-head h3 { margin: 0; font-size: 1.16rem; font-weight: 700; }
.flag { font-size: 1.25rem; line-height: 1; }
.origin { margin: 3px 0 10px; color: var(--ink-faint); font-size: .8rem; }
.blurb { margin: 0 0 16px; color: var(--ink-dim); font-size: .9rem; flex: 1; }

.specs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 12px; }
.spec {
    background: var(--bg); border: 1px solid var(--line-soft); border-radius: 10px;
    padding: 9px 4px; text-align: center;
}
.spec .sv { display: block; font-family: 'Space Grotesk'; font-weight: 700; font-size: 1rem; }
.spec .sv small { font-size: .62rem; color: var(--ink-faint); font-weight: 500; }
.spec .sl { display: block; font-size: .62rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-faint); margin-top: 2px; }

.caffbar { height: 6px; border-radius: 999px; background: var(--bg); overflow: hidden; border: 1px solid var(--line-soft); }
.caffbar-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--accent-2), var(--caff-lime) 55%, var(--accent-3)); }

.empty { text-align: center; color: var(--ink-faint); padding: 40px 0 80px; }

/* ── Prose (About / Error) ────────────────────────────────────────────── */
.prose { max-width: 760px; padding-top: 46px; padding-bottom: 70px; }
.prose h1 { font-size: clamp(2rem, 5vw, 2.8rem); margin: 0 0 18px; }
.prose h2 { font-size: 1.3rem; margin: 34px 0 10px; }
.prose p, .prose li { color: var(--ink-dim); }
.prose ul { padding-left: 20px; }
.prose li { margin: 6px 0; }
.prose b { color: var(--ink); }
.back { margin-top: 34px; }

/* ── Footer ───────────────────────────────────────────────────────────── */
.foot { border-top: 1px solid var(--line-soft); padding: 30px 0 46px; margin-top: 20px; }
.foot p { margin: 0 0 8px; color: var(--ink-dim); font-size: .9rem; }
.foot .fine { color: var(--ink-faint); font-size: .78rem; max-width: 820px; }

/* ── Responsive ───────────────────────────────────────────────────────── */
@media (max-width: 720px) {
    .hero { padding: 48px 0 26px; }
    .right-controls { margin-left: 0; width: 100%; justify-content: space-between; }
    .search { flex-basis: 100%; }
}

@media (prefers-reduced-motion: reduce) {
    .card, body { transition: none; }
    html { scroll-behavior: auto; }
}
