/* 內湖美食街 — paper, ink and flat colour, matching the isometric demos. */
:root {
  --paper: #f1ece1;
  --paper-2: #faf6ee;
  --ink: #1d1a17;
  --ink-2: #5b544b;
  --line: #2b2723;
  --open: #3d8b5a;
  --shut: #8a8178;
  --accent: #b8432f;
  --zh: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  --mono: "DM Mono", ui-monospace, Menlo, monospace;
  --r: 10px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; background-color: var(--paper); color: var(--ink); font-family: var(--zh); }
body {
  /* graph paper, like the demo */
  background-image:
    linear-gradient(to right, rgb(0 0 0 / .045) 1px, transparent 1px),
    linear-gradient(to bottom, rgb(0 0 0 / .045) 1px, transparent 1px);
  background-size: 48px 48px;
}
body.night { background-image: linear-gradient(to right, rgb(255 255 255 / .04) 1px, transparent 1px), linear-gradient(to bottom, rgb(255 255 255 / .04) 1px, transparent 1px); }
body.night .tag { background: color-mix(in srgb, #1f2742 75%, transparent); }
.mono { font-family: var(--mono); letter-spacing: .02em; }
.small { font-size: 12px; }
.muted { color: var(--ink-2); }
button, select, input { font: inherit; color: inherit; }

#street { position: fixed; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; }
#street:active { cursor: grabbing; }

/* ---------- labels ---------- */
#labels { position: fixed; inset: 0; pointer-events: none; }
#labels .leaders { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
#labels line { stroke: var(--line); stroke-width: 1; }
#labels circle { fill: var(--line); }
.tag {
  position: absolute; left: 0; top: 0; pointer-events: auto; cursor: pointer;
  background: none; border: 0; padding: 0 0 4px; text-align: left; white-space: nowrap;
  font-size: 13px; font-weight: 700; line-height: 1.25; border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--paper) 82%, transparent); padding: 3px 6px 4px; border-radius: 4px 4px 0 0;
  transition: opacity .3s;
}
.tag .tag-sep, .tag .tag-state { font-family: var(--mono); font-weight: 500; letter-spacing: .04em; }
.tag .tag-state { color: var(--open); }
.tag .tag-detail { display: block; font-family: var(--mono); font-weight: 400; font-size: 11px; color: var(--ink-2); }
.tag.closed .tag-state { color: var(--shut); }
.tag.closed { opacity: .82; }
.tag.unknown .tag-state { color: var(--ink-2); }

