/*
 * BTL MTG – the BTL101 look: dark surface, dotted grid, cyan-to-purple gradient,
 * Space Mono for headings and labels, DM Sans for text.
 * Fonts are self-hosted (SIL OFL, see fonts/OFL-*.txt): the CSP allows our own origin only.
 */

@font-face {
  font-family: 'DM Sans';
  font-style: normal;
  font-weight: 300 600;
  font-display: swap;
  src: url('fonts/DMSans-300-600-latin-ext.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-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: 'DM Sans';
  font-style: normal;
  font-weight: 300 600;
  font-display: swap;
  src: url('fonts/DMSans-300-600-latin.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 Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('fonts/SpaceMono-400-latin-ext.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-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: 'Space Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('fonts/SpaceMono-400-latin.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 Mono';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('fonts/SpaceMono-700-latin-ext.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-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: 'Space Mono';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('fonts/SpaceMono-700-latin.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;
}

:root {
  --bg: #0a0e17;
  --surface: #111827;
  --surface2: #1a2236;
  --surface-glass: rgba(17, 24, 39, 0.7);
  --border: #1f2d45;
  --accent: #00d4ff;
  --accent2: #7c3aed;
  --accent3: #10b981;
  --violet: #a78bfa;
  --warn: #f59e0b;
  --danger: #ef4444;
  --text: #e2e8f0;
  --dim: #cbd5e1;
  --muted: #64748b;
  --gradient: linear-gradient(135deg, var(--accent), var(--accent2));
  --mono: 'Space Mono', ui-monospace, 'Cascadia Mono', monospace;
  --sans: 'DM Sans', system-ui, sans-serif;
  /* Mana colours. */
  --mW: #f8f1d4;
  --mU: #3b8fd9;
  --mB: #6b5f73;
  --mR: #e5533d;
  --mG: #2f9e5b;
  --mC: #9aa3ad;
  color-scheme: dark;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

/* A column, so the legal footer sits at the bottom of the window on short pages. */
body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.6;
  background:
    radial-gradient(circle at 18% 6%, rgba(0, 212, 255, 0.10), transparent 38%),
    radial-gradient(circle at 92% 92%, rgba(124, 58, 237, 0.14), transparent 42%),
    var(--bg);
  background-attachment: fixed;
}

/* Dotted grid over the whole surface, fading out at the bottom. */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(0, 212, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 212, 255, 0.04) 1px, transparent 1px);
  background-size: 40px 40px;
  mask-image: linear-gradient(180deg, #000 0%, #000 70%, transparent 100%);
}

a { color: var(--accent); text-decoration: none; border-bottom: 1px solid rgba(0, 212, 255, 0.3); }
a:hover { border-bottom-color: var(--accent); }
b, strong { color: var(--text); font-weight: 600; }
button { font: inherit; }
code { font-family: var(--mono); font-size: 0.85em; color: var(--accent); }

.grad {
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ---------- Top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 24px;
  background: rgba(10, 14, 23, 0.85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.brand { font-family: var(--mono); font-weight: 700; font-size: 17px; color: var(--text); border: none; }

.sections { display: flex; flex-wrap: wrap; gap: 4px 6px; font-family: var(--mono); font-size: 13px; }
.sections a { padding: 4px 12px; color: var(--dim); border: 1px solid transparent; border-radius: 99px; }
.sections a:hover { color: var(--text); border-color: var(--border); }
.sections a.active { color: var(--accent); background: rgba(0, 212, 255, 0.08); border-color: rgba(0, 212, 255, 0.5); }

.subnav { display: flex; flex-wrap: wrap; gap: 4px 18px; padding: 8px 24px; font-family: var(--mono); font-size: 12px; background: rgba(17, 24, 39, 0.6); border-bottom: 1px solid var(--border); }
.subnav a { padding: 2px 0; color: var(--muted); border-bottom: 2px solid transparent; }
.subnav a:hover { color: var(--text); }
.subnav a.active { color: var(--text); border-bottom-color: var(--accent); }

.home-label a { color: inherit; border-bottom-color: var(--border); }
.home-label a:hover { color: var(--accent); }

.user { display: flex; align-items: center; gap: 6px; margin-left: auto; font-family: var(--mono); font-size: 12px; }
.user a, .user button { padding: 4px 12px; color: var(--dim); background: none; border: 1px solid var(--border); border-radius: 99px; cursor: pointer; }
.user a:hover, .user button:hover { color: var(--text); border-color: var(--muted); }
.user a.active { color: var(--accent); border-color: rgba(0, 212, 255, 0.5); }
.user button { font-size: 12px; }

.lang-switch { display: flex; gap: 4px; font-family: var(--mono); font-size: 11px; }
.lang-switch a, .lang-switch .current { padding: 2px 9px; border: 1px solid var(--border); border-radius: 99px; color: var(--muted); }
.lang-switch a:hover { color: var(--text); border-color: var(--muted); }
.lang-switch .current { color: var(--accent); border-color: rgba(0, 212, 255, 0.5); background: rgba(0, 212, 255, 0.08); }

/* ---------- Page ---------- */

.container { flex: 1 0 auto; width: 100%; max-width: 1400px; margin: 0 auto; padding: 0 24px 64px; }

.page-head { padding: 28px 0 22px; }
.page-head p + p { margin-top: 8px; }
/* The head of a page that keeps the window for its work. */
.page-head.compact { padding: 14px 0 12px; }
.page-head.compact h1 { font-size: 22px; }
.page-head .head-row { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: space-between; }
.page-head.compact .subtitle { margin-top: 2px; font-size: 13px; }
.guide { max-width: 46rem; color: var(--dim); }
.guide h2 { margin: 28px 0 10px; font-family: var(--mono); font-size: 16px; color: var(--text); }
.guide ol, .guide ul { margin: 0 0 0 22px; }
.guide li { margin: 6px 0; }
.guide p { margin: 10px 0; }
.guide .hint { font-size: 13px; color: var(--muted); }
.guide code { padding: 2px 6px; font-family: var(--mono); font-size: 13px; color: var(--accent); background: var(--surface2); border-radius: 4px; overflow-wrap: anywhere; }

.badge {
  display: inline-block;
  margin-bottom: 14px;
  padding: 3px 12px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 99px;
}

h1 { font-family: var(--mono); font-size: clamp(28px, 4vw, 44px); font-weight: 700; line-height: 1.1; letter-spacing: -0.02em; }

.subtitle { margin-top: 10px; max-width: 900px; color: var(--dim); font-size: 15px; font-weight: 300; }

/* ---------- Account pages and their forms ---------- */

.account-card { max-width: 30rem; margin: 40px auto 0; padding: 28px; background: var(--surface-glass); border: 1px solid var(--border); border-left: 3px solid var(--accent2); border-radius: 10px; }
.account-card.wide { max-width: 46rem; }
.account-card h1 { margin-bottom: 14px; font-size: 26px; }
.account-card h2 { margin: 28px 0 8px; font-family: var(--mono); font-size: 15px; }
.account-card h2.first { margin-top: 0; }
.account-card + .account-card { margin-top: 20px; }
.account-card p { margin: 10px 0; color: var(--dim); }
.account-card .hint { font-size: 13px; color: var(--muted); }
.account-card label, .account-card .field-label { display: block; margin: 16px 0 6px; font-family: var(--mono); font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.account-card label.check { display: flex; align-items: center; gap: 8px; letter-spacing: 0.04em; text-transform: none; }
.account-card input:not([type=checkbox], [type=radio], [type=file]), .account-card select { width: 100%; padding: 10px 12px; font: inherit; color: var(--text); background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; outline: none; }
.account-card input:focus, .account-card select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(0, 212, 255, 0.18); }
.account-card input[type=checkbox], .account-card input[type=radio] { flex: none; width: 16px; height: 16px; accent-color: var(--accent); }
.account-card label.check + label.check { margin-top: 8px; }

.file-pick { display: flex; align-items: center; gap: 12px; padding: 8px 10px; background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; }
.file-pick-input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.account-card .file-pick-button { flex: none; margin: 0; padding: 6px 14px; letter-spacing: 0.06em; color: var(--text); background: var(--surface); border: 1px solid var(--muted); border-radius: 99px; cursor: pointer; }
.account-card .file-pick-button:hover { color: var(--accent); border-color: var(--accent); }
.file-pick-input:focus-visible + .file-pick-button { outline: 2px solid var(--accent); outline-offset: 2px; }
.file-pick-name { overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.file-pick-name.chosen { color: var(--text); }
/* A button that does something, as opposed to a chip, which narrows a list. */
.btn { display: inline-block; padding: 7px 14px; font-family: var(--mono); font-size: 12px; font-weight: 700; letter-spacing: 0.04em; line-height: 1.4; color: var(--text); background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 1px 0 rgba(0, 0, 0, 0.4); cursor: pointer; }
.btn:hover { border-color: var(--accent); }
/* As a link it keeps the look of a button, not of a link in text. */
a.btn { letter-spacing: 0.04em; text-decoration: none; }
a.btn.head-action { margin-left: 10px; }
a.btn.head-action:first-of-type { margin-left: 14px; }
.btn:active { transform: translateY(1px); box-shadow: none; }
/* A gradient starts at the border's edge: from the padding's it would repeat as a stripe under the transparent border. */
.btn.primary { color: #fff; background: var(--gradient); border-color: transparent; background-origin: border-box; }
.btn.primary:hover { filter: brightness(1.15); }
/* Something a model has a hand in: the gradient, with the mark inside. */
.btn.ai { color: #fff; background: var(--gradient); border-color: transparent; background-origin: border-box; }
.btn.ai:hover { filter: brightness(1.15); }
.btn-ai { margin-left: 6px; padding: 0 6px; font-size: 10px; letter-spacing: 0.06em; color: #fff; background: rgba(10, 14, 23, 0.45); border-radius: 99px; }
.btn.danger { color: var(--danger); border-color: rgba(239, 68, 68, 0.5); }
.btn.danger:hover { border-color: var(--danger); }
.btn.quiet { color: var(--muted); background: transparent; box-shadow: none; }
.btn.small { padding: 5px 10px; font-size: 11px; }
.btn.done { color: #06281d; background: var(--accent3); border-color: var(--accent3); }
.btn.skipped { color: var(--warn); border-color: var(--warn); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; filter: none; }
.btn:disabled:hover { border-color: var(--border); }
.account-card button, .account-card a.button { display: inline-block; margin-top: 20px; padding: 10px 20px; font-family: var(--mono); font-size: 12px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: #fff; background: var(--gradient); border: 0; border-radius: 8px; cursor: pointer; }
.account-card form > button { width: 100%; }
.account-card a.button { margin-top: 6px; }
.account-card button.danger { background: var(--danger); }
.account-card .consent-scopes { margin: 6px 0 6px 20px; color: var(--text); }
.account-card .consent-form { display: flex; gap: 12px; }
.account-card .connected-app { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.account-card .connected-app .hint { display: block; }
.account-card .connected-app > button { width: auto; margin-top: 0; }
.account-card .error, .validation-message { color: var(--danger); }
.account-card .error { padding: 10px 14px; background: rgba(239, 68, 68, 0.08); border: 1px solid rgba(239, 68, 68, 0.4); border-radius: 8px; }
.validation-message { margin-top: 4px; font-size: 13px; }
.account-card .notice { padding: 10px 14px; border: 1px solid var(--border); border-left: 3px solid var(--warn); border-radius: 8px; }
.account-card .notice.ok { border-left-color: var(--accent3); }
/* A field people never see; see RegistrationGuard. Off-screen rather than display:none, which scripts check for. */
.account-card .trap { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* ---------- Landing page ---------- */

.home-label { margin: 26px 0 12px; font-family: var(--mono); font-size: 11px; font-weight: 400; letter-spacing: 0.15em; text-transform: uppercase; color: var(--muted); }
.home-note { opacity: 0.7; letter-spacing: 0.02em; text-transform: none; }

/* Pages that are a column of tiles sit in the middle of the window instead of hugging its left edge. */
.tiles-page { max-width: 900px; margin: 0 auto; }
.home-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; max-width: 900px; }

.home-card {
  display: block;
  padding: 18px 20px;
  color: var(--text);
  background: var(--surface-glass);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 10px;
  transition: transform 0.2s, border-color 0.2s;
}
.home-card:hover { transform: translateY(-2px); border-color: rgba(0, 212, 255, 0.45); border-left-color: var(--accent); }
.home-card.purple { border-left-color: var(--accent2); }
.home-card.green { border-left-color: var(--accent3); }
.home-card.soon { border-left-color: var(--muted); opacity: 0.6; cursor: default; }
.home-card.soon:hover { transform: none; border-color: var(--border); border-left-color: var(--muted); }

.home-card-title { display: block; margin-bottom: 6px; font-family: var(--mono); font-size: 16px; font-weight: 700; }
.home-card-desc { display: block; color: var(--dim); font-size: 14px; font-weight: 300; }
.home-ai { margin-left: 8px; padding: 1px 8px; font-family: var(--mono); font-size: 10px; font-weight: 400; letter-spacing: 0.04em; color: #fff; background: var(--gradient); border-radius: 99px; vertical-align: 2px; white-space: nowrap; }
.home-soon { margin-left: 6px; padding: 1px 8px; font-family: var(--mono); font-size: 10px; font-weight: 400; color: var(--warn); border: 1px solid rgba(245, 158, 11, 0.5); border-radius: 99px; vertical-align: 2px; }

/* ---------- Legal footer ---------- */

.legal { padding: 18px 24px 22px; text-align: center; font-size: 11px; line-height: 1.5; color: var(--muted); border-top: 1px solid var(--border); }
.legal p { max-width: 900px; margin: 0 auto; }
.legal p + p { margin-top: 4px; }
.legal a { color: var(--muted); border-bottom-color: rgba(100, 116, 139, 0.5); }
.legal a:hover { color: var(--dim); }

@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; gap: 8px 12px; padding: 10px 16px; }
  .subnav { padding: 8px 16px; }
  .container { padding: 0 16px 48px; }
  .home-grid { grid-template-columns: 1fr; }
}

@media print {
  .topbar, .subnav, .legal { display: none; }
}

/* A window over the page (Components/Common/Modal). */
.modal-back { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px 16px; overflow: auto; background: rgba(5, 8, 14, 0.78); backdrop-filter: blur(3px); }
.modal { position: relative; width: 100%; max-width: 30rem; padding: 28px; background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--accent2); border-radius: 12px; box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6); }
.modal.wide { max-width: 68rem; }
.modal-close { position: absolute; top: 10px; right: 14px; font-size: 24px; line-height: 1; color: var(--muted); text-decoration: none; }
.modal-close:hover { color: var(--text); }
.modal .account-card { max-width: none; margin: 0; padding: 0; background: none; border: 0; }
.page-head .head-action { margin-left: 14px; vertical-align: middle; }
/* A box that shows whether a switch is on, inside the button that flips it. */
.tick { display: inline-block; width: 12px; height: 12px; margin-right: 4px; vertical-align: -1px; border: 1px solid var(--muted); border-radius: 3px; }
.tick.on { background: var(--accent3); border-color: var(--accent3); box-shadow: inset 0 0 0 2px var(--surface2); }
