/* ============================================================
   AGYX Discovery Playbook — Stylesheet
   Palette per brief; type stack: Fraunces (display), Inter (body)
   Light theme only — per user preference, no dark backgrounds for client-facing
   ============================================================ */

:root {
  --ink:        #0E1A2B;
  --ink-2:      #2A3850;
  --ink-3:      #5C6A85;
  --ink-4:      #8B96AA;
  --paper:      #FDFCF8;
  --paper-2:    #F5F1E8;
  --paper-3:    #EFEAD9;
  --gold:       #B89030;
  --gold-deep:  #8E6E22;
  --gold-wash:  #FAF4E0;
  --rule:       #D8CFB8;
  --rule-soft:  #E8E1CD;
  --error:      #B83030;
  --error-bg:   #FBEEEE;
  --warn:       #B87830;
  --warn-bg:    #FAF1DF;
  --success:    #2E7D5C;
  --shadow-sm:  0 1px 2px rgba(14,26,43,0.06), 0 1px 4px rgba(14,26,43,0.04);
  --shadow-md:  0 2px 6px rgba(14,26,43,0.06), 0 6px 16px rgba(14,26,43,0.06);
  --shadow-lg:  0 4px 12px rgba(14,26,43,0.08), 0 16px 40px rgba(14,26,43,0.10);
  --radius-sm:  6px;
  --radius:     10px;
  --radius-lg:  14px;
}

