/* AudioSilo connect and setup pages (the admin console is the separate admin-ui
   app). They wear the console's Shelf look: the tokens below mirror
   admin-ui/src/styles/globals.css (STYLEGUIDE.md section 3), and the card, field
   and button rules mirror the console's sign-in page (login-page.tsx). Keep them
   in sync when the console's tokens change. The pages are served under a strict
   same-origin CSP (style-src 'self'; script-src 'self'), so ALL styling lives
   here - there are no inline <style> blocks or style="" attributes in the HTML.
   theme-init.js sets data-theme on <html> before the first paint. */

/* Self-hosted variable fonts (latin subset, SIL OFL 1.1, from @fontsource-variable)
   - no CDN, so they work offline and under the CSP. */
@font-face {
  font-family: "Figtree";
  font-style: normal;
  font-weight: 300 900;
  font-display: swap;
  src: url("/assets/fonts/figtree-variable.woff2") format("woff2-variations");
}
@font-face {
  font-family: "Bricolage Grotesque";
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url("/assets/fonts/bricolage-grotesque-variable.woff2") format("woff2-variations");
}

:root {
  color-scheme: light;
  --radius-sm: 8px;
  --radius-md: 10px;   /* buttons, inputs */
  --radius-btn-lg: 12px;
  --radius-xl: 16px;   /* cards */

  --background: #f5f7fa;
  --foreground: #121c36;
  --card: #ffffff;
  --primary: #15203d;
  --primary-foreground: #f5f7fa;
  --muted: #eef1f5;
  --muted-foreground: #5b6680;
  --subtle-foreground: #8590a6;
  --accent: #e8ecf3;
  --destructive: #c42b3c;
  --border: #e0e5ed;
  --border-strong: #cdd4df;
  --input: #d4dae4;
  --ring: #db2777;
  --brand: #db2777;

  --font-display: "Bricolage Grotesque", "Figtree", ui-sans-serif, system-ui, sans-serif;
  --font-sans: "Figtree", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --dur-1: 120ms;
}

[data-theme="dark"] {
  color-scheme: dark;
  --background: #0a0f1e;
  --foreground: #e7ebf4;
  --card: #10172b;
  --primary: #eef1f8;
  --primary-foreground: #0a0f1e;
  --muted: #151d34;
  --muted-foreground: #8f9ab3;
  --subtle-foreground: #66718b;
  --accent: #1a2340;
  --destructive: #f0606e;
  --border: #1d2640;
  --border-strong: #2a3555;
  --input: #283252;
  --ring: #ec4f95;
  --brand: #ec4f95;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  background: var(--background);
  color: var(--foreground);
  -webkit-font-smoothing: antialiased;
}

::selection { background: color-mix(in oklab, var(--brand) 25%, transparent); }
:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }

h1, h2 { font-family: var(--font-display); line-height: 1.15; margin: 0; }
h1 { font-size: 26px; font-weight: 700; letter-spacing: -0.03em; }
h2 { font-size: 19px; font-weight: 650; letter-spacing: -0.015em; }
p { margin: 6px 0 0; }
.muted { color: var(--muted-foreground); }
.hidden { display: none !important; }

/* ---- Layout: a 400px column centred on the page (the console's sign-in) ---- */
.center { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 40px 16px; }
.column { width: 100%; max-width: 400px; }
.inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 18px; }

/* ---- Brand: the mark on its ink tile + the wordmark (logo.tsx LogoTile) ---- */
.brand { display: flex; align-items: center; gap: 10px; margin-bottom: 24px; }
.brand .tile {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--primary);
}
/* The mark is favicon.svg used as a mask, so it takes the brand colour in both
   themes without a second copy of its path. favicon.svg pads the mark, hence 23px
   for the console's 20px. */
.brand .tile .mark {
  width: 23px;
  height: 23px;
  background: var(--brand);
  -webkit-mask: url("/assets/favicon.svg") center / contain no-repeat;
  mask: url("/assets/favicon.svg") center / contain no-repeat;
}
.brand .wordmark { font-family: var(--font-display); font-size: 16px; font-weight: 700; letter-spacing: -0.02em; }

/* ---- Card ---- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 24px;
}
@media (min-width: 640px) { .card { padding: 32px; } }

/* ---- Forms ---- */
form { display: flex; flex-direction: column; gap: 16px; margin-top: 24px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field .muted { margin: 0; font-size: 13px; }
label { font-size: 13px; font-weight: 600; }
input, select, button { font: inherit; }
input {
  width: 100%;
  min-width: 0;
  height: 38px;
  padding: 0 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--input);
  background: var(--card);
  color: var(--foreground);
  transition: border-color var(--dur-1), box-shadow var(--dur-1);
}
input::placeholder { color: var(--subtle-foreground); }
/* iOS Safari zooms into a focused field whose text is under 16px, and these pages
   are opened on phones (an invite link), so fields read 16px there. */
@media (max-width: 639px) { input, select { font-size: 16px; } }
input:focus-visible, select:focus-visible {
  outline: none;
  border-color: var(--ring);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--ring) 20%, transparent);
}

/* ---- Buttons (and links styled as buttons): Shelf ink default, hairline outline ---- */
button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  padding: 0 14px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  background: var(--primary);
  color: var(--primary-foreground);
  font-size: 13.5px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  transition: background-color var(--dur-1), border-color var(--dur-1), transform var(--dur-1);
}
button:hover, .button:hover {
  background: color-mix(in oklab, var(--primary) 88%, var(--brand));
}
button:active, .button:active { transform: translateY(1px); }
button:disabled, [aria-disabled="true"] { opacity: 0.45; pointer-events: none; }
/* A full-width button may wrap: a translated label can outgrow a narrow phone. */
.block {
  width: 100%;
  height: auto;
  min-height: 44px;
  padding: 8px 20px;
  border-radius: var(--radius-btn-lg);
  font-size: 15px;
  white-space: normal;
  text-align: center;
}
form .block { margin-top: 4px; }
.button.secondary {
  background: var(--card);
  color: var(--foreground);
  border-color: var(--border-strong);
}
.button.secondary:hover { background: var(--accent); }

/* ---- Messages ---- */
.msg { display: none; margin: 16px 0 0; font-size: 13px; font-weight: 500; color: var(--destructive); }
.msg.show { display: block; }

/* ---- QR / links (connect) ---- */
#result, #setup-done { margin-top: 24px; }
.qr { display: flex; justify-content: center; margin: 20px 0; }
/* The QR is a PNG with a white quiet zone, so it sits on a white tile in both themes. */
.qr img {
  width: 240px;
  max-width: 100%;
  height: auto;
  aspect-ratio: 1;
  image-rendering: pixelated;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 12px;
}
.links { display: flex; flex-direction: column; gap: 10px; margin-top: 20px; }

/* ---- Footer row under the card (language picker) ---- */
.lang-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
  font-size: 13px;
  color: var(--muted-foreground);
}
.lang-row label { font-weight: 500; }
.lang-select {
  height: 32px;
  padding: 0 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--input);
  background: var(--card);
  color: var(--foreground);
}

/* ---- Code (the "console not built" page) ---- */
pre {
  margin: 16px 0;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: var(--muted);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 13px;
  overflow-x: auto;
}
