/* AI 寫的程式要過四道關卡:水泥灰、柏油黑、柵欄紅白、指示牌藍 */

:root {
  color-scheme: light dark;
  --concrete: #e2e1dc;   /* 水泥地:頁面底色 */
  --ink: #17181b;        /* 內文 */
  --soft: #474a50;       /* 次要文字 */
  --rule: #b4b3ad;       /* 分隔線 */
  --red: #c41f19;        /* 柵欄紅 */
  --red-text: #a81812;   /* 紅字(淺底) */
  --blue: #1450b4;       /* 指示牌藍 */
  --link: #1450b4;
  --asphalt: #24262a;    /* 柏油:流程圖底 */
  --asphalt-ink: #f1f0ec;
  --asphalt-soft: #b9bbc0;
  --plate: #ffffff;      /* 牌子 */
  --plate-ink: #17181b;
  --track: #cfcec8;      /* 圖表軌道 */
  --post: #24262a;       /* 柵欄柱 */

  --font: "Overpass", "Chiron GoRound TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
  --stripe: repeating-linear-gradient(-55deg, var(--red) 0 22px, #fff 22px 44px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --concrete: #16171a;
    --ink: #edece7;
    --soft: #a9abb1;
    --rule: #3a3d43;
    --red: #e2372f;
    --red-text: #ff7a70;
    --link: #8ab6ff;
    --asphalt: #26292e;
    --track: #2e3136;
    --post: #5a5e66;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--concrete);
  color: var(--ink);
  font-family: var(--font);
  font-size: 1.0625rem;
  line-height: 1.8;
}

a { color: var(--link); text-underline-offset: 0.2em; }
a:hover { color: var(--red-text); }

:focus-visible {
  outline: 3px solid var(--link);
  outline-offset: 3px;
  border-radius: 2px;
}

h1, h2, h3 { line-height: 1.2; margin: 0; font-weight: 900; }
p { margin: 0 0 1em; }
ol, ul { margin: 0; padding: 0; list-style: none; }

.wrap {
  width: min(100% - 2.5rem, 68rem);
  margin-inline: auto;
}

.sr {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ── 圓形指示牌(關卡編號) ── */
.sign {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  border: 3px solid #fff;
  box-shadow: 0 0 0 2px var(--blue);
  font-weight: 900;
  font-size: 1.75rem;
  line-height: 1;
  padding-top: 0.12em; /* Overpass 數字視覺置中 */
}
.sign-s {
  width: 1.6rem;
  height: 1.6rem;
  font-size: 0.9rem;
  border-width: 2px;
  box-shadow: 0 0 0 1px var(--blue);
}

/* ── Hero ── */
.hero {
  position: relative;
  overflow: hidden;
  padding: 1.5rem 0 0;
}
.home {
  display: inline-block;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--ink);
}
.hero h1 {
  margin-top: clamp(2.5rem, 8vw, 5.5rem);
  font-size: clamp(2.6rem, 9.2vw, 6.75rem);
  letter-spacing: -0.01em;
  line-height: 1.08;
}
.hero-sub {
  max-width: 34em;
  margin: 1.5rem 0 0;
  font-size: clamp(1.05rem, 2.2vw, 1.3rem);
  color: var(--soft);
}

.gate {
  position: relative;
  height: clamp(3.25rem, 7vw, 4.75rem);
  margin-top: clamp(2.5rem, 7vw, 5rem);
}
.gate-post {
  position: absolute;
  left: max(1.25rem, calc((100% - 68rem) / 2));
  bottom: 0;
  width: clamp(1.5rem, 3vw, 2.25rem);
  height: 100%;
  background: var(--post);
  border-radius: 4px 4px 0 0;
  z-index: 1;
}
.gate-post::after { /* 軸心 */
  content: "";
  position: absolute;
  left: 50%; top: 32%;
  width: 46%; aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: var(--concrete);
}
.gate-arm {
  position: absolute;
  left: max(1.25rem, calc((100% - 68rem) / 2));
  right: -2rem;
  top: 12%;
  height: 40%;
  background: var(--stripe);
  border-block: 2px solid var(--post);
  transform-origin: clamp(0.75rem, 1.5vw, 1.125rem) 50%;
  animation: gate-down 1.1s cubic-bezier(.3, 1.4, .5, 1) 0.25s both;
}
@keyframes gate-down {
  from { transform: rotate(-9deg); }
  to   { transform: rotate(0); }
}

/* ── 來源說明 ── */
.intro { padding: clamp(2.5rem, 6vw, 4.5rem) 0; }
.intro h2 { font-size: clamp(1.5rem, 3vw, 2rem); margin-bottom: 1.25rem; }
.intro-cols { display: grid; gap: 0 3rem; }
@media (min-width: 52rem) {
  .intro-cols { grid-template-columns: 1fr 1fr; }
}

/* ── 流程圖:一條路、四道關卡 ── */
.road {
  background: var(--asphalt);
  color: var(--asphalt-ink);
  padding: clamp(2.5rem, 6vw, 4.5rem) 0;
}
.road h2 { font-size: clamp(1.9rem, 4.5vw, 3rem); }
.road-hint { margin: 0.75rem 0 2.25rem; color: var(--asphalt-soft); }
.road-note { margin: 2rem 0 0; font-size: 0.9rem; color: var(--asphalt-soft); }

.lane {
  position: relative;
  display: grid;
  gap: 2.25rem;
}
/* 路面標線 */
.lane::before {
  content: "";
  position: absolute;
  left: calc(1.75rem - 2px);
  top: 0; bottom: 0;
  width: 4px;
  background: repeating-linear-gradient(to bottom, #fff 0 16px, transparent 16px 30px);
  opacity: 0.55;
}
.station {
  position: relative;
  display: grid;
  grid-template-columns: 3.5rem 1fr;
  column-gap: 1rem;
  align-items: start;
}
.station .sign { grid-row: 1 / span 3; position: relative; }
.station h3 { font-size: 1.5rem; padding-top: 0.35rem; }
.ask { margin: 0.2rem 0 0.9rem; color: var(--asphalt-soft); font-size: 0.98rem; line-height: 1.5; }
.plates { display: grid; gap: 0.5rem; grid-column: 2; }

.plate {
  display: block;
  padding: 0.6rem 0.8rem 0.5rem;
  background: var(--plate);
  color: var(--plate-ink);
  border-radius: 6px;
  border-left: 8px solid var(--red);
  font-weight: 900;
  font-size: 1.08rem;
  line-height: 1.25;
  text-decoration: none;
  transition: transform 0.15s ease;
}
.plate small {
  display: block;
  margin-top: 0.15rem;
  font-weight: 400;
  font-size: 0.8rem;
  color: #50535a;
}
.plate:hover { color: var(--plate-ink); transform: translateX(4px); }
.road :focus-visible { outline-color: #fff; }

@media (min-width: 56rem) {
  .lane { grid-template-columns: repeat(4, 1fr); gap: 1.5rem; }
  .lane::before {
    left: 0; right: 0; bottom: auto;
    top: calc(1.75rem - 2px);
    width: auto; height: 4px;
    background: repeating-linear-gradient(to right, #fff 0 22px, transparent 22px 40px);
  }
  .station { display: block; }
  .station h3 { padding-top: 1.1rem; font-size: 1.6rem; }
  .ask { min-height: 3em; }
}

/* ── 各關卡的工具說明 ── */
.stage { padding: clamp(3rem, 7vw, 5rem) 0 0; }
.stage-head {
  display: flex;
  gap: 1.1rem;
  align-items: flex-start;
  padding-top: 1.5rem;
  border-top: 14px solid transparent;
  border-image: var(--stripe) 14;
}
.stage-head h2 { font-size: clamp(1.7rem, 4vw, 2.5rem); }
.stage-head p { margin: 0.4rem 0 0; color: var(--soft); max-width: 36em; }

.tools { margin-top: 1.5rem; }
.tool {
  display: grid;
  gap: 0.5rem 2rem;
  padding: 1.4rem 0;
  border-top: 2px solid var(--ink);
  scroll-margin-top: 1rem;
}
.tool + .tool { border-top: 1px solid var(--rule); }
.tool h3 { font-size: 1.45rem; }
.tool h3 a { color: var(--ink); text-decoration-thickness: 2px; text-decoration-color: var(--red); }
.tool h3 a:hover { color: var(--red-text); }
.tool p { margin: 0; max-width: 38em; }
.tool .differs {
  margin-top: 0.6rem;
  padding-left: 0.9rem;
  border-left: 4px solid var(--blue);
  color: var(--soft);
}
.tool:target { background: color-mix(in srgb, var(--blue) 9%, transparent); box-shadow: 0 0 0 0.75rem color-mix(in srgb, var(--blue) 9%, transparent); }

.spec { margin: 0.4rem 0 0; display: flex; flex-wrap: wrap; gap: 0.25rem 1.5rem; font-size: 0.92rem; }
.spec div { display: flex; gap: 0.45rem; min-width: 0; }
.spec dt { color: var(--soft); flex: none; }
.spec dd { margin: 0; font-weight: 700; overflow-wrap: anywhere; }

@media (min-width: 56rem) {
  .tool { grid-template-columns: 17rem 1fr 15rem; align-items: start; }
  .tool .body { grid-column: 2; }
  .tool .differs { grid-column: 2; }
  .tool .spec { grid-column: 3; grid-row: 1 / span 2; margin: 0.2rem 0 0; display: grid; gap: 0.2rem; }
  .tool .spec dt { width: 2.6em; }
}

/* ── 圖表共用 ── */
.chart-sec { padding: clamp(3.5rem, 8vw, 6rem) 0 0; }
.chart-sec h2 { font-size: clamp(1.7rem, 4vw, 2.5rem); }
.chart-lede { margin: 0.8rem 0 1.5rem; max-width: 40em; color: var(--soft); }
.chart-foot { margin: 1rem 0 0; font-size: 0.9rem; color: var(--soft); }

/* 星數 */
.sorter { display: inline-flex; margin-bottom: 1.25rem; border: 2px solid var(--ink); border-radius: 6px; overflow: hidden; }
.sorter button {
  font: inherit;
  font-weight: 700;
  font-size: 0.95rem;
  padding: 0.45rem 1rem;
  min-height: 2.75rem;
  background: transparent;
  color: var(--ink);
  border: 0;
  cursor: pointer;
}
.sorter button + button { border-left: 2px solid var(--ink); }
.sorter button[aria-pressed="true"] { background: var(--ink); color: var(--concrete); }
.sorter button:focus-visible { outline-offset: -5px; outline-color: var(--red); }

.bars li {
  display: grid;
  grid-template-columns: 1.6rem 1fr auto;
  grid-template-areas: "sign name num" "bar bar bar";
  gap: 0.3rem 0.6rem;
  align-items: center;
  padding: 0.5rem 0;
}
.bars .sign { grid-area: sign; }
.b-name { grid-area: name; font-weight: 700; line-height: 1.3; }
.b-num { grid-area: num; font-weight: 900; font-variant-numeric: tabular-nums; }
.b-track { grid-area: bar; height: 0.9rem; background: var(--track); border-radius: 2px; }
.b-track i { display: block; height: 100%; min-width: 3px; background: var(--red); border-radius: 2px; }

@media (min-width: 46rem) {
  .bars li {
    grid-template-columns: 1.6rem 15rem 1fr 4.5rem;
    grid-template-areas: "sign name bar num";
    padding: 0.35rem 0;
  }
  .b-num { text-align: right; }
  .b-track { height: 1.15rem; }
}

/* 存在多久 */
.ages li, .a-axis {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: "name date" "bar bar";
  gap: 0.25rem 0.6rem;
  align-items: center;
  padding: 0.45rem 0;
}
.a-name { grid-area: name; font-weight: 700; line-height: 1.3; }
.a-date { grid-area: date; color: var(--soft); font-variant-numeric: tabular-nums; font-size: 0.92rem; }
.a-track {
  grid-area: bar;
  position: relative;
  height: 0.9rem;
  background:
    linear-gradient(to right, var(--rule) 0 1px, transparent 1px) 0 0 / 26.667% 100%,
    var(--track);
  border-radius: 2px;
}
.a-track i {
  position: absolute;
  top: 0; bottom: 0;
  right: 0.8%;
  min-width: 5px;
  background: var(--blue);
  border-radius: 2px;
}
.a-axis { padding: 0; }
.a-axis > span:not(.a-ticks) { display: none; }
.a-ticks { grid-area: bar; position: relative; height: 1.6rem; font-size: 0.85rem; color: var(--soft); }
.a-ticks b { position: absolute; top: 0.1rem; font-weight: 400; }

@media (prefers-color-scheme: dark) {
  .a-track i { background: #4f8cf0; }
}

@media (min-width: 46rem) {
  .ages li, .a-axis {
    grid-template-columns: 15rem 4.5rem 1fr;
    grid-template-areas: "name date bar";
    padding: 0.3rem 0;
  }
  .a-axis { padding: 0; }
  .a-axis > span:not(.a-ticks) { display: block; }
  .a-track { height: 1.15rem; }
}

/* 授權 */
.lic { display: grid; gap: 1.25rem; }
.lic-zone {
  padding: 1.4rem 1.4rem 1.5rem;
  border: 3px solid var(--ink);
  border-radius: 8px;
}
.lic-copyleft { border-style: dashed; }
.lic-zone h3 { font-size: 1.3rem; display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }
.lic-zone h3 b { font-size: 3rem; line-height: 0.9; }
.lic-zone > p { margin: 0.6rem 0 1rem; color: var(--soft); }
.lic-list { margin: 0; }
.lic-list div { padding: 0.55rem 0; border-top: 1px solid var(--rule); }
.lic-list dt { font-weight: 900; }
.lic-list dd { margin: 0; }
.lic-cells { display: flex; gap: 5px; margin-top: 1.1rem; }
.lic-cells i { width: 1.5rem; height: 1.5rem; border-radius: 3px; background: var(--blue); }
.lic-copyleft .lic-cells i { background: var(--red); }

@media (min-width: 52rem) {
  .lic { grid-template-columns: 3fr 2fr; align-items: stretch; }
  .lic-zone { display: flex; flex-direction: column; }
  .lic-cells { margin-top: auto; padding-top: 1.1rem; }
}

/* ── Reference ── */
.refs { padding: clamp(3.5rem, 8vw, 6rem) 0 3rem; }
.refs h2 { font-size: clamp(1.5rem, 3vw, 2rem); margin-bottom: 0.9rem; }
.refs p { color: var(--soft); max-width: 40em; }
.refs ol { list-style: decimal; padding-left: 1.6rem; }
.refs li { padding: 0.2rem 0; overflow-wrap: anywhere; }
@media (min-width: 52rem) {
  .refs ol { columns: 2; column-gap: 3rem; }
  .refs li { break-inside: avoid; }
}

/* ── 頁尾 ── */
.foot { text-align: center; padding-bottom: 2.5rem; }
.stripe { height: 14px; background: var(--stripe); margin-bottom: 2rem; }
.foot a { font-weight: 700; color: var(--ink); }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .gate-arm { animation: none; }
  .plate { transition: none; }
  .plate:hover { transform: none; }
}
