/* ==========================================================================
   JachAI — public component layer
   --------------------------------------------------------------------------
   academy, talent, plans, how, certificate, verify-email, reset-password.
   Loaded after theme.css, which defines every token this file uses. Nothing
   here declares a colour.

   These pages are wider and quieter than the workspace and read top to
   bottom, which is why the component layer differs from app.css even though
   the tokens are shared.
   ========================================================================== */

/* ==========================================================================
   2. Reset
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }
html { min-width: 320px; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  font: 16px/1.6 var(--font);
  color: var(--ink);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--brand-ink); }
img, svg { max-width: 100%; }
button { cursor: pointer; font: inherit; color: inherit; }
button:disabled { cursor: not-allowed; opacity: .55; }
::selection { background: var(--brand-200); color: var(--brand-900); }

/* ==========================================================================
   3. Layout
   ========================================================================== */

.page {
  width: min(100%, var(--max));
  flex: 1 0 auto;
  margin: 0 auto;
  padding: clamp(28px, 5vw, 64px) clamp(18px, 4vw, 40px) var(--sp-10);
}
.page--narrow { width: min(100%, 640px); }
.page--auth {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: stretch;
  padding-block: clamp(28px, 5vh, 56px);
}
.page--auth .card { padding: clamp(22px, 3vw, 34px); }

.section { margin-top: var(--sp-9); }
.section--tight { margin-top: var(--sp-7); }
.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-2);
  margin-bottom: var(--sp-4);
}
.section-head p { margin: 0; color: var(--muted); font-size: var(--text-base); }

.grid { display: grid; gap: var(--sp-4); margin-top: var(--sp-8); }
.cols-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.cols-3 { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.cols-4 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }

/* ==========================================================================
   4. Chrome
   ========================================================================== */

.topbar {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  flex-wrap: wrap;
  padding: var(--sp-4) clamp(18px, 4vw, 64px);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-3);
  color: var(--ink);
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  letter-spacing: -.05em;
  text-decoration: none;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--brand);
  color: var(--accent);
  font-size: 19px;
  font-weight: var(--weight-bold);
  box-shadow: var(--shadow-soft);
}
.brand-accent { color: var(--brand-ink); }

.topnav {
  margin-left: auto;
  display: flex;
  gap: var(--sp-5);
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
}
.topnav a {
  padding: var(--sp-2) 2px;
  color: var(--ink-soft);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  transition: border-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.topnav a:hover { color: var(--brand-ink); border-bottom-color: var(--brand-200); }
.topnav a[aria-current="page"] { color: var(--brand-ink); border-bottom-color: var(--brand); }

.footer {
  margin-top: auto;
  background: var(--surface);
  border-top: 1px solid var(--line);
}
.footer .inner {
  width: min(100%, var(--max));
  margin: 0 auto;
  padding: var(--sp-7) clamp(18px, 4vw, 40px);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-4);
  color: var(--muted);
  font-size: var(--text-md);
}
.footer .inner nav { margin-left: auto; display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.footer .inner a {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 7px 11px;
  border-radius: var(--radius-sm);
  color: var(--ink-soft);
  font-weight: var(--weight-semibold);
  text-decoration: none;
}
.footer .inner a:hover { color: var(--brand-ink); background: var(--surface-brand); }
.footer .inner a:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 2px; }

/* ==========================================================================
   5. Typography
   ========================================================================== */

.eyebrow {
  margin: 0 0 var(--sp-3);
  color: var(--brand-ink);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  letter-spacing: .19em;
  text-transform: uppercase;
}
.eyebrow--accent { color: var(--accent); text-shadow: var(--shadow-text); }

h1 {
  margin: 0 0 var(--sp-4);
  font-size: var(--text-2xl);
  line-height: 1.06;
  letter-spacing: -.042em;
  font-weight: var(--weight-bold);
}
h2 { margin: 0 0 var(--sp-3); font-size: var(--text-xl); letter-spacing: -.03em; font-weight: var(--weight-bold); }
h3 { margin: 0 0 var(--sp-2); font-size: 15.5px; letter-spacing: -.015em; font-weight: var(--weight-bold); }