/* ---------- reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4 { font-family: 'Fraunces', Georgia, 'Times New Roman', serif; font-weight: 500; line-height: 1.25; margin: 0; color: var(--ink); }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.4rem; }
a { color: var(--ink-2); text-decoration: underline; text-decoration-color: var(--rule); text-underline-offset: 3px; transition: color .15s, text-decoration-color .15s; }
a:hover { color: var(--gold-deep); text-decoration-color: var(--gold); }
button { font: inherit; cursor: pointer; }
.mono { font-family: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 12px 22px;
  font-family: 'Inter', sans-serif;
  font-size: 0.96rem; font-weight: 500;
  border-radius: var(--radius);
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s, transform .05s;
  user-select: none;
  white-space: nowrap;
}
.btn--primary { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.btn--primary:hover { background: var(--gold-deep); border-color: var(--gold-deep); }
.btn--primary:active { transform: translateY(1px); }
.btn--ghost { background: transparent; color: var(--ink-2); border-color: var(--rule); }
.btn--ghost:hover { background: var(--paper-2); border-color: var(--ink-3); color: var(--ink); }
.btn.is-disabled { pointer-events: none; opacity: 0.4; }

/* ---------- alerts ---------- */
.alert {
  padding: 12px 14px; border-radius: var(--radius-sm);
  font-size: 0.92rem;
  margin: 16px 0;
}
.alert--error { background: var(--error-bg); color: var(--error); border: 1px solid #F2D6D6; }
.alert--warn { background: var(--warn-bg); color: var(--warn); border: 1px solid #F2DFB6; }

/* ---------- brand mark ---------- */
.brand-mark { display: inline-flex; align-items: baseline; gap: 10px; }
.brand-mark__primary {
  font-family: 'Fraunces', serif;
  font-weight: 600;
  font-size: 1.25rem;
  letter-spacing: 0.02em;
  color: var(--ink);
}
.brand-mark__by {
  font-family: 'Inter', sans-serif;
  font-size: 0.78rem;
  color: var(--ink-3);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* ---------- topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--rule-soft);
  background: var(--paper);
  position: sticky; top: 0; z-index: 5;
}
.topbar--playbook { gap: 16px; }
.topbar--admin { background: var(--paper-2); }

/* ---------- progress (top-right of topbar in question pages) ---------- */
.progress {
  display: flex; flex-direction: column; align-items: flex-end; gap: 4px;
  flex: 1; max-width: 360px;
}
.progress__module { font-size: 0.78rem; color: var(--ink-3); letter-spacing: 0.04em; }
.progress__count { font-size: 0.86rem; color: var(--ink-2); font-weight: 500; }
.progress__bar { width: 100%; height: 4px; background: var(--rule-soft); border-radius: 99px; overflow: hidden; margin-top: 2px; }
.progress__bar > span { display: block; height: 100%; background: var(--gold); transition: width .3s ease; }

/* ---------- footer ---------- */
.footer { padding: 24px 16px 32px; text-align: center; }
.footer__inner { color: var(--ink-3); font-size: 0.82rem; }
.footer__sep { margin: 0 8px; color: var(--rule); }
.footer__link { color: var(--ink-3); }

/* ============================================================
   LOCK PAGE
   ============================================================ */
.page-lock { min-height: 100vh; display: flex; flex-direction: column; }
.lock {
  flex: 1; display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.lock__card {
  background: #fff;
  border: 1px solid var(--rule-soft);
  border-radius: var(--radius-lg);
  padding: 40px 36px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-md);
}
.lock__title { font-family: 'Fraunces', serif; font-size: 1.5rem; margin: 18px 0 4px; }
.lock__subtitle { color: var(--ink-3); margin: 0 0 24px; font-size: 0.95rem; }
.lock__form { display: flex; flex-direction: column; gap: 14px; margin-top: 8px; }
.lock__label { font-size: 0.85rem; color: var(--ink-3); font-weight: 500; letter-spacing: 0.02em; }
.lock__input {
  width: 100%; padding: 14px 16px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.05rem;
  letter-spacing: 0.06em;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--paper-2);
  color: var(--ink);
  transition: border-color .15s, background .15s;
}
.lock__input:focus { outline: none; border-color: var(--gold); background: #fff; }
.lock__btn { margin-top: 4px; }
.lock__note {
  margin-top: 24px;
  font-size: 0.82rem;
  color: var(--ink-3);
  text-align: center;
  border-top: 1px solid var(--rule-soft);
  padding-top: 18px;
}

/* ============================================================
   WELCOME / DONE
   ============================================================ */
.welcome { padding: 48px 24px 32px; }
.welcome__inner { max-width: 640px; margin: 0 auto; }
.welcome__heading {
  font-family: 'Fraunces', serif; font-size: 2.2rem;
  font-weight: 500; margin-bottom: 24px; line-height: 1.2;
  color: var(--ink);
}
.welcome__body { font-size: 1.05rem; color: var(--ink-2); margin: 0 0 18px; line-height: 1.65; }
.welcome__actions { margin-top: 36px; display: flex; gap: 12px; }
.welcome__meta { margin-top: 36px; font-size: 0.88rem; color: var(--ink-3); }

/* ============================================================
   QUESTION PAGE
   ============================================================ */
.qmain {
  max-width: 720px;
  margin: 0 auto;
  padding: 36px 24px 64px;
}
.qform {
  background: #fff;
  border: 1px solid var(--rule-soft);
  border-radius: var(--radius-lg);
  padding: 32px 32px 24px;
  box-shadow: var(--shadow-sm);
}
.qform__id {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  color: var(--gold-deep);
  letter-spacing: 0.06em;
  margin-bottom: 14px;
  display: flex; gap: 6px; align-items: center;
}
.qform__star { color: var(--gold); font-size: 1rem; }
.qform__text {
  font-family: 'Fraunces', serif;
  font-size: 1.45rem;
  line-height: 1.35;
  font-weight: 500;
  color: var(--ink);
  margin: 0 0 14px;
}
.qform__help {
  color: var(--ink-3);
  font-size: 0.94rem;
  font-style: italic;
  line-height: 1.6;
  margin: 0 0 22px;
  padding: 12px 14px;
  background: var(--gold-wash);
  border-left: 2px solid var(--gold);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.qform__input { margin-bottom: 8px; }

/* ---------- inputs ---------- */
.input {
  width: 100%;
  font-family: 'Inter', sans-serif;
  font-size: 1rem;
  line-height: 1.5;
  padding: 14px 16px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
  transition: border-color .15s, background .15s;
}
.input:focus { outline: none; border-color: var(--gold); background: #fff; }
.input--textarea { min-height: 200px; resize: vertical; }
.input--number { max-width: 200px; font-variant-numeric: tabular-nums; }

/* ---------- choices (radio / checkbox) ---------- */
.choices { display: flex; gap: 12px; flex-wrap: wrap; }
.choices--stacked { flex-direction: column; gap: 8px; }
.choice {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background .15s, border-color .15s;
  user-select: none;
  flex: 1;
}
.choices--stacked .choice { flex: none; width: 100%; }
.choice:hover { background: var(--paper-2); border-color: var(--ink-3); }
.choice input[type="radio"], .choice input[type="checkbox"] { accent-color: var(--gold-deep); width: 18px; height: 18px; flex-shrink: 0; }
.choice:has(input:checked) { background: var(--gold-wash); border-color: var(--gold); }
.choice__label { font-size: 0.96rem; color: var(--ink); }

/* ---------- save status ---------- */
.qform__status {
  min-height: 22px;
  margin-top: 12px;
  font-size: 0.82rem;
  color: var(--ink-3);
  transition: opacity .3s;
}
.qform__status.is-saving { color: var(--ink-3); }
.qform__status.is-saved { color: var(--success); }
.qform__status.is-error { color: var(--error); }

/* ---------- nav ---------- */
.qform__nav {
  display: flex; gap: 12px; justify-content: space-between;
  margin-top: 24px; padding-top: 20px;
  border-top: 1px solid var(--rule-soft);
}
.qform__skip { margin-top: 14px; text-align: center; font-size: 0.85rem; }
.qform__skip a { color: var(--ink-3); text-decoration-color: var(--rule); }
.qform__starnote { color: var(--ink-3); font-size: 0.84rem; }

/* ---------- module nav (below the form) ---------- */
.modules-nav {
  margin-top: 36px;
  padding: 24px;
  background: var(--paper-2);
  border-radius: var(--radius-lg);
}
.modules-nav__title {
  font-family: 'Inter', sans-serif;
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin: 0 0 14px;
}
.modules-nav ul { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 8px; }
.modules-nav li a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--ink-2);
  font-size: 0.88rem;
  transition: background .15s;
}
.modules-nav li a:hover { background: var(--paper-3); }
.modules-nav li.is-current a { background: var(--gold-wash); color: var(--ink); font-weight: 500; }
.modules-nav__num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px;
  background: #fff;
  border: 1px solid var(--rule);
  border-radius: 99px;
  font-size: 0.74rem;
  font-weight: 500;
  color: var(--ink-3);
  flex-shrink: 0;
}
.modules-nav li.is-current .modules-nav__num { background: var(--gold); border-color: var(--gold); color: #fff; }
.modules-nav__name { line-height: 1.2; }

/* ============================================================
   MODAL
   ============================================================ */
.modal[hidden] { display: none; }
.modal {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.modal__backdrop {
  position: absolute; inset: 0;
  background: rgba(14,26,43,0.45);
  backdrop-filter: blur(2px);
}
.modal__card {
  position: relative;
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 28px 28px 24px;
  max-width: 480px; width: 100%;
  box-shadow: var(--shadow-lg);
}
.modal__title { font-family: 'Fraunces', serif; font-size: 1.3rem; margin: 0 0 12px; }
.modal__body { color: var(--ink-2); font-size: 0.96rem; margin-bottom: 24px; line-height: 1.55; }
.modal__actions { display: flex; gap: 10px; justify-content: flex-end; }

/* ============================================================
   ADMIN
   ============================================================ */
.adminmain { max-width: 1100px; margin: 0 auto; padding: 32px 24px 64px; }
.adminmain__h1 { font-size: 1.7rem; margin-bottom: 24px; }
.adminmain__h2 { font-size: 1.2rem; margin: 36px 0 16px; }
.adminmain__actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 28px; }

.adminnav { display: flex; align-items: center; gap: 14px; }
.adminnav a { color: var(--ink-3); text-decoration: none; font-size: 0.92rem; padding: 6px 4px; border-bottom: 2px solid transparent; }
.adminnav a:hover { color: var(--ink); }
.adminnav a.is-current { color: var(--ink); border-bottom-color: var(--gold); }
.adminnav__logout { background: transparent; border: 0; color: var(--ink-3); font-size: 0.88rem; cursor: pointer; padding: 6px 4px; }
.adminnav__logout:hover { color: var(--ink); }

.cards {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px; margin-bottom: 28px;
}
.card {
  background: #fff;
  border: 1px solid var(--rule-soft);
  border-radius: var(--radius);
  padding: 18px 20px;
}
.card__label { font-size: 0.78rem; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 6px; }
.card__big { font-family: 'Fraunces', serif; font-size: 1.7rem; font-weight: 500; color: var(--ink); }
.card__sub { font-size: 1rem; color: var(--ink-3); }

.kv { background: #fff; border: 1px solid var(--rule-soft); border-radius: var(--radius); padding: 6px 0; }
.kv__row { display: flex; justify-content: space-between; padding: 12px 18px; border-bottom: 1px solid var(--rule-soft); font-size: 0.92rem; }
.kv__row:last-child { border-bottom: 0; }
.kv__k { color: var(--ink-3); }
.kv__v { color: var(--ink); font-weight: 500; }

.audit-table { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--rule-soft); border-radius: var(--radius); overflow: hidden; font-size: 0.88rem; }
.audit-table th, .audit-table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--rule-soft); vertical-align: top; }
.audit-table th { background: var(--paper-2); color: var(--ink-3); font-weight: 500; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; }
.audit-table td:last-child { word-break: break-all; }
.audit-table tr:last-child td { border-bottom: 0; }
.small { font-size: 0.84rem; }
.muted { color: var(--ink-3); }
.warn { color: var(--warn); }

