/* 慢車之旅 發車資訊（示範）：三分割——左上 LED 發車看板、左下選站與小故事、右邊路網圖 */

/* 隔天的班次：時間右上角小小的 +1 */
sup.day { font-size: .5em; vertical-align: super; margin-left: 2px; opacity: .75; font-weight: 600; letter-spacing: 0; }
.route li time sup.day { font-size: .8em; color: var(--amber-soft); opacity: .9; }
:root {
  --night: #14213D; --night-deep: #0B1428; --panel: #1C2C50; --line: #2E4373;
  --amber: #F2B544; --amber-soft: #F7CE7A; --moon: #F4F1EA; --text: #E7E4DC; --muted: #AEB7CC;
  --pink: #F5A9B8; --blue: #5BCEFA;
  --led-green: #3BEA6A; --led-orange: #FFA43A; --led-red: #FF3B30; --led-yellow: #FFD84A; --led-bg: #0A0A0A;
  --sans: "Noto Sans TC", "Noto Sans CJK TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  --serif: "Noto Serif TC", "Noto Serif CJK TC", "Songti TC", serif;
  --mono: "IBM Plex Mono", "Noto Sans Mono", ui-monospace, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html { color-scheme: dark; }
body {
  margin: 0; min-height: 100vh; color: var(--text); font: 16px/1.7 var(--sans);
  background: radial-gradient(ellipse at 30% -10%, #23365F 0%, transparent 60%), linear-gradient(var(--night), var(--night-deep));
}
a { color: var(--amber-soft); }
button, select, input { font: inherit; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 12px; top: 12px; z-index: 10; background: var(--amber); color: var(--night-deep); padding: 6px 12px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* 頁首 */
.top { display: flex; align-items: center; gap: 14px; height: 60px; padding: 0 clamp(16px, 3vw, 28px); border-bottom: 1px solid var(--line); background: rgba(11, 20, 40, .7); }
.brand { display: flex; align-items: center; gap: 10px; color: var(--moon); text-decoration: none; font: 600 17px/1 var(--serif); letter-spacing: .12em; }
.lh { position: relative; width: 14px; height: 14px; border-radius: 50%; background: radial-gradient(circle, #FFF4D6 0 30%, var(--amber) 31% 55%, transparent 56%); }
.lh::after { content: ""; position: absolute; left: 50%; top: 50%; width: 26px; height: 3px; margin: -1.5px 0 0; transform-origin: 0 50%; background: linear-gradient(90deg, rgba(242, 181, 68, .8), transparent); animation: lh 6s linear infinite; }
@keyframes lh { to { transform: rotate(360deg); } }
.demo-badge { font-size: 12px; letter-spacing: .1em; color: var(--night-deep); background: var(--pink); border-radius: 4px; padding: 2px 8px; }
.exit { margin-left: auto; border: 0; border-radius: 999px; padding: 9px 16px; background: var(--moon); color: var(--night-deep); font-weight: 600; font-size: 14px; cursor: pointer; }
.exit:hover { background: #fff; }
.is-embed .exit { display: none; }
.memorial { margin: 0; padding: 10px clamp(16px, 3vw, 28px); text-align: center; background: #2A2240; color: var(--moon); border-bottom: 1px solid #4A3E6A; }

/* 三分割 */
.hall {
  display: grid; gap: 18px; padding: 18px clamp(16px, 2vw, 24px) 24px;
  grid-template-columns: minmax(0, 1.75fr) minmax(320px, 1fr);
  grid-template-areas: "board map" "info map";
  grid-template-rows: auto 1fr;
  min-height: calc(100vh - 61px);
}
.hall > * { min-width: 0; }
.area-board { grid-area: board; }
.area-info { grid-area: info; }
.area-map { grid-area: map; }

/* LED 發車看板（外殼淺灰、黑底點陣字） */
.led-board {
  display: grid; grid-template-columns: 168px minmax(0, 1fr); gap: 16px;
  padding: 16px; border-radius: 10px; color: #1C1F24;
  background: linear-gradient(#F1F2F4, #D8DADD); border: 1px solid #B9BCC1;
  box-shadow: 0 18px 40px rgba(0, 0, 0, .45), inset 0 1px 0 #fff;
}
.led-side { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 4px; border-right: 1px solid #C3C6CB; padding-right: 14px; }
.led-side h1 { margin: 0 0 10px; font: 800 clamp(30px, 3.2vw, 44px)/1.1 var(--sans); letter-spacing: .06em; color: #15181D; }
.led-side h1 small { display: block; font: 700 15px/1.2 var(--sans); letter-spacing: .02em; color: #2B2F36; margin-top: 4px; }
.side-k { margin: 0; font: 700 14px/1.2 var(--sans); color: #2B2F36; }
.side-k span { display: block; font-size: 11px; font-weight: 600; color: #4A4F57; }
.led { position: relative; background: var(--led-bg); border-radius: 4px; overflow: hidden; }
.led-clock { margin: 4px 0 0; width: 100%; padding: 6px 8px; font: 700 30px/1.15 var(--mono); color: var(--led-red); text-shadow: 0 0 3px rgba(255, 59, 48, .35); letter-spacing: .04em; font-variant-numeric: tabular-nums; }
.is-preview .led-clock { color: #49B6FF; text-shadow: 0 0 3px rgba(73, 182, 255, .35); }

.led-table { width: 100%; border-collapse: separate; border-spacing: 0 8px; table-layout: fixed; margin-top: -8px; }
.led-table th { text-align: center; font: 800 18px/1.15 var(--sans); color: #15181D; padding: 0 4px 2px; }
.led-table th span { display: block; font: 700 11.5px/1.2 var(--sans); color: #3A3F47; letter-spacing: .02em; }
.led-table .c-no { width: 17%; } .led-table .c-to { width: 33%; } .led-table .c-time { width: 18%; } .led-table .c-plat { width: 11%; } .led-table .c-st { width: 21%; }
.led-table td {
  position: relative; background: var(--led-bg); height: 52px; padding: 0 12px;
  font: 700 23px/1.1 var(--sans); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: center;
}
.led-table td:first-child { border-radius: 4px 0 0 4px; }
.led-table td:last-child { border-radius: 0 4px 4px 0; }
.led-table td.c-no { color: var(--led-green); text-shadow: 0 0 3px rgba(59, 234, 106, .35); }
.led-table td.c-to { color: var(--led-orange); text-shadow: 0 0 3px rgba(255, 164, 58, .35); }
.led-table td.c-time { color: var(--led-red); text-shadow: 0 0 3px rgba(255, 59, 48, .35); font-family: var(--mono); font-variant-numeric: tabular-nums; }
.led-table td.c-plat { color: var(--led-yellow); text-shadow: 0 0 3px rgba(255, 216, 74, .35); }
.led-table td.c-st { color: var(--led-orange); text-shadow: 0 0 3px rgba(255, 164, 58, .35); }
.led-table td.c-st.soon { color: var(--led-red); text-shadow: 0 0 3px rgba(255, 59, 48, .35); animation: blink 1.4s steps(2) infinite; }
.led-table td.c-st.gone { color: #6F6F6F; text-shadow: none; }
.led-table tr.k-branch td.c-no { font-size: 20px; }
.led-table tr.k-boat td.c-no { color: var(--pink); text-shadow: 0 0 3px rgba(245, 169, 184, .35); font-size: 20px; }
.led-table tbody tr { cursor: pointer; }
.led-table tbody tr.is-empty { display: none; }
.led-table tbody tr:focus { outline: none; }
.led-table tbody tr:hover td, .led-table tbody tr:focus td { background: #151515; }
.led-table tbody tr.is-sel td { box-shadow: inset 0 3px 0 #F2B544, inset 0 -3px 0 #F2B544; }
.led-table tbody tr.is-sel td:first-child { box-shadow: inset 3px 3px 0 #F2B544, inset 0 -3px 0 #F2B544; }
.led-table tbody tr.is-sel td:last-child { box-shadow: inset -3px 3px 0 #F2B544, inset 0 -3px 0 #F2B544; }
@keyframes blink { 50% { opacity: .35; } }

.led-marquee { height: 52px; display: flex; align-items: center; }
.led-marquee p {
  margin: 0; white-space: nowrap; display: inline-block; padding-left: 100%;
  font: 700 22px/1 var(--sans); color: var(--led-red); text-shadow: 0 0 3px rgba(255, 59, 48, .35);
  animation: marquee var(--dur, 24s) linear infinite;
}
@keyframes marquee { to { transform: translateX(-100%); } }
.hint { margin: 10px 0 0; text-align: center; color: var(--muted); font-size: 13.5px; }

/* 左下：選站、這班車上、站務廣播 */
.area-info {
  display: grid; gap: 14px 18px; align-content: start;
  grid-template-columns: minmax(240px, 300px) minmax(0, 1fr);
}
.area-info > * { grid-column: 1; }
.area-info > .detail { grid-column: 2; grid-row: 1 / span 4; }
.area-info > .foot { grid-column: 1 / -1; }
.picker { display: grid; gap: 8px; }
.picker label { color: var(--muted); font-size: 14px; }
.picker select { background: var(--panel); color: var(--moon); border: 1px solid var(--line); border-radius: 8px; padding: 9px 12px; width: 100%; font-size: 17px; }
.shuttles { display: grid; gap: 6px; }
.shuttle { text-align: left; background: transparent; border: 1px dashed var(--line); color: var(--text); border-radius: 8px; padding: 6px 12px; cursor: pointer; font-size: 14px; }
.shuttle:hover { border-color: var(--amber); }
.shuttle b { color: var(--amber); font-weight: 600; margin-right: 6px; }
.shuttle span { display: block; color: var(--muted); font-size: 12.5px; }
.broadcast { background: rgba(11, 20, 40, .6); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.bc-k { margin: 0 0 6px; font: 600 12px/1 var(--mono); letter-spacing: .2em; color: var(--night-deep); background: var(--amber); border-radius: 3px; padding: 5px 7px; display: inline-block; }
.broadcast p#ticker-text { margin: 0; color: var(--amber-soft); font-size: 15px; line-height: 1.75; }
.broadcast p#ticker-text b { display: block; color: var(--pink); font-weight: 500; font-size: 13px; }
.broadcast p#ticker-text.roll { animation: fadein .6s ease-out; }
@keyframes fadein { from { opacity: 0; transform: translateY(4px); } }
.lighthouse-note { margin: 0; color: var(--amber-soft); font-size: 13.5px; }
.preview { display: grid; gap: 6px; color: var(--muted); font-size: 13.5px; }
.preview output { font-family: var(--mono); color: var(--blue); margin-left: 6px; }
.preview input { width: 100%; accent-color: var(--blue); }
.preview button { justify-self: start; background: transparent; color: var(--text); border: 1px solid var(--line); border-radius: 999px; padding: 4px 14px; cursor: pointer; font-size: 13.5px; }
.foot { color: var(--muted); font-size: 12.5px; }
.foot p { margin: 0 0 4px; }
.foot strong { color: var(--pink); font-weight: 500; }

/* 車次詳情 */
.detail { margin: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 22px clamp(16px, 3vw, 28px) 26px; scroll-margin-top: 16px; }
.det-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 16px; position: relative; padding-right: 40px; }
.det-head h2 { margin: 0; font: 600 22px/1.3 var(--serif); color: var(--moon); }
.det-head p { margin: 0; color: var(--amber-soft); font-size: 15px; }
.det-close { position: absolute; right: -6px; top: -8px; width: 40px; height: 40px; border: 0; background: transparent; color: var(--muted); font-size: 26px; cursor: pointer; }
.det-close:hover { color: var(--moon); }
.route { position: relative; display: flex; gap: 0; list-style: none; margin: 18px 0 0; padding: 14px 0 18px; overflow-x: auto; scrollbar-width: thin; }
.route li { position: relative; flex: none; min-width: 74px; padding: 22px 6px 0; text-align: center; }
.route li::before { content: ""; position: absolute; left: 0; right: 0; top: 7px; height: 3px; background: var(--amber); }
.route li::after { content: ""; position: absolute; left: 50%; top: 2px; width: 13px; height: 13px; margin-left: -6.5px; border-radius: 50%; background: var(--night-deep); border: 3px solid var(--amber); }
.route li.past::before, .route li.past::after { border-color: var(--line); background: var(--line); }
.route li.here b { color: var(--amber); }
.route li time { display: block; font: 13px/1.3 var(--mono); color: var(--muted); }
.route li b { display: block; font-weight: 500; color: var(--moon); font-size: 15px; white-space: nowrap; }
.route li.past b, .route li.past time { color: var(--muted); opacity: .7; }
.route li.train-at { min-width: 0; width: 0; padding: 0; }
.route li.train-at::before, .route li.train-at::after { display: none; }
.route li.train-at span { position: absolute; top: -6px; left: calc(-37px + 74px * var(--p)); width: 30px; height: 18px; margin-left: -15px; border-radius: 6px 10px 4px 4px; background: var(--moon); box-shadow: 0 0 14px rgba(242, 181, 68, .8); z-index: 1; }
.route li.train-at span::after { content: ""; position: absolute; left: 5px; top: 4px; width: 14px; height: 5px; border-radius: 1px; background: var(--amber); }

.onboard { margin: 18px 0 0; padding: 18px 22px; border-left: 3px solid var(--pink); background: rgba(11, 20, 40, .55); border-radius: 0 12px 12px 0; }
.ob-h { margin: 0 0 6px; font: 500 12px/1 var(--mono); letter-spacing: .2em; color: var(--muted); }
.onboard blockquote { margin: 0; }
.onboard blockquote p { margin: 0; font: 17px/1.95 var(--serif); color: var(--moon); }
.onboard figcaption { margin-top: 8px; color: var(--pink); font-size: 14px; }
.onboard figcaption span { margin-left: 8px; font-size: 12px; color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 0 6px; }

.preview { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px 14px; margin-top: 30px; color: var(--muted); font-size: 14px; }
.preview output { font-family: var(--mono); color: var(--blue); margin-left: 6px; }
.preview input { width: min(360px, 70vw); accent-color: var(--blue); }
.preview button { background: transparent; color: var(--text); border: 1px solid var(--line); border-radius: 999px; padding: 5px 14px; cursor: pointer; }

.foot { max-width: 760px; margin: 0 auto; padding: 10px clamp(16px, 4vw, 40px) 48px; color: var(--muted); font-size: 13.5px; text-align: center; }
.route.k-boat li::before { background: var(--pink); }
.route.k-boat li::after { border-color: var(--pink); }
.route.k-branch li::before { background: var(--blue); }
.route.k-branch li::after { border-color: var(--blue); }
.route.k-boat li.past::before, .route.k-boat li.past::after, .route.k-branch li.past::before, .route.k-branch li.past::after { border-color: var(--line); background: var(--line); }
/* 船班：路線上的標記換成小船 */
.route.k-boat li.train-at span { top: -1px; height: 10px; border-radius: 2px 2px 12px 12px; background: var(--pink); box-shadow: 0 0 14px rgba(245, 169, 184, .8); }
.route.k-boat li.train-at span::after { left: 10px; top: -15px; width: 12px; height: 15px; border-radius: 0; background: var(--moon); clip-path: polygon(0 100%, 30% 0, 100% 100%); }
.route.k-branch li.train-at span { box-shadow: 0 0 14px rgba(91, 206, 250, .8); }
.route.k-branch li.train-at span::after { background: var(--blue); }
.det-empty { margin: 4px 0 0; color: var(--muted); font-size: 15px; line-height: 1.85; }
.det-acts { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 12px 0 0; }
.det-ticket { border-radius: 999px; padding: 4px 14px; background: var(--amber); color: var(--night-deep); font-size: 13.5px; font-weight: 600; text-decoration: none; }
.det-ticket:hover { background: var(--amber-soft); }
.det-back { margin-top: 0; background: transparent; border: 1px solid var(--line); color: var(--text); border-radius: 999px; padding: 4px 14px; cursor: pointer; font-size: 13.5px; }
.det-back:hover { border-color: var(--amber); }
.det-k { margin: 0 0 4px; font: 600 12px/1 var(--mono); letter-spacing: .2em; color: var(--muted); }

/* 看板旁的小地圖 */
.mapbox { background: #05080D; border: 1px solid #1E2A40; border-radius: 12px; padding: 14px 14px 12px; box-shadow: 0 20px 50px rgba(0, 0, 0, .5); }
.mapbox h2 { margin: 0 0 6px; font: 500 12px/1 var(--mono); letter-spacing: .2em; color: var(--muted); }
#map-svg { display: block; width: 100%; height: auto; }
.m-land path, .m-land ellipse { fill: #142038; stroke: #2E4373; stroke-width: 1; }
.m-inset { fill: none; stroke: #2E4373; stroke-dasharray: 3 3; }
.m-isl { font: 9px/1 var(--sans); fill: var(--muted); text-anchor: middle; }
.m-rail { fill: none; stroke: var(--amber); stroke-width: 1.6; opacity: .55; stroke-linejoin: round; }
.m-branch { fill: none; stroke: var(--blue); stroke-width: 1.2; opacity: .6; }
.m-sea { fill: none; stroke: var(--pink); stroke-width: 1; stroke-dasharray: 2 3; opacity: .45; }
.m-st { cursor: pointer; }
.m-hit { fill: transparent; }
.m-dot { fill: #05080D; stroke: var(--amber-soft); stroke-width: 1.2; }
.m-st.small .m-dot { stroke: var(--blue); }
.m-st.port .m-dot { stroke: var(--pink); }
.m-st:hover .m-dot { fill: var(--amber-soft); }
.m-lab { font: 10px/1 var(--sans); fill: var(--text); }
.m-here circle { fill: none; stroke: var(--moon); stroke-width: 1.4; }
.m-here text { font: 10px/1 var(--sans); fill: var(--moon); }
.m-lh-dot { fill: #FFF4D6; }
.m-lh-beam { fill: rgba(242, 181, 68, .35); animation: lh 6s linear infinite; transform-box: fill-box; transform-origin: 0 50%; }
.m-v { cursor: pointer; }
.m-v:focus { outline: none; }
.m-v-shape { stroke: #05080D; stroke-width: 1.2; }
.m-train .m-v-shape { fill: var(--amber); filter: drop-shadow(0 0 3px rgba(242, 181, 68, .9)); }
.m-branch .m-v-shape { fill: var(--blue); }
.m-boat .m-v-shape { fill: var(--pink); stroke-width: .8; }
.m-v-lab { font: 600 9px/1 var(--mono); fill: var(--moon); paint-order: stroke; stroke: #05080D; stroke-width: 2.5px; }
.m-v:hover .m-v-shape, .m-v:focus .m-v-shape, .m-v.is-sel .m-v-shape { stroke: var(--moon); stroke-width: 1.8; }
/* 目前選的班次：地圖上放大加光圈，並標出接下來要走的路線；其他車船淡化 */
.m-selroute { fill: none; stroke: var(--amber); stroke-width: 3.2; stroke-linecap: round; stroke-linejoin: round; opacity: .9; filter: drop-shadow(0 0 3px rgba(242, 181, 68, .7)); }
.m-selroute.k-boat { stroke: var(--pink); filter: drop-shadow(0 0 3px rgba(245, 169, 184, .7)); }
.m-selroute.k-branch { stroke: var(--blue); filter: drop-shadow(0 0 3px rgba(91, 206, 250, .7)); }
.m-halo { fill: none; stroke: transparent; stroke-width: 2; }
.m-v.is-sel .m-halo { stroke: var(--moon); }
.m-v.is-sel .m-v-shape { transform: scale(1.45); transform-box: fill-box; transform-origin: center; }
.m-v.is-sel .m-v-lab { font-size: 11px; }
.m-v.is-dim { opacity: .4; }
.m-v.is-dim:hover, .m-v.is-dim:focus { opacity: 1; }
.m-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; list-style: none; margin: 6px 0 0; padding: 0; font-size: 12px; color: var(--muted); }
.m-legend i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; vertical-align: -1px; }
.lg-train { background: var(--amber); } .lg-branch { background: var(--blue); } .lg-boat { background: var(--pink); border-radius: 2px !important; }
.m-hint { margin: 6px 0 0; font-size: 12px; color: var(--muted); }
.is-memorial .m-lh-beam { fill: rgba(255, 255, 255, .5); }
@media (prefers-reduced-motion: reduce) { .m-lh-beam { animation: none; } }

/* 右：路網圖填滿整欄 */
.area-map { display: flex; flex-direction: column; position: sticky; top: 12px; height: calc(100vh - 85px); min-height: 520px; }
.area-map h2 span { margin-left: 8px; color: #6B7894; }
.area-map #map-svg { flex: 1; min-height: 0; width: 100%; height: 100%; }

/* 紀念日 */
.is-memorial .led-table td.c-no, .is-memorial .led-table td.c-to, .is-memorial .led-table td.c-st, .is-memorial .led-table td.c-plat { color: #F4F1EA; text-shadow: 0 0 3px rgba(255, 255, 255, .35); }
.is-memorial .lh { background: radial-gradient(circle, #fff 0 40%, var(--moon) 41% 60%, transparent 61%); }
.is-memorial .m-lh-beam { fill: rgba(255, 255, 255, .5); }

@media (max-width: 1180px) and (min-width: 1101px), (max-width: 700px) {
  .area-info { grid-template-columns: minmax(0, 1fr); }
  .area-info > .detail { grid-column: 1; grid-row: auto; }
}
@media (max-width: 1100px) {
  .hall { grid-template-columns: minmax(0, 1fr); grid-template-areas: "board" "info" "map"; grid-template-rows: auto; min-height: 0; }
  .area-map { display: block; position: static; height: auto; min-height: 0; }
  .area-map #map-svg { height: auto; max-height: 85vh; }
  .led-board { grid-template-columns: minmax(0, 1fr); padding: 10px; gap: 10px; }
  .led-side { flex-direction: row; flex-wrap: wrap; justify-content: space-between; border-right: 0; border-bottom: 1px solid #C3C6CB; padding: 0 0 10px; }
  .led-side h1 { margin: 0; font-size: 30px; text-align: left; }
  .led-side .side-k:first-child { display: none; }
  .led-side .side-k + h1 + .side-k { margin-left: auto; }
  .led-clock { width: auto; font-size: 24px; }
  .area-map { max-width: 620px; width: 100%; justify-self: center; }
}
@media (max-width: 760px) {
  .led-table th { font-size: 14px; }
  .led-table th span { font-size: 9.5px; }
  .led-table td { height: 42px; padding: 0 6px; font-size: 16px; }
  .led-table tr.k-branch td.c-no, .led-table tr.k-boat td.c-no { font-size: 14px; }
  .led-table .c-no { width: 20%; } .led-table .c-to { width: 32%; } .led-table .c-time { width: 20%; } .led-table .c-plat { width: 10%; } .led-table .c-st { width: 18%; }
  .led-marquee { height: 42px; }
  .led-marquee p { font-size: 17px; }
}
@media (max-width: 520px) {
  .led-table .c-plat { display: none; }
  .led-table .c-no { width: 22%; } .led-table .c-to { width: 38%; } .led-table .c-time { width: 22%; } .led-table .c-st { width: 18%; }
  .led-table td { font-size: 14.5px; padding: 0 4px; }
  .led-table td.c-st { font-size: 12.5px; }
}
@media (prefers-reduced-motion: reduce) {
  .lh::after, .led-table td.c-st.soon, .broadcast p#ticker-text.roll, .m-lh-beam { animation: none; }
  .led-marquee p { animation: none; padding-left: 12px; }
}
