/* rittenberry.io
   Cyanotype blue ground, paper-white ink, one amber "safelight" accent.
   Everything sits on a 32px grid, the tile size of the game and the map designer. */

:root {
    --bg: #0b2239;
    --bg-2: #0f2d4a;
    --bg-3: #163d62;
    --line: rgba(190, 218, 240, 0.16);
    --line-strong: rgba(190, 218, 240, 0.34);
    --grid: rgba(190, 218, 240, 0.055);
    --text: #e8f1f8;
    --muted: #9db6cb;
    --amber: #ffb347;
    --amber-ink: #231400;
    --paper: #f1f6fa;
    --danger: #ff8a7a;

    --tile: 32px;
    --rail: 16rem;
    --font-display: "Big Shoulders Display", "Arial Narrow", "Helvetica Neue", Arial, sans-serif;
    --font-body: "Hanken Grotesk", "Segoe UI", system-ui, -apple-system, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html { color-scheme: dark; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 400 1.0625rem/1.6 var(--font-body);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--font-display); font-weight: 800; line-height: 1; margin: 0; letter-spacing: 0.005em; }
p { margin: 0 0 1rem; max-width: 62ch; }
a { color: var(--text); text-decoration-color: var(--amber); text-underline-offset: 0.2em; text-decoration-thickness: 2px; }
a:hover { color: var(--amber); }
ul { list-style: none; margin: 0; padding: 0; }
img { max-width: 100%; }
/* Canvases are never scaled by CSS: the map designer maps pointer position straight to pixels. */
canvas { max-width: none; }

:focus-visible { outline: 2px solid var(--amber); outline-offset: 3px; }

.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.skip-link {
    position: absolute; left: 1rem; top: -4rem; z-index: 50;
    background: var(--amber); color: var(--amber-ink); padding: 0.6rem 1rem; font-weight: 700;
}
.skip-link:focus { top: 1rem; color: var(--amber-ink); }

.muted { color: var(--muted); }

/* ---------- Shell ---------- */

.shell { display: grid; grid-template-columns: var(--rail) minmax(0, 1fr); min-height: 100vh; }

.rail {
    position: sticky; top: 0; align-self: start; height: 100vh;
    display: flex; flex-direction: column;
    padding: 1.5rem 0;
    background: var(--bg-2);
    border-right: 1px solid var(--line);
}
.rail-top { display: flex; align-items: center; justify-content: space-between; padding: 0 1.5rem 1.75rem; }
.wordmark {
    font: 800 2rem/1 var(--font-display); letter-spacing: 0.01em;
    text-decoration: none; color: var(--text);
}
.wordmark span { color: var(--muted); }
.wordmark:hover { color: var(--text); }
.wordmark:hover span { color: var(--amber); }

.rail nav { flex: 1; }
.rail-link {
    display: flex; align-items: center; gap: 0.85rem;
    padding: 0.7rem 1.5rem; text-decoration: none; color: var(--muted);
    border-left: 4px solid transparent; font-weight: 500;
}
.rail-link .fa { color: var(--muted); }
.rail-link:hover { color: var(--text); background: var(--bg-3); }
.rail-link.is-active { color: var(--text); border-left-color: var(--amber); background: var(--bg-3); }
.rail-link.is-active .fa { color: var(--amber); }
.rail-foot { margin: 0; padding: 0 1.5rem; color: var(--muted); font-size: 0.9rem; }
.rail-toggle { display: none; }

.stage {
    min-width: 0;
    padding: clamp(1.5rem, 4vw, 3.5rem);
    background-image:
        linear-gradient(var(--grid) 1px, transparent 1px),
        linear-gradient(90deg, var(--grid) 1px, transparent 1px);
    background-size: var(--tile) var(--tile);
    background-position: -1px -1px;
}
.stage:focus { outline: none; }

@media (max-width: 52rem) {
    .shell { display: block; }
    .rail { position: sticky; top: 0; z-index: 20; height: auto; padding: 0; border-right: 0; border-bottom: 1px solid var(--line); }
    .rail-top { padding: 0.75rem 1rem; }
    .wordmark { font-size: 1.6rem; }
    .rail-toggle {
        display: inline-flex; align-items: center; justify-content: center;
        width: 2.75rem; height: 2.75rem; background: none; color: var(--text);
        border: 1px solid var(--line-strong); border-radius: 0; cursor: pointer;
    }
    .rail nav, .rail-foot { display: none; }
    .rail.is-open nav { display: block; padding-bottom: 0.75rem; }
    .rail-link { padding: 0.85rem 1rem; }
}

/* ---------- Page heads and shared bits ---------- */

