/* The Periodic Table of Whisky — styles */

:root {
  --bg: #F2F1EC;
  --surface: #FBFAF6;
  --ink: #16181B;
  --ink-2: #3A3E44;
  --muted: #5B5F66;
  --rule: #16181B;
  --grid: #DFDCD3;
  --sticky: #F2F1EC;
  --focus: #1F5FBF;
  --ph-bg: #16181B;
  --ph-ink: #F2F1EC;
  --band: #E8E6DE;
  --shadow: 0 24px 60px rgba(22, 24, 27, 0.25);

  /* Flavour families: the same in both themes so a tile always reads the same */
  --f-pm: #7FA3B3; --f-sd: #CF8E6D; --f-oc: #E7D07E; --f-tr: #EFA35C; --f-rh: #A8B87A;
  --f-wj: #BF8299; --f-cc: #A39A8E; --f-mi: #B7A3D4; --f-yg: #CDE08E;
  --tile-ink: #16181B;
  --cn-k: #16181B; --cn-g: #55595F; --cn-w: #FFFFFF;

  --tile-w: 72px;
  --tile-h: 80px;
  --house-w: 188px;
  --gap: 3px;
  --tb-h: 140px;

  --sans: Archivo, "Helvetica Neue", Helvetica, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141619; --surface: #1C1F23; --ink: #EEECE6; --ink-2: #CFCCC4; --muted: #A6A39B;
    --rule: #EEECE6; --grid: #2C3036; --sticky: #141619; --focus: #8AB4FF;
    --ph-bg: #EEECE6; --ph-ink: #141619; --band: #1F2226; --shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #141619; --surface: #1C1F23; --ink: #EEECE6; --ink-2: #CFCCC4; --muted: #A6A39B;
  --rule: #EEECE6; --grid: #2C3036; --sticky: #141619; --focus: #8AB4FF;
  --ph-bg: #EEECE6; --ph-ink: #141619; --band: #1F2226; --shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--sans); line-height: 1.45; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 16px; top: -60px; background: var(--ink); color: var(--bg); padding: 10px 14px; z-index: 50; }
.skip:focus { top: 12px; }

/* Masthead */
.masthead { padding: 40px 24px 24px; border-bottom: 3px solid var(--rule); }
.masthead-inner { max-width: 1400px; }
.kicker { margin: 0 0 10px; font-family: var(--mono); font-size: 12px; letter-spacing: 2px; text-transform: uppercase; }
h1 { margin: 0 0 14px; font-size: clamp(44px, 8vw, 104px); line-height: 0.92; font-weight: 900; font-stretch: 70%; letter-spacing: -0.02em; }
.lede { margin: 0; max-width: 780px; font-size: clamp(16px, 1.6vw, 19px); }
.star { font-family: var(--mono); }
.masthead-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; margin-top: 18px; }
.tally { margin: 0; font-family: var(--mono); font-size: 13px; color: var(--muted); }

.btn { min-height: 44px; padding: 0 16px; border: 2px solid var(--ink); border-radius: 4px; background: transparent; font-weight: 700; cursor: pointer; }
.btn:hover { background: var(--ink); color: var(--bg); }
.btn-small { min-height: 40px; padding: 0 12px; font-family: var(--mono); font-size: 13px; font-weight: 600; }
.btn[aria-pressed="true"] { background: var(--ink); color: var(--bg); }

