/* Hallmark · shape: app screen · genre: modern-minimal · theme: Furrow (by request) · redesign: full
 * nav: top bar, the wordmark and the menu key, sticky · signature: the month sheet beside the run book, under a generated survey band · states: loading, empty, error, full
 * axes: light/grotesk-sans/warm · posture: committed · modes: light+dark · contrast: pass · v2.0.0 */
/* Hallmark · pre-emit critique: P4 H5 E4 S4 R4 V4 · weakest: P, a club calendar has little to argue; the survey band and the club marks on the month sheet carry the voice instead of copy */

/* 到處跑 Run Around design system: tokens, base and shared components. Every page links this first and only adds
   page layout on top. design-system/README.md says how to use it. */
:root {
  color-scheme: light;
  --space-3xs: 2px; --space-2xs: 4px; --space-xs: 8px; --space-sm: 12px; --space-md: 16px; --space-lg: 24px; --space-xl: 40px; --space-2xl: 64px; --space-3xl: 96px; --space-4xl: 144px;
  --text-xs: 0.75rem; --text-sm: 0.875rem; --text-md: 1rem; --text-lg: 1.2rem; --text-xl: 1.44rem; --text-2xl: 1.728rem; --text-3xl: 2.074rem;
  --text-display: 2.5rem; --text-display-s: 2rem; --text-section: 1.44rem; --text-title: 1.0625rem; --text-lead: 1.125rem;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1); --ease-in: cubic-bezier(0.7, 0, 0.84, 0); --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --dur-micro: 120ms; --dur-short: 220ms; --dur-long: 420ms;
  --container: 1440px; --gutter: 16px; --gap-columns: 16px; --bar-h: 56px;
  --z-base: 1; --z-raised: 10; --z-dropdown: 100; --z-sticky: 200; --z-sticky-nav: 300; --z-modal: 400; --z-toast: 500; --z-tooltip: 600;

  /* Furrow: manila paper, near-black ink, one tangerine signal (a fill with ink on it), survey colours for the map. */
  --color-paper: oklch(96% 0.011 85); --color-paper-2: oklch(99.5% 0.005 85); --color-paper-3: oklch(92% 0.016 85);
  --color-ink: oklch(18% 0.006 60); --color-ink-2: oklch(28% 0.008 60); --color-muted: oklch(44% 0.012 60); --color-rule: oklch(88% 0.013 85);
  --color-accent: oklch(70% 0.19 40); --color-accent-ink: oklch(18% 0.006 60); --color-accent-soft: oklch(91% 0.05 50); --color-focus: oklch(60% 0.19 40);
  --color-green: oklch(48% 0.11 150); --color-green-soft: oklch(92% 0.04 150);
  --color-contour: oklch(62% 0.07 58); --color-water: oklch(60% 0.05 232); --color-hedge: oklch(50% 0.1 150);
  --color-grid: oklch(90% 0.014 85); --color-sheet: oklch(99.3% 0.004 85);
  --color-backdrop: oklch(18% 0.006 60 / 0.42);
  --edge-lit: oklch(99.5% 0.005 85 / 0.7); --edge-shade: oklch(18% 0.006 60 / 0.12);
  --font-display: "Red Hat Display", "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", ui-sans-serif, sans-serif;
  --font-body: "Red Hat Text", "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", ui-sans-serif, system-ui, sans-serif;
  --font-outlier: "Red Hat Mono", ui-monospace, monospace; /* figures only: dates, times, distances */
  --radius-card: 10px; --radius-entry: 14px; --radius-pill: 6px; --rule-hair: 1px;
  --shadow-card: 0 1px 2px oklch(18% 0.006 60 / 0.08), 0 14px 28px -16px oklch(18% 0.006 60 / 0.28);
  --shadow-lift: 0 1px 1px oklch(18% 0.006 60 / 0.1), 0 2px 4px -1px oklch(18% 0.006 60 / 0.1), 0 24px 44px -20px oklch(18% 0.006 60 / 0.42);
  --tracking-display: -0.035em; --display-weight: 600;
}

