/* AoM Retold Tracker, Copyright (C) 2026 XxSeRyIxX. SPDX-License-Identifier: AGPL-3.0-or-later. Additional terms: see NOTICE. */
:root {
  --bg: #0c1120;
  --bar: #0f1628;
  --card: #151f36;
  --card-2: #1a2642;
  --text: #ece7da;
  --muted: #9aa5bd;
  --line: #26324f;
  --gold: #e2b85c;
  --gold-2: #f6dc94;
  --gold-soft: rgba(226, 184, 92, .14);
  --ok: #5fd08a;
  --ok-soft: rgba(95, 208, 138, .14);
  --warn: #f1a93b;
  --warn-soft: rgba(241, 169, 59, .16);
  --danger: #f06a80;
  --track: #24304c;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .28);
  /* Every card has the same size, whatever it holds; the details dialog shows the rest. */
  --card-h: 120px;
  --art: 72px;
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4efe4;
    --bar: #fbf7ef;
    --card: #fffdf8;
    --card-2: #f8f2e6;
    --text: #231d12;
    --muted: #6e6552;
    --line: #e1d6bf;
    --gold: #a8741a;
    --gold-2: #7d560f;
    --gold-soft: rgba(168, 116, 26, .12);
    --ok: #18804a;
    --ok-soft: rgba(24, 128, 74, .1);
    --warn: #9a5a00;
    --warn-soft: rgba(154, 90, 0, .1);
    --danger: #c4314b;
    --track: #e8dfcc;
    --shadow: 0 6px 18px rgba(80, 60, 20, .1);
    color-scheme: light;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
/* app.js marks the edition, and whether public profiles are read by hand; until then nothing meant for one of them shows. */
.booting [data-only], .booting [data-profile], html:not(.desktop) [data-only="desktop"], html.desktop [data-only="web"],
html.profile-by-hand [data-profile="auto"], html:not(.profile-by-hand) [data-profile="by-hand"] { display: none !important; }
body.booting main { visibility: hidden; }

/* Shown until the first render, so the window is never blank while the desktop reads the game's files. */
.loading {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-content: center; justify-items: center; gap: 16px;
  background: var(--bg); color: var(--muted);
}
.loading img { border-radius: 14px; }
.loading p { margin: 0; min-height: 1.45em; }
body:not(.booting) .loading { display: none; }
.spinner { width: 30px; height: 30px; border-radius: 50%; border: 3px solid var(--track); border-top-color: var(--gold); animation: spin .9s linear infinite; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; font-weight: 650; }
h2 { font-size: 15px; }
a { color: var(--gold); }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Top bar: the app, its two tabs, and the player's state and settings. */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 22px;
  height: 56px; padding: 0 22px;
  background: color-mix(in srgb, var(--bar) 92%, transparent); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 650; font-size: 15px; white-space: nowrap; }