.page-head { margin-bottom: 2.5rem; }
.page-head h1 { font-size: clamp(3rem, 8vw, 5.5rem); line-height: 0.9; }
.lede { margin: 1rem 0 0; color: var(--muted); font-size: 1.15rem; max-width: 46ch; }
.section-title { font-size: 2rem; margin: 2.5rem 0 1rem; }

.btn {
    display: inline-flex; align-items: center; gap: 0.5rem;
    padding: 0.65rem 1.1rem; min-height: 2.75rem;
    font: 700 1rem/1 var(--font-body); text-decoration: none; cursor: pointer;
    background: var(--amber); color: var(--amber-ink); border: 2px solid var(--amber);
}
.btn:hover { background: #ffc673; border-color: #ffc673; color: var(--amber-ink); }
.btn-quiet { background: transparent; color: var(--text); border-color: var(--line-strong); }
.btn-quiet:hover { background: var(--bg-3); border-color: var(--text); color: var(--text); }
.btn.is-on { border-color: var(--amber); color: var(--amber); }
.btn:disabled, .btn:disabled:hover {
    cursor: not-allowed; opacity: 0.45; background: transparent; color: var(--muted); border-color: var(--line);
}
.actions { display: flex; flex-wrap: wrap; gap: 0.75rem; margin: 0 0 1.5rem; }

.notice { border: 1px solid var(--line-strong); background: var(--bg-2); padding: 1.25rem 1.5rem; max-width: 36rem; }
.notice p:last-child { margin-bottom: 0; }

/* ---------- Home ---------- */

.hero-name {
    /* Sized from the space the name has, so the longer line never runs off the screen. */
    font-size: clamp(3rem, calc((100vw - 3rem) / 6.2), 10rem);
    line-height: 0.84; margin-bottom: 2.5rem;
}
@media (min-width: 52rem) {
    .hero-name { font-size: clamp(3rem, calc((100vw - 16rem - 8rem) / 6.2), 10rem); }
}
.hero-body { display: grid; gap: 2rem; align-items: start; }
.hero-lede { font-size: 1.25rem; color: var(--muted); max-width: 30ch; margin: 0; }
@media (min-width: 64rem) {
    .hero-body { grid-template-columns: minmax(0, 0.6fr) minmax(0, 1.4fr); gap: 3rem; }
}

/* The world map is shown as a cyanotype print: its colours are mapped onto the page palette. */
.world { margin: 0; border: 1px solid var(--line-strong); background: var(--bg-2); padding: 0.75rem; }
.world canvas {
    display: block; width: 100%; height: auto; max-width: 100%;
    image-rendering: pixelated; cursor: crosshair;
    filter: url(#cyanotype);
}
.world figcaption { padding-top: 0.6rem; color: var(--muted); font-size: 0.95rem; min-height: 2rem; }
.world figcaption strong { color: var(--amber); font-weight: 700; }

.rooms { margin-top: clamp(3rem, 8vw, 6rem); max-width: 56rem; }
.rooms li { border-top: 1px solid var(--line-strong); }
.rooms li:last-child { border-bottom: 1px solid var(--line-strong); }
.room {
    display: grid; grid-template-columns: 3rem minmax(0, 14rem) minmax(0, 1fr);
    align-items: center; gap: 0.5rem 1rem;
    padding: 1rem 0.5rem; text-decoration: none; border-left: 4px solid transparent;
}
.room .fa { color: var(--amber); font-size: 1.4rem; text-align: center; }
.room-title { font: 800 2.1rem/1 var(--font-display); }
.room-blurb { color: var(--muted); }
.room:hover { background: var(--bg-2); border-left-color: var(--amber); color: var(--text); }
@media (max-width: 40rem) {
    .room { grid-template-columns: 2.5rem 1fr; }
    .room-blurb { grid-column: 2; }
}

/* Photography styles live in photography.css */

/* ---------- Contact ---------- */

.contact-mail { font: 800 clamp(2rem, 6vw, 3.5rem)/1.05 var(--font-display); margin-bottom: 2.5rem; }
.profiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr)); gap: 0.75rem; max-width: 44rem; }
.profiles a {
    display: flex; align-items: center; gap: 0.85rem; padding: 0.85rem 1rem;
    border: 1px solid var(--line-strong); text-decoration: none; background: var(--bg-2);
}
.profiles a:hover { border-color: var(--amber); color: var(--text); background: var(--bg-3); }
.profiles .fa { color: var(--amber); }

/* ---------- Game ---------- */

