/* shadcn/ui default neutral — https://ui.shadcn.com/docs/theming */
@font-face {
  font-family: Geist;
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url("assets/fonts/geist-sans-latin-wght.woff2") format("woff2");
}

@font-face {
  font-family: "Geist Mono";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url("assets/fonts/geist-mono-latin-wght.woff2") format("woff2");
}

:root {
  --font-sans:
    Geist, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", ui-sans-serif, system-ui, sans-serif;
  --font-mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --radius: 0.625rem;
  --radius-sm: calc(var(--radius) * 0.6);
  --radius-md: calc(var(--radius) * 0.8);
  --radius-lg: var(--radius);

  --background: oklch(1 0 0);
  --foreground: oklch(0.145 0 0);
  --card: oklch(1 0 0);
  --card-foreground: oklch(0.145 0 0);
  --popover: oklch(1 0 0);
  --popover-foreground: oklch(0.145 0 0);
  --primary: oklch(0.205 0 0);
  --primary-foreground: oklch(0.985 0 0);
  --secondary: oklch(0.97 0 0);
  --secondary-foreground: oklch(0.205 0 0);
  --muted: oklch(0.97 0 0);
  --muted-foreground: oklch(0.556 0 0);
  --accent: oklch(0.97 0 0);
  --accent-foreground: oklch(0.205 0 0);
  --destructive: oklch(0.577 0.245 27.325);
  --border: oklch(0.922 0 0);
  --input: oklch(0.922 0 0);
  --ring: oklch(0.708 0 0);
  --readable-muted: color-mix(in oklab, var(--foreground) 70%, var(--muted-foreground));

  --container-px: 1rem;
  --measure: 40rem;
  --figure: 36rem;
  --touch: 2.75rem;
  --space: 0.75rem;
  --space-section: 2.5rem;
}

.dark {
  --background: oklch(0.145 0 0);
  --foreground: oklch(0.985 0 0);
  --card: oklch(0.205 0 0);
  --card-foreground: oklch(0.985 0 0);
  --popover: oklch(0.205 0 0);
  --popover-foreground: oklch(0.985 0 0);
  --primary: oklch(0.922 0 0);
  --primary-foreground: oklch(0.205 0 0);
  --secondary: oklch(0.269 0 0);
  --secondary-foreground: oklch(0.985 0 0);
  --muted: oklch(0.269 0 0);
  --muted-foreground: oklch(0.708 0 0);
  --accent: oklch(0.269 0 0);
  --accent-foreground: oklch(0.985 0 0);
  --destructive: oklch(0.704 0.191 22.216);
  --border: oklch(1 0 0 / 10%);
  --input: oklch(1 0 0 / 15%);
  --ring: oklch(0.556 0 0);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

body {
  margin: 0;
  color: var(--foreground);
  background: var(--background);
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.625;
  letter-spacing: -0.011em;
}

a {
  color: var(--foreground);
}

button {
  appearance: none;
  font: inherit;
  color: inherit;
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

:is(a, button, summary, .skip):focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}

.kicker,
.live,
.mark,
.name,
footer {
  color: var(--readable-muted);
}

/* page shell */
.container {
  width: 100%;
  margin-inline: auto;
  padding-inline: var(--container-px);
  padding-block: 1.25rem 5rem;
}

@media (min-width: 40rem) {
  .container {
    max-width: 40rem;
  }
}
@media (min-width: 48rem) {
  .container {
    max-width: 48rem;
  }
}
@media (min-width: 64rem) {
  .container {
    max-width: 64rem;
    --container-px: 2rem;
  }
}
@media (min-width: 80rem) {
  .container {
    max-width: 80rem;
  }
}
@media (min-width: 96rem) {
  .container {
    max-width: 96rem;
  }
}

/* reading column */
.measure {
  width: 100%;
  max-width: var(--measure);
  margin-inline: auto;
}

.measure > * + *,
.measure section > * + * {
  margin-top: var(--space);
}
.measure > section {
  margin-top: var(--space-section);
}

.skip {
  position: absolute;
  inset-inline-start: var(--container-px);
  top: 0.5rem;
  z-index: 1;
  padding: 0.4rem 0.7rem;
  background: var(--primary);
  color: var(--primary-foreground);
  border-radius: var(--radius-sm);
  text-decoration: none;
  transform: translateY(-200%);
}

.skip:focus {
  transform: none;
}

h1,
h2,
h3 {
  text-wrap: balance;
  font-weight: 600;
  letter-spacing: -0.02em;
}

h1 {
  margin: 0;
  font-size: 1.875rem;
  line-height: 1.2;
  letter-spacing: -0.025em;
}

h2 {
  font-size: 1.25rem;
}
h3 {
  font-size: 1rem;
}

p {
  text-wrap: pretty;
}

.kicker {
  margin: 0 0 0.55rem;
  font-size: 0.8125rem;
}

code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: var(--muted);
  padding: 0.05em 0.3em;
  border-radius: var(--radius-sm);
  word-break: normal;
  overflow-wrap: break-word;
}

