/* Self-hosted, latin subset (OFL, see fonts/OFL-*.txt). */
@font-face {
  font-family: "Jost";
  src: url("./fonts/jost-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

/*
  Fraunces (display): soft serif, moderate contrast, sturdy strokes. Variable
  latin subset instanced from the Google Fonts release with fontTools:
  wght 500–700, opsz 9–48, SOFT pinned at 50, WONK pinned at 0.
*/
@font-face {
  font-family: "Fraunces";
  src: url("./fonts/fraunces-latin.woff2") format("woff2");
  font-weight: 500 700;
  font-style: normal;
  font-display: swap;
}

/*
  Design system « D · Synthèse Afrique »: square corners, hairlines, no shadows.
  Contrast (WCAG 2.1) against --bg / --surface, light then dark:
    text 15.4 / 16.4 · 15.0 / 13.6      text-secondary 8.7 / 9.2 · 10.1 / 9.1
    muted 5.5 / 5.9 · 6.9 / 6.2         error 6.1 / 6.5 · 7.2 / 6.5
    success 5.7 / 6.0 · 7.9 / 7.1       info 6.2 / 6.6 · 8.1 / 7.3
    on-accent / accent 9.4              focus 3.6 / 3.8 · 9.4 / 8.5 (non-text, 1.4.11)
    field-line 3.4 / 3.6 · 4.6 / 4.1 (input boundary, 1.4.11)
  --decor-gold is decoration only (2.6:1 in light): never text.
*/
:root {
  --bg: #f5f1e8;
  --surface: #fbf8f1;
  --line: #d9d2c3;
  --line-strong: #bfb6a4;
  /* Input underline: needs 3:1 to identify the field (1.4.11); --line stays for dividers. */
  --field-line: #8a8272;
  --text: #121a2b;
  --text-secondary: #3a4458;
  --muted: #5a6170;
  --accent: #e4bb00;
  --accent-hover: #f5cc30;
  --on-accent: #121a2b;
  --focus: #9a7b05;
  --decor-gold: #b8930a;
  --disabled-bg: #e8e1d2;
  --error: #a3322a;
  --success: #2e6b3f;
  --info: #2f5c8a;
  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-ui: "Jost", "Futura", system-ui, -apple-system, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121a2b;
    --surface: #1a2336;
    --line: #343a47;
    --line-strong: #4a5263;
    --field-line: #7a8396;
    --text: #f2eee6;
    --text-secondary: #c9c5bc;
    --muted: #9aa3b5;
    --focus: #e4bb00;
    --disabled-bg: #232d44;
    --error: #f08a7e;
    --success: #6fbf8a;
    --info: #8db4e2;
  }
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: max(32px, env(safe-area-inset-top)) 24px max(32px, env(safe-area-inset-bottom));
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 16px;
  font-weight: 400;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
}

.shell {
  width: 100%;
  max-width: 420px;
}

/* Full-bleed on phones; a hairline sheet on wider screens. */
.card {
  background: transparent;
}

@media (min-width: 560px) {
  body {
    padding-top: max(64px, env(safe-area-inset-top));
  }

  .shell {
    max-width: 468px;
  }

  .card {
    padding: 40px;
    border: 1px solid var(--line);
    background: var(--surface);
  }
}

/* Caps labels: 11px, letter-spacing 3px. Uppercased in CSS so translations stay in sentence case. */
.brand-name,
.tab,
.divider,
.field > label:not(.checkbox),
.account-label {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 3px;
  line-height: 1.45;
  text-transform: uppercase;
}

.card-header {
  margin-bottom: 28px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 28px;
}

.brand-mark {
  flex: none;
  fill: none;
  stroke: var(--decor-gold);
  stroke-width: 1.6;
  stroke-linecap: round;
}

.brand .brand-name {
  font-size: 13px;
  letter-spacing: 6px;
  color: var(--text);
}

/*
  Display titles: weight 600, SOFT 50, WONK 0. Low optical sizes have sturdier
  strokes than the high-contrast large ones, so opsz is capped at 36 for h1;
  h2 keeps automatic optical sizing (22).
*/
h1,
h2 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-optical-sizing: auto;
  font-variation-settings: "SOFT" 50, "WONK" 0;
  color: var(--text);
}

h1 {
  font-size: 32px;
  line-height: 1.15;
  letter-spacing: -0.2px;
  font-variation-settings: "opsz" 36, "SOFT" 50, "WONK" 0;
}

