/* tierlist.bbdev.hu: same token set as bbdev.hu's dark look.
   Layout: sticky nav, title + toolbar, the S…F table, the unranked pool, a trash pill that slides in while dragging. */
:root {
    --ink: #0e0d12;
    --ink-2: #17151d;
    --ink-3: #201d28;
    --line: #2d2936;
    --fg: #f1ecf5;
    --muted: #a19aae;
    --amber: #ffb547;
    --coral: #ff7a5c;
    --leaf: #8bd99a;
    --tier-ink: #17151d;

    --display: "Bricolage Grotesque", "Arial Black", system-ui, sans-serif;
    --body: "Instrument Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
    --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

    --step--1: clamp(.8rem, .78rem + .1vw, .875rem);
    --step-0: clamp(1rem, .96rem + .2vw, 1.125rem);
    --step-2: clamp(1.75rem, 1.4rem + 1.6vw, 2.75rem);

    --aurora: 22%;
    --shadow: 0 30px 60px -30px #000;
    --btn-glow: 0 8px 30px -10px var(--amber);
    --btn-glow-hover: 0 12px 40px -8px var(--amber);

    --size: 84px; /* one tiered picture */
    --radius: 20px;
    --ease: cubic-bezier(.2, .8, .2, 1);
    color-scheme: dark;
}
@media (max-width: 600px) { :root { --size: 64px; } }

*, *::before, *::after { box-sizing: border-box; }
body {
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    background: var(--ink);
    color: var(--fg);
    font: 400 var(--step-0)/1.6 var(--body);
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}
body::before { /* slow amber aurora behind the header area */
    content: "";
    position: fixed;
    inset: -40vh -10vw auto 40vw;
    height: 90vh;
    z-index: -1;
    pointer-events: none;
    background: radial-gradient(closest-side, color-mix(in oklab, var(--amber) var(--aurora), transparent), transparent 70%);
    filter: blur(30px);
}
::selection { background: var(--amber); color: var(--ink); }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--amber); outline-offset: 3px; border-radius: 6px; }
.mono { font-family: var(--mono); }
.dim { color: var(--muted); }
.small { font-size: var(--step--1); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.wrap {
    width: 100%;
    max-width: 1160px;
    margin-inline: auto;
    padding-left: max(16px, env(safe-area-inset-left, 0px));
    padding-right: max(16px, env(safe-area-inset-right, 0px));
}
@media (min-width: 720px) {
    .wrap { padding-left: max(32px, env(safe-area-inset-left, 0px)); padding-right: max(32px, env(safe-area-inset-right, 0px)); }
}
h1, h2, h3 { font-family: var(--display); line-height: 1.05; letter-spacing: -.02em; margin: 0; }
p { margin: 0; }

/* nav */
.nav {
    position: sticky;
    top: 0;
    z-index: 50;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    background: color-mix(in oklab, var(--ink) 70%, transparent);
    border-bottom: 1px solid color-mix(in oklab, var(--line) 60%, transparent);
}
.nav-inner { display: flex; align-items: center; justify-content: space-between; height: 64px; }
.logo { display: inline-flex; align-items: center; gap: 2px; font: 800 1.35rem/1 var(--display); text-decoration: none; letter-spacing: -.03em; }
.logo-mark { width: 22px; height: auto; flex: none; }
.logo-text { margin-top: 5px; } /* each letter takes a tier colour, S to F (set inline in index.html) */
.toggles { display: flex; gap: .4rem; align-items: center; }
.toggle {
    height: 34px; min-width: 34px; padding: 0 .6rem;
    display: inline-grid; place-items: center;
    border-radius: 999px; border: 1px solid var(--line);
    background: transparent; color: var(--fg);
    font-size: .72rem; font-weight: 600; letter-spacing: .04em; cursor: pointer;
    transition: border-color .2s, color .2s, transform .3s var(--ease);
}
.toggle:hover { border-color: var(--amber); color: var(--amber); }
.toggle:active { transform: scale(.92); }

/* title + toolbar */
.main { flex: 1; padding-block: clamp(1.5rem, 4vw, 3rem) 3rem; }
.head { display: grid; gap: .5rem; margin-bottom: 1.4rem; }
.title-input {
    width: 100%;
    padding: 0;
    border: 0;
    border-bottom: 2px dashed transparent;
    background: transparent;
    color: var(--fg);
    font: 800 var(--step-2)/1.15 var(--display);
    letter-spacing: -.02em;
    transition: border-color .2s;
}
.title-input::placeholder { color: color-mix(in oklab, var(--muted) 70%, transparent); }
.title-input:hover, .title-input:focus { border-bottom-color: var(--line); outline: none; }
.privacy { display: flex; align-items: center; gap: .55rem; font-size: .75rem; color: var(--muted); }
.dot { width: 7px; height: 7px; flex: none; border-radius: 50%; background: var(--leaf); box-shadow: 0 0 0 4px color-mix(in oklab, var(--leaf) 20%, transparent); }

.toolbar { display: flex; flex-wrap: wrap; gap: .6rem; margin-bottom: 1.4rem; }
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
    font: 600 var(--step--1)/1 var(--body);
    padding: .8rem 1.2rem; border-radius: 999px;
    text-decoration: none; cursor: pointer; border: 0;
    transition: transform .3s var(--ease), background .2s, box-shadow .3s, color .2s;
}
.btn:active { transform: scale(.96); }
.btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn-primary { background: var(--amber); color: var(--ink); box-shadow: var(--btn-glow); }
.btn-primary:hover { box-shadow: var(--btn-glow-hover); }
.btn-ghost { color: var(--fg); background: transparent; box-shadow: inset 0 0 0 1px var(--line); }
.btn-ghost:hover { box-shadow: inset 0 0 0 1px var(--muted); }
.btn-danger:hover { color: var(--coral); box-shadow: inset 0 0 0 1px var(--coral); }
label.btn:has(+ input:focus-visible) { outline: 2px solid var(--amber); outline-offset: 3px; } /* labels standing in for hidden file inputs */

