/* Colour themes, chosen with the palette button in the top bar (theme.js).
   Dark is the default and lives in app.css; these override its tokens.
   Blossom (pink) and Sky (light blue) are soft light themes with their own
   accent; green and red keep their meaning (rises, falls, verified). */

:root[data-theme="light"],
:root[data-theme="blossom"],
:root[data-theme="sky"] {
  --card-shadow: 0 1px 2px rgba(20, 24, 40, 0.10), 0 18px 36px -20px rgba(20, 24, 40, 0.30);
  --pop-shadow: 0 12px 32px -12px rgba(20, 24, 40, 0.28);
  --up: #059669;
  --down: #DC2626;
  --fresh: #059669;
  --fresh-wash: rgba(5, 150, 105, 0.12);
  --ageing: #B7791F;
  --ageing-wash: rgba(183, 121, 31, 0.13);
  --stale: #6B7280;
  --stale-wash: rgba(107, 114, 128, 0.13);
  --danger: #B4232A;
  --danger-wash: rgba(180, 35, 42, 0.10);
  color-scheme: light;
}

:root[data-theme="light"] {
  --bg: #F6F7FA;
  --surface: #FFFFFF;
  --surface-2: #F0F1F5;
  --ink: #15171E;
  --ink-2: #4B4F5C;
  --ink-3: #6B6F7B;
  --line: #E3E5EB;
  --line-strong: #CDD0D8;
  --accent: #7C4DFF;
  --accent-wash: rgba(124, 77, 255, 0.12);
  --chart: #7C4DFF;
  --chart-fill: rgba(124, 77, 255, 0.28);
  --reference: #2563EB;
  --price: #15171E;
}

:root[data-theme="blossom"] {
  --bg: #FFF5F8;
  --surface: #FFFFFF;
  --surface-2: #FFEAF1;
  --ink: #2A1520;
  --ink-2: #6B4A58;
  --ink-3: #8E6F7C;
  --line: #F7DAE4;
  --line-strong: #EFC2D2;
  --accent: #DB4F93;
  --accent-wash: rgba(219, 79, 147, 0.12);
  --chart: #DB4F93;
  --chart-fill: rgba(219, 79, 147, 0.26);
  --reference: #6C82E8;
  --price: #2A1520;
}

:root[data-theme="sky"] {
  --bg: #F3F8FD;
  --surface: #FFFFFF;
  --surface-2: #E7F1FB;
  --ink: #10202F;
  --ink-2: #45596B;
  --ink-3: #6A7E90;
  --line: #D7E6F4;
  --line-strong: #BCD4EA;
  --accent: #2F86D6;
  --accent-wash: rgba(47, 134, 214, 0.12);
  --chart: #2F86D6;
  --chart-fill: rgba(47, 134, 214, 0.24);
  --reference: #A26BE0;
  --price: #10202F;
}

/* The home headline gradient follows the theme's accent. */
:root[data-theme="light"] .home-hero h1 span,
:root[data-theme="blossom"] .home-hero h1 span,
:root[data-theme="sky"] .home-hero h1 span {
  background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 70%, var(--ink)), var(--accent) 60%,
              color-mix(in srgb, var(--accent) 55%, #F0ABFC));
  -webkit-background-clip: text;
  background-clip: text;
}