h2 {
  margin-bottom: 8px;
  font-size: 22px;
  line-height: 1.27;
}

.subtitle,
.help {
  margin: 10px 0 0;
  color: var(--text-secondary);
  font-size: 15px;
  line-height: 1.6;
}

.help {
  margin: 0 0 20px;
}

.kente {
  display: block;
  margin-top: 22px;
}

.kente path {
  fill: none;
  stroke: var(--decor-gold);
  stroke-width: 1;
}

/* Tabs: text only, ink underline on the selected one. */
.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--line);
}

.tab {
  position: relative;
  min-height: 48px;
  padding: 0 8px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  cursor: pointer;
  transition: color 0.15s ease-out;
}

.tab:hover {
  color: var(--text);
}

.tab[aria-selected="true"] {
  color: var(--text);
  font-weight: 600;
}

.tab[aria-selected="true"]::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  background: var(--text);
}

.tab:focus-visible {
  outline-offset: -2px;
}

.social-auth {
  display: grid;
  gap: 10px;
}

.social-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 50px;
  padding: 0 16px;
  border: 1px solid var(--text);
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.15s ease-out;
}

.social-button:hover {
  background: var(--surface);
}

@media (min-width: 560px) {
  .social-button:hover {
    background: var(--bg);
  }
}

.divider {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 8px 0 6px;
  color: var(--muted);
}

.divider::before,
.divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

/* The divider only makes sense when at least one provider button is shown. */
.social-auth:not(:has(.social-button:not([hidden]))) {
  display: none;
}

form {
  display: grid;
  gap: 16px;
}

.field {
  display: grid;
  gap: 4px;
  padding-top: 8px;
}

.field > label:not(.checkbox) {
  color: var(--muted);
  transition: color 0.15s ease-out;
}

.field:focus-within > label:not(.checkbox) {
  color: var(--text);
}

.field:has([aria-invalid="true"]) > label:not(.checkbox) {
  color: var(--error);
}

.field-hint,
.field-error {
  margin: 4px 0 0;
  font-size: 13px;
  line-height: 1.38;
  letter-spacing: 0.2px;
}

.field-hint {
  color: var(--muted);
}

.field-hint.is-met {
  color: var(--success);
}

.field-error {
  display: flex;
  gap: 8px;
  color: var(--error);
  font-weight: 500;
}

/* Not colour alone: a mark precedes every error. */
.field-error::before {
  content: "!";
  /* Empty alt text: screen readers read the message only. */
  content: "!" / "";
  flex: none;
  display: grid;
  place-items: center;
  width: 16px;
  height: 16px;
  margin-top: 1px;
  border-radius: 50%;
  background: var(--error);
  color: var(--bg);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}

.input-wrap {
  position: relative;
}

.input-wrap input {
  padding-right: 48px;
}

