/* ===========================================================================
   Frosted Glass — ported from wessamlauf/homeassistant-frosted-glass-themes
   ("Frosted Glass Dark", v1.3). Token values below are taken from that theme's
   YAML so the two look like the same product:

     card tint      rgba(28, 29, 33, 0.18)
     card blur      blur(10px) saturate(1.2)
     card border    0.5px solid rgba(234, 235, 238, 0.1)
     card radius    18px  (small 10px, medium 14px)
     card shadow    0 12px 20px rgba(0, 0, 0, 0.28) + inner bevel
     header blur    blur(8px) saturate(1.1)
     text           rgba(234, 235, 238, .98 / .8 / .45)
     feedback       success 118,214,152 · warning 255,219,117
                    error 234,114,135  · info 106,116,211
   =========================================================================== */

:root {
  --glass-tint: rgba(28, 29, 33, 0.18);
  --glass-blur: blur(10px) saturate(1.2);
  --glass-border: rgba(234, 235, 238, 0.1);
  --glass-border-strong: rgba(234, 235, 238, 0.22);

  /* Outer drop shadow plus the inner bevel that gives the glass an edge. */
  --glass-shadow:
    0 12px 20px rgba(0, 0, 0, 0.28),
    3px 3px 0.5px -3.5px rgba(255, 255, 255, 0.15) inset,
    -2px -2px 0.5px -2px rgba(255, 255, 255, 0.1) inset,
    0 0 8px 1px rgba(255, 255, 255, 0.06) inset,
    0 0 2px 0 rgba(0, 0, 0, 0.18);

  --radius-sm: 10px;
  --radius-md: 14px;
  --radius: 18px;

  --text: rgba(234, 235, 238, 0.98);
  --text-2: rgba(234, 235, 238, 0.8);
  --muted: rgba(234, 235, 238, 0.55);
  --faint: rgba(234, 235, 238, 0.45);
  --line: rgba(84, 84, 98, 0.28);

  --accent: rgb(118, 214, 152);
  --accent-dim: rgba(118, 214, 152, 0.14);
  --warn: rgb(255, 219, 117);
  --warn-dim: rgba(255, 219, 117, 0.13);
  --danger: rgb(234, 114, 135);
  --danger-dim: rgba(234, 114, 135, 0.14);
  --info: rgb(106, 116, 211);
  --info-dim: rgba(106, 116, 211, 0.18);

  /* Fills for elements sitting *inside* a glass panel. Nesting backdrop-filter
     is expensive and muddy, so these are plain translucent washes. */
  --inner: rgba(255, 255, 255, 0.05);
  --inner-2: rgba(255, 255, 255, 0.08);
  --hover: rgba(255, 255, 255, 0.045);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background-color: #0b0d12;
  color: var(--text);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
        Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
  -webkit-font-smoothing: antialiased;
}

/* A fixed layer rather than background-attachment: fixed, which janks badly on
   mobile Safari. The image is a soft gradient, so `cover` upscaling is free. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background: #0b0d12 url("/static/frosted-bg.jpg") center / cover no-repeat;
}

/* ---------- chrome ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 24px;
  height: 60px;
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(30, 30, 30, 0.28);
  backdrop-filter: blur(8px) saturate(1.1);
  -webkit-backdrop-filter: blur(8px) saturate(1.1);
  border-bottom: 0.5px solid var(--glass-border);
}

.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); }
.brand-mark {
  background: var(--accent-dim); color: var(--accent);
  border: 0.5px solid rgba(118, 214, 152, 0.35);
  font-weight: 700; letter-spacing: .5px;
  padding: 3px 8px; border-radius: var(--radius-sm); font-size: 13px;
}
.brand-text { font-weight: 600; }

.topbar nav { display: flex; gap: 4px; margin-left: auto; }
.topbar nav a {
  color: var(--text-2); text-decoration: none; padding: 7px 14px;
  border-radius: var(--radius-sm); font-weight: 500;
  transition: background .15s, color .15s;
}
.topbar nav a:hover { color: var(--text); background: var(--inner); }
.topbar nav a.active {
  color: var(--accent); background: var(--accent-dim);
  box-shadow: 0 0 0 0.5px rgba(118, 214, 152, 0.25) inset;
}

.season-chip {
  font-variant-numeric: tabular-nums; font-weight: 600; color: var(--text-2);
  border: 0.5px solid var(--glass-border-strong); background: var(--inner);
  padding: 4px 12px; border-radius: 20px; font-size: 13px;
}

main { max-width: 1180px; margin: 0 auto; padding: 28px 24px 60px; }

footer {
  max-width: 1180px; margin: 0 auto; padding: 0 24px 40px;
  color: var(--muted); font-size: 13px;
}
footer code { color: var(--text-2); }

/* ---------- typography ---------- */

