/* Shared look for every page. Colours and fonts follow brand/README.md;
   see "Design standards" in CLAUDE.md. */

/* Fonts are served from our own server (no third-party requests).
   Space Grotesk for headings, the wordmark's font; Inter for text. Both SIL OFL 1.1. */
@font-face { font-family: 'Space Grotesk'; font-style: normal; font-weight: 300 700; font-display: swap; src: url(/fonts/space-grotesk-latin-wght-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Space Grotesk'; font-style: normal; font-weight: 300 700; font-display: swap; src: url(/fonts/space-grotesk-latin-ext-wght-normal.woff2) format('woff2'); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 300 700; font-display: swap; src: url(/fonts/inter-latin-wght-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 300 700; font-display: swap; src: url(/fonts/inter-latin-ext-wght-normal.woff2) format('woff2'); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }

:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --text: #0d0d3b;
  --muted: #5a5d7a;
  --border: #dcdcea;
  --accent: #4555d6;
  --accent-hover: #3644b8;
  --accent-soft: #eceefe;
  --danger: #d93025;
  --shadow: 0 1px 3px rgba(13, 13, 59, .12), 0 4px 12px rgba(13, 13, 59, .08);
  --coral: #f26457;
  --coral-soft: #fdeceb;
  --on-coral: #ffffff;
  --lavender: #b8bcf4;
  --success: #188038;
  /* Behind 3D previews, in both themes. */
  --stage-top: #2e3858;
  --stage-bottom: #1d2433;
  --on-stage: #ffffff;
  --stage-label: rgb(0 0 0 / .55);
  /* A light studio backdrop for pictures of 3D things (the builder's palette), the same in dark mode. */
  --preview-light: #ffffff;
  --preview-bg: #dde2f0;
  /* Type. */
  --font-display: 'Space Grotesk', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --text-xs: 12px;
  --text-sm: 14px;
  --text-md: 16px;
  --text-lg: 18px;
  --text-xl: 22px;
  --text-2xl: 28px;
  --text-display: clamp(32px, 4vw, 48px);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-pill: 999px;
  --header-height: 56px;
  /* Spacing scale. Use these for every margin, padding and gap; see "Spacing" in CLAUDE.md. */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;
  --space-9: 80px;
  /* Space between page content and the edge of the screen: 16px on phones, up to 48px on wide screens. */
  --gutter: clamp(16px, 4vw, 48px);
  /* Content widths. */
  --page-max: 1200px;
  --text-max: 720px;
  color-scheme: light;
  font-family: var(--font-body);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1d2433;
    --surface: #262f42;
    --text: #eef0ff;
    --muted: #a3a8c3;
    --border: #3d4760;
    --accent: #8f9bff;
    --accent-hover: #b8bcf4;
    --accent-soft: #2f3a57;
    --danger: #f28b82;
    --coral-soft: #4a3140;
    --success: #81c995;
    --shadow: 0 1px 3px rgba(0, 0, 0, .4), 0 4px 12px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); min-height: 100vh; font-size: var(--text-md); line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); }
h1, h2, h3 { font-family: var(--font-display); font-weight: 500; letter-spacing: -.02em; line-height: 1.15; }

/* Layout: every page's content sits in a .container, which keeps it off the
   screen edges and caps its width. Add .narrow for long-form text. */
.container { width: 100%; max-width: calc(var(--page-max) + 2 * var(--gutter)); margin-inline: auto; padding-inline: var(--gutter); }
.container.narrow { max-width: calc(var(--text-max) + 2 * var(--gutter)); }