.brand img { border-radius: 7px; }
.tabs { display: flex; align-self: stretch; gap: 4px; }
.tabs a {
  display: flex; align-items: center; gap: 7px; padding: 0 12px;
  color: var(--muted); text-decoration: none; font-weight: 650;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs a:hover { color: var(--text); }
.tabs a[aria-selected="true"] { color: var(--text); border-bottom-color: var(--gold); }
.tab-count { padding: 1px 7px; border-radius: 999px; background: var(--track); color: var(--muted); font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.bar-end { display: flex; align-items: center; gap: 8px; margin-left: auto; }

.player {
  display: inline-flex; align-items: center; gap: 8px; max-width: 260px; height: 34px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--card); cursor: pointer; font-weight: 600;
}
.player span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player:hover { border-color: var(--gold); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.player.ok .dot { background: var(--ok); }
.player.todo { border-color: color-mix(in srgb, var(--gold) 60%, var(--line)); color: var(--gold); }
.player.todo .dot { background: var(--gold); }

.icon-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--card); cursor: pointer; color: var(--muted);
}
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn:hover:not(:disabled) { color: var(--text); border-color: var(--gold); }
.icon-btn:disabled { opacity: .55; cursor: default; }
.icon-btn.busy svg, .btn.busy svg { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Buttons and inputs */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 36px; padding: 0 14px; border-radius: 10px; text-decoration: none; white-space: nowrap;
  border: 1px solid var(--line); background: var(--card); color: var(--text); cursor: pointer; font-weight: 600;
}
.btn svg { width: 18px; height: 18px; }
.btn.small { min-height: 30px; padding: 0 10px; font-size: 13px; }
.btn:hover:not(:disabled) { border-color: var(--gold); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.ghost { background: transparent; }
.btn.primary { background: linear-gradient(180deg, var(--gold-2), var(--gold)); border-color: transparent; color: #1d1608; }
.btn.primary:hover:not(:disabled) { filter: brightness(1.06); }

.segmented { display: inline-flex; padding: 3px; border-radius: 10px; background: var(--card); border: 1px solid var(--line); }
.segmented button { border: 0; background: none; padding: 4px 10px; border-radius: 7px; cursor: pointer; color: var(--muted); font-weight: 600; }
.segmented button[aria-pressed="true"] { background: var(--gold-soft); color: var(--gold); }
.segmented button:hover { color: var(--text); }

select, .search { min-height: 36px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); }
select { padding: 0 10px; cursor: pointer; }
.search { display: inline-flex; align-items: center; gap: 8px; padding: 0 10px; flex: 1 1 240px; max-width: 400px; color: var(--muted); }
.search svg { width: 18px; height: 18px; }
.search input { flex: 1; min-width: 0; border: 0; background: none; outline: none; color: var(--text); }
.search:focus-within { border-color: var(--gold); }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; color: var(--muted); }
.check input { accent-color: var(--gold); width: 16px; height: 16px; }

main { max-width: 1500px; margin: 0 auto; padding: 18px 22px 40px; }
.toolbar { display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.count { margin: 0 0 10px; font-size: 12.5px; }
.empty { text-align: center; padding: 40px 0; }

.notice {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 14px; margin-bottom: 14px; border-radius: 10px;
  background: var(--warn-soft); color: var(--warn); border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent);
}
.notice > span { flex: 1 1 320px; }