.lede {
  margin: 0;
  max-width: 62ch;
  color: var(--muted);
  font-size: var(--text-lg);
  line-height: 1.6;
}

/* ==========================================================================
   6. Components
   ========================================================================== */

/* -- Button --------------------------------------------------------------- */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  min-height: 46px;
  padding: var(--sp-3) var(--sp-6);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-weight: var(--weight-semibold);
  text-decoration: none;
  transition: transform var(--dur) var(--ease),
              background var(--dur) var(--ease),
              border-color var(--dur) var(--ease),
              box-shadow var(--dur) var(--ease);
}
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:active:not(:disabled) { transform: translateY(0); }

.button.primary { background: var(--brand); color: var(--on-brand); box-shadow: var(--shadow-soft); }
.button.primary:hover { background: var(--brand-hover); box-shadow: var(--shadow-brand); }
.button.secondary { background: var(--mint); color: var(--mint-ink); }
.button.secondary:hover { background: var(--brand-200); }
.button.quiet { background: var(--surface); border-color: var(--line); color: var(--ink-soft); }
.button.quiet:hover { border-color: var(--line-strong); background: var(--surface-sunk); }

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

.cta-row { display: flex; flex-wrap: wrap; gap: var(--sp-3); margin: var(--sp-7) 0 0; }

/* -- Card ----------------------------------------------------------------- */

.card {
  padding: var(--sp-6);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.card p { margin: 0; color: var(--muted); font-size: var(--text-base); }

.card--featured { border-color: var(--brand); box-shadow: var(--shadow-brand); }
.card--featured::before {
  content: "";
  display: block;
  height: 4px;
  margin: calc(var(--sp-6) * -1) calc(var(--sp-6) * -1) var(--sp-5);
  background: linear-gradient(90deg, var(--brand) 0%, var(--accent) 100%);
  border-radius: var(--radius) var(--radius) 0 0;
}

/* -- Workflow (numbered steps) -------------------------------------------- */

ol.workflow { margin: 0; padding: 0; list-style: none; display: grid; gap: var(--sp-4); }
ol.workflow li {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: var(--sp-4);
  align-items: start;
  padding: var(--sp-5);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-soft);
}
ol.workflow p { margin: 2px 0 0; color: var(--muted); font-size: var(--text-base); }

.step-number {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--brand);
  color: var(--accent);
  font-size: 14px;
  font-weight: var(--weight-bold);
}

/* -- Facts ---------------------------------------------------------------- */

.facts { display: grid; gap: var(--sp-3); margin: 0; padding: 0; list-style: none; }
.facts li {
  position: relative;
  padding-left: var(--sp-6);
  color: var(--muted);
  font-size: var(--text-base);
}
.facts li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 9px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--brand);
}
.facts li strong { color: var(--ink); }

/* -- Notes / callouts ----------------------------------------------------- */

.note {
  margin-top: var(--sp-8);
  padding: var(--sp-5);
  background: var(--success-surface);
  border: 1px solid var(--line);
  border-radius: 14px;
}
.note p { margin: 0; color: var(--success-ink); font-size: var(--text-base); }
.note--warn { background: var(--warn-surface); border-color: var(--warn-border); }
.note--warn p { color: var(--warn); }
.note--accent { background: var(--accent-soft); border-color: var(--accent-300); }
.note--accent p { color: var(--accent-ink); }

/* -- Trust markers -------------------------------------------------------- */

.trust-row { display: flex; flex-wrap: wrap; gap: var(--sp-3); margin-top: var(--sp-6); }
.trust-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  color: var(--ink-soft);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
}
.trust-chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--brand); }

/* -- Certificate ---------------------------------------------------------- */

.cert-card { padding: clamp(20px, 4vw, 28px); }

