/* Leitor IA: shared styles (public: also used by the login page).
 *
 * Direction: "tinta e luz de gravação". A cool desk (--bg) with white pages
 * (--surface) written in deep blue-violet ink (--ink); amber (--rec) is the
 * recording light, used only for audio being generated. The texts being read
 * use the system serif (New York on Apple devices); the interface uses the
 * system sans; timecodes use the system mono. No external fonts (CSP 'self').
 */

:root {
  color-scheme: light dark;

  --bg: #eceef3;
  --surface: #ffffff;
  --surface-2: #f5f6f9;
  --ink: #1e2242;
  --ink-2: #464b6b;
  --muted: #5b6080;
  --line: #d6d9e3;
  --line-strong: #b4b9cb;
  --accent: #1e2242;
  --accent-fg: #ffffff;
  --accent-soft: #e3e5f2;
  --focus: #4553d6;
  --rec: #d97b1e;
  --rec-text: #8f4a00;
  --rec-soft: #fcebd6;
  --ok: #1d6a48;
  --ok-soft: #dcf0e5;
  --error: #b3261e;
  --error-soft: #fbe5e3;
  --warn-fg: #6b4500;
  --warn-bg: #fff1d4;
  --tape-played: #1e2242;
  --tape-ready: #bec3d8;
  --tape-pending: #d6d9e3;
  --shadow: 0 1px 2px rgba(22, 26, 56, 0.06), 0 10px 30px -12px rgba(22, 26, 56, 0.18);
  --shadow-up: 0 -1px 0 rgba(22, 26, 56, 0.06), 0 -12px 32px -18px rgba(22, 26, 56, 0.35);

  --font-ui: -apple-system, BlinkMacSystemFont, system-ui, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --font-read: ui-serif, "New York", "Iowan Old Style", "Charter", Georgia, "Times New Roman", serif;
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;

  --radius: 16px;
  --radius-sm: 11px;
  --gutter: 16px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1120;
    --surface: #181b2e;
    --surface-2: #1e2238;
    --ink: #e8e9f4;
    --ink-2: #c0c3da;
    --muted: #a0a5c0;
    --line: #2d3150;
    --line-strong: #464b72;
    --accent: #c4c9ff;
    --accent-fg: #14173a;
    --accent-soft: #272c4d;
    --focus: #9aa3ff;
    --rec: #f0a04b;
    --rec-text: #f6b56f;
    --rec-soft: #3a2a17;
    --ok: #7fd3a6;
    --ok-soft: #173326;
    --error: #ff9a91;
    --error-soft: #3b1d1f;
    --warn-fg: #ffd98a;
    --warn-bg: #3a2f15;
    --tape-played: #c4c9ff;
    --tape-ready: #454a72;
    --tape-pending: #2d3150;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 12px 30px -14px rgba(0, 0, 0, 0.6);
    --shadow-up: 0 -1px 0 rgba(255, 255, 255, 0.04), 0 -14px 32px -18px rgba(0, 0, 0, 0.7);
  }
}

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

[hidden] { display: none !important; }

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

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.5 var(--font-ui);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-wrap: anywhere;
}

h1, h2, h3 { margin: 0; line-height: 1.2; }
p { margin: 0; }
a { color: var(--ink); text-underline-offset: 3px; }
code, kbd { font-family: var(--font-mono); font-size: 0.92em; }

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

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

/* --- wordmark ----------------------------------------------------------------- */

.wordmark {
  display: inline-flex;
  align-items: baseline;
  gap: 0.3em;
  font-family: var(--font-read);
  font-weight: 600;
  font-size: 1.35rem;
  letter-spacing: -0.01em;
  color: var(--ink);
  text-decoration: none;
}
.wordmark small {
  font-family: var(--font-ui);
  font-size: 0.58em;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--rec-text);
}

/* --- form controls -------------------------------------------------------------- */

label, .label {
  display: block;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--ink-2);
}

input[type="text"], input[type="password"], input[type="number"], input:not([type]),
select, textarea {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  font: inherit;
  font-size: 17px; /* >= 16px: iOS does not zoom on focus */
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  appearance: none;
  -webkit-appearance: none;
}

select {
  padding-right: 40px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
                    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}

input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 0;
  border-color: transparent;
}

input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }

.field { display: grid; gap: 6px; }
.field + .field { margin-top: 14px; }
.hint { font-size: 0.86rem; color: var(--muted); }

/* --- buttons ------------------------------------------------------------------------ */

button { font: inherit; color: inherit; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  min-width: 46px;
  padding: 10px 18px;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease, transform 80ms ease;
  touch-action: manipulation;
}
.btn:hover { border-color: var(--ink-2); }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn[aria-busy="true"] { cursor: progress; }

.btn.primary {
  color: var(--accent-fg);
  background: var(--accent);
  border-color: var(--accent);
}
.btn.primary:hover { filter: brightness(1.12); }

.btn.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--ink-2);
  padding-inline: 12px;
}
.btn.ghost:hover { background: var(--accent-soft); border-color: transparent; }

.btn.danger { color: var(--error); }
.btn.danger:hover { border-color: var(--error); }

.btn.block { width: 100%; }

.btn svg, .icon { width: 20px; height: 20px; flex: none; }

/* --- messages ------------------------------------------------------------------------- */

.message {
  font-size: 0.95rem;
  font-weight: 600;
}
.message.error { color: var(--error); }
.message.info { color: var(--ok); }

.notice {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  color: var(--warn-fg);
  background: var(--warn-bg);
}

/* --- login --------------------------------------------------------------------------- */

.login-page {
  display: grid;
  place-items: center;
  padding: max(24px, env(safe-area-inset-top)) var(--gutter) max(24px, env(safe-area-inset-bottom));
}

.login {
  width: 100%;
  max-width: 26rem;
}

.login-brand {
  display: grid;
  justify-items: center;
  gap: 10px;
  margin-bottom: 22px;
  text-align: center;
}
.login-brand img {
  width: 64px;
  height: 64px;
  border-radius: 15px;
  box-shadow: var(--shadow);
}
.login-brand .wordmark { font-size: 1.9rem; }
.login-brand p { color: var(--muted); font-size: 0.95rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px 20px;
  box-shadow: var(--shadow);
}

.card h2 { font-size: 1.25rem; margin-bottom: 10px; }

.form { display: grid; gap: 14px; }
.form .btn { margin-top: 4px; }

.steps { padding-left: 1.3rem; margin: 0 0 16px; color: var(--ink-2); }
.steps li + li { margin-top: 6px; }

.qr {
  display: block;
  width: min(220px, 100%);
  height: auto;
  aspect-ratio: 1;
  margin: 4px auto 10px;
  padding: 8px;
  background: #ffffff;
  border-radius: 12px;
  border: 1px solid var(--line);
}

.otpauth { text-align: center; margin-bottom: 14px; }

.secret-box { margin-bottom: 18px; }
.secret, .codes {
  font-family: var(--font-mono);
  color: var(--ink);
  word-break: break-all;
}
.secret {
  display: block;
  margin-top: 6px;
  padding: 10px 12px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
}

.codes {
  columns: 2;
  column-gap: 24px;
  padding: 14px 14px 14px 2.2rem;
  margin: 14px 0 18px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
}
.codes li { padding: 2px 0; }

.actions { display: grid; gap: 10px; }

.warning {
  margin: 0 0 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--warn-fg);
  background: var(--warn-bg);
  font-weight: 600;
}

.login .message { margin-top: 16px; text-align: center; }

@media (max-width: 380px) {
  .codes { columns: 1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
