/* Shared base: reset, type, buttons, forms, header, footer, auth dialog. */

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 5rem;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--background);
  color: var(--foreground);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: 400;
  line-height: 1.7;
  letter-spacing: 0.005em;
  font-kerning: normal;
  font-optical-sizing: auto;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

img, svg { display: block; max-width: 100%; }
h1, h2, h3, p, ul, ol, dl, dd, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
h1, h2, h3 { text-wrap: balance; font-weight: 600; }
p { text-wrap: pretty; }

a { color: var(--primary-link); text-underline-offset: 0.2em; }
a:hover { color: var(--foreground); }

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

::selection { background: #2f5bff66; color: #fff; }

.skip-link {
  position: absolute;
  left: var(--space-4);
  top: -4rem;
  z-index: var(--z-modal);
  padding: var(--space-3) var(--space-4);
  background: var(--foreground);
  color: var(--background);
  font-weight: 700;
  border-radius: var(--radius);
}
.skip-link:focus { top: var(--space-4); }

.wrap {
  width: 100%;
  max-width: calc(var(--content) + var(--gutter) * 2);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

/* ---------- Labels, buttons ---------- */

.label {
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 2.75rem;
  padding: 0.75rem 1.75rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font: 700 0.72rem/1 var(--font-sans);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
  transition: background-color var(--dur-fast) ease, border-color var(--dur-fast) ease,
    color var(--dur-fast) ease, transform var(--dur-fast) var(--ease-out-quart);
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); color: #fff; }

.btn-secondary { background: transparent; color: var(--foreground); border-color: var(--hair-strong); }
.btn-secondary:hover:not(:disabled) { background: var(--accent); color: var(--foreground); border-color: #ffffff3d; }

.btn-gold { background: transparent; color: var(--gold-soft); border-color: var(--gold-line); }
.btn-gold:hover:not(:disabled) { background: #d0ac3716; border-color: var(--gold); color: var(--gold-soft); }

.btn-full { width: 100%; }

.link-btn {
  background: none;
  border: 0;
  padding: 0.5rem 0.25rem;
  color: var(--primary-link);
  font: inherit;
  text-decoration: underline;
  text-underline-offset: 0.2em;
  cursor: pointer;
}
.link-btn:hover { color: var(--foreground); }

/* ---------- Wordmark ---------- */

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  color: var(--foreground);
  text-decoration: none;
}
.wordmark img { width: 2rem; height: 2rem; }
.wordmark span {
  font-weight: 800;
  font-size: 0.95rem;
  letter-spacing: 0.3em;
  line-height: 1;
}

/* ---------- Header ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: var(--z-header);
  background: #070d1cd9;
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  border-bottom: 1px solid var(--hair);
}
.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-5);
  min-height: 4rem;
}
.site-nav { display: none; }
.site-nav ul { display: flex; gap: var(--space-6); }
.site-nav a {
  display: inline-block;
  padding: var(--space-3) 0;
  color: var(--muted-foreground);
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-decoration: none;
  transition: color var(--dur-fast) ease;
}
.site-nav a:hover { color: var(--foreground); }
.site-nav a[aria-current="page"] { color: var(--gold-soft); }
.header-actions { display: flex; align-items: center; gap: var(--space-3); }
.header-actions .btn { min-height: 2.5rem; padding: 0.65rem 1.25rem; }

@media (min-width: 62rem) {
  .site-nav { display: block; }
}

/* ---------- Footer ---------- */

.site-footer {
  border-top: 1px solid var(--hair);
  background: var(--background);
  padding-block: var(--space-8) var(--space-6);
  color: var(--muted-foreground);
  font-size: var(--text-sm);
}
.footer-top {
  display: grid;
  gap: var(--space-6);
  padding-bottom: var(--space-6);
  border-bottom: 1px solid var(--hair);
}
.footer-top .wordmark { margin-bottom: var(--space-4); }
.footer-about { max-width: 34rem; line-height: 1.65; }
.footer-links { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-5); align-content: start; }
.footer-links a {
  display: inline-block;
  padding: var(--space-2) 0;
  color: var(--foreground);
  text-decoration: none;
  font-weight: 500;
}
.footer-links a:hover { color: var(--gold-soft); }
.footer-risk {
  padding-block: var(--space-5);
  border-bottom: 1px solid var(--hair);
  max-width: 62rem;
  line-height: 1.65;
}
.footer-risk strong { color: var(--foreground); font-weight: 700; }
.footer-legal {
  padding-top: var(--space-5);
  display: grid;
  gap: var(--space-2);
  font-size: var(--text-xs);
  line-height: 1.6;
}

@media (min-width: 48rem) {
  .footer-top { grid-template-columns: minmax(0, 1fr) auto; gap: var(--space-8); align-items: start; }
  .footer-links { justify-content: flex-end; }
}

/* ---------- Auth dialog ---------- */

.auth-dialog {
  width: min(26rem, calc(100vw - 2rem));
  max-height: calc(100dvh - 2rem);
  margin: auto;
  padding: var(--space-6);
  background: var(--card);
  color: var(--foreground);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 40px 120px -20px var(--shadow-float);
  overflow-y: auto;
}
.auth-dialog::backdrop { background: var(--scrim); backdrop-filter: blur(3px); }
.auth-dialog[open] { animation: dialog-in var(--dur-base) var(--ease-out-quart); }
.auth-dialog[open]::backdrop { animation: fade-in var(--dur-base) ease; }

@keyframes dialog-in { from { opacity: 0; transform: translateY(8px); } }
@keyframes fade-in { from { opacity: 0; } }

.auth-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}
.auth-title { font-size: var(--text-xl); line-height: 1.25; letter-spacing: -0.015em; }
.auth-lede { margin-top: var(--space-2); color: var(--muted-foreground); font-size: var(--text-sm); line-height: 1.6; }
.auth-close {
  flex: none;
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  margin: -0.5rem -0.5rem 0 0;
  background: none;
  border: 0;
  border-radius: var(--radius);
  color: var(--muted-foreground);
  cursor: pointer;
}
.auth-close:hover { background: var(--accent); color: var(--foreground); }

.auth-message {
  margin-bottom: var(--space-4);
  padding: var(--space-3) var(--space-4);
  border: 1px solid;
  border-radius: var(--radius);
  font-size: var(--text-sm);
  line-height: 1.55;
}
.auth-message[hidden] { display: none; }
.auth-message.is-error { color: var(--bear-text); background: #e0475c14; border-color: #e0475c66; }
.auth-message.is-info { color: var(--bull-text); background: #0ecb8112; border-color: #0ecb8160; }

.btn-google {
  background: var(--secondary);
  color: var(--foreground);
  border-color: var(--hair-strong);
  letter-spacing: 0.12em;
}
.btn-google:hover:not(:disabled) { background: var(--accent); color: var(--foreground); }
.btn-google svg { width: 1.1rem; height: 1.1rem; }

.auth-divider {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin-block: var(--space-5);
  color: var(--muted-foreground);
  font-size: var(--text-xs);
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--hair-strong); }

.form-group { margin-bottom: var(--space-4); }
.form-group[hidden] { display: none; }
.form-label {
  display: block;
  margin-bottom: var(--space-2);
  color: var(--foreground);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.form-input {
  width: 100%;
  min-height: 2.75rem;
  padding: 0.7rem 1rem;
  background: var(--muted);
  color: var(--foreground);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font: inherit;
  font-size: var(--text-base);
  transition: border-color var(--dur-fast) ease;
}
.form-input::placeholder { color: var(--muted-foreground); opacity: 1; }
.form-input:hover { border-color: var(--border-hover); }
.form-input:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; border-color: var(--ring); }

.auth-switch { margin-top: var(--space-5); text-align: center; color: var(--muted-foreground); font-size: var(--text-sm); }
.auth-switch[hidden], #verify-pending[hidden], #auth-form[hidden], .auth-divider[hidden], .btn-google[hidden] { display: none; }
.auth-note { margin-top: var(--space-5); color: var(--muted-foreground); font-size: var(--text-xs); line-height: 1.6; }
.auth-forgot { display: flex; justify-content: flex-end; margin: calc(var(--space-2) * -1) 0 var(--space-3); font-size: var(--text-sm); }
.auth-forgot[hidden], #forgot-form[hidden] { display: none; }
.auth-help { margin-top: var(--space-2); color: var(--muted-foreground); font-size: var(--text-xs); line-height: 1.6; }

/* Email action page (/auth/action, /auth/invite): the dialog's card, standing on the page. */
.auth-page {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  display: grid;
  place-items: center;
  min-height: 70vh;
  padding: var(--space-8) var(--gutter);
}
.auth-page-orn {
  position: absolute;
  z-index: -1;
  right: -10rem;
  top: -8rem;
  width: 32rem;
  max-width: none;
  opacity: 0.18;
  pointer-events: none;
}
.auth-card {
  width: min(26rem, 100%);
  padding: var(--space-6);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.auth-card .auth-lede { margin: var(--space-2) 0 var(--space-5); }
.auth-card .auth-title:focus { outline: none; }
/* Headings take focus only programmatically (tabindex=-1, never in the tab order), to move screen readers to the new state. */
.auth-card .form-input[readonly] { color: var(--muted-foreground); }
.auth-card .form-input[aria-invalid="true"] { border-color: var(--bear); }
.auth-card .btn + .btn { margin-top: var(--space-3); }
.auth-facts { margin: 0 0 var(--space-5); display: grid; gap: var(--space-2); font-size: var(--text-sm); }
.auth-facts div { display: flex; justify-content: space-between; gap: var(--space-4); padding-bottom: var(--space-2); border-bottom: 1px solid var(--hair); }
.auth-facts dt { color: var(--muted-foreground); }
.auth-facts dd { margin: 0; text-align: right; overflow-wrap: anywhere; }
#verify-pending p { color: var(--muted-foreground); font-size: var(--text-sm); margin-bottom: var(--space-4); }
#verify-pending strong { color: var(--foreground); font-weight: 600; overflow-wrap: anywhere; }

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