/* Set art keeps a dark backdrop (white names on logos), tinted to the theme. */
:root[data-theme="blossom"] :is(.set-art, .set-hero-art) { background: linear-gradient(135deg, #6B2A4C, #2A1220); }
:root[data-theme="sky"] :is(.set-art, .set-hero-art) { background: linear-gradient(135deg, #24496E, #0F1E2F); }

/* ---------- Theme picker ---------- */
.theme-picker { position: relative; flex-shrink: 0; margin-left: auto; }
.topbar-inner:has(.site-nav) .theme-picker { margin-left: 0; }
.theme-button {
  display: inline-grid; place-items: center; width: 40px; height: 40px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface);
  color: var(--ink-2); cursor: pointer;
}
.theme-button:hover, .theme-button[aria-expanded="true"] { color: var(--ink); border-color: var(--line-strong); }
.theme-button svg { width: 20px; height: 20px; }
.theme-menu {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 40;
  display: grid; gap: 4px; min-width: 180px; padding: 8px;
  border: 1px solid var(--line-strong); border-radius: 14px; background: var(--surface);
  box-shadow: var(--pop-shadow);
}
.theme-menu[hidden] { display: none; }
.theme-menu-title { margin: 2px 8px 6px; color: var(--ink-3); font-size: 12px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }
.theme-option {
  display: flex; align-items: center; gap: 10px; padding: 8px; border: 0; border-radius: 10px;
  background: transparent; color: var(--ink); font: inherit; font-size: 14px; font-weight: 600; text-align: left; cursor: pointer;
}
.theme-option:hover { background: var(--surface-2); }
.theme-option[aria-checked="true"] { background: var(--accent-wash); }
.theme-swatch {
  width: 22px; height: 22px; border-radius: 999px; flex-shrink: 0;
  border: 1px solid rgba(0, 0, 0, 0.12); box-shadow: inset 0 0 0 3px var(--sw-bg);
  background: var(--sw-accent);
}

/* ---------- Card images (theme.js marks them) ---------- */
:is(.set-card-art, .home-card-art, .pf-thumb, .card-face) img { opacity: 0; transition: opacity 0.25s ease; }
.home-tile img { opacity: 0; transition: opacity 0.25s ease, transform 0.15s; }
:is(.set-card-art, .home-card-art, .home-tile, .pf-thumb, .card-face) img.is-loaded { opacity: 1; }
/* A landscape card turned a quarter to fill the portrait frame. */
.is-landscape:is(.set-card-art, .pf-thumb, .card-face) { position: relative; }
.is-landscape:is(.set-card-art, .pf-thumb, .card-face) img {
  position: absolute; top: 50%; left: 50%;
  width: calc(100% * 88 / 63); height: calc(100% * 63 / 88); max-width: none;
  transform: translate(-50%, -50%) rotate(90deg); object-fit: cover;
}
@media (prefers-reduced-motion: reduce) {
  :is(.set-card-art, .home-card-art, .home-tile, .pf-thumb, .card-face) img { transition: none; }
}

/* ---------- Account (account.js, login.html) ---------- */
/* Admin-only controls stay hidden until /api/auth/me says this is the admin. */
:root:not([data-admin]) :is(.comp-invalid, #review-link) { display: none; }

.account-picker { position: relative; flex-shrink: 0; margin-left: auto; display: flex; align-items: center; }
.topbar-inner:has(.site-nav) .account-picker, .account-picker + .theme-picker { margin-left: 0; }
.topbar-inner:has(.account-picker) { gap: 10px; }
.account-button { font: inherit; font-size: 15px; font-weight: 800; color: var(--ink); }
.account-login {
  display: inline-flex; align-items: center; height: 40px; padding: 0 16px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface);
  color: var(--ink); font-size: 14px; font-weight: 700; text-decoration: none; white-space: nowrap;
}
.account-login:hover { border-color: var(--line-strong); }
.account-menu { min-width: 220px; }
.account-email { margin: 0 8px 6px; color: var(--ink-2); font-size: 13px; overflow-wrap: anywhere; }
a.theme-option { text-decoration: none; }

.auth-page { display: grid; justify-items: center; padding: 40px var(--gutter) 64px; }
.auth-card {
  width: min(400px, 100%); display: grid; gap: 16px; padding: 28px 24px;
  border: 1px solid var(--line); border-radius: 18px; background: var(--surface);
}
.auth-card[hidden] { display: none; }
.auth-title { margin: 0; font-size: 24px; font-weight: 800; }
.auth-subtitle { margin: 0; font-size: 16px; font-weight: 800; }
.auth-lede { margin: -8px 0 0; color: var(--ink-2); font-size: 14px; }
.auth-google {
  display: flex; align-items: center; justify-content: center; gap: 10px; height: 46px;
  border: 1px solid var(--line-strong); border-radius: 12px; background: var(--bg);
  color: var(--ink); font-weight: 700; text-decoration: none;
}
.auth-google:hover { border-color: var(--accent); }
.auth-google[hidden] { display: none; }
.auth-google svg { width: 18px; height: 18px; }
.auth-divider { display: flex; align-items: center; gap: 10px; margin: 0; color: var(--ink-3); font-size: 12px; }
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.auth-divider[hidden] { display: none; }
.auth-form { display: grid; gap: 12px; }
.auth-field { display: grid; gap: 6px; font-size: 13px; font-weight: 700; color: var(--ink-2); }
.auth-field[hidden] { display: none; }
.auth-field small { font-weight: 500; color: var(--ink-3); }
.auth-field input {
  height: 44px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 10px;
  background: var(--bg); color: var(--ink); font: inherit; font-size: 16px; font-weight: 500;
}
.auth-field input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.auth-hint { margin: 0; color: var(--ink-3); font-size: 12px; }
.auth-error { margin: 0; color: var(--down); font-size: 13px; font-weight: 600; }
.auth-ok { margin: 0; color: var(--up); font-size: 13px; font-weight: 600; }
.auth-hint[hidden], .auth-error[hidden], .auth-ok[hidden] { display: none; }
.auth-submit { height: 46px; }
.auth-switch { margin: 0; color: var(--ink-2); font-size: 14px; text-align: center; }
.auth-link { border: 0; padding: 0; background: none; color: var(--accent); font: inherit; font-weight: 700; cursor: pointer; }
.auth-actions { display: flex; flex-wrap: wrap; gap: 10px; }
@media (max-width: 480px) {
  .account-login { padding: 0 12px; font-size: 13px; }
  .topbar-inner:has(.account-picker) { gap: 8px; }
}
