/* ==========================================================================
   Thamra — design tokens and primitives
   Single source of truth for colour, type and spacing. Every component
   styles through these variables so light/dark stay in lockstep.
   ========================================================================== */

:root {
  /* Surfaces — neutrals carry a slight green bias so they read as chosen */
  --ground: #fcfcfb;
  --panel: #ffffff;
  --sunken: #f2f4f2;
  --line: #e1e6e3;
  --line-strong: #cbd3cf;

  /* Ink */
  --ink: #151e1b;
  --ink-2: #41504b;
  --ink-3: #75847e;

  /* Accent — jade. Validated for contrast against both surfaces. */
  --accent: #0f8a66;
  --accent-ink: #0b6b4f;
  --accent-soft: #e4f2ed;
  --on-accent: #ffffff;

  /* Status. Reserved: never reused as a generic series colour. */
  --hot: #b33127;
  --hot-soft: #faeae8;
  --warm: #c98418;
  --warm-soft: #fbf1e1;
  --cold: #697a81;
  --cold-soft: #eef1f2;

  --shadow-sm: 0 1px 2px rgba(21, 30, 27, 0.05);
  --shadow: 0 1px 2px rgba(21, 30, 27, 0.05), 0 8px 24px -12px rgba(21, 30, 27, 0.18);
  --shadow-lift: 0 2px 4px rgba(21, 30, 27, 0.06), 0 20px 44px -20px rgba(21, 30, 27, 0.3);

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;

  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, "JetBrains Mono", Menlo, Consolas, monospace;

  --step-6: 2.25rem;
  --step-5: 1.75rem;
  --step-4: 1.375rem;
  --step-3: 1.125rem;
  --step-2: 0.9375rem;
  --step-1: 0.8125rem;
  --step-0: 0.6875rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ground: #0e1412;
    --panel: #161e1b;
    --sunken: #1b2521;
    --line: #26312d;
    --line-strong: #37443f;
    --ink: #e8eeeb;
    --ink-2: #a8b5b0;
    --ink-3: #77857f;
    --accent: #2ba77c;
    --accent-ink: #4cc194;
    --accent-soft: #123128;
    --on-accent: #06120d;
    --hot: #cf4437;
    --hot-soft: #331916;
    --warm: #b08a30;
    --warm-soft: #2c2515;
    --cold: #8496a0;
    --cold-soft: #1e2629;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px -12px rgba(0, 0, 0, 0.6);
    --shadow-lift: 0 2px 6px rgba(0, 0, 0, 0.5), 0 20px 44px -20px rgba(0, 0, 0, 0.8);
  }
}

/* The in-app theme toggle stamps data-theme on <html> and must win over the
   media query in both directions. */
:root[data-theme="light"] {
  --ground: #fcfcfb;
  --panel: #ffffff;
  --sunken: #f2f4f2;
  --line: #e1e6e3;
  --line-strong: #cbd3cf;
  --ink: #151e1b;
  --ink-2: #41504b;
  --ink-3: #75847e;
  --accent: #0f8a66;
  --accent-ink: #0b6b4f;
  --accent-soft: #e4f2ed;
  --on-accent: #ffffff;
  --hot: #b33127;
  --hot-soft: #faeae8;
  --warm: #c98418;
  --warm-soft: #fbf1e1;
  --cold: #697a81;
  --cold-soft: #eef1f2;
  --shadow-sm: 0 1px 2px rgba(21, 30, 27, 0.05);
  --shadow: 0 1px 2px rgba(21, 30, 27, 0.05), 0 8px 24px -12px rgba(21, 30, 27, 0.18);
  --shadow-lift: 0 2px 4px rgba(21, 30, 27, 0.06), 0 20px 44px -20px rgba(21, 30, 27, 0.3);
}