.state {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin: 0 0 var(--sp-2);
  font-size: 19px;
  font-weight: var(--weight-bold);
  letter-spacing: -.02em;
}
.state .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--muted); flex: 0 0 auto; }
.state.valid { color: var(--brand-ink); }
.state.valid .dot { background: var(--brand); }
.state.invalid { color: var(--danger); }
.state.invalid .dot { background: var(--danger); }
.state.checking { color: var(--muted); }
.state.checking .dot { animation: pulse 1.2s ease-in-out infinite; }

@keyframes pulse {
  0%, 100% { opacity: .4; transform: scale(.9); }
  50% { opacity: 1; transform: scale(1.05); }
}

.code {
  margin: 0 0 var(--sp-5);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: var(--text-md);
  overflow-wrap: anywhere;
  font-variant-ligatures: none;
}

dl.cert-details {
  display: grid;
  grid-template-columns: minmax(7rem, 9rem) 1fr;
  gap: var(--sp-3) var(--sp-4);
  margin: var(--sp-5) 0 0;
  padding-top: var(--sp-5);
  border-top: 1px solid var(--line);
}
dl.cert-details dt { color: var(--muted); font-size: var(--text-md); }
dl.cert-details dd { margin: 0; font-weight: var(--weight-semibold); overflow-wrap: anywhere; }

/* -- Pricing -------------------------------------------------------------- */

.plan-card {
  display: grid;
  gap: var(--sp-2);
  padding: var(--sp-6);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.plan-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }

.plan-card--featured {
  position: relative;
  border-color: var(--brand);
  box-shadow: var(--shadow-brand);
}
.plan-card--featured .plan-badge {
  position: absolute;
  top: -12px;
  left: var(--sp-6);
  padding: var(--sp-1) var(--sp-3);
  background: var(--accent);
  color: var(--accent-on);
  border-radius: var(--r-pill);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  letter-spacing: .08em;
  text-transform: uppercase;
  box-shadow: var(--e-2);
}

.plan-name { font-size: var(--text-xl); font-weight: var(--weight-bold); letter-spacing: -.02em; }
.plan-price { display: flex; align-items: baseline; gap: var(--sp-2); color: var(--muted); font-size: 15px; }
.plan-price strong {
  color: var(--brand-ink);
  font-size: 32px;
  font-weight: var(--weight-bold);
  letter-spacing: -.03em;
  font-variant-numeric: tabular-nums;
}
.plan-price span { font-size: var(--text-md); }

.plan-features { display: grid; gap: var(--sp-2); margin: var(--sp-3) 0 0; padding: 0; }
.plan-features li {
  display: grid;
  grid-template-columns: 20px 1fr;
  gap: var(--sp-2);
  align-items: start;
  color: var(--ink-soft);
  font-size: var(--text-base);
  list-style: none;
}
.plan-features li::before {
  content: '';
  width: 8px;
  height: 8px;
  margin-top: 7px;
  border-radius: 50%;
  background: var(--brand);
}
.plan-features li.muted { color: var(--muted); }
.plan-features li.muted::before { background: var(--line-strong); }

/* -- Comparison table ----------------------------------------------------- */

.compare-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-soft);
}
.compare-table th, .compare-table td {
  padding: var(--sp-4);
  text-align: left;
  border-bottom: 1px solid var(--line-soft);
  font-size: var(--text-base);
}
.compare-table th {
  background: var(--surface-sunk);
  color: var(--muted);
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  letter-spacing: .08em;
  text-transform: uppercase;
}
.compare-table tr:last-child td { border-bottom: 0; }
.compare-table .yes { color: var(--brand-ink); font-weight: var(--weight-semibold); }
.compare-table .no { color: var(--muted); }

/* -- FAQ ------------------------------------------------------------------ */