/* build-game:start */
.game-frame { display: inline-block; max-width: 100%; overflow: auto; padding: 0.75rem; border: 1px solid var(--line-strong); background: var(--bg-2); }
.game-frame canvas { display: block; background: #000; width: min(400px, calc(100vw - 4.5rem)); height: auto; aspect-ratio: 1; }

/* On-screen controls: only on touch screens. They send ordinary key events (see components/TouchControls.js). */
.touch-controls, .touch-help { display: none; }
@media (pointer: coarse) {
    .touch-controls {
        display: flex; align-items: center; justify-content: space-between; gap: 1rem;
        width: min(400px, calc(100vw - 4.5rem)); margin-top: 0.75rem; padding: 0 0.75rem 0 0.25rem;
        user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: none;
    }
    .touch-controls * { -webkit-tap-highlight-color: transparent; }
    /* Keep the game and its pad on one screen: the keyboard instructions and menu buttons move out of the way. */
    .game-page .page-head { margin-bottom: 0.9rem; }
    .game-page .lede, .game-page .game-buttons { display: none; }
    .touch-help { display: block; margin-top: 1rem; color: var(--muted); font-size: 0.9rem; }
}
.dpad { position: relative; width: 9.5rem; height: 9.5rem; border-radius: 50%; background: var(--bg-2); border: 1px solid var(--line-strong); touch-action: none; flex: none; }
.dpad-arm { position: absolute; background: var(--bg-3); border: 1px solid var(--line-strong); transition: background-color 0.06s; }
.dpad-arm.up, .dpad-arm.down { left: 50%; width: 2.9rem; margin-left: -1.45rem; height: 3.6rem; }
.dpad-arm.left, .dpad-arm.right { top: 50%; height: 2.9rem; margin-top: -1.45rem; width: 3.6rem; }
.dpad-arm.up { top: 0.35rem; border-radius: 0.6rem 0.6rem 0 0; }
.dpad-arm.down { bottom: 0.35rem; border-radius: 0 0 0.6rem 0.6rem; }
.dpad-arm.left { left: 0.35rem; border-radius: 0.6rem 0 0 0.6rem; }
.dpad-arm.right { right: 0.35rem; border-radius: 0 0.6rem 0.6rem 0; }
.dpad-arm.on { background: var(--amber); border-color: var(--amber); }
.dpad-hub { position: absolute; left: 50%; top: 50%; width: 2.9rem; height: 2.9rem; margin: -1.45rem 0 0 -1.45rem; background: var(--bg-3); }
.dpad-arm::after { content: ""; position: absolute; left: 50%; top: 50%; border: solid transparent; border-width: 0.4rem; }
.dpad-arm.up::after { border-bottom-color: var(--text); margin: -0.6rem 0 0 -0.4rem; }
.dpad-arm.down::after { border-top-color: var(--text); margin: -0.2rem 0 0 -0.4rem; }
.dpad-arm.left::after { border-right-color: var(--text); margin: -0.4rem 0 0 -0.6rem; }
.dpad-arm.right::after { border-left-color: var(--text); margin: -0.4rem 0 0 -0.2rem; }
.dpad-arm.on::after { border-bottom-color: var(--amber-ink); }
.dpad-arm.down.on::after { border-bottom-color: transparent; border-top-color: var(--amber-ink); }
.dpad-arm.left.on::after { border-bottom-color: transparent; border-right-color: var(--amber-ink); }
.dpad-arm.right.on::after { border-bottom-color: transparent; border-left-color: var(--amber-ink); }
.touch-side { display: flex; flex-direction: column; align-items: flex-end; gap: 1.1rem; min-width: 0; }
.touch-main { display: flex; gap: 0.9rem; align-items: flex-end; }
.touch-small { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 0.3rem; }
.touch-btn { font: inherit; font-weight: 700; color: var(--text); background: var(--bg-3); border: 1px solid var(--line-strong); touch-action: none; cursor: pointer; }
.touch-btn.on { background: var(--amber); color: var(--amber-ink); border-color: var(--amber); }
.touch-btn.round { width: 4rem; height: 4rem; border-radius: 50%; font-size: 1.25rem; }
.touch-btn.round.a { margin-bottom: 1.4rem; }
.touch-btn.small { padding: 0.4rem 0.5rem; border-radius: 999px; font-size: 0.65rem; letter-spacing: 0.03em; text-transform: uppercase; }
.game-buttons { display: flex; flex-wrap: wrap; gap: 0.75rem; margin: 1rem 0 0; }
/* build-game:end */

@media (prefers-reduced-motion: no-preference) {
    .rail-link, .room, .btn, .profiles a { transition: background-color 0.12s, border-color 0.12s, color 0.12s; }
}