ol,
ul {
  margin: 0;
  padding-inline-start: 1.25rem;
}

ol li + li,
ul li + li {
  margin-top: 0.4rem;
}

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.1rem;
  margin-top: 0.85rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
  font-size: 0.875rem;
}

.nav a {
  display: inline-flex;
  align-items: center;
  min-height: var(--touch);
  color: var(--readable-muted);
  text-decoration: none;
}

.nav a[aria-current="page"] {
  color: var(--foreground);
  font-weight: 600;
}

/* figure */
figure {
  width: min(100%, var(--figure));
  margin-inline: auto;
}

figure a {
  display: block;
  overflow: hidden;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

figure img {
  display: block;
  width: 100%;
  height: auto;
}

figcaption {
  margin-top: 0.4rem;
  color: var(--muted-foreground);
  font-size: 0.75rem;
  line-height: 1.45;
  text-align: center;
}

/* surfaces */
.card,
.glossary,
.shots {
  background: var(--card);
  color: var(--card-foreground);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.card {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.85rem 1rem;
}

.rail {
  list-style: none;
  padding: 0;
  margin: 0;
  counter-reset: rail;
}

.rail li {
  position: relative;
  margin: 0;
  padding: 0.15rem 0 1.15rem 2.15rem;
}

.rail li:last-child {
  padding-bottom: 0;
}

.rail li + li::before {
  content: "";
  position: absolute;
  inset-inline-start: 0.7rem;
  top: -0.85rem;
  bottom: calc(100% - 0.35rem);
  width: 1px;
  background: var(--border);
}

.rail li::after {
  counter-increment: rail;
  content: counter(rail);
  position: absolute;
  inset-inline-start: 0;
  top: 0.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.4rem;
  height: 1.4rem;
  border: 1px solid var(--border);
  border-radius: calc(infinity * 1px);
  background: var(--background);
  color: var(--readable-muted);
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 500;
  line-height: 1;
}

.rail strong {
  display: block;
  font-weight: 600;
}

.rail-branch {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.55rem;
}

@media (min-width: 36rem) {
  .rail-branch {
    grid-template-columns: 1fr 1fr;
  }
}

.rail-branch li {
  margin: 0;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
}

.rail-branch strong {
  display: block;
  font-weight: 600;
}

[role="tablist"] {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: var(--space);
}

[role="tab"] {
  min-height: var(--touch);
  padding: 0.35rem 0.45rem;
  border: 0;
  border-bottom: 1px solid transparent;
  background: transparent;
  color: var(--readable-muted);
  font-size: 0.9375rem;
}

[role="tab"][aria-selected="true"] {
  color: var(--foreground);
  border-bottom-color: var(--foreground);
}

[role="tabpanel"] {
  line-height: 1.75;
}

[role="tabpanel"] p + p {
  margin-top: 0.7rem;
}

.mark {
  font-size: 0.8125rem;
}

.shots {
  padding: 0;
  list-style: none;
}

.shots li {
  margin: 0;
}

.shots button {
  display: block;
  width: 100%;
  min-height: var(--touch);
  padding: 0.75rem 1rem;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: transparent;
  text-align: left;
  font-size: 0.9375rem;
}

.shots li:last-child button {
  border-bottom: 0;
}

.shots button[aria-pressed="true"] {
  background: var(--accent);
  color: var(--accent-foreground);
}

.live {
  min-height: 1.4em;
  font-size: 0.875rem;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.filters button {
  min-height: var(--touch);
  padding: 0 0.85rem;
  border: 1px solid var(--input);
  border-radius: calc(infinity * 1px);
  background: var(--card);
  color: var(--readable-muted);
  font-size: 0.8125rem;
}

.filters button[aria-pressed="true"] {
  color: var(--primary-foreground);
  background: var(--primary);
  border-color: var(--primary);
}

.glossary details {
  border-bottom: 1px solid var(--border);
}
.glossary details:last-child {
  border-bottom: 0;
}

.glossary summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: var(--touch);
  padding: 0.55rem 0.95rem;
  font-weight: 600;
  list-style: none;
}

.name {
  margin-inline-start: auto;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 400;
}

.glossary summary::-webkit-details-marker {
  display: none;
}

.glossary details p {
  margin: 0;
  padding: 0 0.95rem 0.85rem;
  font-size: 0.9375rem;
}

footer {
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.875rem;
}

footer p {
  margin: 0;
}

@media print {
  body {
    background: var(--background);
  }
  .container {
    max-width: none;
    padding: 0;
  }
  .skip,
  .nav {
    display: none;
  }
  figure {
    break-inside: avoid;
  }
}