/* station name signs */
.station-tag {
  position: absolute; left: 0; top: 0; pointer-events: auto; cursor: pointer; white-space: nowrap;
  display: flex; align-items: center; gap: 7px; padding: 5px 12px 5px 5px;
  background: #fff; border: 1.5px solid var(--ink); border-radius: 999px; box-shadow: 2px 2px 0 var(--ink);
  font-size: 15px; font-weight: 700;
}
.station-tag .st-icon { width: 22px; height: 22px; border-radius: 50%; background: #2f6db3; color: #fff; display: grid; place-items: center; font: 700 12px var(--mono); }
.station-tag .st-en { font: 500 11px var(--mono); color: #2f6db3; text-transform: uppercase; letter-spacing: .06em; }
.tag:hover .tag-name, .tag.selected .tag-name { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 3px; }
body.night .tag { color: #f4ecdc; border-color: #f4ecdc; }
body.night .tag .tag-detail { color: #c9c0b0; }
body.night #labels line { stroke: #f4ecdc; }
body.night #labels circle { fill: #f4ecdc; }

/* ---------- HUD ---------- */
.hud-top { position: fixed; top: 0; left: 0; right: 0; display: flex; justify-content: space-between; align-items: flex-start; padding: 18px 22px; pointer-events: none; }
.brand h1 { margin: 0; font-size: 22px; letter-spacing: .08em; }
.brand p { margin: 4px 0 0; font-size: 13px; color: var(--ink-2); }
.clock { display: flex; gap: 10px; align-items: center; text-align: right; }
.clock .pod { margin: 0; font-size: 26px; font-weight: 700; letter-spacing: .1em; }
.clock p { margin: 0; }
#sun { width: 34px; height: 34px; }
/* (weather icons are drawn by js/ui/wxicon.js) */
#sun .rays circle { fill: #e9b949; stroke: var(--ink); stroke-width: 1.4; }
#sun .rays path { stroke: #e9b949; stroke-width: 2.4; stroke-linecap: round; }
#sun .crescent { fill: #f2e3a6; stroke: var(--ink); stroke-width: 1.4; display: none; }
#sun.moon .rays { display: none; }
#sun.moon .crescent { display: block; }
body.night .hud-top, body.night .hint { color: #f4ecdc; }
body.night .brand p, body.night .clock .small { color: #c9c0b0; }

.hud-bottom { position: fixed; left: 0; right: 0; bottom: 0; padding: 0 16px 14px; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.hud-bottom > * { pointer-events: auto; }
.blocks { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.blocks button, .btn {
  background: var(--paper-2); border: 1.5px solid var(--ink); border-radius: 999px; padding: 5px 12px; cursor: pointer;
  box-shadow: 2px 2px 0 var(--ink); font-size: 14px; text-decoration: none; display: inline-flex; align-items: center; gap: 4px;
}
.blocks button:hover, .btn:hover { transform: translate(-1px, -1px); box-shadow: 3px 3px 0 var(--ink); }
.btn.on { background: var(--ink); color: var(--paper-2); }
.btn.primary { background: var(--accent); color: #fff; }
.btn.line { background: #06c755; color: #fff; border-color: #048a3b; box-shadow: 2px 2px 0 #048a3b; }
.btn:disabled { opacity: .5; cursor: default; transform: none; }
.timebar {
  display: flex; align-items: center; gap: 10px; background: var(--paper-2); border: 1.5px solid var(--ink);
  border-radius: 14px; padding: 8px 12px; box-shadow: 3px 3px 0 var(--ink); max-width: 100%;
}
.timebar .btn { white-space: nowrap; }
.clock .small { white-space: nowrap; }
.timebar select { border: 1px solid var(--ink-2); border-radius: 6px; background: transparent; padding: 3px 4px; }
#time { width: min(42vw, 320px); accent-color: var(--ink); }
#time-label { min-width: 84px; font-size: 13px; }
.hint { margin: 0; font-size: 11px; color: var(--ink-2); }

/* ---------- drawers ---------- */
.drawer-left, .drawer-right {
  position: fixed; top: 12px; bottom: 12px; width: min(400px, calc(100vw - 24px)); background: var(--paper-2);
  border: 1.5px solid var(--ink); border-radius: 16px; box-shadow: 4px 4px 0 var(--ink); overflow: auto;
  transition: transform .35s cubic-bezier(.2,.8,.2,1); z-index: 5;
}
.drawer-left { left: 12px; transform: translateX(calc(-100% - 30px)); padding: 14px; }
.drawer-right { right: 12px; transform: translateX(calc(100% + 30px)); }
.drawer-left.open, .drawer-right.open { transform: none; }

.l-head { display: flex; flex-direction: column; gap: 8px; position: sticky; top: -14px; background: var(--paper-2); padding: 0 0 8px; }
.l-head input[type=search] { border: 1.5px solid var(--ink); border-radius: 10px; padding: 8px 10px; background: #fff; }
.chk { font-size: 14px; }
.l-items { list-style: none; margin: 0; padding: 0; }
.l-items button { width: 100%; display: grid; grid-template-columns: 14px 1fr; column-gap: 8px; text-align: left; background: none; border: 0; border-bottom: 1px dashed #cfc5b2; padding: 10px 2px; cursor: pointer; }
.l-items button:hover .l-name { text-decoration: underline; }
.l-name { font-weight: 700; }
.l-meta { grid-column: 2; font-size: 12px; color: var(--ink-2); font-family: var(--mono); }
.dot { width: 12px; height: 12px; border-radius: 50%; border: 1.5px solid var(--ink); background: #ddd; margin-top: 4px; }
.dot.on { background: var(--c, var(--open)); }

.p-inner { padding: 22px 22px 30px; position: relative; }
.p-close { position: absolute; top: 10px; right: 12px; border: 0; background: none; font-size: 28px; cursor: pointer; line-height: 1; }
.p-kicker { margin: 0; font-family: var(--mono); font-size: 12px; color: var(--ink-2); letter-spacing: .06em; }
.p-title { margin: 6px 40px 6px 0; font-size: 24px; line-height: 1.25; border-bottom: 4px solid var(--accent); display: inline-block; padding-bottom: 2px; }
.p-sample { margin: 4px 0; font-size: 13px; color: #a05a00; }
.p-status { margin: 8px 0; font-family: var(--mono); font-size: 14px; font-weight: 500; }
.p-status.is-open { color: var(--open); }
.p-status.is-closed { color: var(--shut); }
.p-summary { margin: 10px 0 14px; line-height: 1.7; }
.p-facts { margin: 0 0 14px; display: grid; grid-template-columns: 64px 1fr; gap: 8px 10px; font-size: 14px; }
.p-facts dt { color: var(--ink-2); }
.p-facts dd { margin: 0; }
.p-facts a { color: inherit; }
.p-hours { border-collapse: collapse; font-family: var(--mono); font-size: 13px; }
.p-hours th { text-align: left; font-weight: 400; padding: 1px 10px 1px 0; font-family: var(--zh); }
.p-hours tr.today { font-weight: 700; background: #f5e9c8; }
.p-note { margin: 6px 0 0; font-size: 12px; color: #a05a00; }
.p-links { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 16px; }
.p-more summary { cursor: pointer; font-weight: 700; margin-bottom: 6px; }
.p-desc p { margin: 0 0 10px; line-height: 1.75; font-size: 14px; }
.p-gallery { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 0 0 14px; }
.p-gallery img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; border: 1.5px solid var(--ink); }
.p-gallery.small { grid-template-columns: repeat(3, 72px); }
.p-social { margin-top: 18px; border-top: 1.5px solid var(--ink); padding-top: 12px; }
.p-social h3 { display: flex; justify-content: space-between; align-items: center; margin: 0 0 10px; font-size: 17px; }
.like.on { background: #e05a6a; color: #fff; }
.p-post { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.p-post textarea { border: 1.5px solid var(--ink); border-radius: 10px; padding: 8px; resize: vertical; background: #fff; }
.p-post .file { font-size: 13px; }
.p-feed { list-style: none; margin: 0; padding: 0; }
.p-feed li { display: grid; grid-template-columns: 36px 1fr; gap: 10px; padding: 10px 0; border-bottom: 1px dashed #cfc5b2; font-size: 14px; }
.p-feed p { margin: 4px 0; line-height: 1.6; }
.p-feed time { font-family: var(--mono); font-size: 11px; color: var(--ink-2); }
.avatar { width: 36px; height: 36px; border-radius: 50%; border: 1.5px solid var(--ink); object-fit: cover; }

.boot-error { position: fixed; top: 40%; left: 50%; transform: translateX(-50%); background: var(--paper-2); border: 1.5px solid var(--ink); padding: 14px 18px; border-radius: 12px; }
body.no-webgl #street, body.no-webgl .timebar input, body.no-webgl .hint { display: none; }

/* ---------- phones ---------- */
@media (max-width: 640px) {
  .hud-top { padding: 12px 14px; }
  .brand h1 { font-size: 18px; }
  .brand p { font-size: 11px; max-width: 46vw; }
  .clock .pod { font-size: 20px; }
  .timebar { gap: 6px; padding: 6px 8px; flex-wrap: wrap; justify-content: center; width: 100%; }
  #time { flex: 1 1 140px; width: auto; }
  #time-label { min-width: 0; }
  .brand .en { display: none; }
  .hint { display: none; }
  .tag { font-size: 12px; }
  .drawer-right { top: auto; left: 8px; right: 8px; bottom: 8px; width: auto; max-height: 72vh; transform: translateY(calc(100% + 30px)); }
}
@media (prefers-reduced-motion: reduce) {
  .drawer-left, .drawer-right, body { transition: none; }
}

/* ---------- account, posting, toast ---------- */
.account { margin-top: 6px; pointer-events: auto; position: relative; display: flex; justify-content: flex-end; }
.btn.sm { padding: 3px 10px; font-size: 13px; }
.account .me { display: flex; align-items: center; gap: 6px; background: var(--paper-2); border: 1.5px solid var(--ink); border-radius: 999px; padding: 2px 10px 2px 2px; cursor: pointer; box-shadow: 2px 2px 0 var(--ink); font-size: 13px; }
.account .me img { width: 24px; height: 24px; border-radius: 50%; object-fit: cover; }
.account .me span { max-width: 9em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-menu { position: absolute; top: calc(100% + 6px); right: 0; background: var(--paper-2); border: 1.5px solid var(--ink); border-radius: 10px; box-shadow: 2px 2px 0 var(--ink); overflow: hidden; z-index: 6; }
.me-menu button { border: 0; background: none; padding: 8px 18px; cursor: pointer; }
.me-menu button:hover { background: #f0e6cf; }
body.night .account .me, body.night .me-menu { color: var(--ink); }

.tag .tag-social { display: block; font-family: var(--mono); font-weight: 400; font-size: 11px; color: #c0392b; }
.tag .tag-social:empty { display: none; }

.p-login { width: 100%; justify-content: center; margin-bottom: 12px; }
.p-post { background: #fff; border: 1.5px solid var(--ink); border-radius: 12px; padding: 10px; }
.p-post textarea { width: 100%; border: 1px solid #d8cfbd; }
.p-post-who { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; }
.avatar.sm { width: 24px; height: 24px; }
.p-post-actions { display: flex; align-items: center; gap: 8px; }
.p-post-actions .primary { margin-left: auto; }
.p-previews { display: flex; gap: 6px; flex-wrap: wrap; }
.p-previews figure { margin: 0; position: relative; }
.p-previews img { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; border: 1.5px solid var(--ink); display: block; }
.p-previews button { position: absolute; top: -6px; right: -6px; width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--ink); background: #fff; cursor: pointer; line-height: 1; }
.p-del { border: 0; background: none; color: var(--ink-2); font-size: 12px; cursor: pointer; text-decoration: underline; float: right; }
.p-more-posts { margin-top: 10px; }
.p-feed .empty { display: block; }
.toast { position: fixed; left: 50%; top: 18px; transform: translate(-50%, -20px); opacity: 0; z-index: 20; background: var(--ink); color: var(--paper-2); padding: 10px 16px; border-radius: 12px; font-size: 14px; transition: .3s; pointer-events: none; max-width: 90vw; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }

.clock .wx { color: var(--ink-2); margin-top: 2px; }
body.night .clock .wx { color: #c9c0b0; }
/* keep the clock readable when clouds drift behind it */
.hud-top .clock, .hud-top .brand { background: color-mix(in srgb, var(--paper) 72%, transparent); border-radius: 12px; padding: 6px 10px; }
body.night .hud-top .clock, body.night .hud-top .brand { background: color-mix(in srgb, #1f2742 65%, transparent); }
.brand h1 { white-space: nowrap; }
@media (max-width: 640px) { .brand p { display: none; } .hud-top .clock, .hud-top .brand { padding: 4px 8px; } }

/* ---------- station portal ---------- */
.station-tag .st-go { font: 700 11px var(--mono); background: #2f6db3; color: #fff; border-radius: 999px; padding: 2px 8px; margin-left: 2px; }
.station-tag:hover .st-go { background: var(--ink); }
.portal { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; }
.portal-backdrop { position: absolute; inset: 0; background: rgb(29 26 23 / .45); opacity: 0; transition: opacity .25s; }
.portal-window {
  position: relative; width: min(1280px, 94vw); height: min(860px, 90vh); display: flex; flex-direction: column;
  background: var(--paper-2); border: 1.5px solid var(--ink); border-radius: 18px; box-shadow: 6px 6px 0 var(--ink);
  overflow: hidden; transform: translateY(16px) scale(.98); opacity: 0; transition: transform .28s cubic-bezier(.2,.8,.2,1), opacity .25s;
}
.portal.open .portal-backdrop { opacity: 1; }
.portal.open .portal-window { transform: none; opacity: 1; }
.portal-bar { display: flex; align-items: center; gap: 10px; padding: 8px 10px 8px 14px; border-bottom: 1.5px solid var(--ink); background: #fff; }
.portal-bar .st-icon { width: 24px; height: 24px; border-radius: 50%; background: #2f6db3; color: #fff; display: grid; place-items: center; font: 700 12px var(--mono); flex: none; }
.portal-bar h2 { margin: 0; font-size: 17px; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.portal-bar .pt-en { font: 500 12px var(--mono); color: #2f6db3; text-transform: uppercase; letter-spacing: .06em; }
.portal-close { border: 1.5px solid var(--ink); background: var(--paper-2); width: 34px; height: 34px; border-radius: 50%; font-size: 22px; line-height: 1; cursor: pointer; flex: none; }
.portal-close:hover { background: var(--ink); color: var(--paper-2); }
.portal-body { position: relative; flex: 1; background: #f8f5eb; }
.portal-frame { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; opacity: 0; transition: opacity .3s; }
.portal.loaded .portal-frame { opacity: 1; }
.portal-loading { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 12px; color: var(--ink-2); font-size: 14px; }
.portal.loaded .portal-loading { display: none; }
.spinner { width: 28px; height: 28px; border: 3px solid #d8cfbd; border-top-color: #2f6db3; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (max-width: 640px) {
  .portal-window { width: 100vw; height: 100dvh; border-radius: 0; border: 0; box-shadow: none; }
  .portal-bar { padding-top: max(8px, env(safe-area-inset-top)); }
  .portal-newtab { display: none; }
}
@media (prefers-reduced-motion: reduce) { .portal-window, .portal-backdrop { transition: none; } .spinner { animation: none; } }
