/* mtgupdate
   One loud thing: the color-coded date column. Everything else stays quiet. */

:root {
  color-scheme: light;
  --paper: #ffffff;
  --raise: #f3f5f8;
  --ink: #1c2230;
  --muted: #5c6475;
  --faint: #8a91a0;
  --rule: #e4e7ec;
  --rule-strong: #cdd2da;
  --focus: #2563eb;
  --live: #d33a2c;

  /* Event types, after the color-coded community schedule sheet. */
  --spotlight: #d06a12;
  --rc: #2f8a3a;
  --pt: #2366c4;
  --lc: #b4407a;
  --worlds: #6a4fc0;
  --tint-mix: 9%;

  --display: "Barlow Condensed", "Arial Narrow", ui-sans-serif, sans-serif;
  --text: "Barlow", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --rail: 132px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --paper: #121620;
    --raise: #1b2130;
    --ink: #e8ebf1;
    --muted: #a2a9b8;
    --faint: #737b8c;
    --rule: #252c3b;
    --rule-strong: #364053;
    --focus: #7aa7ff;
    --live: #ff6b5e;
    --spotlight: #f59a4f;
    --rc: #6cc27a;
    --pt: #6ea6f5;
    --lc: #ee88bb;
    --worlds: #a991f5;
    --tint-mix: 14%;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #121620;
  --raise: #1b2130;
  --ink: #e8ebf1;
  --muted: #a2a9b8;
  --faint: #737b8c;
  --rule: #252c3b;
  --rule-strong: #364053;
  --focus: #7aa7ff;
  --live: #ff6b5e;
  --spotlight: #f59a4f;
  --rc: #6cc27a;
  --pt: #6ea6f5;
  --lc: #ee88bb;
  --worlds: #a991f5;
  --tint-mix: 14%;
}

.t-spotlight { --accent: var(--spotlight); }
.t-rc        { --accent: var(--rc); }
.t-pt        { --accent: var(--pt); }
.t-lc        { --accent: var(--lc); }
.t-worlds    { --accent: var(--worlds); }

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.45 var(--text);
  -webkit-font-smoothing: antialiased;
}

p { margin: 0; }
a { color: inherit; text-decoration-color: var(--rule-strong); text-underline-offset: 3px; }
a:hover { text-decoration-color: currentColor; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }

svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; }

.visually-hidden, .skip:not(:focus) {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}
.skip { position: absolute; top: 8px; left: 8px; z-index: 10; background: var(--paper); padding: 8px 12px; }

/* ---- Header ---- */

.top-inner { display: flex; align-items: baseline; gap: 18px; padding-top: 16px; padding-bottom: 10px; }
.brand {
  font: 500 34px/1 var(--display); letter-spacing: -0.01em; text-decoration: none; color: var(--ink);
}
.brand b { font-weight: 700; }
.tagline { flex: 1; color: var(--muted); font-size: 15px; white-space: nowrap; }
.top-actions { display: flex; gap: 4px; align-self: center; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 36px; padding: 0 12px;
  border: 1px solid var(--rule-strong); border-radius: 8px;
  background: var(--paper); color: var(--ink);
  font: 500 15px var(--text); text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--ink); }
.btn.ghost { border-color: transparent; }
.btn.ghost:hover { background: var(--raise); }
.btn.icon { width: 36px; padding: 0; justify-content: center; }

#theme .moon { display: none; }
:root[data-theme="dark"] #theme .sun { display: none; }
:root[data-theme="dark"] #theme .moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) #theme .sun { display: none; }
  :root:not([data-theme="light"]) #theme .moon { display: block; }
}

/* ---- Filters ---- */

/* The header and filter bar stay pinned together, so jumping through the schedule (or turning
   on Show completed) never leaves the logo, search and filters behind. Phones pin only the
   filter bar; see the small-screen rules. */
.masthead {
  position: sticky; top: 0; z-index: 5;
  background: color-mix(in srgb, var(--paper) 94%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.filters {
  padding: 10px 0;
  border-bottom: 1px solid var(--rule);
}
.filter-bar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px 16px; }
.filter-tools { display: flex; gap: 8px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  height: 34px; padding: 0 13px;
  border: 1px solid var(--rule-strong); border-radius: 999px;
  background: var(--paper); color: var(--ink);
  font: 500 15px var(--text); cursor: pointer;
}
.chip:hover { border-color: var(--accent); }
.chip .swatch { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--paper); font-weight: 600; }
.chip[aria-pressed="true"] .swatch { background: var(--paper); }
.chip.all { --accent: var(--ink); }
.chip.all .swatch { display: none; }

.search {
  display: flex; align-items: center; flex: 0 1 300px; min-width: 0; align-self: center; margin-left: auto;
  height: 36px; padding: 0 10px; gap: 8px;
  background: var(--paper); border: 1px solid var(--rule-strong); border-radius: 8px;
}
.search:focus-within { border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 18%, transparent); }
.search svg { color: var(--faint); }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--ink); font: 15px var(--text); }

