/* curionode.com — curio-node and curio-city.
 *
 * The page is one scene at night, drawn on a canvas by hub.js: every course a
 * node in a web, coloured by its field; held together, the nodes rise into a
 * city whose lit windows are the courses' plates. The HTML around it is only
 * the name, one paragraph, the search bar and a button, laid over the scene
 * and kept out of its way. The scene is the same in light and dark mode: it is
 * a night, not a theme.
 */

:root {
    --night:   #0c1220;
    --night-2: #141c33;
    --paper:   #ece6d6;
    --mute:    #9ba4bb;
    --faint:   #69728b;
    --lamp:    #ffc96b;
    --glass:   rgb(16 23 42 / 0.82);
    --edge:    rgb(236 230 214 / 0.16);

    --display: 'Fraunces', Georgia, 'Times New Roman', serif;
    --body:    'Source Serif 4', Georgia, 'Times New Roman', serif;
    --cjk:     'Source Serif 4', 'Noto Serif SC', 'Source Han Serif SC', 'Songti SC', 'STSong', 'SimSun', serif;
    --gutter:  clamp(16px, 3.4vw, 40px);
    color-scheme: dark;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; height: 100%; }
body {
    min-height: 100%;
    background: var(--night);
    color: var(--paper);
    font-family: var(--body);
    font-size: 17px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}
body.lang-zh { font-family: var(--cjk); line-height: 1.7; }
a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
:focus-visible { outline: 2px solid var(--lamp); outline-offset: 3px; border-radius: 3px; }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip { position: absolute; left: -9999px; z-index: 20; }
.skip:focus { left: var(--gutter); top: 8px; background: var(--night); padding: 6px 10px; }

/* ── the stage ────────────────────────────────────────────────────── */

.stage {
    position: fixed; inset: 0;
    overflow: hidden;
    background: radial-gradient(120% 90% at 50% 38%, var(--night-2), var(--night) 70%);
}
#scene {
    position: absolute; inset: 0; width: 100%; height: 100%;
    display: block;
    touch-action: none;
    -webkit-user-select: none; user-select: none;
    -webkit-touch-callout: none;
    cursor: grab;
}
body.over #scene { cursor: pointer; }
body.holding #scene { cursor: grabbing; }

/* The overlays sit on the scene but let presses through to it, except where
   there is something to press. */
.intro, .dock, .fine, .card { position: absolute; z-index: 2; }
.intro { top: 0; left: 0; padding: clamp(18px, 4vh, 40px) var(--gutter) 0; pointer-events: none; max-width: 640px; }

.name {
    font-family: var(--display);
    font-variation-settings: 'opsz' 144, 'SOFT' 100;
    font-weight: 600;
    font-size: clamp(46px, 7.6vw, 104px);
    line-height: 0.95;
    letter-spacing: -0.035em;
    text-shadow: 0 2px 24px rgb(12 18 32 / 0.9);
    white-space: nowrap;
}
/* The hyphen is a thread between two words, as the web's threads are. */
.name .hy {
    display: inline-block; vertical-align: 0.3em;
    width: 0.3em; height: 0.07em; margin: 0 0.05em 0 0.07em;
    background: var(--lamp); color: transparent; overflow: hidden;
    border-radius: 1em;
    box-shadow: 0 0 12px rgb(255 201 107 / 0.7);
}
.name .sw { display: inline-block; }
.name .sw span { display: inline-block; transform-origin: 50% 60%; }
.name .sw span.flip { animation: flip 300ms ease-in-out; }
@keyframes flip {
    0%   { transform: none; opacity: 1; }
    50%  { transform: rotateX(90deg) translateY(-0.08em); opacity: 0.2; }
    100% { transform: none; opacity: 1; }
}

/* The two themes. The first belongs to the web — understanding is the
   threads you draw yourself — and the second to the city, which only rises
   because you went and pulled things together. Each is lit in its own mode. */