.faq { display: grid; gap: var(--sp-3); }
.faq details {
  padding: var(--sp-4) var(--sp-5);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  transition: border-color var(--dur) var(--ease);
}
.faq details[open] { border-color: var(--brand-200); }
.faq summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--sp-3);
  font-weight: var(--weight-semibold);
  cursor: pointer;
  list-style: none;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
  content: '+';
  color: var(--muted);
  font-size: 18px;
  font-weight: var(--weight-bold);
  transition: transform var(--dur) var(--ease);
}
.faq details[open] summary::after { transform: rotate(45deg); }
.faq p { margin: var(--sp-3) 0 0; color: var(--muted); font-size: var(--text-base); }

/* -- Form fields ----------------------------------------------------------
   Used by the verify-email and reset-password pages, which are unauthenticated
   and so sit on this stylesheet rather than app.css.
   ------------------------------------------------------------------------- */

.field { display: grid; gap: var(--sp-2); margin-bottom: var(--sp-4); }
.field label { color: var(--ink-soft); font-size: var(--text-md); font-weight: var(--weight-semibold); }
.field small { color: var(--muted); font-weight: var(--weight-regular); }

input[type="email"], input[type="password"], input[type="text"] {
  width: 100%;
  min-height: 46px;
  padding: var(--sp-3);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  color: var(--ink);
  font: inherit;
  outline: none;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}

/* Password visibility toggle */
.password-field {
  position: relative;
  display: grid;
  gap: var(--sp-2);
}
.password-field > input[type="password"],
.password-field > input[type="text"] {
  width: 100%;
  min-width: 0;
  padding-right: 52px;
}
.password-toggle {
  position: absolute;
  right: 0;
  top: auto;
  bottom: 0;
  height: 46px;
  width: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-left: 1px solid var(--line-strong);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--ink-soft);
  cursor: pointer;
  padding: 0;
}
.password-toggle:hover {
  background: var(--surface-sunk);
  color: var(--ink);
}
.password-toggle:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: -3px;
  border-radius: var(--radius-sm);
}
.password-toggle svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
}
input:hover:not(:disabled) { border-color: var(--brand-300); }
input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus-ring) 22%, transparent);
}
input::placeholder { color: var(--neutral-400); }

/* A status line only becomes a callout once it actually says something, so
   the page does not open with an empty coloured box. */
.status:not(:empty) {
  margin: var(--sp-5) 0 0;
  padding: var(--sp-3) var(--sp-4);
  background: var(--surface-sunk);
  border: 1px solid var(--line);
  border-left: 3px solid var(--line-strong);
  border-radius: var(--radius-sm);
  color: var(--ink-soft);
  font-size: var(--text-base);
}
.status.is-ok:not(:empty) {
  background: var(--success-surface);
  border-color: var(--success-ink);
  border-left-color: var(--brand);
  color: var(--success-ink);
}
.status.is-error:not(:empty) {
  background: var(--danger-surface);
  border-color: var(--danger-ink);
  border-left-color: var(--danger);
  color: var(--danger-ink);
}

/* Explanatory copy sitting above a form inside a card. */
.form-note { margin: var(--sp-5) 0 var(--sp-4); color: var(--muted); font-size: var(--text-base); }

.auth-aside { margin: var(--sp-6) 0 0; font-size: var(--text-base); }
.auth-return { align-self: flex-start; margin-top: var(--sp-6); text-decoration: none; }
.auth-return:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 2px; }

/* ==========================================================================
   7. Responsive
   ========================================================================== */

@media (max-width: 560px) {
  .topnav { width: 100%; margin-left: 0; gap: var(--sp-4); }
  .button { width: 100%; }
  .cta-row { flex-direction: column; }
  ol.workflow li { grid-template-columns: 1fr; padding: var(--sp-4); }
  ol.workflow li .step-number { width: 28px; height: 28px; font-size: 13px; }
  .section { margin-top: var(--sp-8); }
  .plan-card--featured .plan-badge { left: var(--sp-4); }
  .page--auth { padding-block: var(--sp-7); }
  .auth-return { width: 100%; }
  .footer .inner { align-items: flex-start; }
  .footer .inner nav { width: 100%; margin-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
  .button:hover:not(:disabled), .card:hover, .plan-card:hover { transform: none; }
  .state.checking .dot { animation: none; }
}
