/* Sign-in / registration pages (login.html, register.html) - same look as the landing page (index.html).
   Behaviour comes from app.js, which works on the element ids (#authStepStart, #authStepCode, #authCode, ...). */
:root {
  --on-accent: #ffffff;
  --bg: #faf6f0;
  --card: #fffdf9;
  --text: #1f2933;
  --muted: #6f756f;
  --primary: #22303f;
  --primary-text: #faf6f0;
  --primary-muted: #a9b2bc;
  --accent: #c9ad6a;
  --accent-strong: #b5974f;
  --accent-soft: rgba(201, 173, 106, 0.14);
  --success: #3f8a63;
  --danger: #a84b47;
  --danger-soft: rgba(168, 75, 71, 0.08);
  --border: rgba(0, 0, 0, 0.08);
  --border-strong: rgba(0, 0, 0, 0.16);
  --tint: rgba(0, 0, 0, 0.03);
  --input-bg: #ffffff;
  --shadow: 0 10px 30px rgba(31, 41, 51, 0.08);
  --font: 'Quicksand', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --radius: 12px;
  --radius-lg: 20px;
  --page: 1440px;
  --gutter: clamp(20px, 4vw, 64px);
}

[data-theme="dark"] {
  --on-accent: #ffffff;
  --bg: #0d1117;
  --card: #161b22;
  --text: #e6edf3;
  --muted: #8b949e;
  --primary: #1c2633;
  --primary-text: #e6edf3;
  --primary-muted: #8b949e;
  --accent: #c9a85a;
  --accent-strong: #d8b96c;
  --accent-soft: rgba(201, 168, 90, 0.14);
  --success: #52c48a;
  --danger: #ef6b6b;
  --danger-soft: rgba(239, 107, 107, 0.1);
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.18);
  --tint: rgba(255, 255, 255, 0.04);
  --input-bg: #0d1117;
  --shadow: 0 12px 36px rgba(0, 0, 0, 0.55);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  font-weight: 500;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
h1, p { margin: 0; }
button, input { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }

.container { width: 100%; max-width: var(--page); margin: 0 auto; padding: 0 var(--gutter); }

.eyebrow { font-size: 13px; font-weight: 700; line-height: 1.4; letter-spacing: 0.16em; text-transform: uppercase; color: var(--accent); }

/* ---------- Top bar ---------- */
.auth-top { height: 84px; display: flex; align-items: center; gap: 16px; }
.logo { display: inline-flex; align-items: center; color: var(--text); min-width: 0; }
.logo svg { display: block; height: 30px; width: auto; max-width: 100%; }
.logo text { fill: currentColor; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.home-link { display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 12px; border-radius: 10px; font-size: 14px; font-weight: 600; color: var(--muted); }
.home-link:hover { color: var(--text); background: var(--tint); }
.home-link svg { width: 16px; height: 16px; }

.icon-btn { display: inline-grid; place-items: center; width: 40px; height: 40px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); cursor: pointer; }
.icon-btn:hover { color: var(--text); background: var(--tint); }
.icon-btn svg { width: 18px; height: 18px; }
.theme-toggle .i-sun { display: none; }
[data-theme="dark"] .theme-toggle .i-sun { display: block; }
[data-theme="dark"] .theme-toggle .i-moon { display: none; }

.lang-select-wrapper { position: relative; }
.lang-btn { display: inline-flex; align-items: center; gap: 4px; height: 40px; padding: 0 10px; border: 0; border-radius: 10px; background: transparent; font-size: 14px; font-weight: 700; letter-spacing: 0.06em; color: var(--muted); cursor: pointer; }
.lang-btn:hover { color: var(--text); background: var(--tint); }
.lang-menu { position: absolute; right: 0; top: calc(100% + 8px); min-width: 180px; margin: 0; padding: 6px; list-style: none; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); z-index: 60; }
.lang-menu li { padding: 10px 12px; border-radius: 8px; font-size: 15px; cursor: pointer; }
.lang-menu li:hover { background: var(--tint); }
.lang-menu li[aria-current="true"] { background: var(--accent-soft); }

/* ---------- Layout: the form, centred ---------- */
.auth-shell {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-top: 24px;
  padding-bottom: 84px; /* same as the top bar, so the card sits in the optical centre */
}