.themes {
    margin-top: 18px; max-width: 34ch;
    font-family: var(--display);
    font-variation-settings: 'opsz' 48, 'SOFT' 100;
    font-style: italic; font-weight: 500;
    font-size: clamp(17px, 1.7vw, 22px); line-height: 1.3;
    text-shadow: 0 1px 14px rgb(12 18 32 / 0.95);
    text-wrap: balance;
}
.lang-zh .themes { font-family: var(--cjk); font-style: normal; font-weight: 600; max-width: 22em; line-height: 1.5; }
.themes .th {
    display: block; position: relative; padding-left: 16px;
    color: var(--mute);
    transition: color 600ms ease-out;
}
.themes .th + .th { margin-top: 4px; }
.themes .th::before {
    content: ""; position: absolute; left: 0; top: 0.62em;
    width: 7px; height: 7px; border-radius: 50%;
    background: var(--faint);
    transition: background 600ms ease-out, box-shadow 600ms ease-out;
}
[data-mode="web"] .th-0, [data-mode="city"] .th-1 { color: var(--paper); }
[data-mode="web"] .th-0::before, [data-mode="city"] .th-1::before {
    background: var(--lamp); box-shadow: 0 0 10px rgb(255 201 107 / 0.8);
}

.deck {
    margin-top: 14px; max-width: 46ch;
    font-size: clamp(15px, 1.35vw, 17.5px); color: var(--mute);
    text-shadow: 0 1px 12px rgb(12 18 32 / 0.95);
    text-wrap: pretty;
}
.lang-zh .deck { max-width: 30em; }

.lang {
    position: absolute; z-index: 2; top: clamp(18px, 4vh, 40px); right: var(--gutter);
    font-size: 15px; color: var(--mute); text-decoration: none;
    padding: 4px 2px;
}
.lang:hover { color: var(--paper); text-decoration: underline; }

/* ── the dock: search, and the one button ─────────────────────────── */

.dock {
    left: 50%; bottom: max(38px, env(safe-area-inset-bottom));
    transform: translateX(-50%);
    width: min(640px, calc(100% - 2 * var(--gutter)));
}
.search { position: relative; }
.search input {
    width: 100%; height: 56px;
    font: inherit; font-size: 18px; color: var(--paper);
    background: var(--glass)
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239ba4bb' stroke-width='1.8'%3E%3Ccircle cx='10.5' cy='10.5' r='6.5'/%3E%3Cpath d='M15.5 15.5l5 5' stroke-linecap='round'/%3E%3C/svg%3E")
        no-repeat 18px 50% / 22px;
    border: 1px solid var(--edge);
    border-radius: 12px;
    padding: 0 18px 0 52px;
    -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
    -webkit-appearance: none; appearance: none;
    box-shadow: 0 10px 40px rgb(0 0 0 / 0.35);
}
.search input::placeholder { color: var(--faint); opacity: 1; }
.search input:focus { outline: none; border-color: rgb(255 201 107 / 0.7); }
.search input::-webkit-search-cancel-button { filter: invert(0.7); }

.hits {
    position: absolute; left: 0; right: 0; bottom: calc(100% + 8px);
    list-style: none;
    background: var(--glass);
    -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
    border: 1px solid var(--edge); border-radius: 12px;
    padding: 6px;
    max-height: min(52vh, 440px); overflow-y: auto;
    box-shadow: 0 10px 40px rgb(0 0 0 / 0.45);
}
.hits[hidden] { display: none; }
.hits li { border-radius: 8px; }
.hits a {
    display: grid; grid-template-columns: 10px 1fr; gap: 2px 12px; align-items: baseline;
    padding: 8px 12px; text-decoration: none;
}
.hits li[aria-selected="true"], .hits li:hover { background: rgb(236 230 214 / 0.08); }
.hits .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--fc); box-shadow: 0 0 8px var(--fc); align-self: center; }
.hits .t { font-family: var(--display); font-weight: 600; font-size: 17.5px; line-height: 1.3; }
.lang-zh .hits .t { font-family: var(--cjk); font-weight: 700; }
.hits .m { grid-column: 2; font-size: 14px; color: var(--mute); line-height: 1.35; }
.hits .more { padding: 8px 12px 6px 34px; font-size: 14px; color: var(--faint); font-style: italic; }
.lang-zh .hits .more { font-style: normal; }

