:root {
  --ink: #1f2d3d;
  --paper: #fffaf0;
  --muted: #5b6b7b;
  --line: #e3e0d6;
  --sky-top: #cdeefc;
  --sky-bottom: #fdf3df;
  --quiet: #5ad1b3;
  --moderate: #ffc857;
  --busy: #ff7a6b;
  --none: #b83a4f;
  --closed: #dfe5ea;
  --accent: #4aa8d8;
  --font: Fredoka, system-ui, sans-serif;
}
/* Fredoka has no Vietnamese, Arabic, Gurmukhi, Devanagari or Thai letters; the Worker loads a
   Baloo 2 font (Mitr for Thai) in the same rounded style for those pages. Chinese and Korean use
   the system's font. */
:root:lang(vi) { --font: 'Baloo 2', Fredoka, system-ui, sans-serif; }
:root:lang(ar) { --font: 'Baloo Bhaijaan 2', system-ui, sans-serif; }
:root:lang(pa) { --font: 'Baloo Paaji 2', system-ui, sans-serif; }
:root:lang(hi), :root:lang(ne) { --font: 'Baloo 2', system-ui, sans-serif; }
:root:lang(th) { --font: Fredoka, Mitr, system-ui, sans-serif; }
:root:lang(ko) { --font: Fredoka, 'Apple SD Gothic Neo', 'Malgun Gothic', 'Noto Sans KR', system-ui, sans-serif; }
:root:lang(zh-Hans) { --font: Fredoka, 'PingFang SC', 'Microsoft YaHei', 'Noto Sans SC', system-ui, sans-serif; }
:root:lang(zh-Hant) { --font: Fredoka, 'PingFang HK', 'PingFang TC', 'Microsoft JhengHei', 'Noto Sans TC', system-ui, sans-serif; }

* { box-sizing: border-box; }
html { background: var(--sky-bottom); }
body {
  margin: 0; min-height: 100vh; font-family: var(--font); color: var(--ink);
  background: linear-gradient(180deg, var(--sky-top), var(--sky-bottom) 480px);
}
.page { max-width: 1240px; margin: 0 auto; padding: 16px; display: flex; flex-direction: column; gap: 16px; }

.card {
  background: var(--paper); border: 2.5px solid var(--ink); border-radius: 18px; box-shadow: 4px 4px 0 var(--ink);
  animation: pop .45s cubic-bezier(.3, 1.6, .5, 1) both;
}
.card:nth-child(2) { animation-delay: .05s; }
.card:nth-child(3) { animation-delay: .1s; }