.topbar { position: sticky; top: 0; z-index: 10; min-height: var(--header-height); display: flex; align-items: center; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid transparent; transition: border-color .2s; }
.topbar.scrolled { border-bottom-color: var(--border); }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); padding-block: var(--space-3); }
.brand { display: flex; align-items: center; gap: var(--space-2); text-decoration: none; flex: none; }
.brand .mark { width: 32px; height: 32px; }
.brand picture { display: flex; }
.brand .wordmark { height: 21px; width: auto; }
.topbar-nav { display: flex; align-items: center; gap: var(--space-1); margin-left: var(--space-6); margin-right: auto; }
.topbar-nav a { display: inline-flex; align-items: center; gap: var(--space-2); height: 36px; padding: 0 var(--space-3); border-radius: var(--radius-pill); color: var(--muted); text-decoration: none; font-size: var(--text-sm); font-weight: 500; transition: background .15s, color .15s; }
.topbar-nav a svg { width: 16px; height: 16px; flex: none; }
.topbar-nav a:hover { color: var(--text); background: var(--accent-soft); }
.topbar-nav a[aria-current="page"] { color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: var(--space-4); color: var(--muted); font-size: var(--text-sm); }
.clock { white-space: nowrap; font-variant-numeric: tabular-nums; }
@media (max-width: 860px) {
  .topbar-nav, .clock { display: none; }
}

.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2); height: 40px; padding: 0 var(--space-5); border-radius: var(--radius-pill); border: 1px solid transparent; font: inherit; font-size: var(--text-sm); font-weight: 600; letter-spacing: 0; cursor: pointer; text-decoration: none; transition: background .15s, box-shadow .15s; }
.btn-primary { background: var(--accent); color: var(--bg); }
.btn-primary:hover { background: var(--accent-hover); box-shadow: 0 1px 2px rgba(60, 64, 67, .3), 0 1px 3px 1px rgba(60, 64, 67, .15); }
.btn-outline { background: transparent; color: var(--accent); border-color: var(--border); }
.btn-outline:hover { background: var(--accent-soft); }
.btn-text { background: none; color: var(--accent); padding: 0 var(--space-3); }
.btn-text:disabled { color: var(--muted); opacity: .6; cursor: default; }
.btn svg { width: 18px; height: 18px; flex: none; }

/* Account menu in the header (built by site.js). */
.account { position: relative; }
.account-btn { display: flex; align-items: center; gap: var(--space-2); height: 40px; padding: 0 var(--space-2) 0 var(--space-1); border: 1px solid var(--border); border-radius: var(--radius-pill); background: var(--surface); color: var(--text); font: inherit; font-size: var(--text-sm); font-weight: 600; cursor: pointer; transition: box-shadow .15s, border-color .15s; }
.account-btn:hover, .account-btn[aria-expanded="true"] { border-color: var(--accent); box-shadow: var(--shadow); }
.account-btn svg { width: 20px; height: 20px; }
.account-btn.menu-only { display: none; width: 40px; padding: 0; justify-content: center; }
.account-name { max-width: 14ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-chevron { display: grid; color: var(--muted); transition: transform .15s; }
.account-btn[aria-expanded="true"] .account-chevron { transform: rotate(180deg); }
.account-pic { display: grid; flex: none; }
.account-pic img, .account-pic .initial { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--accent); }
.account-pic .initial { display: grid; place-items: center; background: var(--accent); color: var(--bg); font-weight: 600; }
.account-pic.big img, .account-pic.big .initial { width: 48px; height: 48px; font-size: var(--text-lg); }
.account-menu { position: absolute; right: 0; top: calc(100% + var(--space-2)); z-index: 20; width: 280px; max-width: calc(100vw - 2 * var(--gutter)); padding: var(--space-2); border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); box-shadow: 0 12px 32px rgba(13, 13, 59, .18); animation: menu-in .14s ease-out; }
@keyframes menu-in { from { opacity: 0; transform: translateY(-4px); } }
.account-head { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3); margin-bottom: var(--space-1); border-radius: var(--radius-sm); background: var(--accent-soft); color: var(--text); text-decoration: none; }
.account-who { display: grid; min-width: 0; }
.account-who strong { font-family: var(--font-display); font-size: var(--text-md); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-who span { color: var(--muted); font-size: var(--text-sm); }
.account-links { display: grid; margin: 0; padding-block: var(--space-1); }
.account-links + .account-links { border-top: 1px solid var(--border); }
.account-links a, .account-links button { display: flex; align-items: center; gap: var(--space-3); width: 100%; height: 40px; padding: 0 var(--space-3); border: 0; border-radius: var(--radius-sm); background: none; color: var(--text); font: inherit; font-size: var(--text-sm); font-weight: 500; text-decoration: none; text-align: left; cursor: pointer; }
.account-links a:hover, .account-links button:hover, .account-links :focus-visible { background: var(--accent-soft); outline: none; }
.account-links svg { width: 20px; height: 20px; color: var(--muted); flex: none; }
.account-links a.current { color: var(--accent); font-weight: 600; }
.account-links a.current svg { color: var(--accent); }
.account-links .nav-only { display: none; }
@media (max-width: 860px) {
  .account-name, .account-chevron { display: none; }
  .account-btn { padding: 0 var(--space-1); }
  .account-btn.menu-only { display: flex; }
  .account-links .nav-only { display: flex; }
  .account-links .account-only { display: none; }
}

/* Privacy policy and terms pages. */
.legal { padding-block: var(--space-5) var(--space-8); line-height: 1.6; }
.legal h1 { font-size: var(--text-2xl); margin: var(--space-4) 0 var(--space-1); }
.legal h2 { font-size: 20px; font-weight: 500; margin: var(--space-6) 0 var(--space-2); }
.legal .updated { color: var(--muted); margin: 0 0 var(--space-5); }
.legal li { margin: var(--space-1) 0; }
.site-footer { margin-top: auto; border-top: 1px solid var(--border); color: var(--muted); font-size: var(--text-sm); }
.footer-inner { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: var(--space-4) var(--space-6); padding-block: var(--space-5); }
.footer-brand { display: flex; align-items: center; gap: var(--space-3); }
.footer-brand img { width: 24px; height: 24px; }
.footer-links { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-5); }
.site-footer a { color: inherit; text-decoration: none; }
.site-footer a:hover { color: var(--text); text-decoration: underline; }
@media (max-width: 600px) {
  .footer-inner { flex-direction: column; align-items: flex-start; }
}
/* "Still in development" notes. */
.preview-pill { display: inline-flex; align-items: center; gap: var(--space-2); margin: 0 0 var(--space-4); padding: var(--space-1) var(--space-3); border-radius: var(--radius-pill); background: var(--coral-soft); color: var(--text); font-size: var(--text-sm); font-weight: 500; }
.preview-pill a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.preview-pill::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--coral); }
.btn-sm { height: 34px; padding: 0 var(--space-4); font-size: var(--text-sm); }
/* Scrolling pages (home, privacy, terms): header, content, footer pinned to the bottom. */
body.page { display: flex; flex-direction: column; }

