/* ============================================================
   Kizoona — onboarding
   System-only typography (CSP blocks external fonts). Editorial
   serif pairs with humanist sans; terracotta is the single
   accent, used sparingly.
   ============================================================ */

:root {
  /* paper → ink, warm neutral spine */
  --paper: #faf7f2;
  --paper-raised: #fffdf7;
  --paper-warm: #f6f0e6;
  --ink: #1f1b16;
  --ink-mid: #4d4840;
  --muted: #857c6f;
  --rule: #e5dfd4;
  --rule-soft: #efebe2;
  --accent: #c25a3a;
  --accent-deep: #9b4529;
  --accent-tint: #fff2ec;
  --accent-rule: #f0c0b6;
  --ok: #2e6547;
  --ok-tint: #f1f7f4;
  --ok-rule: #c6d9cd;
  --err: #a43428;

  /* type */
  --font-display:
    ui-serif, "New York", "Charter", "Bitstream Charter", "Sitka Text",
    Cambria, Georgia, serif;
  --font-body:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --font-mono:
    ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --text-xs: 12px;
  --text-sm: 14px;
  --text-base: 16px;
  --text-md: 18px;
  --text-lg: 24px;
  --text-xl: 32px;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;
  --space-9: 96px;

  --radius: 10px;
  --radius-lg: 14px;

  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

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

html, body { margin: 0; padding: 0; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  min-height: 100vh;

  /* Two large soft radial gradients for atmosphere; pin to the
     corners so they don't drift with scroll. Subtle enough that
     the page still reads as "warm paper" not "gradient" */
  background:
    radial-gradient(ellipse 700px 600px at 0% 0%, #fdfaf4 0%, transparent 60%),
    radial-gradient(ellipse 700px 600px at 100% 100%, var(--paper-warm) 0%, transparent 60%),
    var(--paper);
  background-attachment: fixed;
}

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

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

/* ------ Layout ------------------------------------------- */

.app {
  max-width: 480px;
  margin: 0 auto;
  padding: var(--space-6) var(--space-5) var(--space-8);
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  min-height: 100vh;
}

/* ------ Masthead ----------------------------------------- */

.masthead {
  padding-top: var(--space-3);
}
.mark {
  font-family: var(--font-display);
  font-size: 38px;
  font-weight: 500;
  letter-spacing: -0.025em;
  line-height: 1;
  color: var(--ink);
  font-feature-settings: "liga", "kern";
}
.subhead {
  margin-top: var(--space-2);
  font-size: var(--text-sm);
  color: var(--muted);
  letter-spacing: 0.01em;
}

/* ------ Progress ----------------------------------------- */

.progress {
  display: flex;
  gap: var(--space-2);
}
.tick {
  flex: 1;
  height: 2px;
  background: var(--rule);
  border-radius: 1px;
  transition: background 260ms var(--ease);
}
.tick--done { background: var(--ink); }
.tick--active { background: var(--accent); }

/* ------ Screen container --------------------------------- */

.screen { padding: var(--space-1) 0; }

.step {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  animation: screen-enter 260ms var(--ease);
}
@keyframes screen-enter {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ------ Type primitives ---------------------------------- */

.h1 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: var(--text-xl);
  letter-spacing: -0.02em;
  line-height: 1.12;
  margin: 0;
  color: var(--ink);
  font-feature-settings: "kern";
}
.h1__name {
  color: var(--accent);
  font-style: italic;
}

.lede {
  margin: 0;
  color: var(--ink-mid);
  font-size: var(--text-base);
  line-height: 1.55;
  max-width: 40ch;
}
.fine {
  margin: 0;
  color: var(--muted);
  font-size: var(--text-sm);
  line-height: 1.55;
  max-width: 42ch;
}

.eyebrow {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 3px 10px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  align-self: flex-start;
  background: var(--paper-raised);
}
.eyebrow--ok {
  color: var(--ok);
  border-color: var(--ok-rule);
  background: var(--ok-tint);
}

/* ------ Role cards --------------------------------------- */

.roles {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.role {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
  padding: var(--space-5);
  background: var(--paper-raised);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  cursor: pointer;
  transition:
    border-color 180ms var(--ease),
    background 180ms var(--ease),
    transform 140ms var(--ease);
}
.role:hover {
  border-color: var(--ink-mid);
}
.role:active {
  transform: scale(0.995);
}
.role:focus-within {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}
.role__input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}
.role__body { flex: 1; min-width: 0; }
.role__title {
  font-family: var(--font-display);
  font-size: var(--text-md);
  font-weight: 500;
  margin-bottom: 2px;
  letter-spacing: -0.005em;
  color: var(--ink);
}
.role__desc {
  font-size: var(--text-sm);
  color: var(--muted);
  line-height: 1.45;
}
.role__check {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1.5px solid var(--rule);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: transparent;
  flex-shrink: 0;
  margin-top: 2px;
  transition: all 180ms var(--ease);
}
.role--selected {
  border-color: var(--accent);
  background: var(--accent-tint);
}
.role--selected:hover {
  border-color: var(--accent-deep);
}
.role--selected .role__check {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--paper-raised);
}

/* ------ Fields ------------------------------------------- */

.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.field__label {
  font-size: var(--text-sm);
  color: var(--ink-mid);
  font-weight: 500;
}
.field__hint {
  font-size: var(--text-xs);
  color: var(--muted);
  line-height: 1.5;
  margin-top: 2px;
}
.input {
  width: 100%;
  padding: 14px 16px;
  background: var(--paper-raised);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  font-size: var(--text-base);
  color: var(--ink);
  appearance: none;
  -webkit-appearance: none;
  transition:
    border-color 180ms var(--ease),
    box-shadow 180ms var(--ease),
    background 180ms var(--ease);
}
.input::placeholder { color: var(--muted); }
.input:hover { border-color: var(--ink-mid); }
.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}

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

