/* 北京 · 五环之内 — interface chrome.
   Palette is taken from the city's own materials; one typeface (Source Han Serif, subset in /fonts). */

@font-face { font-family: 'Jing Serif'; src: url('../fonts/jing-serif-400.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Jing Serif'; src: url('../fonts/jing-serif-600.woff2') format('woff2'); font-weight: 600; font-display: swap; }
@font-face { font-family: 'Jing Serif'; src: url('../fonts/jing-serif-900.woff2') format('woff2'); font-weight: 900; font-display: swap; }

:root {
  --marble: #f3ecdd;       /* 汉白玉: text over the scene */
  --ink: #1d1814;          /* 墨 */
  --palace: #a22f24;       /* 宫墙红: the one accent */
  --glaze: #e2aa35;        /* 琉璃黄: the sun */
  --moon: #dfe6f5;
  --shade: 0 1px 1px rgba(24, 16, 10, .55), 0 0 14px rgba(24, 16, 10, .5);
  --serif: 'Jing Serif', 'Source Han Serif SC', 'Noto Serif CJK SC', 'Songti SC', 'STSong', 'SimSun', serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #14110e; overflow: hidden; }
body { font-family: var(--serif); color: var(--marble); -webkit-font-smoothing: antialiased; }

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

/* ---------------------------------------------------------------- layout */
#ui {
  position: fixed; inset: 0; pointer-events: none;
  display: grid; grid-template-columns: 1fr auto 1fr; grid-template-rows: auto 1fr auto auto auto;
  grid-template-areas: 'mast . compass' '. . .' 'loader hint .' 'places dial switches' '. . credit';
  gap: 10px 20px; padding: 22px 26px 12px;
  text-shadow: var(--shade);
  transition: opacity .5s;
}
/* soft scrims keep the text readable over a bright, busy city without boxing it in */
#ui::before { content: ''; position: absolute; inset: 0; pointer-events: none; z-index: 0; transition: opacity .5s;
  background: linear-gradient(to top, rgba(22, 15, 9, .5), rgba(22, 15, 9, .18) 110px, transparent 210px), linear-gradient(to bottom, rgba(22, 15, 9, .34), transparent 130px); }
body.bare #ui::before { opacity: 0; }
body.bare .hint { display: none; }
#ui > * { pointer-events: auto; position: relative; z-index: 1; }
#ui > .labels { position: absolute; z-index: 0; }
#ui > .labels { pointer-events: none; }
body.bare #ui > :not(.labels) { opacity: 0; pointer-events: none; transition: opacity .4s; }

button { font: inherit; color: inherit; background: none; border: 0; padding: 6px 2px; cursor: pointer; text-shadow: inherit; opacity: .84; transition: opacity .2s; }
button:hover { opacity: 1; }
:focus-visible { outline: 2px solid var(--glaze); outline-offset: 3px; border-radius: 2px; }

/* ---------------------------------------------------------------- masthead */
.masthead { grid-area: mast; display: flex; align-items: center; gap: 14px; pointer-events: none !important; }
.seal {
  width: 48px; height: 48px; flex: none; display: grid; place-items: center;
  background: var(--palace); color: #f7eedb; font-weight: 900; font-size: 31px; line-height: 1; text-shadow: none;
  border-radius: 5px 4px 6px 4px; transform: rotate(-2deg);
  box-shadow: inset 0 0 0 2px rgba(247, 238, 219, .3), 0 2px 12px rgba(20, 10, 6, .35);
}
.title h1 { margin: 0; font-size: 40px; font-weight: 900; letter-spacing: .18em; line-height: 1; }
.title p { margin: 8px 0 0; font-size: 13.5px; letter-spacing: .34em; opacity: .92; }

/* ---------------------------------------------------------------- compass */
.compass { grid-area: compass; justify-self: end; align-self: start; width: 46px; height: 46px; padding: 0; opacity: .9; }
.compass .rose { position: relative; display: block; width: 100%; height: 100%; border: 1px solid rgba(243, 236, 221, .55); border-radius: 50%; }
.compass i { position: absolute; left: 50%; top: 5px; width: 0; height: 0; margin-left: -4px; border: 4px solid transparent; border-bottom: 9px solid var(--palace); border-top: 0; filter: drop-shadow(0 0 2px rgba(20, 10, 6, .5)); }
.compass b { position: absolute; left: 0; right: 0; top: 17px; text-align: center; font-size: 15px; font-weight: 600; line-height: 1; }

