/* Interval Atlas — one stylesheet, no external requests. */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #eef1f5;
  --text: #14181f;
  --muted: #5b6472;
  --line: #dde2ea;
  --navy: #001a4b;
  --accent: #0b6bcb;
  --accent-soft: #e4effb;
  --warm: #c2610f;
  --good: #1f7a4d;
  --alert: #b3261e;
  --radius: 12px;
  --maxw: 1240px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1116;
    --surface: #161b22;
    --surface-2: #1d232c;
    --text: #e7ecf3;
    --muted: #9aa6b6;
    --line: #2a323d;
    --navy: #9db8f0;
    --accent: #6aa9f0;
    --accent-soft: #17243a;
    --warm: #e0a05a;
    --good: #56c98d;
    --alert: #f2837a;
  }
}

:root[data-theme="dark"] {
  --bg: #0e1116; --surface: #161b22; --surface-2: #1d232c; --text: #e7ecf3;
  --muted: #9aa6b6; --line: #2a323d; --navy: #9db8f0; --accent: #6aa9f0;
  --accent-soft: #17243a; --warm: #e0a05a; --good: #56c98d; --alert: #f2837a;
}
:root[data-theme="light"] {
  --bg: #f6f7f9; --surface: #ffffff; --surface-2: #eef1f5; --text: #14181f;
  --muted: #5b6472; --line: #dde2ea; --navy: #001a4b; --accent: #0b6bcb;
  --accent-soft: #e4effb; --warm: #c2610f; --good: #1f7a4d; --alert: #b3261e;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }

/* ---------- header ---------- */

header.top {
  background: var(--navy);
  color: #fff;
  padding: 14px 0;
  position: sticky; top: 0; z-index: 50;
}
@media (prefers-color-scheme: dark) { header.top { background: #0a1224; } }
:root[data-theme="dark"] header.top { background: #0a1224; }
:root[data-theme="light"] header.top { background: #001a4b; }

header.top .wrap { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
header.top a { color: #fff; }
.brand { font-weight: 700; letter-spacing: .2px; font-size: 1.05rem; }
.brand span { opacity: .65; font-weight: 400; }
nav.links { display: flex; gap: 18px; font-size: .92rem; margin-left: auto; flex-wrap: wrap; }
nav.links a { opacity: .85; }
nav.links a:hover, nav.links a[aria-current] { opacity: 1; }

button.theme {
  background: rgba(255,255,255,.12); color: #fff; border: 0;
  border-radius: 999px; padding: 5px 12px; cursor: pointer; font-size: .85rem;
}

/* ---------- layout blocks ---------- */

main { padding: 28px 0 64px; }
h1 { font-size: 1.9rem; line-height: 1.2; margin: 0 0 8px; letter-spacing: -.02em; }
h2 { font-size: 1.25rem; margin: 32px 0 12px; letter-spacing: -.01em; }
h3 { font-size: 1rem; margin: 20px 0 8px; }
.lede { color: var(--muted); max-width: 68ch; margin: 0 0 22px; }

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px;
}

.statrow {
  display: grid; gap: 12px; margin: 20px 0 28px;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}
.stat { background: var(--surface); border: 1px solid var(--line);
        border-radius: var(--radius); padding: 14px 16px; }
.stat b { display: block; font-size: 1.6rem; letter-spacing: -.02em; }
.stat span { color: var(--muted); font-size: .82rem; }

/* ---------- filters ---------- */

.filters {
  display: grid; gap: 12px; margin-bottom: 18px;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px;
}
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: .76rem; text-transform: uppercase;
               letter-spacing: .05em; color: var(--muted); font-weight: 600; }
input[type=search], select {
  background: var(--bg); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px; font: inherit; font-size: .92rem;
  width: 100%;
}
input[type=range] { width: 100%; accent-color: var(--accent); }
.checks { display: flex; flex-wrap: wrap; gap: 10px 16px; }
.checks label { display: flex; align-items: center; gap: 6px; font-size: .88rem;
                color: var(--text); text-transform: none; letter-spacing: 0;
                font-weight: 400; }

.resultbar { display: flex; align-items: center; justify-content: space-between;
             gap: 12px; flex-wrap: wrap; margin-bottom: 10px; color: var(--muted);
             font-size: .9rem; }

/* ---------- table ---------- */

/* The wrapper is the scroll container; the table must be free to exceed it.
   With width:100% the table was compressed to the wrapper and its right-hand
   columns were clipped with nothing to scroll to. */
.tablewrap { overflow-x: auto; border: 1px solid var(--line);
             border-radius: var(--radius); background: var(--surface);
             scrollbar-color: var(--muted) var(--surface-2); }
.tablewrap::-webkit-scrollbar { height: 12px; }
.tablewrap::-webkit-scrollbar-track { background: var(--surface-2);
             border-radius: 0 0 var(--radius) var(--radius); }
.tablewrap::-webkit-scrollbar-thumb { background: var(--muted); border-radius: 6px;
             border: 3px solid var(--surface-2); }
/* width:auto lets the table grow past the wrapper (so it scrolls) without
   max-content blowing every column out to its longest line. */
table { border-collapse: separate; border-spacing: 0; width: auto;
        min-width: 100%; font-size: .9rem; }
th, td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line);
         white-space: nowrap; }
th { position: sticky; top: 0; background: var(--surface-2); z-index: 2;
     font-size: .74rem; text-transform: uppercase; letter-spacing: .05em;
     color: var(--muted); cursor: pointer; user-select: none; }

/* Keep the resort name in view while the score columns scroll past it. */
#grid td.name, #grid th:first-child { position: sticky; left: 0; z-index: 3;
     background: var(--surface); box-shadow: 1px 0 0 var(--line); }
#grid th:first-child { z-index: 4; background: var(--surface-2); }
#grid tbody tr:hover td.name { background: var(--surface-2); }
@media (max-width: 700px) {
  #grid td.name, #grid th:first-child { position: static; box-shadow: none; }
}
th.sorted::after { content: " ▾"; color: var(--accent); }
tbody tr:hover { background: var(--surface-2); }
td.name { white-space: normal; min-width: 190px; max-width: 250px;
          font-weight: 600; }
td.place { white-space: normal; color: var(--muted); font-size: .85rem;
           min-width: 150px; max-width: 210px; }

.num { text-align: right; font-variant-numeric: tabular-nums; }

/* score pill */
.score { display: inline-block; min-width: 38px; text-align: center;
         padding: 2px 7px; border-radius: 6px; font-variant-numeric: tabular-nums;
         font-weight: 600; font-size: .85rem; background: var(--surface-2); }
.s5 { background: #1f7a4d; color: #fff; }
.s4 { background: #4a9c6d; color: #fff; }
.s3 { background: var(--accent-soft); color: var(--text); }
.s2 { background: var(--surface-2); color: var(--muted); }
.s1 { background: transparent; color: var(--muted); }

/* ---------- badges ---------- */

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px;
         font-size: .74rem; font-weight: 600; letter-spacing: .02em;
         border: 1px solid var(--line); background: var(--surface-2);
         color: var(--muted); }
.badge.tier-Elite, .badge.tier-EliteBoutique { background: var(--navy); color: #fff;
         border-color: transparent; }
:root[data-theme="dark"] .badge.tier-Elite { color: #0a1224; }
.badge.tier-Premier, .badge.tier-PremierBoutique { background: var(--accent-soft);
         color: var(--accent); border-color: transparent; }
.badge.yes { background: var(--accent-soft); color: var(--good); border-color: transparent; }
.badge.alert { background: rgba(179,38,30,.12); color: var(--alert);
         border-color: transparent; }
.badge.warm { background: rgba(194,97,15,.12); color: var(--warm); border-color: transparent; }

/* ---------- resort detail ---------- */

.detail { display: grid; gap: 26px; grid-template-columns: minmax(0,2fr) minmax(0,1fr); }
@media (max-width: 900px) { .detail { grid-template-columns: 1fr; } }

.gallery { display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(150px,1fr)); }
.gallery img { width: 100%; height: 130px; object-fit: cover; border-radius: 10px;
               border: 1px solid var(--line); background: var(--surface-2); }
.hero-img { width: 100%; max-height: 340px; object-fit: cover; border-radius: var(--radius);
            border: 1px solid var(--line); margin-bottom: 14px; background: var(--surface-2); }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: .92rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

.bars { display: grid; gap: 9px; }
.bar { display: grid; grid-template-columns: 118px 1fr 42px; align-items: center;
       gap: 10px; font-size: .87rem; }
.bar .track { display: block; background: var(--surface-2); border-radius: 999px;
              height: 9px; overflow: hidden; }
/* <i> is inline by default, so without this the width is ignored entirely. */
.bar .fill { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.bar .val { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }

ul.amen { list-style: none; padding: 0; margin: 0; display: grid; gap: 4px;
          grid-template-columns: repeat(auto-fit, minmax(190px,1fr)); font-size: .9rem; }
ul.amen li::before { content: "· "; color: var(--muted); }

/* ---------- TDI ---------- */

.tdi { display: grid; gap: 2px; }
.tdi-row { display: grid; grid-template-columns: 52px 1fr 52px; align-items: center;
           gap: 8px; font-size: .8rem; }
.tdi-row .wk { color: var(--muted); font-variant-numeric: tabular-nums; }
.tdi-row .dates { color: var(--muted); font-size: .78rem; }
/* A <span>, so it must be blockified before height and position apply. */
.tdi-bar { display: block; position: relative; height: 15px; min-width: 140px;
           background: var(--surface-2); border-radius: 3px; overflow: hidden; }
.tdi-bar i { position: absolute; top: 0; bottom: 0; display: block; }
.tdi-bar .mid { left: 50%; width: 1px; background: var(--line); }
.tdi-fill { background: var(--accent); opacity: .85; }
.tdi-fill.high { background: var(--warm); }
.tdi-fill.low  { background: var(--good); }
.tdi-legend { display: flex; gap: 16px; flex-wrap: wrap; color: var(--muted);
              font-size: .82rem; margin: 8px 0 14px; }
.swatch { display: inline-block; width: 11px; height: 11px; border-radius: 3px;
          vertical-align: -1px; margin-right: 5px; }

table.weeks td, table.weeks th { white-space: nowrap; }
table.weeks tr.peak td { background: rgba(194,97,15,.10); }
table.weeks tr.value td { background: rgba(31,122,77,.10); }

.note { font-size: .86rem; color: var(--muted); border-left: 3px solid var(--line);
        padding: 6px 0 6px 12px; margin: 14px 0; }

footer { border-top: 1px solid var(--line); color: var(--muted); font-size: .85rem;
         padding: 22px 0 40px; }
footer a { color: var(--muted); text-decoration: underline; }

.cards { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(250px,1fr)); }
.rcard { background: var(--surface); border: 1px solid var(--line);
         border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; }
.rcard img { width: 100%; height: 132px; object-fit: cover; background: var(--surface-2); }
.rcard .body { padding: 12px 14px; display: flex; flex-direction: column; gap: 5px; flex: 1; }
.rcard .body b { font-size: .95rem; line-height: 1.3; }
.rcard .body small { color: var(--muted); }
.rcard .row { display: flex; align-items: center; gap: 8px; margin-top: auto; padding-top: 8px; }

tr.flagged td { background: rgba(179,38,30,.06); }

/* ---------- multi-select filter ---------- */

.ms { position: relative; }
.ms-btn {
  width: 100%; text-align: left; background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 26px 8px 10px;
  font: inherit; font-size: .92rem; cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ms-btn::after {
  content: "▾"; position: absolute; right: 10px; top: 50%;
  transform: translateY(-50%); color: var(--muted); pointer-events: none;
}
.ms-btn.active { border-color: var(--accent); color: var(--accent); font-weight: 600; }

.ms-panel {
  position: absolute; z-index: 40; top: calc(100% + 4px); left: 0;
  min-width: 100%; width: max-content; max-width: 320px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; box-shadow: 0 10px 26px rgba(0,0,0,.16); padding: 8px;
}
.ms-search {
  width: 100%; margin-bottom: 6px; background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px;
  font: inherit; font-size: .88rem;
}
.ms-actions { display: flex; justify-content: flex-end; margin-bottom: 4px; }
.ms-actions button {
  background: none; border: 0; color: var(--accent); cursor: pointer;
  font: inherit; font-size: .8rem; padding: 2px 4px;
}
.ms-list { max-height: 260px; overflow-y: auto; display: grid; gap: 2px; }
.ms-list label {
  display: flex; align-items: center; gap: 8px; padding: 4px 6px;
  border-radius: 6px; font-size: .9rem; cursor: pointer;
  text-transform: none; letter-spacing: 0; font-weight: 400; color: var(--text);
}
.ms-list label:hover { background: var(--surface-2); }