/* ---------- worlds: cards (explore page, world picker) ---------- */
.world-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); gap: var(--space-5); }
.world-card { position: relative; display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); overflow: hidden; text-align: left; color: var(--text); font: inherit; padding: 0; cursor: pointer; transition: box-shadow .15s, border-color .15s, transform .15s; }
.world-card:hover, .world-card:focus-visible { border-color: var(--accent); box-shadow: var(--shadow); transform: translateY(-2px); outline: none; }
.world-card[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.world-thumb { aspect-ratio: 16 / 10; width: 100%; object-fit: cover; display: block; background: linear-gradient(160deg, var(--stage-top), var(--stage-bottom)); }
/* No picture: the world's initial, centred. In dark mode the stage colours are close to the card's, so a line marks the edge. */
.world-thumb-empty { display: grid; place-items: center; color: var(--on-stage); font-family: var(--font-display); font-size: var(--text-2xl); font-weight: 500; line-height: 1; user-select: none; }
@media (prefers-color-scheme: dark) {
  .world-thumb-empty { box-shadow: inset 0 -1px 0 var(--border); }
}
/* The text takes the card's height, so the buttons (pushed to the bottom) line up across a row. */
.world-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: var(--space-1); padding: var(--space-3) var(--space-4) var(--space-4); }
.world-info h3 { margin: 0; font-size: var(--text-md); font-family: var(--font-display); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.world-info p { margin: 0; color: var(--muted); font-size: var(--text-sm); line-height: 1.45; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.world-meta { display: flex; align-items: center; gap: var(--space-1); color: var(--muted); font-size: var(--text-xs); white-space: nowrap; }
.world-author { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.world-plays { flex: none; }
.world-badge { position: absolute; top: var(--space-2); left: var(--space-2); padding: var(--space-1) var(--space-2); border-radius: var(--radius-pill); background: var(--stage-label); color: var(--on-stage); font-size: var(--text-xs); font-weight: 600; line-height: 1.2; backdrop-filter: blur(6px); }
.world-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: auto; padding-top: var(--space-2); }

/* A dialog (the world picker): a sheet from the bottom on phones, a centred panel elsewhere. */
.sheet { width: min(920px, calc(100vw - 2 * var(--gutter))); max-height: min(86vh, 860px); padding: 0; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--bg); color: var(--text); box-shadow: 0 24px 64px rgba(13, 13, 59, .3); }
.sheet::backdrop { background: rgb(13 13 59 / .45); backdrop-filter: blur(4px); }
.sheet[open] { display: flex; flex-direction: column; animation: sheet-in .18s ease-out; }
@keyframes sheet-in { from { opacity: 0; transform: translateY(12px); } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-5) var(--space-5) var(--space-3); }
.sheet-head h2 { margin: 0; font-size: var(--text-xl); }
.sheet-body { overflow-y: auto; padding: 0 var(--space-5) var(--space-5); }
.sheet-body h3.section { margin: var(--space-5) 0 var(--space-3); font-size: var(--text-xs); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-family: var(--font-body); }
.sheet-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: var(--space-3); padding: var(--space-3) var(--space-5); border-top: 1px solid var(--border); }
.sheet-foot .spacer { flex: 1; }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; border: 0; background: none; color: var(--muted); display: grid; place-items: center; cursor: pointer; }
.icon-btn:hover { background: var(--accent-soft); color: var(--text); }
.icon-btn svg { width: 22px; height: 22px; }
/* The New room picker: smaller cards without descriptions (four across on a desktop), so your
   own worlds show without scrolling. Phones keep the compact two columns (below). */