/* header */
.head { padding: 10px 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.eyebrow { font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: .04em; }
h1 { margin: 0; font-size: 26px; font-weight: 700; line-height: 1.1; }
h2 { margin: 0; font-size: 20px; font-weight: 700; }
.controls { display: flex; align-items: center; justify-content: flex-end; gap: 14px; flex-wrap: wrap; margin-inline-start: auto; }
.seg { display: inline-flex; gap: 4px; padding: 3px; border: 2px solid var(--ink); border-radius: 999px; background: #fff; }
.seg button {
  font: inherit; font-weight: 600; font-size: 15px; color: var(--ink); background: none; border: 0;
  padding: 4px 16px; border-radius: 999px; cursor: pointer; transition: transform .15s, background .2s;
}
.seg button:hover { background: #eef7fb; }
.seg button.on { background: var(--accent); color: #fff; }
.seg[hidden] { display: none; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.loc-picker {
  font: inherit; font-weight: 600; font-size: 15px; color: var(--ink); background: #fff
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%231f2d3d' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E")
    no-repeat right 12px center / 12px 8px;
  appearance: none; -webkit-appearance: none; border: 2px solid var(--ink); border-radius: 999px;
  padding-block: 6px; padding-inline: 14px 34px; cursor: pointer; max-width: 100%;
}
[dir="rtl"] .loc-picker { background-position: left 12px center; }
.loc-picker:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
body.loading .now-card, body.loading .heat-card { opacity: .55; transition: opacity .2s; pointer-events: none; }

/* now card */
.now-card { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); overflow: hidden; }
.pool-wrap { position: relative; min-width: 0; border-inline-end: 2.5px solid var(--ink); background: linear-gradient(180deg, #e3f5fc, #f6fbf8); }
.pool-scene { position: relative; height: 440px; overflow: hidden; }   /* relative: stays above the night sky */
/* night sky: fades in behind the canvas, a few stars */
.pool-wrap::before {
  content: ''; position: absolute; inset: 0; opacity: 0; transition: opacity 1s; pointer-events: none;
  background:
    radial-gradient(1.5px 1.5px at 12% 18%, #fff8, transparent), radial-gradient(1.5px 1.5px at 30% 8%, #fff9, transparent),
    radial-gradient(1px 1px at 47% 22%, #fff7, transparent), radial-gradient(1.5px 1.5px at 68% 12%, #fff9, transparent),
    radial-gradient(1px 1px at 82% 28%, #fff7, transparent), radial-gradient(1.5px 1.5px at 91% 9%, #fff8, transparent),
    radial-gradient(1px 1px at 22% 34%, #fff6, transparent), radial-gradient(1px 1px at 58% 5%, #fff7, transparent),
    linear-gradient(180deg, #1b2747, #33466b);
}
.pool-wrap.night::before { opacity: 1; }
/* moon at its phase in the night sky, behind the pool */
.pool-moon {
  position: absolute; top: 12px; inset-inline-end: 16px; opacity: 0; transition: opacity 1s; pointer-events: none;
  filter: drop-shadow(0 0 10px rgba(255, 243, 196, .45));
}
.pool-wrap.night .pool-moon.show { opacity: 1; }
.pool-scene canvas { display: block; }
.pool-closed {
  position: absolute; top: 14px; inset-inline-start: 14px; padding: 4px 12px; border-radius: 999px; background: var(--ink); color: var(--paper);
  font-weight: 600; font-size: 14px;
}
.pool-hint {
  position: absolute; inset-inline-start: 14px; bottom: 12px; font-size: 13px; font-weight: 600; color: var(--muted);
  background: rgba(255, 250, 240, .85); padding: 3px 10px; border-radius: 999px; pointer-events: none;
  transition: opacity .3s;
}
.pool-hint.gone, .pool-hint.empty { opacity: 0; }
.follow-bar {
  position: absolute; left: 12px; right: 12px; top: 12px; display: flex; justify-content: space-between; align-items: center; gap: 8px;
  pointer-events: none; animation: pop .35s cubic-bezier(.3, 1.6, .5, 1) both;
}
.follow-info {
  background: var(--ink); color: var(--paper); font-weight: 600; font-size: 14px; padding: 4px 12px; border-radius: 999px;
}
.zoom-out {
  pointer-events: auto; display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  font: inherit; font-weight: 600; font-size: 14px; color: var(--ink); background: var(--paper);
  border: 2.5px solid var(--ink); border-radius: 999px; padding: 4px 12px; box-shadow: 2px 2px 0 var(--ink);
  transition: transform .12s;
}
.zoom-out:hover { transform: translateY(-1px); background: #fff; }
.zoom-out:active { transform: translateY(1px); box-shadow: 1px 1px 0 var(--ink); }
.summary { min-width: 0; padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.slot-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.slot-when { font-weight: 600; color: var(--muted); }
.back {
  font: inherit; font-size: 13px; font-weight: 600; padding: 3px 10px; border-radius: 999px; cursor: pointer;
  border: 2px solid var(--ink); background: #fff; color: var(--ink);
}
.back:hover { background: #eef7fb; }
.big { display: flex; align-items: center; gap: 14px; }
.big-num {
  width: 76px; height: 76px; flex: none; border-radius: 20px; border: 2.5px solid var(--ink); box-shadow: 3px 3px 0 var(--ink);
  display: grid; place-items: center; font-size: 40px; font-weight: 700; background: var(--closed); transition: background .3s;
}
.big-of { font-size: 18px; font-weight: 600; }
.big-status { font-size: 14px; color: var(--muted); }
.closing[hidden], .weather[hidden] { display: none; }
.closing {
  display: grid; grid-template-columns: 22px 1fr; gap: 8px; align-items: center;
  padding: 8px 12px; border: 2px solid var(--ink); border-radius: 14px; background: #fff1cc; font-size: 15px;
}
.closing svg { display: block; }
#typical { background: #f3fbff; }
.weather {
  display: grid; grid-template-columns: 48px 1fr; gap: 4px 12px; align-items: center;
  padding: 10px 12px; border: 2px solid var(--ink); border-radius: 14px; background: #f3fbff;
}
.weather svg { display: block; }
.w-icon { grid-row: span 2; }
.w-main { font-size: 16px; font-weight: 600; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.w-temp { font-size: 22px; font-weight: 700; }
.w-tag { font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); border: 1.5px solid currentColor; border-radius: 999px; padding: 0 6px; }
.w-sub { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 4px 10px; flex-wrap: wrap; }
.w-sub span { display: inline-flex; align-items: center; gap: 4px; }
.w-sub b { color: var(--ink); font-weight: 600; }
.w-gusty { color: #c2410c; font-weight: 600; }
.w-note { grid-column: 1 / -1; font-size: 12px; color: var(--muted); }
.tips { list-style: none; margin: 0; padding: 12px 0 0; border-top: 2px dashed var(--line); display: flex; flex-direction: column; gap: 10px; }
.tips li { display: grid; grid-template-columns: 22px 1fr; gap: 8px; font-size: 15px; line-height: 1.35; }
.tips .ico { display: flex; padding-top: 1px; }
.tips .ico svg { display: block; }
.tips small { display: block; color: var(--muted); font-size: 13px; }

/* heatmap */
.heat-card { padding: 16px; }
.heat-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.heat-title { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.updated { font-size: 13px; color: var(--muted); }
/* which pool the grid is for, when the location has more than one (the toggle is out of view on phones) */
.heat-pool { align-self: center; font-size: 13px; font-weight: 700; color: #fff; background: var(--accent); border: 2px solid var(--ink); border-radius: 999px; padding: 1px 10px; }
.heat-pool[hidden] { display: none; }
.hint { margin: 6px 0 12px; font-size: 13px; color: var(--muted); }
.legend { display: flex; gap: 14px; font-size: 14px; font-weight: 500; flex-wrap: wrap; }
.legend span { display: flex; align-items: center; gap: 6px; }
.sw { width: 14px; height: 14px; border-radius: 4px; border: 2px solid var(--ink); display: inline-block; }
.sw.quiet { background: var(--quiet); }
.sw.moderate { background: var(--moderate); }
.sw.busy { background: var(--busy); }
.sw.none { background: var(--none); }
.legend .lg-s { display: none; }
.sw.closed { background: repeating-linear-gradient(45deg, var(--closed) 0 3px, #fff 3px 6px); }

.heat-scroll { overflow-x: auto; padding: 6px 6px 8px; margin: -6px -6px -8px; }   /* room for the selected cell's outline */
.heatmap { display: grid; gap: 3px; min-width: 0; }
/* desktop: grow the grid to its columns when they overflow, so the scroller's padding lands after the last column */
.heatmap.across { width: max-content; min-width: 100%; }
.hm-corner, .hm-col, .hm-row { font-size: 12px; font-weight: 600; color: var(--muted); display: flex; align-items: center; }
.hm-col { justify-content: flex-start; white-space: nowrap; }
.hm-row { justify-content: flex-end; padding-inline-end: 8px; white-space: nowrap; gap: 5px; }
.hm-row.today { color: var(--ink); }
.hm-row.today b { background: var(--ink); color: var(--paper); padding: 0 7px; border-radius: 999px; }
.hm-row small { font-weight: 500; }
.closed-now { font-weight: 600; color: var(--muted); }

.cell {
  position: relative; height: 34px; border-radius: 6px; border: 0; padding: 0; cursor: pointer;
  font: inherit; font-size: 13px; font-weight: 600; color: var(--ink); background: var(--c, var(--closed));
  transition: transform .12s, box-shadow .12s, opacity .3s;
  animation: cellIn .35s ease-out both; animation-delay: var(--d, 0s);
}
.cell:hover, .cell:focus-visible { transform: translateY(-2px); box-shadow: 0 0 0 2px var(--ink); z-index: 1; outline: none; }
.cell.closed { background: repeating-linear-gradient(45deg, var(--closed) 0 4px, #f4f6f8 4px 8px); color: transparent; }
.cell.none, .big-num.none { color: #fff; }   /* white on the deep red */
.cell.past { opacity: .28; color: transparent; }
.cell.hour { margin-inline-start: 3px; }
.cell.now { box-shadow: 0 0 0 2.5px var(--ink); z-index: 2; }
.cell.now::after {
  content: attr(data-now); position: absolute; left: 50%; top: -15px; transform: translateX(-50%);
  font-size: 9px; line-height: 12px; letter-spacing: .06em; color: var(--paper); background: var(--ink); padding: 1px 5px; border-radius: 999px;
  white-space: nowrap;   /* one line even when the word is wider than a narrow cell (現在, BÂY GIỜ) */
  animation: bob 1.6s ease-in-out infinite;
}
.cell.selected { box-shadow: 0 0 0 3px var(--accent), 0 0 0 5px var(--ink); z-index: 3; }

.tooltip {
  position: fixed; z-index: 10; pointer-events: none; transform: translate(-50%, calc(-100% - 12px));
  background: var(--paper); border: 2.5px solid var(--ink); border-radius: 12px; box-shadow: 3px 3px 0 var(--ink);
  padding: 6px 10px; font-size: 13px; white-space: nowrap;
}
.tooltip b { font-size: 16px; }
.tooltip .muted { color: var(--muted); }

@keyframes pop { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: none; } }
@keyframes cellIn { from { opacity: 0; transform: scale(.6); } to { transform: none; } }
@keyframes bob { 50% { transform: translate(-50%, -3px); } }

@media (max-width: 860px) {
  .now-card { grid-template-columns: minmax(0, 1fr); }   /* minmax: let the canvas column shrink below the canvas width */
  .pool-wrap { border-inline-end: 0; border-bottom: 2.5px solid var(--ink); }
  .pool-scene { height: 260px; }
}
@media (max-width: 720px) {
  .legend .lg-x { display: none; }   /* "Plenty of lanes" becomes "Plenty" */
  .legend .lg-s { display: inline; }
  .page { padding: 12px; gap: 12px; }
  h1 { font-size: 21px; }
  .cell { height: 26px; font-size: 12px; }
  .cell.hour { margin-inline-start: 0; margin-top: 3px; }
  .hm-col { display: block; text-align: center; line-height: 1.15; padding-bottom: 2px; }   /* block so the <br> between day and date works */
  .hm-col small { font-weight: 500; font-size: 10px; }
  .hm-row { justify-content: flex-end; }
}
@media (prefers-reduced-motion: reduce) {
  .card, .cell, .cell.now::after { animation: none; }
}
.heatmap.static .cell { animation: none; }
.follow-bar[hidden] { display: none; }

/* server-rendered summary, 7-day plan and directory (#seo) */
.info { padding: 18px 20px; font-size: 15px; line-height: 1.45; }
.info:empty { display: none; }
.info h2 { margin: 4px 0 8px; }
.info h2 + p, .info p { margin: 6px 0; }
.info .asof { color: var(--muted); font-size: 14px; }
.info .now-list { margin: 6px 0 12px; padding-inline-start: 18px; }
.info .now-list li { margin: 4px 0; }
.info details { border: 2px solid var(--ink); border-radius: 12px; background: #fff; margin: 8px 0; overflow: hidden; }
.info summary { cursor: pointer; font-weight: 600; padding: 8px 12px; }
.info details[open] summary { border-bottom: 2px dashed var(--line); }
.info a { color: var(--ink); text-decoration-color: var(--accent); text-decoration-thickness: 2px; text-underline-offset: 2px; }
.plan { width: 100%; border-collapse: collapse; font-size: 14px; }
.plan th, .plan td { text-align: start; padding: 6px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.plan thead th { font-size: 12px; color: var(--muted); font-weight: 600; }
.plan tbody tr:last-child th, .plan tbody tr:last-child td { border-bottom: 0; }
.plan small { color: var(--muted); font-weight: 500; }
.info .table-wrap { border: 2px solid var(--ink); border-radius: 12px; background: #fff; overflow-x: auto; margin: 8px 0; }
.info details { overflow-x: auto; }
.info .addr { color: var(--muted); font-size: 14px; margin-top: 12px; }
.dir { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 4px 16px; }
.dir h3 { margin: 6px 0 2px; font-size: 13px; color: var(--muted); letter-spacing: .04em; }
.dir ul { list-style: none; margin: 0; padding: 0; }
.dir li { padding: 2px 0; }
/* the whole text summary is collapsed by default; the outer <details> overrides the boxed inner ones */
.info details.more { border: 0; border-radius: 0; background: none; margin: 0; overflow: visible; }
.info details.more > summary { list-style: none; display: flex; align-items: center; gap: 10px; padding: 0; }
.info details.more > summary::-webkit-details-marker { display: none; }
.info details.more > summary h2 { margin: 4px 0; }
.info details.more > summary::after {
  content: ''; flex: none; width: 9px; height: 9px; margin-inline-start: auto; margin-inline-end: 4px;
  border-right: 2.5px solid var(--ink); border-bottom: 2.5px solid var(--ink); transform: rotate(45deg) translateY(-3px); transition: transform .15s;
}
.info details.more[open] > summary::after { transform: rotate(225deg) translateY(-3px); }
.info details.more[open] > summary { border-bottom: 0; margin-bottom: 8px; }
.info .disclaimer { margin-top: 14px; padding-top: 10px; border-top: 2px dashed var(--line); color: var(--muted); font-size: 13px; }
@media (max-width: 720px) {
  .info { padding: 16px 14px; }
  .plan { font-size: 13px; }
  .plan th, .plan td { padding: 6px 7px; }
}

/* language links under the disclaimer */
.info .langs { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 8px; font-size: 14px; }
.info .langs b { font-weight: 600; }