.select select {
  height: 36px; padding: 0 30px 0 10px; max-width: 230px;
  background: var(--paper) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a91a0' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 8px center / 16px;
  border: 1px solid var(--rule-strong); border-radius: 8px;
  color: var(--ink); font: 15px var(--text); appearance: none; cursor: pointer;
}
.select select.set { border-color: var(--ink); font-weight: 600; }

/* Checkbox menus (Format, Location) */
.menu { position: relative; }
.menu-button {
  display: inline-flex; align-items: center; justify-content: space-between; gap: 10px;
  height: 36px; min-width: 150px; max-width: 240px; padding: 0 8px 0 10px;
  background: var(--paper); border: 1px solid var(--rule-strong); border-radius: 8px;
  color: var(--ink); font: 15px var(--text); cursor: pointer;
}
.menu-button:hover { border-color: var(--ink); }
.menu-button svg { width: 16px; height: 16px; color: var(--faint); }
.menu-button[aria-expanded="true"] svg { transform: rotate(180deg); }
.menu-button.set { border-color: var(--ink); font-weight: 600; }
.menu-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-panel {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 20;
  width: max-content; min-width: 100%; max-width: min(320px, calc(100vw - 32px));
  background: var(--paper); border: 1px solid var(--rule-strong); border-radius: 10px;
  box-shadow: 0 10px 30px rgb(0 0 0 / 0.18);
}
.menu-options { max-height: min(60vh, 420px); overflow-y: auto; padding: 6px; }
.opt {
  display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px;
  font-size: 15px; cursor: pointer; user-select: none;
}
.opt:hover { background: var(--raise); }
.opt input { width: 15px; height: 15px; margin: 0; accent-color: var(--ink); flex: none; }
.opt .n { margin-left: auto; padding-left: 16px; color: var(--faint); font-size: 13.5px; font-variant-numeric: tabular-nums; }
.opt.region { font-weight: 600; }
.opt.region:not(:first-child) { margin-top: 4px; }
.opt.country { padding-left: 30px; }
.opt.zero .opt-label { color: var(--faint); }
.opt:has(input:disabled) { cursor: default; }
.opt:has(input:disabled) .opt-label { color: var(--muted); }
.menu-foot { display: flex; justify-content: space-between; padding: 8px 14px; border-top: 1px solid var(--rule); }
.menu-foot .link:disabled { opacity: 0.4; cursor: default; text-decoration: none; }

.toggle { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 15px; cursor: pointer; user-select: none; }
.toggle input { width: 15px; height: 15px; margin: 0; accent-color: var(--ink); }

/* ---- Summary ---- */

.summary { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 4px 18px; padding: 18px 0 4px; }
.summary p { color: var(--muted); font-size: 15px; }
.summary p strong { color: var(--ink); font-weight: 600; }
.summary-actions { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 18px; }
.link {
  padding: 0; border: 0; background: none; color: var(--muted);
  font: 15px var(--text); text-decoration: underline; text-underline-offset: 3px;
  text-decoration-color: var(--rule-strong); cursor: pointer;
}
.link:hover { color: var(--ink); text-decoration-color: currentColor; }

/* ---- The schedule ---- */

.month {
  display: grid; grid-template-columns: var(--rail) minmax(0, 1fr);
  border-top: 2px solid var(--ink);
  margin-top: 28px;
}
.month h2 {
  align-self: start; position: sticky; top: calc(var(--filters-h, 0px) + 14px);
  display: flex; flex-direction: column;
  margin: 0; padding-top: 12px;
  font: 600 28px/0.95 var(--display); letter-spacing: -0.005em;
}
.month h2 .y { color: var(--faint); font-weight: 500; font-size: 20px; margin-top: 4px; }
.month ol { list-style: none; margin: 0; padding: 0; }
.month, .event { scroll-margin-top: calc(var(--filters-h, 0px) + 6px); }

.event {
  display: grid; grid-template-columns: 104px minmax(0, 1fr) 180px 168px;
  gap: 18px; align-items: start;
  padding: 16px 0 17px;
  border-top: 1px solid var(--rule);
}
.event:first-child { border-top: 0; }

.when { display: flex; flex-direction: column; }
.days {
  color: var(--accent); white-space: nowrap;
  font: 700 38px/0.9 var(--display); letter-spacing: -0.01em;
  font-variant-numeric: lining-nums tabular-nums;
}
.dow { margin-top: 5px; color: var(--muted); font-size: 14px; }

.what { min-width: 0; padding-top: 1px; }
.fmt { color: var(--accent); font-size: 14px; font-weight: 600; }
.event h3 { margin: 1px 0 0; font: 600 23px/1.1 var(--display); letter-spacing: 0; }
.event h3 a { text-decoration: none; }
.event h3 a:hover { text-decoration: underline; text-decoration-thickness: 1px; }
.meta { display: flex; flex-wrap: wrap; gap: 2px 14px; margin-top: 4px; color: var(--muted); font-size: 14.5px; }
.meta .feeds { color: var(--ink); }