.auth-card {
  width: 100%;
  max-width: 520px;
  padding: clamp(32px, 4vw, 48px);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.step-pill { display: inline-flex; padding: 6px 14px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: 13px; font-weight: 700; letter-spacing: 0.04em; }
.step-pill .s2 { display: none; }
body:has(#authStepCode:not([hidden])) .step-pill .s1 { display: none; }
body:has(#authStepCode:not([hidden])) .step-pill .s2 { display: inline; }

.auth-title { margin-top: 20px; font-size: clamp(30px, 3.4vw, 40px); font-weight: 700; line-height: 1.1; letter-spacing: -0.02em; }
.auth-sub { margin-top: 12px; color: var(--muted); font-size: 16px; }
.auth-sub strong { color: var(--text); font-weight: 700; overflow-wrap: anywhere; }

.auth-step { animation: step-in .45s cubic-bezier(.2, .7, .2, 1); }
@keyframes step-in { from { opacity: 0; transform: translateY(10px); } }

.mail-badge { width: 56px; height: 56px; margin-top: 20px; border-radius: 16px; display: grid; place-items: center; background: var(--accent); color: #fff; box-shadow: 0 8px 20px rgba(201, 173, 106, 0.3); }
.mail-badge svg { width: 26px; height: 26px; }
.mail-badge + .auth-title { margin-top: 18px; }

.fields { margin-top: 32px; display: grid; gap: 20px; }
.field { display: grid; gap: 8px; }
.label { font-size: 14px; font-weight: 700; }
.input {
  width: 100%;
  height: 54px;
  padding: 0 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  background: var(--input-bg);
  font-size: 16px;
  font-weight: 600;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.input::placeholder { color: var(--muted); opacity: .7; font-weight: 500; }
.input:hover { border-color: var(--muted); }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.input.input-invalid { border-color: var(--danger); box-shadow: 0 0 0 4px var(--danger-soft); }
.field-error { font-size: 13px; font-weight: 600; color: var(--danger); }
.hint { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; font-weight: 600; line-height: 1.5; color: var(--muted); }
.hint .pw-icon { width: 24px; height: 24px; flex-shrink: 0; display: grid; place-items: center; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }
.hint .pw-icon svg { width: 13px; height: 13px; }

.code-input { height: 68px; text-align: center; font-size: 30px; font-weight: 700; letter-spacing: 0.5em; padding-left: 0.5em; font-variant-numeric: tabular-nums; }
.code-input::placeholder { letter-spacing: 0.5em; }

.auth-error {
  margin-top: 20px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--danger-soft);
  border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent);
  color: var(--danger);
  font-size: 14px;
  font-weight: 600;
}

/* ---------- Buttons ---------- */
.actions { margin-top: 28px; display: grid; gap: 12px; }
.btn {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; height: 54px; padding: 0 22px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-size: 16px; font-weight: 700; line-height: 1;
  cursor: pointer;
  transition: background-color .15s ease, color .15s ease, border-color .15s ease, box-shadow .15s ease, transform .15s ease, opacity .15s ease;
}
/* dark text on gold: white had 2.2:1 contrast */
.btn-primary { background: var(--accent); color: var(--on-accent); box-shadow: 0 4px 12px rgba(201, 173, 106, 0.25); }
.btn-primary:hover:not(:disabled) { background: var(--accent-strong); box-shadow: 0 6px 18px rgba(201, 173, 106, 0.32); transform: translateY(-1px); }
.btn-outline { background: transparent; color: var(--accent); border-color: var(--accent); }
.btn-outline:hover:not(:disabled) { background: var(--accent); color: var(--on-accent); }
.btn:disabled { cursor: not-allowed; opacity: .55; transform: none; }
.btn-outline:disabled { color: var(--muted); border-color: var(--border-strong); opacity: 1; }
/* app.js adds .loading while a request is running */
.btn.loading { color: transparent !important; }
.btn.loading::after {
  content: ''; position: absolute; width: 20px; height: 20px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.45); border-top-color: #fff;
  animation: spin .7s linear infinite;
}
.btn-outline.loading::after { border-color: var(--accent-soft); border-top-color: var(--accent); }
@keyframes spin { to { transform: rotate(360deg); } }

.switch { margin-top: 28px; padding-top: 24px; border-top: 1px solid var(--border); text-align: center; font-size: 15px; color: var(--muted); }
.switch a, .text-link { font-weight: 700; color: var(--accent); }
.switch a:hover, .text-link:hover { color: var(--accent-strong); text-decoration: underline; text-underline-offset: 3px; }
.back-row { margin-top: 20px; text-align: center; font-size: 14px; }

/* ---------- Responsive ---------- */
@media (max-width: 560px) {
  :root { --gutter: 16px; }
  .auth-top { height: 68px; gap: 8px; }
  .logo svg { height: 20px; }
  .home-link span { display: none; }
  .home-link { padding: 0 10px; }
  .top-actions { gap: 0; }
  .lang-btn { padding: 0 6px; }
  .icon-btn { width: 36px; }
  .auth-shell { align-items: flex-start; padding-top: 8px; padding-bottom: 40px; }
  .auth-card { padding: 28px 20px; border-radius: 16px; }
  .code-input { font-size: 26px; letter-spacing: 0.4em; padding-left: 0.4em; }
}

@media (prefers-reduced-motion: reduce) {
  .auth-step { animation-name: fade-in; }
  @keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
  .btn-primary:hover:not(:disabled) { transform: none; }
}

/* toasts from app.js (it only positions the container itself when the page has none) */
#toast-container { position: fixed; right: 16px; bottom: 16px; z-index: 20000; display: grid; gap: 8px; max-width: min(420px, calc(100vw - 32px)); }
#toast-container .toast { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 14px !important; border-radius: 12px !important; font-size: 14px; font-weight: 600; box-shadow: var(--shadow); }
#toast-container .toast button { border: 0; background: transparent; color: inherit; cursor: pointer; opacity: .8; }

/* "Check your inbox": the mail icon sits next to the heading */
.code-head { margin-top: 20px; display: flex; align-items: center; gap: 16px; }
.code-head .mail-badge, .code-head .auth-title { margin-top: 0; }
.code-head .mail-badge { width: 52px; height: 52px; border-radius: 14px; flex-shrink: 0; }
@media (max-width: 560px) {
  .code-head { gap: 12px; }
  .code-head .mail-badge { width: 44px; height: 44px; border-radius: 12px; }
  .code-head .mail-badge svg { width: 22px; height: 22px; }
  .code-head .auth-title { font-size: 26px; }
}

.auth-notice {
  margin-top: 20px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
}
.auth-notice[hidden] { display: none; }
.auth-legal { margin-top: 18px; font-size: 13px; color: var(--muted); text-align: center; }
.auth-legal a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.auth-legal a:hover { color: var(--accent); }