/* Toolbar */
.toolbar { position: sticky; top: 0; z-index: 20; background: var(--bg); border-bottom: 1px solid var(--rule); padding: 10px 24px 10px; display: flex; flex-direction: column; gap: 10px; }
.regions { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: thin; padding-bottom: 2px; }
.pill { flex: none; min-height: 34px; font-family: var(--mono); font-size: 12px; letter-spacing: 1px; text-transform: uppercase; background: transparent; padding: 0 12px; border: 1px solid var(--grid); border-radius: 999px; cursor: pointer; }
.pill:hover { border-color: var(--ink); }
.pill[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.operator-note { margin: 0; padding: 10px 24px; background: #8A2B1E; color: #FFFFFF; font-family: var(--mono); font-size: 13px; font-weight: 600; }
.controls { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; }
.search { position: relative; display: flex; align-items: center; flex: 1 1 220px; max-width: 340px; }
.search svg { position: absolute; left: 10px; color: var(--muted); }
.search input { width: 100%; min-height: 40px; padding: 0 12px 0 34px; border: 1px solid var(--ink-2); border-radius: 4px; background: var(--surface); }
.seg { display: inline-flex; border: 1px solid var(--ink-2); border-radius: 4px; padding: 0; margin: 0; overflow: hidden; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.seg span { display: inline-flex; align-items: center; gap: 6px; min-height: 38px; padding: 0 12px; font-size: 14px; font-weight: 600; }
.seg input:checked + span { background: var(--ink); color: var(--bg); }
.seg input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: -3px; }
.seg .cn { position: relative; width: 12px; height: 12px; }
.seg .cn-k, .seg .cn-w, .inline-cn .cn-k, .inline-cn .cn-w { background: var(--ink); }
.seg .cn-w > i, .inline-cn .cn-w > i { background: var(--bg); }
.seg input:checked + span .cn-k, .seg input:checked + span .cn-w { background: var(--bg); }
.seg input:checked + span .cn-w > i { background: var(--ink); }
.select select { min-height: 40px; padding: 0 10px; border: 1px solid var(--ink-2); border-radius: 4px; background: var(--surface); font-weight: 600; }
.toggle { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; font-size: 14px; font-weight: 600; cursor: pointer; }
.toggle input { width: 18px; height: 18px; accent-color: var(--ink); }
.more { display: contents; }
.filters-btn { display: none; }
.families { flex-basis: 100%; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: thin; padding-bottom: 2px; }
.fam-btn { flex: none; display: inline-flex; align-items: center; gap: 7px; min-height: 34px; padding: 0 10px 0 6px; border: 1px solid var(--grid); border-radius: 3px; background: transparent; font-size: 13px; font-weight: 600; cursor: pointer; }
.fam-btn i { width: 18px; height: 18px; border-radius: 2px; }
.fam-btn[aria-pressed="true"] { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }

/* Scrolling table area: both axes, so the header row and house column can stay put */
.scroller { height: calc(100dvh - var(--tb-h)); min-height: 420px; overflow: auto; position: relative; outline: none; overscroll-behavior: contain; }
.loading, .noscript { padding: 24px; font-family: var(--mono); }

.pt { border-collapse: separate; border-spacing: var(--gap); margin: 0 12px 24px 0; }
.pt th, .pt td { padding: 0; vertical-align: top; }
.pt thead th { position: sticky; top: 0; z-index: 6; background: var(--sticky); height: 42px; vertical-align: bottom; padding-bottom: 6px; font-weight: 800; font-stretch: 75%; font-size: 24px; text-align: center; box-shadow: 0 1px 0 var(--rule); }
.pt thead th.h-house { left: 0; z-index: 8; text-align: left; font-family: var(--mono); font-size: 11px; font-weight: 500; letter-spacing: 1px; text-transform: uppercase; padding-left: 12px; font-stretch: normal; }
.pt thead th.h-n { font-family: var(--mono); font-size: 18px; font-stretch: normal; }
.pt thead th small { display: block; font-family: var(--mono); font-size: 9px; font-weight: 500; letter-spacing: 1px; text-transform: uppercase; font-stretch: normal; color: var(--muted); }

.house { position: sticky; left: 0; z-index: 4; background: var(--sticky); width: var(--house-w); min-width: var(--house-w); max-width: var(--house-w); text-align: left; padding: 0 10px 0 12px !important; vertical-align: middle !important; }
.house-in { display: flex; align-items: center; gap: 10px; min-height: var(--tile-h); }
.house .code { flex: none; width: 28px; font-family: var(--mono); font-size: 12px; font-weight: 600; }
.house .hname { font-size: 15px; font-weight: 700; line-height: 1.15; }

.region th { padding: 26px 0 6px !important; text-align: left; border-bottom: 2px solid var(--rule); }
.region-in { position: sticky; left: 12px; display: inline-flex; align-items: baseline; gap: 14px; }
.region-in b { font-size: 22px; font-weight: 900; font-stretch: 78%; letter-spacing: 1.5px; text-transform: uppercase; }
.region-in span { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.subhead th { padding: 14px 0 4px !important; text-align: left; }
.subhead-in { position: sticky; left: 12px; font-family: var(--mono); font-size: 11px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--ink-2); }

.cell { width: var(--tile-w); min-width: var(--tile-w); }
.cell-in { display: flex; flex-direction: column; gap: var(--gap); }
.empty { display: block; width: var(--tile-w); height: var(--tile-h); border: 1px solid var(--grid); border-radius: 2px; }

/* N placeholder */
.ph { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; width: var(--tile-w); height: var(--tile-h); border: 0; border-radius: 2px; background: var(--ph-bg); color: var(--ph-ink); font-family: var(--mono); cursor: pointer; }
.ph .ph-star { font-size: 18px; line-height: 1; transition: transform 0.15s; }
.ph .ph-n { font-size: 12px; font-weight: 600; }
.ph[aria-expanded="true"] .ph-star { transform: rotate(45deg); }
.ph:disabled { cursor: default; }

/* Hanging strip */
.strip > td { padding: 0 0 10px !important; }
.strip-in { display: flex; flex-wrap: wrap; gap: var(--gap); padding: 8px 0 0 0; border-top: 1px dashed var(--ink-2); max-width: calc((var(--tile-w) + var(--gap)) * 19); }
.strip .house-in { min-height: 0; padding-top: 8px; font-family: var(--mono); font-size: 12px; color: var(--muted); justify-content: flex-end; }
.nas-band { padding: 0 !important; }
.nas-band-in { display: flex; flex-wrap: wrap; gap: var(--gap); padding: 6px; min-height: calc(var(--tile-h) + 12px); background: var(--band); border-radius: 2px; }

/* Tiles */
a.tile { text-decoration: none; }
.tile { position: relative; display: flex; flex-direction: column; justify-content: space-between; width: var(--tile-w); height: var(--tile-h); padding: 5px 6px; border: 0; border-radius: 2px; color: var(--tile-ink); text-align: left; overflow: hidden; cursor: pointer; transition: opacity 0.15s, transform 0.12s; }
.tile:hover { transform: translateY(-1px); box-shadow: 0 3px 0 rgba(22, 24, 27, 0.35); }
.t-top, .t-bot { position: relative; display: flex; justify-content: space-between; align-items: baseline; font-family: var(--mono); font-size: 9px; line-height: 1; }
.t-top span:first-child { padding-left: 10px; }
.t-sym { position: relative; font-weight: 800; font-stretch: 85%; font-size: 23px; line-height: 1; letter-spacing: -0.02em; text-align: center; }
.t-exp { position: relative; font-size: 8.5px; line-height: 1.1; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; height: 10px; }
.t-w { font-weight: 600; font-size: 11px; }
.p-week { display: none; }
body.show-week .p-usual { display: none; }
body.show-week .p-week { display: inline; }

.f-pm { background: var(--f-pm); } .f-sd { background: var(--f-sd); } .f-oc { background: var(--f-oc); }
.f-tr { background: var(--f-tr); } .f-rh { background: var(--f-rh); } .f-wj { background: var(--f-wj); }
.f-cc { background: var(--f-cc); } .f-mi { background: var(--f-mi); } .f-yg { background: var(--f-yg); }

/* Corner marks */
.cn { position: absolute; left: 0; top: 0; width: 15px; height: 15px; clip-path: polygon(0 0, 100% 0, 0 100%); }
.cn-k { background: var(--cn-k); }
.cn-g { background: var(--cn-g); }
.cn-w { background: var(--cn-k); }
.cn-w > i { position: absolute; left: 0; top: 0; width: 76%; height: 76%; background: var(--cn-w); clip-path: polygon(0 0, 100% 0, 0 100%); }

/* Filtering */
.tile.dim { opacity: 0.16; }
.tile.hit { outline: 3px solid var(--ink); outline-offset: 1px; }
body.aged-only .nasonly, body.aged-only .strip, body.aged-only .subhead { display: none; }

/* Sheets (bottle detail, key) */
.sheet { width: min(460px, calc(100vw - 24px)); max-height: calc(100dvh - 32px); padding: 28px; border: 0; border-radius: 6px; background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.sheet::backdrop { background: rgba(10, 11, 13, 0.45); }
.sheet-wide { width: min(860px, calc(100vw - 24px)); }
.sheet-close { position: absolute; right: 12px; top: 12px; margin: 0; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border: 0; border-radius: 4px; background: transparent; cursor: pointer; }
.icon-btn:hover { background: var(--band); }
.sheet h2 { margin: 0 0 16px; font-size: 36px; font-weight: 900; font-stretch: 72%; line-height: 1; padding-right: 48px; }
.sheet h3 { margin: 22px 0 8px; font-size: 18px; }
.sheet p { margin: 0 0 10px; }

.b-head { display: flex; gap: 18px; align-items: flex-start; margin-bottom: 18px; padding-right: 40px; }
.b-head .tile { cursor: default; flex: none; }
.b-head .tile:hover { transform: none; box-shadow: none; }
.b-title { margin: 0 0 6px; font-size: 26px; font-weight: 800; font-stretch: 80%; line-height: 1.05; }
.b-sub { margin: 0; font-family: var(--mono); font-size: 12px; color: var(--muted); }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; margin: 0; }
.facts dt { font-family: var(--mono); font-size: 12px; letter-spacing: 0.5px; text-transform: uppercase; color: var(--muted); padding-top: 2px; }
.facts dd { margin: 0; font-weight: 600; }
.facts .swatch { display: inline-block; width: 12px; height: 12px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.read-more { margin: 0 0 18px; padding: 14px 0 16px; border-top: 1px solid var(--grid); border-bottom: 1px solid var(--grid); }
.read-more h3 { margin: 0 0 10px; }
.links { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.link-btn { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; color: var(--ink); }
.link-btn:hover { color: var(--bg); }
.kb { margin-top: 12px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.kb-label { margin: 0 !important; flex-basis: 100%; font-family: var(--mono); font-size: 12px; letter-spacing: 0.5px; text-transform: uppercase; color: var(--muted); }
.kb-path { flex: 1 1 240px; min-width: 0; font-family: var(--mono); font-size: 11.5px; padding: 6px 8px; background: var(--band); border-radius: 3px; overflow-wrap: anywhere; }
.sibs { display: flex; flex-wrap: wrap; gap: var(--gap); margin-top: 8px; }

.tile.big { --tile-w: 200px; --tile-h: 224px; width: 200px; height: 224px; padding: 14px 16px; cursor: default; }
.tile.big .t-top, .tile.big .t-bot { font-size: 18px; }
.tile.big .t-top span:first-child { padding-left: 26px; }
.tile.big .t-sym { font-size: 76px; }
.tile.big .t-exp { font-size: 15px; height: 18px; }
.tile.big .t-w { font-size: 24px; }
.tile.big .cn { width: 34px; height: 34px; }
.tile.mid { --tile-w: 112px; --tile-h: 124px; width: 112px; height: 124px; padding: 8px 9px; }
.tile.mid .t-top, .tile.mid .t-bot { font-size: 12px; }
.tile.mid .t-top span:first-child { padding-left: 16px; }
.tile.mid .t-sym { font-size: 38px; }
.tile.mid .t-exp { font-size: 11px; height: 13px; }
.tile.mid .t-w { font-size: 15px; }
.tile.mid .cn { width: 22px; height: 22px; }

.key-grid { display: grid; grid-template-columns: 220px 1fr; gap: 28px; align-items: start; }
.key-list { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; }
.inline-cn { position: relative; display: inline-flex; align-items: center; gap: 4px; }
.inline-cn .cn { position: relative; display: inline-block; width: 13px; height: 13px; outline: 1px solid var(--muted); }
.key-fams { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px 16px; }
.key-fams li { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; }
.key-fams i { width: 20px; height: 20px; border-radius: 2px; flex: none; }

.foot { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 16px 24px 28px; border-top: 3px solid var(--rule); font-family: var(--mono); font-size: 12px; color: var(--ink-2); }
.foot p { margin: 0; }

/* Narrow screens */
@media (max-width: 720px) {
  :root { --tile-w: 62px; --tile-h: 70px; --house-w: 112px; }
  .masthead { padding: 28px 16px 18px; }
  .toolbar { padding: 8px 16px; }
  .search { max-width: none; flex: 1 1 0; }
  .filters-btn { display: inline-flex; align-items: center; min-height: 40px; }
  .more { display: none; }
  .toolbar.expanded .more { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; flex-basis: 100%; }
  .toolbar.expanded { max-height: 70dvh; overflow-y: auto; }
  .house { padding: 0 6px 0 8px !important; }
  .house .code { width: auto; font-size: 11px; }
  .house-in { flex-direction: column; align-items: flex-start; justify-content: center; gap: 2px; }
  .house .hname { font-size: 12.5px; }
  .t-sym { font-size: 20px; }
  .t-exp { display: none; }
  .pt thead th { font-size: 20px; }
  .key-grid { grid-template-columns: 1fr; }
  .key-fams { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .foot { padding: 16px; }
  .sheet { padding: 22px 18px; margin-bottom: 0; border-radius: 10px 10px 0 0; width: 100vw; max-width: 100vw; }
}

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