/* Cards far off screen skip their layout and painting until they come near. */
.cell { position: relative; min-width: 0; content-visibility: auto; contain-intrinsic-size: auto var(--card-h); }
/* Marks by hand: the round button on a card's picture, for anything the data doesn't show as done. */
.mark {
  position: absolute; left: calc(var(--art) - 6px); top: calc((var(--card-h) + var(--art)) / 2 - 21px);
  width: 26px; height: 26px; padding: 0; display: grid; place-items: center; cursor: pointer;
  border-radius: 50%; border: 2px solid var(--muted); background: var(--card); color: color-mix(in srgb, var(--muted) 45%, transparent);
  transition: border-color .15s, background .15s, color .15s;
}
.mark::before { content: ""; position: absolute; inset: -9px; border-radius: 50%; }
.mark svg { width: 14px; height: 14px; stroke-width: 3; }
.mark:hover { border-color: var(--gold); color: var(--gold); }
.mark[aria-pressed="true"] { background: var(--gold); border-color: var(--gold); color: #1d1608; }

.next { margin-bottom: 18px; }
.next h2 { margin-bottom: 10px; color: var(--gold); text-transform: uppercase; font-size: 12px; letter-spacing: .12em; }
.next .item { background: linear-gradient(160deg, var(--card-2), var(--card)); border-color: color-mix(in srgb, var(--gold) 35%, var(--line)); }

/* Cards: one size for all. Long names and texts are cut; the details dialog shows everything. */
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); grid-auto-rows: var(--card-h); }
.item {
  position: relative;
  display: grid; grid-template-columns: var(--art) 1fr; gap: 14px; align-items: center;
  height: var(--card-h); padding: 12px 14px; overflow: hidden; text-align: left;
  border-radius: var(--radius); background: var(--card); border: 1px solid var(--line);
  transition: border-color .15s, background .15s;
}
.item:hover { border-color: color-mix(in srgb, var(--gold) 50%, var(--line)); }
.item.done { background: linear-gradient(160deg, color-mix(in srgb, var(--gold) 7%, var(--card)), var(--card)); }
.art { width: var(--art); height: var(--art); display: grid; place-items: center; }
.art img { width: 100%; height: 100%; object-fit: contain; border-radius: 10px; }
.art .fallback { display: grid; place-items: center; width: 100%; height: 100%; border-radius: 50%; background: var(--track); color: var(--muted); font-size: 24px; }
.item:not(.done) .art img { filter: grayscale(1) brightness(.75); opacity: .85; }
.item.progress .art img { filter: grayscale(.5) brightness(.85); opacity: .95; }
.badge .art img { border-radius: 0; filter: drop-shadow(0 3px 8px rgba(0, 0, 0, .35)); }
.badge:not(.done) .art img { filter: grayscale(1) brightness(.7); }
.item-body { display: grid; grid-template-rows: auto auto 1fr; gap: 4px; min-width: 0; height: 100%; }
.item-head { display: flex; align-items: center; gap: 8px; min-width: 0; }
.item-name { flex: 1; min-width: 0; font-size: 14.5px; line-height: 1.3; }
/* The name opens the details; its ::after spreads its click over the whole card. */
.item-open {
  display: block; width: 100%; padding: 0; border: 0; background: none; text-align: left; cursor: pointer;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.item-open::after { content: ""; position: absolute; inset: 0; border-radius: calc(var(--radius) - 1px); }
.item-open:focus-visible { outline: none; }
.item-open:focus-visible::after { outline: 2px solid var(--gold); outline-offset: -2px; }
.item-desc {
  margin: 0; color: var(--muted); font-size: 12.5px; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.item-desc.secret { filter: blur(4px); user-select: none; }
.item-foot { align-self: end; display: flex; align-items: center; gap: 10px; min-width: 0; font-size: 12.5px; }
.item-foot .bar { flex: 1; }
.state { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.state svg { width: 15px; height: 15px; stroke-width: 2.4; flex: none; }
.state.ok { color: var(--ok); }
.state.locked { color: var(--muted); }
.rarity { margin-left: auto; color: var(--muted); white-space: nowrap; }
.rarity.rare { color: var(--gold); }
.tier { display: inline-flex; gap: 3px; flex: none; }
.tier i { width: 6px; height: 6px; border-radius: 50%; background: var(--track); }
.tier i.on { background: var(--gold); }

/* Progress */
.bar { display: grid; gap: 3px; min-width: 0; }
.bar-line { height: 6px; border-radius: 999px; background: var(--track); overflow: hidden; }
.bar-fill { height: 100%; width: var(--p, 0%); border-radius: inherit; background: linear-gradient(90deg, var(--gold), var(--gold-2)); transition: width .5s ease; }
.done .bar-fill { background: linear-gradient(90deg, var(--gold), var(--gold-2)); }
.bar-label { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.bar-label span:first-child { overflow: hidden; text-overflow: ellipsis; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 999px; font-size: 12.5px; background: var(--track); color: var(--muted); border: 0; }
.chip.done { background: var(--ok-soft); color: var(--ok); font-weight: 600; }
.chip.done::before { content: "✓"; font-weight: 700; }
button.chip { cursor: pointer; }
button.chip:hover { outline: 1px solid var(--gold); }

/* Dialogs */
dialog {
  width: min(560px, calc(100vw - 32px)); padding: 0; border-radius: 16px;
  border: 1px solid var(--line); background: var(--card); color: var(--text); box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(5, 8, 16, .6); backdrop-filter: blur(2px); }
dialog form { display: grid; gap: 12px; padding: 22px 24px; }
dialog h2 { font-size: 18px; }
dialog p { margin: 0; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.dialog-actions .btn:first-child:not(:last-child) { margin-right: auto; }
.about-head, .detail-head { display: flex; align-items: center; gap: 14px; }
.about-head img { border-radius: 12px; }
.detail-art { width: 96px; height: 96px; flex: none; display: grid; place-items: center; }
.detail-art img { width: 100%; height: 100%; object-fit: contain; border-radius: 12px; }
.detail-art.dim img { filter: grayscale(1) brightness(.75); }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 0; font-size: 13px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }

/* Your progress: the game's folder, Steam's files, then the public profile. */
dialog.wide { width: min(680px, calc(100vw - 32px)); }
.source { display: grid; gap: 10px; padding: 14px; border-radius: 12px; border: 1px solid var(--line); background: color-mix(in srgb, var(--card-2) 60%, transparent); }
.source h3 { font-size: 14.5px; }
details.source > summary { cursor: pointer; list-style-position: inside; }
details.source > summary h3 { display: inline; }
.segmented.os { justify-self: start; }
.path-row { display: flex; align-items: center; gap: 8px; }
.path-row code {
  flex: 1; min-width: 0; padding: 6px 10px; border-radius: 8px; background: var(--card); border: 1px solid var(--line);
  font-size: 12px; color: var(--text); word-break: break-all;
}
.path-row .file-state { flex: 1; min-width: 0; word-break: break-all; }
.path-row > p { flex: 1; }
.steps { margin: 0; padding-left: 22px; display: grid; gap: 10px; }
html:not(.profile-by-hand) .steps { padding-left: 0; list-style: none; }
.steps li::marker { color: var(--gold); font-weight: 700; }
.steps .step-state { display: block; margin-top: 3px; }
.step-row { display: flex; align-items: center; gap: 8px; }
.step-row > span { flex: 1; font-weight: 600; }
.step-row input, .step-row textarea {
  flex: 1; min-width: 0; min-height: 34px; padding: 6px 10px; resize: vertical;
  border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--text);
}
.step-row input:focus, .step-row textarea:focus { outline: none; border-color: var(--gold); }
.step-state { font-size: 12.5px; color: var(--muted); }
.step-state.ok { color: var(--ok); }
a.btn[aria-disabled="true"] { opacity: .45; pointer-events: none; }

.file-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.file-list li { display: grid; gap: 4px; padding: 10px 12px; border-radius: 10px; background: var(--card-2); border: 1px solid var(--line); }
.file-row { display: flex; align-items: center; gap: 8px; }
.file-row b { flex: 1; }
.file-state { font-size: 12.5px; color: var(--muted); }
.file-state.ok { color: var(--ok); }
.drop {
  display: flex; align-items: center; justify-content: center; gap: 10px; padding: 18px;
  border: 2px dashed var(--line); border-radius: 12px; color: var(--muted); cursor: pointer; text-align: center;
}
.drop svg { width: 22px; height: 22px; }
.drop:hover, .drop.over { border-color: var(--gold); color: var(--gold); }
.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }

.toast {
  position: fixed; inset: auto auto 22px 50%; transform: translateX(-50%); margin: 0;
  max-width: min(640px, calc(100vw - 32px)); padding: 10px 16px; border-radius: 12px;
  background: var(--card-2); color: var(--text); border: 1px solid var(--line); box-shadow: var(--shadow);
}
.toast.error { border-color: color-mix(in srgb, var(--danger) 50%, var(--line)); color: var(--danger); }

/* The links, where the data comes from, and the notice the game's content rules ask for. */
.footer {
  display: grid; justify-items: center; gap: 10px;
  margin-inline: max(22px, (100% - 1456px) / 2); padding: 24px 0 32px;
  border-top: 1px solid var(--line); color: var(--muted); font-size: 12.5px; text-align: center;
}
body.booting .footer { display: none; }
.footer p { margin: 0; max-width: 760px; }
.footer-brand { display: inline-flex; align-items: center; gap: 8px; color: var(--text); font-size: 14px; font-weight: 650; }
.footer-brand img { border-radius: 6px; }
.footer-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 22px; margin-bottom: 4px; font-size: 13.5px; font-weight: 600; }
.footer-links a, .link { color: var(--text); text-decoration: none; }
.footer-links a:hover, .link:hover { color: var(--gold); text-decoration: underline; }
.link { padding: 0; border: 0; background: none; cursor: pointer; }

@media (max-width: 900px) {
  .topbar { height: auto; flex-wrap: wrap; gap: 8px 16px; padding: 8px 14px 0; }
  .tabs { order: 3; width: 100%; height: 42px; }
  .bar-end { margin-left: auto; }
  /* Still the link's name for screen readers. */
  .brand span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  main { padding: 14px; }
  .grid { grid-template-columns: 1fr; }
  .footer { margin-inline: 14px; }
}

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