h1 { font-size: 26px; margin: 0 0 4px; letter-spacing: -.01em; font-weight: 600; }
h2 { font-size: 17px; margin: 0 0 14px; letter-spacing: -.005em; font-weight: 600; }
.sub { color: var(--text-2); margin: 0 0 26px; }

/* ---------- glass surfaces ---------- */

.panel, .stat, .record {
  background: var(--glass-tint);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 0.5px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: var(--glass-shadow);
}

.panel { padding: 20px; margin-bottom: 20px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-2 > .panel { margin-bottom: 0; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

.stat-row { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 20px; }
.stat { padding: 14px 18px; flex: 1; min-width: 160px; }
.stat .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
.stat .value { font-size: 24px; font-weight: 650; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat .value.warn { color: var(--warn); }
.stat .note { color: var(--muted); font-size: 12px; margin-top: 2px; }

/* ---------- tables ---------- */

table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th {
  text-align: left; color: var(--muted); font-size: 12px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .05em;
  padding: 8px 10px; border-bottom: 0.5px solid var(--glass-border-strong); white-space: nowrap;
}
td { padding: 9px 10px; border-bottom: 0.5px solid var(--line); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--hover); }
td.num, th.num { text-align: right; }

.pick-no {
  display: inline-block; min-width: 26px; text-align: center;
  background: var(--inner); border: 0.5px solid var(--glass-border);
  border-radius: 8px; padding: 2px 6px; font-weight: 650; font-size: 13px;
}
.pick-no.first {
  background: var(--accent-dim); border-color: rgba(118, 214, 152, 0.35); color: var(--accent);
}

.tag {
  font-size: 11px; padding: 2px 8px; border-radius: 20px;
  border: 0.5px solid var(--glass-border); background: var(--inner);
  color: var(--muted); white-space: nowrap;
}
.tag.playoff { color: var(--accent); border-color: rgba(118, 214, 152, 0.3); background: var(--accent-dim); }
.tag.shitoff { color: var(--warn); border-color: rgba(255, 219, 117, 0.3); background: var(--warn-dim); }
.tag.kept { color: #b9a5ff; border-color: rgba(185, 165, 255, 0.3); background: rgba(185, 165, 255, 0.14); }
.tag.undrafted { color: var(--muted); }

.muted { color: var(--muted); }
.danger { color: var(--danger); }
.warn { color: var(--warn); }
a { color: var(--accent); text-decoration-color: rgba(118, 214, 152, 0.4); }
a:hover { text-decoration-color: var(--accent); }

.team-name { display: block; }
.team-user { display: block; color: var(--muted); font-size: 12px; line-height: 1.35; }
.team-user::before { content: "@"; opacity: .6; }
.team-user.inline { display: inline; font-size: 12px; }

/* ---------- snake board ---------- */

.board-wrap { overflow-x: auto; }
.board { border-collapse: separate; border-spacing: 3px; font-size: 12px; }
.board th { padding: 6px 4px; text-align: center; font-size: 11px; border-bottom: none; }
.board th.slot-head { max-width: 84px; white-space: normal; line-height: 1.25; }
.board td {
  border: none; background: var(--inner); border-radius: 6px;
  padding: 6px 4px; text-align: center; min-width: 46px; color: var(--text-2);
}
.board td.owned { background: var(--accent-dim); color: var(--accent); font-weight: 600; }
.board td.traded { background: var(--warn-dim); color: var(--warn); }
.board tr td:first-child { background: none; color: var(--muted); font-weight: 600; }
.board tbody tr:hover { background: none; }

/* ---------- keeper planner ---------- */

.planner { display: grid; grid-template-columns: 1.35fr 1fr; gap: 20px; align-items: start; }
@media (max-width: 980px) { .planner { grid-template-columns: 1fr; } }

.team-select {
  background: rgba(30, 33, 54, 0.7); color: var(--text);
  border: 0.5px solid var(--glass-border-strong);
  border-radius: var(--radius-sm); padding: 8px 12px; font: inherit; font-size: 14px;
}

.cand-row.ineligible { opacity: .45; }
.cand-row.selected { background: var(--accent-dim); }

.cand-row input[type=checkbox] {
  appearance: none; width: 17px; height: 17px; cursor: pointer;
  border: 0.5px solid var(--glass-border-strong); border-radius: 6px;
  background: var(--inner);
  display: grid; place-content: center; transition: background .12s, border-color .12s;
}
.cand-row input[type=checkbox]:hover:not(:disabled) { border-color: var(--accent); }
.cand-row input[type=checkbox]:checked { background: var(--accent); border-color: var(--accent); }
.cand-row input[type=checkbox]:checked::after {
  content: ""; width: 9px; height: 5px; margin-top: -2px;
  border-left: 2px solid #0b2416; border-bottom: 2px solid #0b2416; transform: rotate(-45deg);
}
.cand-row input[type=checkbox]:disabled { cursor: not-allowed; opacity: .4; }

.cost-badge {
  display: inline-block; min-width: 34px; text-align: center; font-weight: 650;
  background: var(--inner); border: 0.5px solid var(--glass-border);
  border-radius: 8px; padding: 2px 6px;
}
.cost-badge.cheap { color: var(--accent); border-color: rgba(118, 214, 152, 0.3); }
.cost-badge.dear { color: var(--warn); border-color: rgba(255, 219, 117, 0.3); }

.ledger-pick {
  display: flex; justify-content: space-between;
  padding: 6px 0; border-bottom: 0.5px solid var(--line);
}
.ledger-pick:last-child { border-bottom: none; }
.ledger-pick.spent { color: var(--muted); text-decoration: line-through; }
.ledger-pick .who { font-size: 12px; }

.alert {
  border-radius: var(--radius-md); padding: 10px 14px; margin-bottom: 12px; font-size: 14px;
  background: var(--danger-dim); border: 0.5px solid rgba(234, 114, 135, 0.35); color: var(--danger);
}
.alert.warn { background: var(--warn-dim); border-color: rgba(255, 219, 117, 0.35); color: var(--warn); }
.alert.info { background: var(--accent-dim); border-color: rgba(118, 214, 152, 0.35); color: var(--accent); }

.counter { font-weight: 650; }
.counter.over { color: var(--danger); }

/* ---------- history ---------- */

.finish {
  display: inline-block; min-width: 24px; text-align: center;
  padding: 2px 6px; border-radius: 8px; font-weight: 650; font-size: 13px;
  border: 0.5px solid var(--glass-border); background: var(--inner); color: var(--muted);
}
.finish.p-champ   { background: var(--warn-dim); border-color: rgba(255, 219, 117, 0.45); color: var(--warn); }
.finish.p-podium  { background: var(--accent-dim); border-color: rgba(118, 214, 152, 0.4); color: var(--accent); }
.finish.p-playoff { background: rgba(118, 214, 152, 0.07); border-color: rgba(118, 214, 152, 0.2); color: rgba(118, 214, 152, 0.8); }
.finish.p-shitoff { background: var(--danger-dim); border-color: rgba(234, 114, 135, 0.3); color: var(--danger); }

/* ---------- keepers by year ---------- */

.keeper-year { margin-bottom: 18px; }
.keeper-year:last-child { margin-bottom: 0; }
.keeper-year-head { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.keeper-season { font-weight: 650; font-variant-numeric: tabular-nums; }

.keep-mark {
  display: inline-block; width: 18px; height: 18px; line-height: 17px;
  text-align: center; border-radius: 5px; font-size: 12px; font-weight: 700;
  border: 0.5px solid var(--glass-border); background: var(--inner);
}
.keep-mark.ok    { color: var(--accent); border-color: rgba(118, 214, 152, .35); background: var(--accent-dim); }
.keep-mark.flag  { color: var(--warn);   border-color: rgba(255, 219, 117, .3);  background: var(--warn-dim); }
.keep-mark.maybe { color: var(--muted); }

/* ---------- head to head ---------- */

.h2h { border-collapse: separate; border-spacing: 3px; font-size: 13px; }
.h2h th { padding: 6px 4px; border-bottom: none; }
.h2h th.slot-head {
  width: 64px; max-width: 64px; white-space: normal; overflow-wrap: anywhere;
  text-transform: none; letter-spacing: 0; font-size: 11px;
  line-height: 1.2; text-align: center; vertical-align: bottom;
}
.h2h th.corner { min-width: 160px; width: 160px; }
.h2h th.row-head {
  text-align: left; text-transform: none; letter-spacing: 0; font-size: 14px;
  color: var(--text); font-weight: 500; border: none; padding-right: 12px;
}
.h2h td {
  border: none; background: var(--inner); border-radius: 6px;
  padding: 7px 6px; text-align: center; min-width: 52px; color: var(--text-2);
}
.h2h td.up { background: var(--accent-dim); color: var(--accent); font-weight: 600; }
.h2h td.down { background: var(--danger-dim); color: var(--danger); }
.h2h td.self { background: none; color: rgba(234, 235, 238, 0.2); }
.h2h td.total { background: none; color: var(--text); font-weight: 650; }
.h2h tbody tr:hover { background: none; }

/* ---------- records ---------- */

.record-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px;
}
.record { padding: 16px 18px; }
.record-label {
  color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em;
}
.record-value {
  font-size: 26px; font-weight: 650; margin: 6px 0 2px;
  font-variant-numeric: tabular-nums; color: var(--accent);
}
.record-who { font-weight: 600; }
.record-detail { color: var(--text-2); font-size: 13px; margin-top: 4px; line-height: 1.45; }
.record-when { color: var(--faint); font-size: 12px; margin-top: 6px; }

/* ---------- phones ---------- */

@media (max-width: 640px) {
  .topbar { height: 54px; padding: 0 10px; gap: 8px; }
  .brand-text { display: none; }
  .season-chip { display: none; }

  /* Six nav items will not fit on a phone, and Phase 3 adds more. Let the nav
     scroll sideways rather than clipping whatever is on the right. */
  .topbar nav {
    gap: 0; flex: 1; overflow-x: auto; scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .topbar nav::-webkit-scrollbar { display: none; }
  .topbar nav a { padding: 6px 10px; font-size: 14px; white-space: nowrap; }

  main { padding: 18px 12px 40px; }
  h1 { font-size: 21px; }
  .sub { margin-bottom: 18px; font-size: 14px; }
  .panel { padding: 14px; border-radius: var(--radius-md); }

  th, td { padding: 7px 6px; white-space: nowrap; }

  .col-basis { display: none; }
  .cand-row td:nth-child(3) { white-space: normal; }

  /* Two up, so four tiles cost two rows rather than four screens. */
  .stat { min-width: calc(50% - 7px); flex: 1 1 calc(50% - 7px); padding: 12px 14px; }
  .stat .value { font-size: 20px; }
  .stat .value[style] { font-size: 15px !important; }

  .record-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .record { padding: 12px 14px; }
  .record-value { font-size: 20px; }

  .planner { gap: 14px; }
  .panel[style*="sticky"] { position: static !important; }
}

@media (max-width: 420px) {
  .record-grid { grid-template-columns: 1fr; }
}

/* The upstream theme ships "Lite" editions that drop the blur for low-end
   devices. This is the same idea: if the viewer has asked for less
   transparency, make the surfaces opaque instead. */
@media (prefers-reduced-transparency: reduce) {
  .panel, .stat, .record, .topbar {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: rgba(24, 26, 32, 0.94);
  }
}
