:root {
  color-scheme: light;
  /* 月台 */
  --platform: #d9dddb;
  --platform-2: #cdd2cf;
  --concrete-line: #b7bdb9;
  --ink: #1b1e23;
  --ink-2: #3f444c;
  --ink-3: #50555c;
  --white: #f9faf8;
  --sign-band: #23364a;
  --tactile: #e8b923;
  /* 票種（硬紙板顏色） */
  --research: #f2bfcc;   /* 復興粉 */
  --project: #b5d3ea;    /* 普快藍 */
  --experience: #f4c88b; /* 莒光橘 */
  --skill: #cbe3b3;      /* 區間綠 */
  --research-ink: #8a2440;
  --project-ink: #1f4f7a;
  --experience-ink: #7a4a0c;
  --skill-ink: #35611d;
  /* 唯一的紅：剪票鋼印 */
  --stamp: #c62a1f;

  --zh: "Noto Sans TC", system-ui, sans-serif;
  --en: "Barlow Semi Condensed", "Noto Sans TC", sans-serif;
  --dot: "DotGothic16", "Noto Sans TC", monospace;
  --ease: cubic-bezier(.16, 1, .3, 1);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
html { scrollbar-color: var(--ink-3) var(--platform); }
body {
  background-color: var(--platform);
  /* 水泥細砂 */
  background-image:
    radial-gradient(rgba(30, 40, 38, .08) 1px, transparent 1.2px),
    radial-gradient(rgba(255, 255, 255, .35) 1px, transparent 1.2px);
  background-size: 7px 7px, 11px 11px;
  background-position: 0 0, 3px 5px;
  color: var(--ink);
  font-family: var(--zh);
  font-size: 17px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}
::selection { background: var(--tactile); color: var(--ink); }
a { color: inherit; text-underline-offset: .22em; text-decoration-thickness: 1px; }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; border-radius: 4px; }

/* ---------- 路線列 ---------- */
.route { border-bottom: 1px solid var(--concrete-line); background: color-mix(in srgb, var(--white) 55%, transparent); overflow-x: auto; scrollbar-width: none; }
.route::-webkit-scrollbar { display: none; }
.route-line {
  list-style: none; margin: 0 auto; padding: 14px 24px 12px; display: flex; gap: 0; min-width: max-content;
  max-width: 1320px; position: relative;
}
.route-line li { position: relative; padding: 0 40px 0 0; display: flex; flex-direction: column; gap: 2px; }
.route-line li::before { /* 站點 */
  content: ""; width: 11px; height: 11px; border-radius: 50%; background: var(--white);
  border: 2.5px solid var(--ink); margin-bottom: 6px; position: relative; z-index: 1;
}
.route-line li::after { /* 軌道 */
  content: ""; position: absolute; top: 5px; left: 11px; right: 0; height: 2.5px; background: var(--ink);
}
.route-line li.is-next::before { background: var(--tactile); }
.route-line li.is-next::after { display: none; }
.stop-name { font-weight: 700; font-size: 15px; white-space: nowrap; }
.stop-time { font-family: var(--dot); font-size: 13px; color: var(--ink-3); letter-spacing: .04em; }
.is-next .stop-time { color: var(--ink-2); }

/* ---------- 月台（第一畫面） ---------- */
.platform { position: relative; min-height: calc(100svh - var(--route-h, 98px)); display: grid; }
.stage {
  position: relative; grid-area: 1 / 1; min-height: calc(100svh - var(--route-h, 98px)); overflow: hidden;
  cursor: grab; touch-action: pan-y; user-select: none; outline: none; isolation: isolate;
}
.stage.is-dragging { cursor: grabbing; }
.stage:focus-visible { box-shadow: inset 0 0 0 3px var(--ink); }
.cloud { position: absolute; inset: 0; }

/* 月台邊緣的導盲磚黃線 */
.platform::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 14px; pointer-events: none;
  background:
    radial-gradient(circle, rgba(0, 0, 0, .14) 1.6px, transparent 2px) 0 0 / 9px 7px,
    var(--tactile);
  box-shadow: 0 -1px 0 rgba(0, 0, 0, .08);
}