.where { display: flex; flex-direction: column; padding-top: 19px; min-width: 0; }
.city { font-weight: 600; }
.flag { margin-right: 7px; }
.country { color: var(--muted); font-size: 14.5px; }

.side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; padding-top: 19px; text-align: right; }
.countdown { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 2px 14px; }
.act {
  padding: 0; border: 0; background: none; color: var(--muted);
  font: 14.5px var(--text); text-decoration: underline; text-underline-offset: 3px;
  text-decoration-color: var(--rule-strong); cursor: pointer; white-space: nowrap;
}
.act:hover { color: var(--ink); text-decoration-color: currentColor; }
.act.live { color: var(--live); font-weight: 600; text-decoration-color: currentColor; }

/* Live: the row lights up in its own color. */
.event.is-live {
  margin: 0 -14px; padding-left: 14px; padding-right: 14px;
  border-top-color: transparent; border-radius: 10px;
  background: color-mix(in srgb, var(--accent) var(--tint-mix), var(--paper));
}
.event.is-live + .event { border-top-color: transparent; }
.is-live .countdown { color: var(--live); }
.live-dot {
  display: inline-block; width: 8px; height: 8px; margin-right: 7px; vertical-align: 1px;
  border-radius: 50%; background: var(--live);
  animation: pulse 1.8s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--live) 55%, transparent); }
  70%, 100% { box-shadow: 0 0 0 7px transparent; }
}

/* Completed: kept for reference, pushed back. */
.event.is-past .days { color: color-mix(in srgb, var(--accent) 45%, var(--paper)); }
.event.is-past h3, .event.is-past .city { color: var(--muted); }
.event.is-past .countdown { color: var(--faint); font-weight: 400; }

/* A shared link to one event. */
.event.is-target { animation: target 2.4s ease-out; border-radius: 10px; }
@keyframes target {
  0%, 35% { background: color-mix(in srgb, var(--accent) 16%, var(--paper)); }
  100% { background: transparent; }
}

@media (prefers-reduced-motion: reduce) {
  .live-dot, .event.is-target { animation: none; }
}

.empty, .loading { padding: 56px 0; text-align: center; color: var(--muted); }
.empty .btn { margin-top: 14px; }

/* ---- Footer ---- */

.foot { margin-top: 72px; border-top: 1px solid var(--rule); }
.foot-inner { padding-top: 22px; padding-bottom: 32px; color: var(--muted); font-size: 14.5px; }
.foot p { margin: 0 0 8px; max-width: 70ch; }
.foot .fine { color: var(--faint); font-size: 13px; }

.toast { display: none; }

/* ---- Smaller screens ---- */

@media (max-width: 960px) {
  .tagline { display: none; }
  .month { display: block; }
  .month h2 { position: static; flex-direction: row; align-items: baseline; gap: 8px; padding: 10px 0 2px; }
  .month h2 .y { margin: 0; }
  .event { grid-template-columns: 96px minmax(0, 1fr) 170px; }
  .side { grid-column: 2 / -1; flex-direction: row; justify-content: space-between; align-items: baseline; padding-top: 0; text-align: left; }
}

@media (max-width: 640px) {
  .top-inner { padding-top: 16px; }
  .tagline { display: none; }
  .top-actions { margin-left: auto; }
  #subscribe span { display: none; }
  .chips { flex-wrap: nowrap; overflow-x: auto; margin: 0 -16px; padding: 0 16px 2px; scrollbar-width: none; }
  .chip { flex: none; }
  .top-inner { flex-wrap: wrap; row-gap: 12px; }
  .masthead { display: contents; }
  .filters {
    position: sticky; top: 0; z-index: 5;
    background: color-mix(in srgb, var(--paper) 94%, transparent);
    backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  }
  .filter-tools { width: 100%; }
  .filter-tools .menu { flex: 1 1 0; min-width: 0; }
  .menu-button { width: 100%; min-width: 0; max-width: none; }
  .filter-tools .menu:last-child .menu-panel { left: auto; right: 0; }
  .search { order: 3; width: auto; flex: 1 1 100%; }
  .event { grid-template-columns: 78px minmax(0, 1fr); gap: 4px 12px; padding: 14px 0; }
  .event.is-live { margin: 0 -10px; padding-left: 10px; padding-right: 10px; }
  .days { font-size: 30px; white-space: nowrap; }
  .when { grid-row: span 3; }
  .where { flex-direction: row; flex-wrap: wrap; gap: 0 6px; padding-top: 4px; }
  .country::before { content: ", "; margin-left: -6px; }
  .side { grid-column: 2; flex-direction: row; flex-wrap: wrap; align-items: baseline; gap: 2px 14px; padding-top: 4px; }
  .actions { justify-content: flex-start; }
}