.reveal {
  position: absolute;
  top: 0;
  right: -8px;
  bottom: 1px;
  width: 44px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.reveal svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.reveal:focus-visible {
  outline-offset: -2px;
}

.reveal:hover {
  color: var(--text);
}

.reveal .icon-hide,
.reveal[aria-pressed="true"] .icon-show {
  display: none;
}

.reveal[aria-pressed="true"] .icon-hide {
  display: block;
}

/* Underlined fields: no box, 1px line at rest, 2px focus / error line (inset, no layout shift). */
input[type="email"],
input[type="password"],
input[type="text"] {
  width: 100%;
  min-height: 44px;
  padding: 0;
  border: 0;
  border-bottom: 1px solid var(--field-line);
  border-radius: 0;
  background: transparent;
  color: var(--text);
  transition: border-color 0.15s ease-out, box-shadow 0.15s ease-out;
  /* 16px keeps iOS from zooming on focus. */
  font: inherit;
  font-size: 16px;
  font-weight: 400;
  -webkit-appearance: none;
  appearance: none;
}

input[readonly] {
  color: var(--muted);
  border-bottom-style: dashed;
  cursor: default;
}

input[type="email"]:focus,
input[type="password"]:focus,
input[type="text"]:focus {
  outline: none;
  border-bottom-color: var(--focus);
  box-shadow: inset 0 -1px 0 var(--focus);
}

input[aria-invalid="true"],
input[aria-invalid="true"]:focus {
  border-bottom-color: var(--error);
  box-shadow: inset 0 -1px 0 var(--error);
}

/* Full opacity: a faded placeholder falls under 4.5:1. */
input::placeholder {
  color: var(--muted);
  opacity: 1;
}

::selection {
  background: var(--accent);
  color: var(--on-accent);
}

:is(input, button, a):focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.checkbox {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-height: 48px;
  padding: 4px 0;
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.5;
  cursor: pointer;
}

/* Square box, 1px muted border; checked: gold fill with an ink check. */
.checkbox input {
  flex: none;
  width: 20px;
  height: 20px;
  margin: 1px 0 0;
  border: 1px solid var(--muted);
  border-radius: 0;
  background: transparent center / 14px 14px no-repeat;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
}

.checkbox input:checked {
  border-color: var(--accent);
  background-color: var(--accent);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 14'%3E%3Cpath d='M2.5 7.5l3 3 6-7' fill='none' stroke='%23121A2B' stroke-width='2' stroke-linecap='square'/%3E%3C/svg%3E");
}

.checkbox input[aria-invalid="true"] {
  border: 2px solid var(--error);
}

a {
  color: var(--text);
  font-weight: 500;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
}

a:hover {
  text-decoration-color: var(--decor-gold);
}

/* One gold button per screen: yellow fill, ink caps. */
.primary-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 54px;
  margin-top: 8px;
  padding: 0 24px;
  border: 0;
  border-radius: 0;
  background: var(--accent);
  color: var(--on-accent);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 3px;
  line-height: 1.23;
  text-transform: uppercase;
  cursor: pointer;
  transition: background-color 0.15s ease-out;
}

.primary-button:hover {
  background: var(--accent-hover);
}

.link-button {
  display: block;
  min-height: 44px;
  margin: 8px 0 0 auto;
  padding: 8px 0;
  border: 0;
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 400;
  text-decoration: underline;
  text-decoration-color: var(--decor-gold);
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
  cursor: pointer;
}

.link-button:hover {
  text-decoration-color: currentColor;
}

/* Reset view: the way back sits on the left, under the form. */
[data-view="reset"] .link-button {
  margin-left: 0;
}

button:disabled,
input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* No faded gold: a flat disabled fill keeps the label at 4.5:1. */
.primary-button:disabled {
  opacity: 1;
  background: var(--disabled-bg);
  color: var(--muted);
}

/* The button that started the action: stays opaque and focusable, shows a spinner. */
button.is-loading {
  cursor: progress;
}

.primary-button.is-loading,
.primary-button.is-loading:hover {
  background: var(--accent);
}

.spinner,
button.is-loading::before {
  content: "";
  flex: none;
  width: 18px;
  height: 18px;
  border: 1.6px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.social-button.is-loading svg {
  display: none;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes pulse {
  50% {
    opacity: 0.35;
  }
}

/* Reauth: the account to confirm, between hairlines. */
.account {
  display: grid;
  gap: 4px;
  margin: 0 0 24px;
  padding: 14px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.account-label {
  color: var(--muted);
}

.account-email {
  font-size: 16px;
  font-weight: 500;
  overflow-wrap: anywhere;
}

/* Redirect return: the form would only invite a second, conflicting sign-in. */
.card.is-pending > :not(.card-header, .account, .pending, .status) {
  display: none;
}

.pending {
  display: grid;
  justify-items: center;
  gap: 16px;
  padding: 32px 0 8px;
  color: var(--text-secondary);
  font-size: 15px;
}

.pending p {
  margin: 0;
}

.spinner-large {
  width: 32px;
  height: 32px;
  border-width: 1.6px;
  color: var(--decor-gold);
}

.status:empty {
  display: none;
}

/* Banner: semantic hairline on top, neutral one below. */
.status {
  margin: 24px 0 0;
  padding: 12px 14px;
  border-top: 1px solid currentColor;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.5;
}

.status.error {
  color: var(--error);
}

.status.success {
  color: var(--success);
}

.status.info {
  color: var(--info);
}

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

  /* Keep a sign of progress, without the rotation. */
  .spinner,
  button.is-loading::before {
    border-right-color: currentColor;
    animation: pulse 1.6s ease-in-out infinite;
  }
}

@media (forced-colors: active) {
  .tab[aria-selected="true"]::after {
    background: CanvasText;
  }

  .checkbox input {
    -webkit-appearance: auto;
    appearance: auto;
  }
}