.act { margin-top: 14px; display: flex; align-items: center; gap: 10px 18px; }
.build {
    flex: none;
    font: inherit; font-size: 15.5px; font-weight: 600;
    color: var(--night); background: var(--lamp);
    border: 0; border-radius: 9px;
    padding: 9px 18px;
    cursor: pointer;
    box-shadow: 0 6px 22px rgb(255 201 107 / 0.18);
    transition: transform 140ms ease-out;
}
.build:hover { transform: translateY(-1px); }
.build:active { transform: translateY(1px); }
.hint { font-size: 14px; color: var(--mute); line-height: 1.4; text-shadow: 0 1px 10px var(--night); }

.fine {
    right: var(--gutter); bottom: 12px;
    font-size: 13px; color: var(--faint);
}
.fine a { color: var(--mute); margin-left: 6px; }
.fine a:hover { color: var(--paper); }

/* ── the card that follows a node or building ─────────────────────── */

.card {
    left: 0; top: 0;
    width: max-content; max-width: min(320px, calc(100vw - 32px));
    pointer-events: none;
    background: var(--glass);
    -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
    border: 1px solid var(--edge);
    border-left: 3px solid var(--fc, var(--lamp));
    border-radius: 4px 10px 10px 4px;
    padding: 11px 15px 12px;
    box-shadow: 0 12px 36px rgb(0 0 0 / 0.45);
}
.card[hidden] { display: none; }
.card-name { font-family: var(--display); font-weight: 600; font-size: 20px; line-height: 1.2; }
.lang-zh .card-name { font-family: var(--cjk); font-weight: 700; }
.card-sec { font-family: var(--cjk); font-size: 14.5px; color: var(--mute); }
.lang-zh .card-sec { font-family: var(--display); font-style: italic; }
.card-line { margin-top: 6px; font-size: 15px; line-height: 1.45; color: var(--paper); }
.card-meta { margin-top: 7px; font-size: 13.5px; color: var(--mute); display: flex; align-items: center; gap: 8px; }
.card-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--fc); flex: none; }

/* ── no script; the missing page ──────────────────────────────────── */

.plain { position: relative; z-index: 5; background: var(--night); padding: 24px var(--gutter) 48px; }
.plain p { color: var(--mute); margin-bottom: 12px; }
.plain ul { columns: 16em; list-style: none; }
.plain li { padding: 2px 0; }

.missing main { max-width: 640px; margin: 0 auto; padding: 18vh var(--gutter) 0; }
.missing h1 { font-family: var(--display); font-weight: 600; font-size: clamp(40px, 6vw, 64px); line-height: 1.05; }
.missing p { margin-top: 18px; color: var(--mute); }
.missing a { color: var(--lamp); }

/* ── narrow and short screens ─────────────────────────────────────── */

@media (max-width: 760px) {
    .themes { margin-top: 12px; font-size: 16px; max-width: 30ch; }
    .themes .th { padding-left: 14px; }
    .deck { font-size: 14.5px; margin-top: 10px; max-width: 34ch; }
    .lang-zh .deck { max-width: 22em; }
    .search input { height: 50px; font-size: 16px; }
    .act { margin-top: 10px; }
    .hint { font-size: 13px; }
    .build { padding: 8px 14px; font-size: 15px; }
    .fine { left: 0; right: 0; bottom: 10px; text-align: center; font-size: 12px; }
}
@media (max-height: 560px) {
    .deck { display: none; }
}
@media (max-height: 400px) {
    .themes { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    .name .sw span.flip { animation: none; }
    .build, .themes .th, .themes .th::before { transition: none; }
}