/* Night: the same roles re-derived on dark paper, hue held. nav.js sets data-theme; with "auto" the system decides.
   Elevation is lightness and a hairline ring, never a drop shadow. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --color-paper: oklch(19% 0.011 85); --color-paper-2: oklch(23% 0.011 85); --color-paper-3: oklch(27% 0.013 85);
  --color-ink: oklch(94% 0.01 85); --color-ink-2: oklch(86% 0.01 85); --color-muted: oklch(73% 0.013 75); --color-rule: oklch(34% 0.012 85);
  --color-accent: oklch(74% 0.16 40); --color-accent-soft: oklch(33% 0.06 45); --color-focus: oklch(74% 0.16 40);
  --color-green: oklch(74% 0.1 150); --color-green-soft: oklch(31% 0.04 150);
  --color-contour: oklch(50% 0.05 58); --color-water: oklch(58% 0.05 232); --color-hedge: oklch(56% 0.08 150);
  --color-grid: oklch(27% 0.011 85); --color-sheet: oklch(23% 0.011 85);
  --color-backdrop: oklch(10% 0.008 60 / 0.66);
  --edge-lit: oklch(99.5% 0.005 85 / 0.1); --edge-shade: oklch(10% 0.006 60 / 0.3);
  --shadow-card: 0 0 0 1px var(--color-rule); --shadow-lift: 0 0 0 1px var(--color-rule);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --color-paper: oklch(19% 0.011 85); --color-paper-2: oklch(23% 0.011 85); --color-paper-3: oklch(27% 0.013 85);
    --color-ink: oklch(94% 0.01 85); --color-ink-2: oklch(86% 0.01 85); --color-muted: oklch(73% 0.013 75); --color-rule: oklch(34% 0.012 85);
    --color-accent: oklch(74% 0.16 40); --color-accent-soft: oklch(33% 0.06 45); --color-focus: oklch(74% 0.16 40);
    --color-green: oklch(74% 0.1 150); --color-green-soft: oklch(31% 0.04 150);
    --color-contour: oklch(50% 0.05 58); --color-water: oklch(58% 0.05 232); --color-hedge: oklch(56% 0.08 150);
    --color-grid: oklch(27% 0.011 85); --color-sheet: oklch(23% 0.011 85);
    --color-backdrop: oklch(10% 0.008 60 / 0.66);
    --edge-lit: oklch(99.5% 0.005 85 / 0.1); --edge-shade: oklch(10% 0.006 60 / 0.3);
    --shadow-card: 0 0 0 1px var(--color-rule); --shadow-lift: 0 0 0 1px var(--color-rule);
  }
}

/* Two breakpoints for the whole site: 40rem (type and gutters) and 60rem (layout). */
@media (min-width: 40rem) { :root { --gutter: 24px; --gap-columns: 24px; --text-display: 3.25rem; --text-section: 1.728rem; } }
@media (min-width: 60rem) { :root { --gutter: 64px; --gap-columns: 32px; --text-display: 4rem; --bar-h: 64px; } }

/* Base */
*, *::before, *::after { box-sizing: border-box; }
html, body { overflow-x: clip; }
html { -webkit-text-size-adjust: 100%; scrollbar-color: var(--color-muted) var(--color-paper); scroll-padding-top: calc(var(--bar-h) + var(--space-lg)); }
body {
  margin: 0;
  background: var(--color-paper); color: var(--color-ink);
  font-family: var(--font-body); font-size: var(--text-md); line-height: 1.6;
  -webkit-font-smoothing: antialiased; caret-color: var(--color-accent);
}
::selection { background: color-mix(in oklab, var(--color-accent) 24%, transparent); color: var(--color-ink); }
:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }
a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
h1, h2, h3 {
  margin: 0;
  font-family: var(--font-display); font-weight: var(--display-weight); font-synthesis: none;
  letter-spacing: var(--tracking-display); line-height: 1.05;
  overflow-wrap: break-word; min-width: 0; text-wrap: balance;
}
h1 { font-size: var(--text-display); line-height: 1; }
h2 { font-size: var(--text-section); }
h3 { font-size: var(--text-title); line-height: 1.3; letter-spacing: 0; }
p { margin: 0; text-wrap: pretty; }
img { max-width: 100%; }
svg { display: block; }
[hidden] { display: none !important; }
button, input { font: inherit; color: inherit; }
.num { font-family: var(--font-outlier); font-variant-numeric: tabular-nums; }