.actions {
  display: flex;
  gap: var(--space-3);
  margin-top: var(--space-2);
}
.actions--split { justify-content: space-between; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 14px 22px;
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: 500;
  line-height: 1;
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  transition:
    transform 120ms var(--ease),
    background 180ms var(--ease),
    border-color 180ms var(--ease),
    color 180ms var(--ease),
    box-shadow 180ms var(--ease);
  letter-spacing: 0.005em;
  -webkit-appearance: none;
  appearance: none;
}
.btn:focus { outline: none; }
.btn:focus-visible {
  box-shadow: 0 0 0 3px var(--accent-tint);
}
.btn:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}
.btn--primary {
  flex: 1;
  background: var(--ink);
  color: var(--paper-raised);
}
.btn--primary:hover:not(:disabled) {
  background: var(--accent-deep);
}
.btn--primary:active:not(:disabled) {
  transform: scale(0.99);
}
.btn--ghost {
  background: transparent;
  color: var(--ink-mid);
  border-color: transparent;
  padding-left: var(--space-3);
  padding-right: var(--space-3);
}
.btn--ghost:hover:not(:disabled) {
  color: var(--ink);
  background: var(--rule-soft);
}

/* ------ Working state ------------------------------------ */

.working {
  padding: var(--space-8) 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-5);
  text-align: center;
}
.working__dots {
  display: inline-flex;
  gap: 8px;
  align-items: center;
}
.working__dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ink);
  opacity: 0.2;
  animation: dot-pulse 1200ms var(--ease) infinite;
}
.working__dots span:nth-child(2) { animation-delay: 180ms; }
.working__dots span:nth-child(3) { animation-delay: 360ms; }
@keyframes dot-pulse {
  0%, 100% { opacity: 0.2; transform: translateY(0); }
  50%      { opacity: 1;   transform: translateY(-3px); }
}
.working__copy {
  margin: 0;
  color: var(--ink-mid);
  font-family: var(--font-display);
  font-style: italic;
  font-size: var(--text-md);
  letter-spacing: 0.005em;
}

/* ------ Recovery code ------------------------------------ */

.code {
  position: relative;
  margin: var(--space-2) 0;
  padding: var(--space-7) var(--space-4);
  background: var(--paper-raised);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 20px;
  line-height: 1.65;
  letter-spacing: 0.08em;
  color: var(--ink);
  text-align: center;
  word-break: break-all;
  user-select: all;
  animation: code-reveal 420ms var(--ease);
  box-shadow: 0 1px 0 0 var(--rule-soft);
}
.code::before {
  content: "RECOVERY CODE";
  position: absolute;
  top: -9px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--paper);
  padding: 0 10px;
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.16em;
  color: var(--muted);
}
@keyframes code-reveal {
  from { opacity: 0; transform: scale(0.98); }
  to   { opacity: 1; transform: scale(1); }
}

/* ------ Summary / data table ----------------------------- */

.data-table {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--paper-raised);
}
.datum {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding: var(--space-4);
  border-bottom: 1px solid var(--rule);
}
.datum:last-child { border-bottom: 0; }
.datum__label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}
.datum__value {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--ink);
  word-break: break-all;
  user-select: all;
}

/* ------ Alerts ------------------------------------------- */

.alert {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius);
  font-size: var(--text-sm);
  line-height: 1.5;
  animation: screen-enter 260ms var(--ease);
}
.alert--error {
  background: #fff1ef;
  border: 1px solid var(--accent-rule);
  color: var(--err);
}

/* ------ Colophon ----------------------------------------- */

.colophon {
  margin-top: auto;
  padding-top: var(--space-6);
  border-top: 1px solid var(--rule);
  font-size: var(--text-xs);
  color: var(--muted);
  line-height: 1.55;
  max-width: 44ch;
  font-style: italic;
  font-family: var(--font-display);
  letter-spacing: 0.005em;
}

/* ------ Responsive --------------------------------------- */

@media (min-width: 720px) {
  .app {
    max-width: 560px;
    padding: var(--space-8) var(--space-6);
    gap: var(--space-7);
  }
  .mark { font-size: 44px; letter-spacing: -0.028em; }
  .h1 { font-size: 42px; }
  .code {
    font-size: 26px;
    padding: var(--space-8) var(--space-6);
  }
  .roles { flex-direction: row; }
  .role { flex: 1; }
}

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