/* optcg.ch: the Thousand Sunny as a blueprint with callouts. Local fonts only, no external requests. */
@font-face { font-family: "IBM Plex Mono"; src: url("../fonts/ibm-plex-mono-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "IBM Plex Mono"; src: url("../fonts/ibm-plex-mono-latin-500-normal.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "IBM Plex Mono"; src: url("../fonts/ibm-plex-mono-latin-600-normal.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Barlow Condensed"; src: url("../fonts/barlow-condensed-latin-500-normal.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Barlow Condensed"; src: url("../fonts/barlow-condensed-latin-600-normal.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Barlow Condensed"; src: url("../fonts/barlow-condensed-latin-700-normal.woff2") format("woff2"); font-weight: 700; font-display: swap; }

:root {
    --bp: #10375a;
    --bp-deep: #0b2a46;
    --line: #dcecff;
    --muted: #9cc2e8;
    --faint: rgba(220, 236, 255, .14);
    --mark: #ffd23f;
    --ink: #0b2a46;
    --cond: "Barlow Condensed", "Arial Narrow", sans-serif;
    --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
    --ease: cubic-bezier(.2, .8, .2, 1);
}

* { box-sizing: border-box; }
html { background: var(--bp-deep); -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    color: var(--line);
    font: 400 14px/1.5 var(--mono);
    background-color: var(--bp);
    background-image:
        linear-gradient(var(--faint) 1px, transparent 1px),
        linear-gradient(90deg, var(--faint) 1px, transparent 1px),
        linear-gradient(rgba(220, 236, 255, .06) 1px, transparent 1px),
        linear-gradient(90deg, rgba(220, 236, 255, .06) 1px, transparent 1px);
    background-size: 80px 80px, 80px 80px, 16px 16px, 16px 16px;
}
a { color: inherit; }
button { font: inherit; }
:focus-visible { outline: 3px solid var(--mark); outline-offset: 2px; }
.zone:focus-visible, .callout:focus-visible { outline: none; }
.defs { position: absolute; }
.visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ---------- screen: header, chart, topics, footer; with JavaScript the page never scrolls ---------- */
.screen { display: flex; flex-direction: column; height: 100vh; height: 100dvh; min-height: 300px; }
.js body { overflow: hidden; }
.top { flex: none; display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .4rem .9rem; border-bottom: 2px solid var(--line); background: var(--bp); }
.logo { display: flex; align-items: center; gap: .5rem; text-decoration: none; }
.logo svg { width: 24px; height: 24px; }
.logo-text { font: 700 1.45rem/1 var(--cond); text-transform: uppercase; letter-spacing: .06em; }
.tagline { margin: 0; font-size: .68rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); text-align: right; }

.stage { position: relative; flex: 1; min-height: 0; overflow: hidden; }
.sheetwrap { position: absolute; inset: 0; }
.chart { position: absolute; inset: 0; width: 100%; height: 100%; display: block; color: var(--line); transform-origin: 0 0; transition: transform .65s var(--ease); will-change: transform; }
.chart.plan { display: none; }

/* ---------- drawing ---------- */
.draw path, .draw circle, .draw polygon, .draw rect { fill: none; stroke: var(--line); stroke-width: 1.6; stroke-linejoin: round; stroke-linecap: round; }
.draw .thin { stroke: var(--muted); stroke-width: 1; }
.draw .hull, .draw .mast { stroke-width: 2.6; }
.draw .hull, .draw .sail, .draw .mane { fill: var(--bp); }
.draw .rig { stroke: var(--muted); stroke-width: .9; }
.draw .water { stroke: var(--muted); stroke-width: 1.1; stroke-dasharray: 4 3; }
.draw .wave { stroke: var(--muted); stroke-width: 1.1; }
.draw .deck { stroke-width: 2; }
.draw .rib { stroke: var(--muted); stroke-width: .9; stroke-dasharray: 2 4; opacity: .8; }
.draw .plank { fill: url(#plank); stroke: none; color: var(--muted); opacity: .55; }
.draw .furn path, .draw .furn circle, .draw .furn rect { stroke: var(--muted); stroke-width: 1.1; }
.draw .grass { fill: url(#grass); stroke: none; color: var(--muted); }
.draw .dim { stroke: var(--muted); stroke-width: 1; }
.draw text { fill: var(--muted); stroke: none; font: 500 11px var(--mono); letter-spacing: .1em; }
.draw .lvl { font-size: 13px; }
.draw .dimt { letter-spacing: .16em; font-size: 10.5px; }

/* ---------- rooms, badges, callouts ---------- */
.zone { cursor: pointer; -webkit-tap-highlight-color: transparent; }
.zone .fill { fill: rgba(11, 42, 70, .12); }
.zone .hatch { color: var(--mark); opacity: 0; transition: opacity .2s; pointer-events: none; }
.zone .edge { fill: none; stroke: var(--muted); stroke-width: 1.3; stroke-dasharray: 7 4; transition: stroke .2s; }
.badge { pointer-events: none; }
.badge circle { fill: var(--bp-deep); stroke: var(--line); stroke-width: 1.6; }
.badge text { fill: var(--line); font: 600 24px var(--mono); text-anchor: middle; dominant-baseline: central; }
.zone.hl .hatch, .zone.on .hatch, .zone:active .hatch { opacity: .26; }
.zone.hl .edge, .zone.on .edge, .zone:active .edge { stroke: var(--mark); stroke-width: 3; stroke-dasharray: none; }
.zone.hl .badge circle, .zone.on .badge circle { fill: var(--mark); stroke: var(--mark); }
.zone.hl .badge text, .zone.on .badge text { fill: var(--ink); }

.callout { cursor: pointer; -webkit-tap-highlight-color: transparent; }
.callout .hit { fill: transparent; }
.callout .leader { fill: none; stroke: var(--muted); stroke-width: 1.3; stroke-linejoin: round; marker-start: url(#dot); pointer-events: none; transition: stroke .2s; }
.callout .box { fill: var(--bp-deep); stroke: var(--line); stroke-width: 1.8; transition: stroke .2s; }
.callout .ct { fill: var(--line); font: 700 25px var(--cond); letter-spacing: .03em; dominant-baseline: central; }
.callout.hl .box, .callout.on .box, .callout:focus-visible .box { stroke: var(--mark); stroke-width: 3; }
.callout.hl .leader, .callout.on .leader, .callout:focus-visible .leader { stroke: var(--mark); stroke-width: 2.2; }
.callout.hl .ct, .callout.on .ct, .callout:focus-visible .ct { fill: var(--mark); }
.callout:focus-visible .box { stroke-dasharray: 8 4; }
.zoomed .callout:not(.on) { opacity: .12; transition: opacity .3s; }
.zoomed .zone:not(.on) { opacity: .35; }

/* ---------- first-visit animation: the ship is drawn, then the callouts follow (about 1.4 s); html.intro is set once per browser ---------- */
@keyframes appear { from { opacity: 0; } }
@keyframes trace { from { stroke-dasharray: 1; stroke-dashoffset: 1; } to { stroke-dasharray: 1; stroke-dashoffset: 0; } }
.intro .draw .hull { animation: trace .7s var(--ease) backwards; }
.intro .draw .mast { animation: trace .55s var(--ease) .2s backwards; }
.intro .draw .deck { animation: trace .5s var(--ease) .3s backwards; }
.intro .draw .part { animation: trace .65s var(--ease) .35s backwards; }
.intro .draw .thin { animation: trace .55s var(--ease) .5s backwards; }
.intro .draw .rig { animation: trace .5s var(--ease) .55s backwards; }
.intro .draw .furn, .intro .draw .rib, .intro .draw .g-base text { animation: appear .4s ease .7s backwards; }
.intro .callout { animation: appear .25s ease calc(.75s + var(--i, 0) * 30ms) backwards; }
.intro .callout .leader { animation: trace .4s var(--ease) calc(.75s + var(--i, 0) * 30ms) backwards; }
.intro .topics li { animation: appear .25s ease calc(.75s + var(--i, 0) * 30ms) backwards; }

/* ---------- callouts under the ship (portrait): 2 columns x 5 rows ---------- */
.topics { flex: none; }
.topics ol { list-style: none; margin: 0 auto; padding: .6rem .75rem; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: repeat(5, minmax(44px, 56px)); gap: 8px; max-width: 720px; }
.topics li { display: flex; min-height: 0; }
.topics a { position: relative; flex: 1; display: flex; align-items: center; gap: .5rem; min-width: 0; padding: 0 .6rem; text-decoration: none; background: var(--bp-deep); border: 1.5px solid var(--line); }
.topics a::before { content: ""; position: absolute; left: 50%; top: -9px; width: 1.5px; height: 8px; background: var(--muted); } /* short leader stub between the rows */
.topics li:nth-child(-n+2) a::before { content: none; } /* the top row has no row above it */
.t-no { flex: none; display: grid; place-items: center; width: 1.6rem; height: 1.6rem; border: 1.5px solid var(--line); border-radius: 50%; font-size: .72rem; font-weight: 600; }
.t-txt { min-width: 0; font: 700 1.2rem/1.02 var(--cond); text-transform: uppercase; letter-spacing: .04em; overflow-wrap: anywhere; }
.topics a:active, .topics a.hl, .topics a.on { background: var(--mark); color: var(--ink); border-color: var(--mark); }
.topics a:active .t-no, .topics a.hl .t-no, .topics a.on .t-no { border-color: var(--ink); }
.topics a:focus-visible { outline-offset: 0; }

/* ---------- footer ---------- */
.site-footer { flex: none; padding: .3rem .9rem calc(.3rem + env(safe-area-inset-bottom)); border-top: 1px solid var(--faint); background: var(--bp); font: 500 13px/1.3 var(--cond); letter-spacing: .03em; color: var(--muted); text-align: center; }
.site-footer p { margin: 0; }

/* ---------- link rows (sheet and no-JavaScript sections) ---------- */
.room-sections { max-width: 720px; margin: 0 auto; padding: 1rem .75rem 2rem; }
.js .room-sections { display: none; }
.room-section { margin-bottom: 2rem; }
.room-section h2 { font: 700 2rem/1.05 var(--cond); text-transform: uppercase; margin: .5rem 0 0; }
.room-description { margin: .25rem 0 .75rem; font-size: .76rem; color: var(--muted); }
.room-empty { padding: .9rem; border: 1px dashed var(--muted); color: var(--muted); font-size: .8rem; }
.link-list { list-style: none; margin: 0; padding: 0; }
.link-tile a { display: grid; grid-template-columns: 44px minmax(0, 1fr); align-items: center; gap: .75rem; min-height: 64px; padding: .5rem .75rem; text-decoration: none; border-bottom: 1px solid var(--faint); }
.link-tile a:active, .link-tile a:focus-visible { background: var(--mark); color: var(--ink); outline-color: var(--line); outline-offset: -3px; }
.link-icon { display: block; width: 44px; height: 44px; }
.link-icon img, .tile-fallback, .tile-add { display: grid; place-items: center; width: 44px; height: 44px; object-fit: cover; border: 1px solid var(--line); }
.link-icon img { background: #fff; }
.tile-fallback { font: 700 1.5rem var(--cond); color: #fff; }
.tile-add { font: 600 1.6rem var(--cond); background: var(--bp-deep); color: var(--line); border-style: dashed; }
.link-text { display: grid; min-width: 0; line-height: 1.25; }
.link-title { font: 600 1.25rem/1.1 var(--cond); text-transform: uppercase; letter-spacing: .04em; }
.link-description { font-size: .74rem; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.lang-badge { margin-left: .4rem; padding: 0 .3rem; border: 1px solid currentColor; font: 500 .68rem var(--mono); letter-spacing: .1em; vertical-align: middle; color: var(--muted); }
.link-tile a:active .link-description, .link-tile a:focus-visible .link-description, .link-tile a:active .lang-badge, .link-tile a:focus-visible .lang-badge { color: var(--ink); }

/* ---------- bottom sheet (portrait) / side panel (landscape) ---------- */
dialog {
    position: fixed; inset: 0; margin: auto auto 0; padding: 0; border: 0; border-top: 2px solid var(--line);
    width: min(100%, 720px); max-width: none; height: 62dvh; max-height: none; overflow: hidden;
    color: var(--line); background-color: var(--bp);
    background-image: linear-gradient(var(--faint) 1px, transparent 1px), linear-gradient(90deg, var(--faint) 1px, transparent 1px);
    background-size: 80px 80px;
    transform: translateY(100%); transition: transform .4s var(--ease);
    flex-direction: column;
}
dialog[open] { display: flex; }
dialog.in { transform: none; }
@keyframes slide-in { from { opacity: 0; transform: translateY(10px); } }
dialog.in .link-tile { animation: slide-in .3s var(--ease) calc(.15s + var(--i, 0) * 45ms) backwards; }
dialog::backdrop { background: rgba(6, 22, 38, .28); touch-action: none; }
.sheet-head { flex: none; position: relative; touch-action: none; display: flex; align-items: flex-start; justify-content: space-between; gap: .75rem; padding: 1rem .9rem .65rem; background: var(--bp); border-bottom: 2px solid var(--line); }
.grip { position: absolute; top: 8px; left: 50%; width: 44px; height: 4px; margin-left: -22px; background: var(--muted); }
.sheet-kicker { margin: 0; font-size: .66rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.sheet-title h2 { margin: 0; font: 700 2.2rem/1 var(--cond); text-transform: uppercase; }
.sheet-title h2:focus { outline: none; }
.sheet-close { flex: none; min-width: 44px; min-height: 44px; padding: 0 .9rem; color: var(--line); background: transparent; border: 1.5px solid var(--line); text-transform: uppercase; letter-spacing: .1em; font-size: .72rem; cursor: pointer; }
.sheet-close:active { background: var(--line); color: var(--ink); }
.sheet-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding-bottom: env(safe-area-inset-bottom); }
.sheet-body > .back-link, .sheet-body > h2 { display: none; }
.sheet-body .room-description { margin: 0; padding: .6rem .9rem; border-bottom: 1px solid var(--faint); }
.sheet-body .room-empty { margin: .75rem; }

/* ---------- landscape: the plan with callouts fills the screen, the panel slides in from the right ---------- */
@media (min-aspect-ratio: 1/1) {
    .chart.plan { display: block; }
    .chart.ship, .topics { display: none; }
    .top { padding: .25rem .9rem; }
    .logo svg { width: 20px; height: 20px; }
    .logo-text { font-size: 1.2rem; }
    dialog {
        margin: 0 0 0 auto; inset: 0 0 0 auto; width: min(440px, 42vw); height: 100vh; height: 100dvh; border-top: 0; border-left: 2px solid var(--line);
        transform: translateX(100%);
    }
    .grip { display: none; }
    .site-footer { padding-block: .15rem; }
    .site-footer p { display: inline; }
}
@media (max-width: 520px) {
    .tagline { display: none; }
}
@media (max-height: 500px) {
    .sheet-title h2 { font-size: 1.7rem; }
}

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