/* One container: centred, capped, the safe area folded into the gutter (iPhone landscape). */
.container {
  width: 100%; max-width: var(--container); margin-inline: auto;
  padding-inline: max(var(--gutter), env(safe-area-inset-left)) max(var(--gutter), env(safe-area-inset-right));
}

/* Top bar: the wordmark and the menu key (nav.js puts the key here). Sticky, clear of the notch. */
.bar {
  position: sticky; top: 0; z-index: var(--z-sticky-nav);
  padding-top: env(safe-area-inset-top);
  background: var(--color-paper);
  border-bottom: var(--rule-hair) solid var(--color-ink);
}
.bar-in { display: flex; align-items: center; justify-content: space-between; gap: var(--space-md); min-height: var(--bar-h); }
.wordmark {
  display: inline-flex; align-items: baseline; gap: var(--space-xs);
  font: 600 var(--text-lg)/1 var(--font-display); letter-spacing: -0.02em;
  text-decoration: none; white-space: nowrap;
}
.wordmark span { font-size: 0.86em; letter-spacing: 0; }

/* Key: the only button. Moulded, 6px, a lit top edge; .primary is tangerine with ink on it, once per view. */
.key {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-xs);
  min-height: 40px; padding: 0 var(--space-md);
  border: var(--rule-hair) solid var(--color-rule); border-radius: var(--radius-pill);
  background: var(--color-paper-2); color: var(--color-ink);
  font: 500 var(--text-sm)/1 var(--font-body);
  white-space: nowrap; text-decoration: none; cursor: pointer;
  box-shadow: inset 0 1px 0 var(--edge-lit), 0 1px 1px var(--color-rule);
  transition: background-color var(--dur-short) var(--ease-out), transform var(--dur-micro) var(--ease-out);
}
.key.primary {
  background: var(--color-accent); color: var(--color-accent-ink);
  border-color: color-mix(in oklab, var(--color-accent) 78%, var(--color-ink));
  box-shadow: inset 0 1px 0 var(--edge-lit), inset 0 -1px 0 var(--edge-shade);
}
.key.icon { width: 40px; padding: 0; font-size: var(--text-lg); }
.key:active { transform: translateY(1px); }
.key:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }
@media (pointer: coarse) { .key { min-height: 44px; } .key.icon { width: 44px; } }

/* Field: white, a muted edge that never changes width; focus is an inset ring. 16px text, or iOS zooms in. */
.field {
  width: 100%; min-height: 48px; padding: 0 var(--space-md);
  border: var(--rule-hair) solid var(--color-muted); border-radius: var(--radius-pill);
  background: var(--color-paper-2); color: var(--color-ink);
  font: 400 var(--text-md)/1.2 var(--font-body);
}
.field::placeholder { color: var(--color-muted); opacity: 1; }
.field:focus-visible { outline-offset: -2px; }