.audit-filters { display: flex; gap: 14px; align-items: end; flex-wrap: wrap; margin-bottom: 18px; }
.audit-filters label { display: flex; flex-direction: column; gap: 4px; font-size: 0.8rem; color: var(--ink-3); }
.audit-filters select { padding: 8px 10px; font-size: 0.9rem; border: 1px solid var(--rule); border-radius: var(--radius-sm); background: #fff; }

/* admin-responses */
.responses-header { margin-bottom: 28px; padding-bottom: 18px; border-bottom: 1px solid var(--rule-soft); }
.responses-meta { color: var(--ink-3); font-size: 0.92rem; margin-top: 6px; }
.responses-meta .dot { margin: 0 8px; color: var(--rule); }
.module-heading {
  font-family: 'Fraunces', serif; font-size: 1.3rem; font-weight: 500;
  margin: 36px 0 14px; padding-bottom: 8px; border-bottom: 1px solid var(--rule);
  color: var(--gold-deep);
}
.qcard { background: #fff; border: 1px solid var(--rule-soft); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 12px; }
.qcard__id { font-family: 'JetBrains Mono', monospace; font-size: 0.78rem; color: var(--gold-deep); letter-spacing: 0.04em; }
.qcard__star { color: var(--gold); margin-left: 4px; }
.qcard__text { color: var(--ink); margin: 6px 0 12px; font-weight: 500; }
.qcard__answer { color: var(--ink-2); font-size: 0.95rem; line-height: 1.6; white-space: pre-wrap; }
.bullets { margin: 0; padding-left: 20px; }

/* ============================================================
   PRINT
   ============================================================ */
@media print {
  body { background: #fff; }
  .no-print, .topbar, .footer { display: none !important; }
  .adminmain, .adminmain--responses { padding: 0; max-width: 100%; }
  .qcard { page-break-inside: avoid; border: 0; padding: 12px 0; }
  .module-heading { page-break-after: avoid; }
  a { color: var(--ink); text-decoration: none; }
}

/* ============================================================
   MOBILE
   ============================================================ */
@media (max-width: 640px) {
  body { font-size: 15.5px; }
  h1 { font-size: 1.5rem; }
  .topbar { padding: 14px 16px; flex-wrap: wrap; gap: 10px; }
  .topbar--playbook { flex-direction: column; align-items: stretch; }
  .progress { max-width: none; align-items: stretch; }
  .progress__count { text-align: right; }
  .lock__card { padding: 28px 22px; }
  .qmain { padding: 20px 14px 48px; }
  .qform { padding: 22px 18px 18px; border-radius: var(--radius); }
  .qform__text { font-size: 1.25rem; }
  .qform__nav { flex-direction: column-reverse; gap: 10px; }
  .qform__nav .btn { width: 100%; }
  .welcome { padding: 28px 18px; }
  .welcome__heading { font-size: 1.7rem; }
  .modules-nav { padding: 18px; margin-top: 24px; }
  .modules-nav ul { grid-template-columns: 1fr; }
  .cards { grid-template-columns: repeat(2, 1fr); }
  .adminnav { gap: 8px; flex-wrap: wrap; }
  .audit-table { font-size: 0.82rem; display: block; overflow-x: auto; }
}

/* ============================================================
   REDUCED MOTION
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