/* the board: tier label column + drop column */
.board {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    table-layout: fixed;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--ink-2);
    box-shadow: var(--shadow);
}
.board .col-tier { width: clamp(64px, 9vw, 104px); }
.board th {
    background: var(--tier);
    color: var(--tier-ink);
    font: 800 clamp(1.6rem, 1.2rem + 1.6vw, 2.4rem)/1 var(--display);
    text-align: center;
    vertical-align: middle;
}
.board td { padding: 0; vertical-align: top; }
.board tr + tr > * { border-top: 1px solid var(--line); }
.board tr + tr > th { border-top-color: color-mix(in oklab, var(--tier-ink) 25%, var(--tier)); }

.zone {
    display: flex;
    flex-wrap: wrap;
    align-content: flex-start;
    gap: 6px;
    min-height: calc(var(--size) + 16px);
    padding: 8px;
    transition: background-color .15s;
}
.zone.is-over { background: color-mix(in oklab, var(--amber) 10%, transparent); }

/* unranked pool */
.pool-wrap { margin-top: 2rem; display: grid; gap: .7rem; }
.pool-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .6rem; }
.pool-title { display: flex; align-items: center; gap: .6rem; font-size: var(--step--1); font-weight: 600; color: var(--amber); letter-spacing: .04em; }
.count { padding: .1rem .5rem; border-radius: 999px; background: var(--ink-3); color: var(--muted); font-size: .72rem; }
.pool {
    min-height: calc(var(--size) * 1.6 + 16px);
    border: 1.5px dashed var(--line);
    border-radius: var(--radius);
    background: color-mix(in oklab, var(--ink-2) 60%, transparent);
}
.pool:empty { align-content: center; justify-content: center; }
.pool:empty::before { content: attr(data-hint); max-width: 46ch; padding: 1rem; text-align: center; color: var(--muted); font-size: var(--step--1); }
.kbd-hint { font-size: .72rem; color: var(--muted); }
@media (hover: none) { .kbd-hint { display: none; } }

/* files dragged in from the computer */
body.file-over .zone { outline: 1.5px dashed color-mix(in oklab, var(--amber) 50%, transparent); outline-offset: -4px; }
body.file-over .zone.is-over { outline-color: var(--amber); }