/* ---------------------------------------------------------------- places */
.places { grid-area: places; align-self: end; display: flex; flex-wrap: wrap; gap: 2px 18px; max-width: 470px; }
.places button { position: relative; font-size: 15.5px; letter-spacing: .08em; padding: 7px 0 8px; }
.places button::after { content: ''; position: absolute; left: 0; right: 0; bottom: 3px; height: 2px; background: var(--palace); transform: scaleX(0); transform-origin: left; transition: transform .35s; box-shadow: 0 0 6px rgba(20, 10, 6, .4); }
.places button.current { opacity: 1; }
.places button.current::after { transform: scaleX(1); }

/* ---------------------------------------------------------------- sun-path dial */
.sundial { grid-area: dial; align-self: end; width: 324px; text-align: center; }
.sundial svg { display: block; width: 100%; height: auto; overflow: visible; cursor: ew-resize; touch-action: none; filter: drop-shadow(0 1px 2px rgba(24, 16, 10, .55)); }
.sundial path { fill: none; stroke-linecap: round; }
.sundial .night { stroke: rgba(243, 236, 221, .42); stroke-width: 1.2; stroke-dasharray: 1.5 4.5; }
.sundial .day { stroke: var(--marble); stroke-width: 1.7; }
.sundial .horizon { stroke: rgba(243, 236, 221, .5); stroke-width: 1; }
.sundial .halo { fill: rgba(226, 170, 53, .28); transition: fill .6s; }
.sundial .disc { fill: var(--glaze); stroke: rgba(255, 244, 214, .9); stroke-width: 1; transition: fill .6s; }
.sundial.night .disc { fill: var(--moon); stroke: #fff; }
.sundial.night .halo { fill: rgba(190, 205, 240, .22); }
.clock { margin: 2px 0 0; font-size: 15px; font-variant-numeric: tabular-nums; }
.clock b { font-size: 17px; font-weight: 600; letter-spacing: .22em; margin-right: .5em; }
.clock span { opacity: .88; letter-spacing: .06em; }
.moments { display: flex; justify-content: center; gap: 14px; margin-top: 2px; }
.moments button { font-size: 13px; letter-spacing: .06em; padding: 5px 0; }

/* ---------------------------------------------------------------- switches */
.switches { grid-area: switches; align-self: end; justify-self: end; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 2px 16px; max-width: 330px; }
.switches button { font-size: 14px; letter-spacing: .06em; display: inline-flex; align-items: center; gap: 7px; }
.switches i { width: 9px; height: 9px; border: 1px solid var(--marble); box-shadow: 0 0 5px rgba(24, 16, 10, .5); transition: background .2s; }
.switches [aria-pressed='true'] i { background: var(--marble); }
.switches .plain { opacity: .72; }
.switches .plain:hover { opacity: 1; }

.credit { grid-area: credit; justify-self: end; margin: 0; font-size: 11.5px; letter-spacing: .04em; opacity: .7; cursor: pointer; }
.credit:hover { opacity: 1; }

/* ---------------------------------------------------------------- loader + hint */
.loader { grid-area: loader; align-self: end; display: flex; align-items: center; gap: 12px; font-size: 13px; letter-spacing: .12em; transition: opacity .9s .5s; }
.loader .bar { width: 150px; height: 2px; background: rgba(243, 236, 221, .28); overflow: hidden; }
.loader .bar i { display: block; height: 100%; background: var(--marble); transform: scaleX(.02); transform-origin: left; transition: transform .4s; }
.loader.done { opacity: 0; pointer-events: none; }
.hint { grid-area: hint; align-self: end; margin: 0; font-size: 13px; letter-spacing: .1em; text-align: center; white-space: nowrap; animation: hint 11s forwards; }
@keyframes hint { 0%, 80% { opacity: .82; } 100% { opacity: 0; visibility: hidden; } }

.fatal { position: fixed; left: 50%; top: 46%; transform: translate(-50%, -50%); width: min(460px, calc(100vw - 48px)); margin: 0; padding: 22px 26px; background: #f4eddf; color: var(--ink);
  border-top: 3px solid var(--palace); text-shadow: none; font-size: 16px; line-height: 1.8; box-shadow: 0 24px 80px rgba(10, 6, 3, .55); z-index: 5; }

/* ---------------------------------------------------------------- labels */
.labels { inset: 0; overflow: hidden; transition: opacity .4s; }
.labels.off { opacity: 0; }
.label { position: absolute; left: 0; top: 0; width: 0; height: 0; opacity: 0; transition: opacity .45s; will-change: transform; }
.label.on { opacity: 1; }
.label .name { position: absolute; white-space: nowrap; }
.label.point .name { bottom: 34px; left: 0; transform: translateX(-50%); writing-mode: vertical-rl; letter-spacing: .2em; font-weight: 600; font-size: 14px; line-height: 1; }
.label.point.r1 .name { font-size: 17px; }
.label.point.r3 .name { font-size: 13px; font-weight: 400; }
.label .stem { position: absolute; left: -.5px; bottom: 0; width: 1px; height: 28px; background: linear-gradient(to top, rgba(243, 236, 221, .95), rgba(243, 236, 221, .3)); box-shadow: 0 0 4px rgba(24, 16, 10, .6); }
.label .stem::after { content: ''; position: absolute; left: -2px; bottom: -2px; width: 5px; height: 5px; border-radius: 50%; background: var(--marble); }
.label.area .name { transform: translate(-50%, -50%); font-size: 13px; letter-spacing: .34em; opacity: .9; }
.label.area.r2 .name { font-size: 14.5px; }
.label.area.r1 .name { font-size: 16px; font-weight: 600; }
.label.k-water .name { color: #e4eef4; font-style: italic; }
.label.k-hill .name { letter-spacing: .5em; }

/* ---------------------------------------------------------------- about */
dialog.about {
  width: min(540px, calc(100vw - 32px)); max-height: calc(100vh - 48px); overflow: auto;
  padding: 26px 30px 22px; border: 0; border-top: 3px solid var(--palace); border-radius: 2px;
  background: #f4eddf; color: var(--ink); text-shadow: none; font-family: var(--serif);
  box-shadow: 0 24px 80px rgba(10, 6, 3, .55);
}
dialog.about::backdrop { background: rgba(16, 11, 7, .58); }
dialog.about h2 { margin: 0 0 12px; font-size: 23px; font-weight: 900; letter-spacing: .06em; }
dialog.about p { margin: 0 0 14px; font-size: 15px; line-height: 1.85; }
dialog.about dl { margin: 0 0 16px; display: grid; grid-template-columns: max-content 1fr; gap: 9px 18px; font-size: 14px; line-height: 1.7; }
dialog.about dt { font-weight: 600; white-space: nowrap; }
dialog.about dd { margin: 0; }
dialog.about .keys { font-size: 13.5px; opacity: .8; }
dialog.about form { text-align: right; margin: 0; }
dialog.about button { opacity: 1; padding: 8px 22px; background: var(--ink); color: #f4eddf; border-radius: 2px; font-size: 14px; letter-spacing: .2em; }

/* ---------------------------------------------------------------- small screens */
@media (max-width: 860px) {
  #ui { grid-template-columns: 1fr auto; grid-template-rows: auto 1fr auto auto auto auto; grid-template-areas: 'mast compass' '. .' 'loader loader' 'places places' 'dial dial' 'switches switches'; padding: 14px 14px 10px; gap: 6px 10px; }
  .seal { width: 38px; height: 38px; font-size: 24px; }
  .title h1 { font-size: 29px; }
  .title p { font-size: 12px; letter-spacing: .26em; margin-top: 6px; }
  .compass { width: 40px; height: 40px; }
  .compass b { top: 14px; font-size: 13.5px; }
  .places, .switches { max-width: none; flex-wrap: nowrap; overflow-x: auto; justify-content: flex-start; justify-self: stretch; scrollbar-width: none; gap: 0 18px; padding: 0 2px; }
  .places::-webkit-scrollbar, .switches::-webkit-scrollbar { display: none; }
  .places button, .switches button { flex: none; white-space: nowrap; }
  .sundial { width: min(324px, 100%); justify-self: center; }
  .hint, .credit { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