/* ---------- 站名牌 ---------- */
.sign {
  grid-area: 1 / 1; align-self: start; justify-self: start; position: relative; z-index: 5;
  margin: clamp(20px, 4vw, 48px) 0 0 clamp(16px, 4vw, 56px); width: min(440px, calc(100% - 32px));
  pointer-events: none;
}
.sign > * { pointer-events: auto; }
.sign-plate {
  background: var(--white); border: 2px solid var(--ink); border-bottom: 0;
  border-radius: 6px 6px 0 0; padding: 18px 24px 16px;
  box-shadow: 0 18px 40px -18px rgba(40, 32, 20, .35);
}
.sign h1 { margin: 0; line-height: 1; }
.sign-zh { display: block; font-weight: 900; font-size: clamp(52px, 7vw, 84px); letter-spacing: .06em; }
.sign-en { display: block; font-family: var(--en); font-weight: 600; font-size: clamp(17px, 1.6vw, 21px); letter-spacing: .32em; margin-top: 10px; color: var(--ink-2); }
.sign-line { margin: 14px 0 0; font-size: 16px; line-height: 1.7; color: var(--ink-2); text-wrap: pretty; }
.sign-band {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  background: var(--sign-band); color: #f4f1e8; border: 2px solid var(--ink); border-radius: 0 0 6px 6px;
  padding: 7px 16px; font-weight: 700; font-size: 14px; letter-spacing: .06em;
}
.sign-band span { display: inline-flex; align-items: center; gap: 6px; }
.sign-band svg { width: 14px; height: 14px; flex: none; }
.windows { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.windows a {
  text-decoration: none; font-weight: 700; font-size: 15px; padding: 9px 18px; min-height: 44px; display: inline-flex; align-items: center;
  background: var(--white); border: 2px solid var(--ink); border-radius: 4px;
  outline: 1px solid var(--ink); outline-offset: -6px; /* 售票口的內框 */
  box-shadow: 0 6px 16px -8px rgba(20, 28, 26, .45);
  transition: transform .18s var(--ease), box-shadow .18s var(--ease), background .18s var(--ease);
}
.windows a:hover { transform: translateY(-2px); background: #fff; box-shadow: 0 12px 22px -10px rgba(20, 28, 26, .5); }
.windows a:active { transform: translateY(1px); box-shadow: 0 3px 8px -6px rgba(20, 28, 26, .5); }
.windows a:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; }

/* ---------- 車票 ---------- */
/* --k 由 main.js 依景深設定（0 遠、1 近）。票永遠不透明，遠的票往月台色混、字也一起淡，不會互相透字。 */
.ticket {
  --c: var(--project); --ci: var(--project-ink); --k: 1;
  --paper: color-mix(in srgb, var(--c) calc(var(--k) * 100%), var(--platform-2));
  --tx: color-mix(in srgb, var(--ink) calc(var(--k) * 100%), var(--platform-2));
  --tx-ci: color-mix(in srgb, var(--ci) calc(var(--k) * 100%), var(--platform-2));
  position: absolute; left: 50%; top: 50%; width: 272px; height: 148px; padding: 0;
  border: 0; border-radius: 5px; cursor: pointer; text-align: left; font: inherit; color: var(--tx);
  background: var(--paper);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .55) inset, 0 -1px 0 rgba(0, 0, 0, .08) inset,
    0 10px 22px -10px rgba(25, 35, 32, .45), 0 2px 4px rgba(25, 35, 32, .12);
  will-change: transform;
  transition: box-shadow .3s var(--ease);
}
.ticket[data-type="research"] { --c: var(--research); --ci: var(--research-ink); }
.ticket[data-type="experience"] { --c: var(--experience); --ci: var(--experience-ink); }
.ticket[data-type="skill"] { --c: var(--skill); --ci: var(--skill-ink); width: 214px; height: 124px; }
.ticket .t-inner {
  position: absolute; inset: 7px; border: 1.5px solid color-mix(in srgb, var(--tx-ci) 55%, transparent); border-radius: 3px;
  padding: 6px 12px 8px; display: grid; grid-template-rows: auto 1fr auto; gap: 2px;
}
/* 票號與日期：售票機印的欄位 */
.t-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-family: var(--dot); font-size: 15px; color: var(--tx-ci); letter-spacing: .04em; }
.t-title { font-weight: 900; font-size: 25px; line-height: 1.2; align-self: center; letter-spacing: .02em; word-break: keep-all; overflow-wrap: anywhere; }
.ticket[data-type="skill"] .t-title { font-size: 22px; }
.t-foot { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; min-width: 0; }
.t-sub { font-size: 15px; font-weight: 500; line-height: 1.35; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.t-kind { flex: none; font-weight: 700; font-size: 14px; color: var(--tx-ci); padding: 0 6px; border: 1.5px solid currentColor; border-radius: 3px; line-height: 1.4; }
.ticket .t-hole { /* 剪票孔：打孔後透出月台 */
  position: absolute; width: 15px; height: 15px; border-radius: 50%; right: 20px; top: 44%; translate: 0 -50%;
  background: var(--platform); box-shadow: inset 0 2px 3px rgba(0, 0, 0, .35); scale: 0; transition: scale .25s var(--ease);
}
.ticket.is-punched .t-hole { scale: 1; }
.ticket.is-near { box-shadow: 0 1px 0 rgba(255, 255, 255, .55) inset, 0 18px 30px -12px rgba(25, 35, 32, .5), 0 3px 6px rgba(25, 35, 32, .14); }

/* ---------- 票種圖例（篩選） ---------- */
.legend {
  grid-area: 1 / 1; align-self: end; justify-self: center; position: relative; z-index: 5;
  margin-bottom: 30px; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none;
  padding: 0 16px;
}
.legend > * { pointer-events: auto; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.stub {
  --c: var(--white); --ci: var(--ink);
  font: inherit; font-weight: 700; font-size: 15px; min-height: 42px; padding: 6px 16px 6px 22px; cursor: pointer; color: var(--ink);
  background: var(--c); border: 1.5px solid var(--ink); border-radius: 4px; position: relative;
  transition: transform .2s var(--ease), box-shadow .2s var(--ease);
}
.stub::before { /* 齒孔 */
  content: ""; position: absolute; left: 7px; top: 6px; bottom: 6px; width: 0;
  border-left: 2px dotted color-mix(in srgb, var(--ink) 45%, transparent);
}
.stub[data-filter="research"] { --c: var(--research); }
.stub[data-filter="project"] { --c: var(--project); }
.stub[data-filter="experience"] { --c: var(--experience); }
.stub[data-filter="skill"] { --c: var(--skill); }
.stub:hover { transform: translateY(-2px); }
.stub.is-on { box-shadow: 0 0 0 2px var(--platform), 0 0 0 4px var(--ink); }
.hint { margin: 0; font-size: 14px; color: var(--ink-2); background: color-mix(in srgb, var(--platform) 80%, transparent); padding: 0 10px; border-radius: 4px; }

/* ---------- 時刻表 ---------- */
.timetable { max-width: 1120px; margin: 0 auto; padding: 96px 24px 48px; }
.timetable h2 { font-weight: 900; font-size: clamp(34px, 4.5vw, 52px); letter-spacing: .12em; margin: 0; line-height: 1.1; }
.tt-sub { margin: 10px 0 0; color: var(--ink-2); }
.tt-group { margin-top: 44px; }
.tt-group h3 {
  display: inline-flex; align-items: center; gap: 10px; margin: 0 0 4px; font-size: 18px; font-weight: 900; letter-spacing: .1em;
}
.tt-group h3::before { content: ""; width: 26px; height: 15px; border-radius: 2px; background: var(--c); border: 1.5px solid var(--ink); }
.tt-rows { list-style: none; margin: 0; padding: 0; border-top: 2.5px solid var(--ink); }
.tt-row {
  display: grid; grid-template-columns: 112px minmax(0, 1.1fr) minmax(0, 1.6fr) 28px; gap: 20px; align-items: baseline;
  padding: 16px 6px; border-bottom: 1px solid var(--concrete-line); cursor: pointer; transition: background .2s var(--ease);
}
.tt-row:hover { background: color-mix(in srgb, var(--c) 45%, transparent); }
.tt-when { font-family: var(--dot); font-size: 15px; color: var(--ink-2); letter-spacing: .03em; }
.tt-name { word-break: keep-all; overflow-wrap: anywhere; font-weight: 900; font-size: 19px; line-height: 1.35; }
.tt-desc { color: var(--ink-2); font-size: 15.5px; line-height: 1.6; }
.tt-go { align-self: center; justify-self: end; color: var(--ink-3); }

/* ---------- 大票根（詳細內容） ---------- */
.sheet { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 16px; }
.sheet[hidden] { display: none; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(32, 30, 26, .5); animation: fade .3s var(--ease); }
.ticket-large {
  --c: var(--project); --ci: var(--project-ink);
  position: relative; width: min(680px, 100%); max-height: 88vh; overflow: auto; background: var(--white); border-radius: 8px;
  box-shadow: 0 40px 90px -20px rgba(0, 0, 0, .55); animation: issue .5s var(--ease);
}
.tl-band {
  position: sticky; top: 0; z-index: 2; display: flex; justify-content: space-between; align-items: center; gap: 12px;
  background: var(--c); padding: 7px 12px 7px 28px; font-weight: 700; font-size: 14px; color: var(--ci); letter-spacing: .1em;
  border-bottom: 2px dashed color-mix(in srgb, var(--ci) 45%, transparent);
}
.tl-serial { font-family: var(--dot); letter-spacing: .04em; }
.tl-body { position: relative; padding: 26px 28px 32px; }
.tl-band-r { display: flex; align-items: center; gap: 14px; }
.tl-close {
  width: 44px; height: 44px; display: grid; place-items: center;
  border: 1.5px solid var(--ink); border-radius: 50%; background: var(--white); color: var(--ink); cursor: pointer;
}
.tl-close:hover { background: var(--platform); }
.ticket-large h3 { word-break: keep-all; overflow-wrap: anywhere; font-weight: 900; font-size: clamp(30px, 4.6vw, 42px); line-height: 1.2; margin: 54px 0 6px 0; letter-spacing: .03em; text-wrap: balance; }
.tl-sub { margin: 0 0 18px; font-family: var(--dot); color: var(--ink-2); font-size: 15px; letter-spacing: .03em; }
.tl-text p { margin: 0 0 14px; max-width: 62ch; }
.tl-via { display: flex; gap: 14px; align-items: baseline; margin: 20px 0 0; padding-top: 16px; border-top: 1px solid var(--concrete-line); }
.tl-via[hidden] { display: none; }
.tl-via dt { font-weight: 900; font-size: 14px; letter-spacing: .2em; color: var(--ci); white-space: nowrap; }
.tl-via dd { margin: 0; }
.tl-via ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 14px; }
.tl-via li { font-family: var(--en); font-weight: 600; font-size: 15px; }
.tl-via li + li::before { content: "・"; margin: 0 4px 0 -10px; color: var(--ink-3); }
.tl-links { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 22px; }
.tl-links:empty { display: none; }
.tl-links a {
  text-decoration: none; font-weight: 700; font-size: 15px; padding: 9px 18px; min-height: 44px; display: inline-flex; align-items: center; gap: 8px;
  background: var(--ink); color: var(--white); border-radius: 4px;
}
.tl-links a:hover { background: var(--ci); }
.tl-links svg { width: 14px; height: 14px; }
.stamp {
  position: absolute; right: 78px; top: calc(100% - 22px); width: 96px; height: 96px; border-radius: 50%;
  background: color-mix(in srgb, var(--white) 72%, transparent);
  border: 3px solid var(--stamp); color: var(--stamp); display: grid; place-content: center; text-align: center;
  rotate: -14deg; opacity: .85; mix-blend-mode: multiply; pointer-events: none;
  animation: stamp .45s .25s var(--ease) both;
}
.stamp span { font-weight: 900; font-size: 17px; letter-spacing: .1em; }
.stamp b { font-family: var(--dot); font-weight: 400; font-size: 13px; }

.foot { text-align: center; padding: 40px 16px 56px; color: var(--ink-2); font-size: 15px; }
.foot p { margin: 4px 0; }
.foot-note { font-size: 13px; color: var(--ink-3); }

@keyframes fade { from { opacity: 0; } }
@keyframes issue { from { opacity: 0; transform: translateY(40px) rotate(-2deg); } }
@keyframes stamp { from { opacity: 0; scale: 1.6; } to { opacity: .85; scale: 1; } }

/* ---------- 手機 ---------- */
@media (max-width: 900px) {
  body { font-size: 16px; }
  .platform { display: block; min-height: 0; padding-bottom: 40px; }
  .sign { margin: 18px 16px 0; width: auto; }
  .sign-plate { padding: 16px 18px 14px; }
  .stage { min-height: 0; height: 50svh; margin-top: -24px; }
  .legend { position: relative; margin: 0; }
  .ticket { width: 232px; height: 130px; }
  .ticket[data-type="skill"] { width: 186px; height: 110px; }
  .t-title { font-size: 21px; }
  .ticket[data-type="skill"] .t-title { font-size: 19px; }
  .timetable { padding-top: 64px; }
  .tt-row { grid-template-columns: 1fr 22px; gap: 4px 12px; }
  .tt-when { grid-column: 1; }
  .tt-name { grid-column: 1; }
  .tt-desc { grid-column: 1; }
  .tt-go { grid-column: 2; grid-row: 1 / span 3; }
  .stamp { width: 76px; height: 76px; right: 66px; }
  .stamp span { font-size: 14px; }
  .stamp b { font-size: 10.5px; letter-spacing: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .ticket-large, .sheet-backdrop, .stamp { animation: none; }
}