/* Chip: a filter toggle; aria-pressed carries the state, tangerine when on. Tag: a read-only label on a run. */
.chips { display: flex; flex-wrap: wrap; gap: var(--space-xs); }
.chip {
  display: inline-flex; align-items: center; gap: var(--space-xs); flex: none;
  min-height: 36px; padding: 0 var(--space-sm);
  border: var(--rule-hair) solid var(--color-rule); border-radius: var(--radius-pill);
  background: var(--color-paper-2); color: var(--color-ink);
  font: 500 var(--text-sm)/1 var(--font-body); white-space: nowrap; cursor: pointer;
  transition: background-color var(--dur-short) var(--ease-out), transform var(--dur-micro) var(--ease-out);
}
.chip[aria-pressed="true"] {
  background: var(--color-accent); color: var(--color-accent-ink);
  border-color: color-mix(in oklab, var(--color-accent) 78%, var(--color-ink));
}
.chip:active { transform: translateY(1px); }
.chip .ava { width: 20px; height: 20px; margin: 0 0 0 calc(-1 * var(--space-2xs)); vertical-align: 0; }
@media (pointer: coarse) { .chip { min-height: 40px; } }
.tag {
  display: inline-block; margin: var(--space-2xs) var(--space-2xs) 0 0; padding: 0 var(--space-xs);
  border: var(--rule-hair) solid transparent; border-radius: var(--radius-pill);
  background: var(--color-paper-3); color: var(--color-ink-2);
  font: 500 var(--text-xs)/1.8 var(--font-body);
}
.tag.km { background: transparent; border-color: var(--color-rule); font-family: var(--font-outlier); font-variant-numeric: tabular-nums; }

@media (hover: hover) {
  .key:hover, .chip:hover { background: var(--color-paper-3); }
  .key.primary:hover, .chip[aria-pressed="true"]:hover { background: color-mix(in oklab, var(--color-accent) 88%, var(--color-ink)); }
  .key:disabled:hover { background: var(--color-paper-2); }
  .key.primary:disabled:hover { background: var(--color-accent); }
}

/* Filter rows: a short label, then the chips. Phones: one swipeable line per row, label above. */
.filters { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-sm); }
.filter { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-xs); }
.flabel { font: 500 var(--text-sm)/1.4 var(--font-body); color: var(--color-muted); }
/* From 40rem the labels share one column, as wide as the longest label ("語言 Language"), never wrapped. */
@media (min-width: 40rem) {
  .filters, .menu .prefs { grid-template-columns: max-content minmax(0, 1fr); align-items: start; column-gap: var(--space-md); }
  .filter { display: contents; }
  .flabel { line-height: 36px; white-space: nowrap; }
}
@media (min-width: 40rem) and (pointer: coarse) { .flabel { line-height: 40px; } }
@media (max-width: 39.99rem) {
  .filters .chips {
    flex-wrap: nowrap; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none;
    margin-inline: calc(-1 * max(var(--gutter), env(safe-area-inset-left))) calc(-1 * max(var(--gutter), env(safe-area-inset-right)));
    padding-inline: max(var(--gutter), env(safe-area-inset-left)) max(var(--gutter), env(safe-area-inset-right));
    scroll-padding-inline: var(--gutter);
  }
  .filters .chips::-webkit-scrollbar { display: none; }
}

/* Club logo: a small round mark before a run's title, sized to the text it sits in. */
.ava {
  width: 1.25em; height: 1.25em; border-radius: 50%; flex: none;
  object-fit: cover; vertical-align: -0.28em; margin-right: 0.4em;
  background: var(--color-paper-3); border: var(--rule-hair) solid var(--color-rule);
}

/* Language: in bilingual mode the English follows the Chinese as a quieter .minor; inside .stack it takes its own line. */
.minor { margin-left: 0.5em; font: 400 0.86em/1.35 var(--font-body); letter-spacing: 0; color: var(--color-muted); }
.stack .minor { display: block; margin: var(--space-2xs) 0 0; }
.key .minor, .chip .minor { color: inherit; font-weight: 400; } /* never grey on a filled control */

/* Dialog: the waterproof notebook card. Ink head with the date and the time, notebook-grid body, step keys at the foot.
   Phones: a bottom sheet clear of the home indicator. */