:root[data-theme="dark"] {
  --ground: #0e1412;
  --panel: #161e1b;
  --sunken: #1b2521;
  --line: #26312d;
  --line-strong: #37443f;
  --ink: #e8eeeb;
  --ink-2: #a8b5b0;
  --ink-3: #77857f;
  --accent: #2ba77c;
  --accent-ink: #4cc194;
  --accent-soft: #123128;
  --on-accent: #06120d;
  --hot: #cf4437;
  --hot-soft: #331916;
  --warm: #b08a30;
  --warm-soft: #2c2515;
  --cold: #8496a0;
  --cold-soft: #1e2629;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px -12px rgba(0, 0, 0, 0.6);
  --shadow-lift: 0 2px 6px rgba(0, 0, 0, 0.5), 0 20px 44px -20px rgba(0, 0, 0, 0.8);
}

/* ---------- reset ---------- */

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

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

body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: var(--step-2);
  line-height: 1.6;
  color: var(--ink);
  background: var(--ground);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  line-height: 1.25;
  text-wrap: balance;
  font-weight: 700;
}

p {
  margin: 0;
}

img,
svg {
  max-width: 100%;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

[hidden] {
  display: none !important;
}

/* ---------- utilities ---------- */

.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: var(--step-0);
  letter-spacing: 0.09em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--accent-ink);
}

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

/* ---------- brand mark ---------- */

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

.brand__mark {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: var(--accent);
  color: var(--on-accent);
  display: grid;
  place-items: center;
  flex: none;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.02em;
}

.brand__name {
  font-size: var(--step-3);
  font-weight: 700;
  letter-spacing: -0.01em;
}

.brand__name span {
  display: block;
  font-size: var(--step-1);
  font-weight: 500;
  color: var(--ink-3);
  letter-spacing: 0;
  line-height: 1.3;
}

/* ---------- form primitives ---------- */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field__label {
  font-size: var(--step-1);
  font-weight: 600;
  color: var(--ink-2);
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.field__label a {
  margin-left: auto;
  font-size: var(--step-1);
  font-weight: 600;
  color: var(--accent-ink);
  text-decoration: none;
}

.field__label a:hover {
  text-decoration: underline;
}

.field__hint {
  font-size: var(--step-1);
  color: var(--ink-3);
}

.input {
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  font-size: var(--step-2);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.input::placeholder {
  color: var(--ink-3);
}

.input:hover {
  border-color: var(--ink-3);
}

.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.input[aria-invalid="true"] {
  border-color: var(--hot);
}

.input-group {
  position: relative;
  display: flex;
}

.input-group .input {
  padding-right: 78px;
}

.input-group__action {
  position: absolute;
  right: 5px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: 0;
  padding: 5px 8px;
  border-radius: 6px;
  font-size: var(--step-1);
  font-weight: 600;
  color: var(--ink-3);
  cursor: pointer;
}

.input-group__action:hover {
  color: var(--ink);
  background: var(--sunken);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--panel);
  color: var(--ink);
  padding: 11px 18px;
  font-size: var(--step-2);
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
}

.btn:hover {
  border-color: var(--ink-3);
}

.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

.btn--primary:hover {
  background: var(--accent-ink);
  border-color: var(--accent-ink);
}

.btn--block {
  width: 100%;
}

.btn[disabled],
.btn[aria-busy="true"] {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn__spinner {
  width: 15px;
  height: 15px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* ---------- notices ---------- */

.notice {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  font-size: var(--step-1);
  font-weight: 500;
  line-height: 1.55;
  border: 1px solid;
}

.notice svg {
  flex: none;
  margin-top: 1px;
}

.notice--error {
  background: var(--hot-soft);
  border-color: color-mix(in srgb, var(--hot) 32%, transparent);
  color: var(--hot);
}

.notice--info {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 30%, transparent);
  color: var(--accent-ink);
}

.notice--warn {
  background: var(--warm-soft);
  border-color: color-mix(in srgb, var(--warm) 32%, transparent);
  color: var(--warm);
}

/* ---------- divider ---------- */

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--ink-3);
  font-size: var(--step-1);
}

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

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