.world-picker .world-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 190px), 1fr)); gap: var(--space-3); }
.world-picker .world-info p { display: none; }
/* Create room, until a world is selected. */
.world-picker .btn-primary:disabled { background: var(--accent); box-shadow: none; opacity: .5; cursor: default; }
.world-picker .picker-status { margin: var(--space-5) 0 0; color: var(--muted); }
/* A list that didn't load: what happened, and Retry. */
.world-picker .picker-failed { display: flex; flex-direction: column; align-items: center; gap: var(--space-3); margin-top: var(--space-5); padding: var(--space-6) var(--space-5); border: 1px dashed var(--border); border-radius: var(--radius-md); color: var(--muted); text-align: center; }
.world-picker .picker-failed p { margin: 0; }
/* Build your own and Explore all: in the footer, or after the worlds on phones. */
.world-picker .picker-links { display: flex; flex-wrap: wrap; gap: var(--space-3); }
.world-picker .sheet-body .picker-links { display: none; justify-content: center; margin-top: var(--space-5); }
@media (max-width: 600px) {
  .sheet { width: 100vw; max-width: 100vw; max-height: 92dvh; margin: auto 0 0; border-radius: var(--radius-md) var(--radius-md) 0 0; border-bottom: 0; }
  .sheet-head, .sheet-body, .sheet-foot { padding-inline: var(--space-4); }
  /* Compact lists (the New room picker, the home page) keep two small cards side by side on phones, without descriptions.
     /worlds isn't compact: one card per row there, so there's room for the description and the buttons. */
  .world-grid.compact { grid-template-columns: 1fr 1fr; gap: var(--space-3); }
  .world-grid.compact .world-info { padding: var(--space-2) var(--space-3) var(--space-3); }
  .world-grid.compact .world-info p { display: none; }
  /* The picker's footer is one row, Cancel and Create room sharing it; the links go after the worlds.
     Each label stays on one line: on the narrowest phones (280px) Create room keeps the width it needs and
     Cancel takes the rest, and on a screen too narrow for both they'd stack. */
  .world-picker .sheet-foot .picker-links, .world-picker .sheet-foot .spacer { display: none; }
  .world-picker .sheet-foot .btn { flex: 1; white-space: nowrap; }
  .world-picker .sheet-body .picker-links { display: flex; }
}

/* The header spans the whole window: the logo at the left edge, the menus at the right (with the gutter). */
.topbar-inner.container { max-width: none; }