dialog {
  width: min(30rem, 100% - 2 * var(--space-lg)); max-width: none;
  max-height: calc(100dvh - 2 * var(--space-lg));
  padding: 0; border: 0; border-radius: var(--radius-entry); overflow: auto;
  background: var(--color-paper-2); color: var(--color-ink);
  box-shadow: 0 0 0 1px var(--color-ink), var(--shadow-lift);
}
dialog::backdrop { background: var(--color-backdrop); }
.entry-head {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; gap: var(--space-md);
  padding: var(--space-md) var(--space-md) var(--space-lg) var(--space-lg); background: var(--color-ink); color: var(--color-paper);
}
.entry-head .day { display: block; font: 500 var(--text-sm)/1.4 var(--font-outlier); }
.entry-head .time { display: block; margin-top: var(--space-xs); font: 600 2.75rem/1 var(--font-display); letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.entry-body {
  display: grid; gap: var(--space-sm); padding: var(--space-lg);
  background: linear-gradient(var(--color-grid) 1px, transparent 1px) 0 0 / 8px 8px,
              linear-gradient(90deg, var(--color-grid) 1px, transparent 1px) 0 0 / 8px 8px, var(--color-paper-2);
}
.entry-body h3 { font-size: var(--text-lg); line-height: 1.35; letter-spacing: -0.01em; }
.entry .actions {
  display: grid; gap: var(--space-sm);
  padding: var(--space-md) var(--space-lg) var(--space-lg);
  border-top: var(--rule-hair) solid var(--color-ink);
}
.entry .actions .key { min-height: 52px; font-size: var(--text-md); }
.entry .actions:not(:has(> :not([hidden]))) { display: none; } /* a past run has nothing to add */
@media (max-width: 39.99rem) {
  dialog {
    width: 100%; max-height: calc(100dvh - env(safe-area-inset-top) - var(--space-xl));
    margin: auto 0 0; border-radius: var(--radius-entry) var(--radius-entry) 0 0;
  }
  .entry .actions { padding-bottom: calc(var(--space-lg) + env(safe-area-inset-bottom)); }
}

/* Menu: the key in the bar opens a sheet under the bar: ruled page links, then the theme and language switches.
   Markup comes from nav.js. */
.menu-toggle span, .menu-toggle span::before, .menu-toggle span::after {
  content: ""; display: block; width: 18px; height: 2px; background: var(--color-ink); position: relative;
  transition: transform var(--dur-short) var(--ease-in-out), opacity var(--dur-short) var(--ease-in-out);
}
.menu-toggle span::before { position: absolute; top: -6px; }
.menu-toggle span::after { position: absolute; top: 6px; }
.menu-toggle[aria-expanded="true"] span { background: transparent; }
.menu-toggle[aria-expanded="true"] span::before { transform: translateY(6px) rotate(45deg); }
.menu-toggle[aria-expanded="true"] span::after { transform: translateY(-6px) rotate(-45deg); }
.menu {
  position: fixed; inset: 0; z-index: var(--z-sticky);
  overflow-y: auto; overscroll-behavior: contain;
  padding: calc(env(safe-area-inset-top) + var(--bar-h) + var(--space-xl)) max(var(--gutter), env(safe-area-inset-right)) calc(var(--space-2xl) + env(safe-area-inset-bottom)) max(var(--gutter), calc((100% - var(--container)) / 2 + var(--gutter)), env(safe-area-inset-left));
  background: var(--color-paper);
}
.menu > * { max-width: 32rem; }
.menu a {
  display: block; padding-block: var(--space-sm);
  border-bottom: var(--rule-hair) solid var(--color-rule);
  font: 500 var(--text-md)/1.5 var(--font-body); /* a step under the wordmark: links, not headlines */
  text-decoration: none;
}
.menu a[aria-current="page"] { text-decoration: underline 3px var(--color-accent); text-underline-offset: 0.2em; }
.menu .prefs { display: grid; gap: var(--space-md); margin-top: var(--space-xl); }
@media (hover: hover) { .menu a:hover { background: var(--color-paper-3); } }
html:has(> body.menu-open) { overflow-y: hidden; }

@media (prefers-reduced-motion: no-preference) {
  dialog[open] { animation: lift var(--dur-long) var(--ease-out); }
  @keyframes lift { from { opacity: 0; transform: translateY(var(--space-md)); } }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}