/* one picture */
.item {
    position: relative;
    width: var(--size);
    height: var(--size);
    flex: none;
    border-radius: 10px;
    overflow: hidden;
    background: var(--ink-3);
    cursor: grab;
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    transition: transform .2s var(--ease), opacity .15s;
}
.item img { display: block; width: 100%; height: 100%; object-fit: cover; pointer-events: none; -webkit-user-drag: none; }
.item:focus-visible { outline-offset: 2px; border-radius: 10px; }
.item.is-dragging { opacity: .3; }
.item.is-doomed { opacity: .12; }
.item-del {
    position: absolute; top: 4px; right: 4px;
    width: 22px; height: 22px; padding: 0;
    display: grid; place-items: center;
    border: 0; border-radius: 50%;
    background: rgba(14, 13, 18, .75); color: #fff;
    font: 600 15px/1 var(--body);
    cursor: pointer;
    opacity: 0;
    transition: opacity .15s, background .15s;
}
.item:hover .item-del, .item:focus-visible .item-del { opacity: 1; }
.item-del:hover { background: var(--coral); }
@media (hover: none) { .item-del { display: none; } }
body.dragging .item-del { display: none; }

.ghost {
    position: fixed;
    top: 0; left: 0;
    z-index: 200;
    margin: 0;
    pointer-events: none;
    cursor: grabbing;
    box-shadow: 0 18px 40px -12px rgba(0, 0, 0, .6);
    outline: 2px solid var(--amber);
    will-change: transform;
}
body.dragging, body.dragging * { cursor: grabbing !important; }
body.dragging { -webkit-user-select: none; user-select: none; }

/* trash pill */
.trash {
    position: fixed;
    left: 50%;
    bottom: max(20px, env(safe-area-inset-bottom, 0px));
    z-index: 150;
    display: flex; align-items: center; gap: .6rem;
    padding: .9rem 1.4rem;
    border-radius: 999px;
    border: 1.5px dashed var(--coral);
    background: color-mix(in oklab, var(--ink-2) 92%, transparent);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: var(--coral);
    font: 600 var(--step--1)/1 var(--body);
    box-shadow: var(--shadow);
    opacity: 0;
    visibility: hidden;
    transform: translate(-50%, 180%);
    transition: transform .3s var(--ease), opacity .2s, visibility 0s .3s, background .15s, color .15s;
}
.trash svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
body.dragging .trash { opacity: 1; visibility: visible; transform: translate(-50%, 0); transition-delay: 0s; }
.trash.is-over { background: var(--coral); color: var(--ink); border-style: solid; transform: translate(-50%, 0) scale(1.08); }

/* import / export dialog */
.io {
    width: min(560px, calc(100vw - 32px));
    padding: clamp(1.4rem, 4vw, 2rem);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--ink-2);
    color: var(--fg);
    box-shadow: var(--shadow);
}
.io[open] { display: grid; gap: 1.4rem; }
.io::backdrop { background: rgba(8, 7, 12, .6); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
.io h2 { font-size: 1.6rem; font-weight: 800; padding-right: 2.5rem; }
.io h3 { font-size: .75rem; font-weight: 600; color: var(--amber); letter-spacing: .06em; text-transform: uppercase; margin-bottom: .7rem; }
.io-close-form { position: absolute; top: 1rem; right: 1rem; margin: 0; }
.io-close { font-size: 1.1rem; }
.io-block { display: grid; gap: .7rem; }
.io-block h3 { margin-bottom: 0; }
.io-row { display: flex; flex-wrap: wrap; gap: .6rem; }
.io textarea {
    width: 100%;
    resize: vertical;
    min-height: 6rem;
    padding: .8rem 1rem;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--ink);
    color: var(--fg);
    font: 400 .78rem/1.5 var(--mono);
    word-break: break-all;
}
.io textarea:focus { outline: none; border-color: var(--amber); }
.io-status { min-height: 1.4em; color: var(--muted); }
.io-status[data-kind="ok"] { color: var(--leaf); }
.io-status[data-kind="error"] { color: var(--coral); }

/* toast */
.toast {
    position: fixed;
    left: 50%;
    bottom: max(20px, env(safe-area-inset-bottom, 0px));
    z-index: 300;
    max-width: min(520px, calc(100vw - 32px));
    padding: .8rem 1.2rem;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: var(--ink-3);
    color: var(--fg);
    font-size: var(--step--1);
    box-shadow: var(--shadow);
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, 12px);
    transition: opacity .25s, transform .3s var(--ease);
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }
.toast[data-kind="error"] { border-color: var(--coral); }

.footer {
    padding-block: 1.6rem 2.2rem;
    border-top: 1px solid var(--line);
    font-size: .75rem;
    color: var(--muted);
    text-align: center;
}
.footer a { text-decoration: none; color: var(--amber); }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
