/* ══════════════════════════════════════════════════════════════════
   style.css — Gnoke TimeTraveller
   Based on Gnoke Suite Design System.
   Accent: cosmic violet #7c3aed
   ══════════════════════════════════════════════════════════════════ */

/* ── 1. TOKENS ─────────────────────────────────────────────────── */
:root {
  --bg:           #f5f0ff;
  --bg2:          #ede5ff;
  --surface:      #ffffff;
  --surface2:     #faf8ff;
  --surface3:     #f3eeff;
  --text:         #1a0a2e;
  --text2:        #3b1f6e;
  --muted:        #8b72b0;
  --border:       #ddd0f5;
  --border2:      #c8b8e8;

  --accent:       #7c3aed;
  --accent-dk:    #6d28d9;
  --accent-lt:    #ede9fe;
  --accent-txt:   #4c1d95;
  --accent-dim:   rgba(124,58,237,0.08);

  --green:        #2d6e4e;
  --green-lt:     #dff2ea;
  --red:          #b83030;
  --red-lt:       #fde8e8;
  --danger:       #dc2626;

  --topbar-bg:    #ffffff;
  --topbar-bdr:   #ddd0f5;
  --topbar-txt:   #1a0a2e;
  --topbar-muted: #8b72b0;
  --topbar-h:     52px;

  --font-sans:    'DM Sans', system-ui, sans-serif;
  --font-mono:    'DM Mono', monospace;
  --font-display: 'Playfair Display', serif;

  --radius:       10px;
  --radius-lg:    14px;
  --shadow:       0 1px 4px rgba(28,10,46,.08), 0 2px 12px rgba(28,10,46,.05);
  --shadow-lg:    0 4px 24px rgba(28,10,46,.14);
  --transition:   0.18s ease;
}

[data-theme="dark"] {
  --bg:       #0f0a1a;
  --bg2:      #160e22;
  --surface:  #1c1230;
  --surface2: #241838;
  --surface3: #2e2040;
  --text:     #f0e8ff;
  --text2:    #c8b0e8;
  --muted:    #7a60a0;
  --border:   #2a1f40;
  --border2:  #3a2e55;

  --topbar-bg:    #1c1230;
  --topbar-bdr:   #2a1f40;
  --topbar-txt:   #f0e8ff;
  --topbar-muted: #7a60a0;

  --accent-lt:    rgba(124,58,237,0.18);
  --accent-dim:   rgba(124,58,237,0.10);
}

/* ── 2. RESET ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; overflow-x: hidden; }
body {
  font-family: var(--font-sans);
  background: var(--bg); color: var(--text);
  line-height: 1.55; min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  overflow: hidden; display: flex; flex-direction: column;
}
a { text-decoration: none; color: inherit; }
input, select, textarea, button { font-family: var(--font-sans); font-size: inherit; }

/* ── 3. LOADING OVERLAY ────────────────────────────────────────── */
#loading-overlay {
  position: fixed; inset: 0;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 16px;
  z-index: 999;
}
.loader-dots { display: flex; gap: 6px; }
.loader-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--accent);
  animation: blink 1.2s infinite;
}
.loader-dot:nth-child(2) { animation-delay: .2s; }
.loader-dot:nth-child(3) { animation-delay: .4s; }
@keyframes blink {
  0%, 80%, 100% { opacity: .2; transform: scale(.8); }
  40%           { opacity: 1;  transform: scale(1);  }
}
.loader-text {
  font-family: var(--font-mono);
  font-size: .7rem; letter-spacing: .12em;
  text-transform: uppercase; color: var(--muted);
}

/* ── 4. TOPBAR ─────────────────────────────────────────────────── */
#topbar {
  height: var(--topbar-h);
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--topbar-bdr);
  display: flex; align-items: center;
  gap: 10px; padding: 0 16px;
  flex-shrink: 0; z-index: 100;
}
#hamburger {
  width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface2); color: var(--topbar-txt);
  font-size: 16px; cursor: pointer;
  display: none; align-items: center; justify-content: center;
  transition: border-color var(--transition);
}
#hamburger:hover { border-color: var(--accent); }
#brand { display: flex; align-items: baseline; gap: 6px; text-decoration: none; flex-shrink: 0; cursor: pointer; }
#brand-gnoke { font-family: var(--font-mono); font-size: .62rem; letter-spacing: .22em; text-transform: uppercase; color: var(--accent); }
#brand-app   { font-family: var(--font-display); font-size: 1.05rem; font-weight: 700; color: var(--topbar-txt); }
#context-info { font-family: var(--font-mono); font-size: .68rem; letter-spacing: .04em; color: var(--topbar-muted); margin-left: 4px; }
.topbar-spacer { flex: 1; }
.menu-group { display: flex; gap: 2px; }
#topbar-right { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
#status-chip {
  font-family: var(--font-mono); font-size: .6rem; letter-spacing: .1em; text-transform: uppercase;
  background: var(--surface2); color: var(--topbar-muted);
  border: 1px solid var(--border); padding: 3px 8px; border-radius: 20px;
  opacity: 0; transition: opacity .3s; pointer-events: none;
}
#status-chip.show { opacity: 1; }
.icon-btn {
  width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--surface2);
  color: var(--topbar-txt); cursor: pointer; font-size: 15px;
  display: flex; align-items: center; justify-content: center;
  transition: border-color var(--transition), background var(--transition);
}
.icon-btn:hover { border-color: var(--accent); background: var(--accent-dim); }

/* ── 5. PAGES ──────────────────────────────────────────────────── */
.pages { flex: 1; overflow: hidden; position: relative; }
.page  { position: absolute; inset: 0; overflow-y: auto; display: none; }
.page.active { display: block; animation: fadeUp .22s ease forwards; }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.page-content { max-width: 600px; margin: 0 auto; padding: 28px 20px 60px; }
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-header h1 { font-family: var(--font-display); font-size: 1.7rem; font-weight: 700; color: var(--text); letter-spacing: -.02em; }
.page-header .sub { font-family: var(--font-mono); font-size: .68rem; letter-spacing: .06em; color: var(--muted); margin-top: 4px; }

/* ── 6. CARDS ──────────────────────────────────────────────────── */
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.form-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px; box-shadow: var(--shadow); }
.card-title { font-family: var(--font-display); font-size: 1rem; font-weight: 600; color: var(--text); margin-bottom: 14px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.hint { font-size: .82rem; font-weight: 300; color: var(--muted); line-height: 1.65; }
.hint strong { color: var(--text); font-weight: 600; }

/* ── 7. BUTTONS ────────────────────────────────────────────────── */
.btn { padding: 9px 16px; border-radius: 8px; border: none; font-family: var(--font-sans); font-size: .82rem; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; transition: opacity var(--transition), transform var(--transition), background var(--transition); white-space: nowrap; }
.btn:active { opacity: .85; transform: scale(.98); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dk); }
.btn-ghost   { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn-danger  { background: var(--danger); color: #fff; }
.btn-outline { background: transparent; color: var(--accent); border: 1.5px solid var(--accent); }
.btn-outline:hover { background: var(--accent-lt); }
.btn-sm { padding: 6px 12px; font-size: .76rem; }

/* ── 8. FORM ELEMENTS ──────────────────────────────────────────── */
label { display: block; font-family: var(--font-mono); font-size: .68rem; font-weight: 500; letter-spacing: .08em; text-transform: uppercase; color: var(--text2); margin-bottom: 5px; }
input[type="text"], input[type="number"], input[type="date"], select { width: 100%; padding: 8px 12px; border: 1.5px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font-size: .88rem; transition: border-color var(--transition), box-shadow var(--transition); }
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-lt); }
.form-group { margin-bottom: 14px; }

/* ── 9. TABLES ─────────────────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
th, td { padding: 10px 14px; border-bottom: 1px solid var(--border); text-align: left; }
th { background: var(--surface2); font-family: var(--font-mono); font-size: .62rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-weight: 500; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface2); }
.about-table { width: 100%; border-collapse: collapse; font-size: .8rem; }
.about-table td { padding: 7px 0; border-bottom: 1px solid var(--border); color: var(--muted); }
.about-table td:first-child { font-family: var(--font-mono); font-size: .72rem; color: var(--text); width: 40%; }
.about-table tr:last-child td { border-bottom: none; }

/* ── 10. MODALS ────────────────────────────────────────────────── */
.modal-overlay { position: fixed; inset: 0; z-index: 300; background: rgba(0,0,0,.4); display: none; align-items: center; justify-content: center; padding: 20px; }
.modal-overlay.show { display: flex; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); width: 100%; max-width: 420px; padding: 20px; box-shadow: 0 16px 48px rgba(0,0,0,.18); }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.modal-head h3 { font-size: .95rem; font-weight: 600; }
.modal-close { background: none; border: none; font-size: 1rem; cursor: pointer; color: var(--muted); padding: 2px 6px; border-radius: 4px; }
.modal-close:hover { color: var(--text); }
.modal-body { font-size: .84rem; color: var(--muted); line-height: 1.6; margin-bottom: 14px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }

/* ── 11. TOAST ─────────────────────────────────────────────────── */
#toast {
  position: fixed; bottom: 28px; left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: var(--text); color: var(--bg);
  font-family: var(--font-mono); font-size: .72rem; letter-spacing: .04em;
  padding: 10px 18px; border-radius: 24px;
  opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s;
  white-space: nowrap; z-index: 999;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.err  { background: var(--danger); color: #fff; }
#toast.ok   { background: var(--green);  color: #fff; }

/* ── 12. MOBILE DRAWER (hmenu.js) ──────────────────────────────── */
#drawer-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 150; }
#drawer-overlay.open { display: block; }
#drawer { position: fixed; top: 0; left: 0; bottom: 0; width: 270px; background: var(--topbar-bg); z-index: 160; border-right: 1px solid var(--topbar-bdr); transform: translateX(-100%); transition: transform .28s ease; display: flex; flex-direction: column; overflow-y: auto; }
#drawer.open { transform: translateX(0); }

/* ── 13. RESPONSIVE ────────────────────────────────────────────── */
@media (max-width: 640px) {
  #hamburger    { display: flex; }
  .menu-group   { display: none; }
  #context-info { display: none; }
  .page-content { padding: 18px 14px 60px; }
  .card-grid    { grid-template-columns: 1fr; }
  .page-header h1 { font-size: 1.4rem; }
}
@media (min-width: 641px) {
  #hamburger { display: none; }
  #drawer, #drawer-overlay { display: none !important; }
}
@media (display-mode: standalone) {
  #topbar { padding-top: env(safe-area-inset-top); height: calc(var(--topbar-h) + env(safe-area-inset-top)); }
}

/* ════════════════════════════════════════════════════════════
   QUIZ-SPECIFIC STYLES
   ════════════════════════════════════════════════════════════ */

/* ── Quiz container ── */
.quiz-wrap {
  min-height: 100%;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}

.quiz-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 32px 28px;
  width: 100%; max-width: 500px;
  box-shadow: var(--shadow-lg);
  animation: fadeUp .3s ease forwards;
}

/* ── Quiz step counter ── */
.quiz-step {
  font-family: var(--font-mono);
  font-size: .64rem; letter-spacing: .12em;
  text-transform: uppercase; color: var(--accent);
  margin-bottom: 20px;
  display: flex; align-items: center; gap: 10px;
}
.quiz-step-dots {
  display: flex; gap: 5px;
}
.step-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--border); transition: background .3s;
}
.step-dot.done { background: var(--accent); }
.step-dot.active { background: var(--accent); box-shadow: 0 0 0 2px var(--accent-lt); }

/* ── Question text ── */
.quiz-question {
  font-family: var(--font-display);
  font-size: 1.4rem; font-weight: 700;
  color: var(--text); line-height: 1.3;
  margin-bottom: 24px;
}

/* ── Answer options ── */
.answer-options {
  display: flex; flex-direction: column; gap: 10px;
}

.answer-btn {
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 13px 16px;
  font-family: var(--font-sans);
  font-size: .88rem; font-weight: 500;
  color: var(--text);
  cursor: pointer; text-align: left;
  transition: border-color .15s, background .15s, transform .1s;
  display: flex; align-items: center; gap: 10px;
}
.answer-btn:hover {
  border-color: var(--accent);
  background: var(--accent-lt);
  transform: translateX(4px);
}
.answer-btn:active { transform: scale(.98); }
.answer-btn.selected {
  border-color: var(--accent);
  background: var(--accent-lt);
  color: var(--accent-txt);
}
.answer-btn .ans-emoji { font-size: 1.1rem; flex-shrink: 0; }

/* ── Progress bar at bottom of quiz card ── */
.quiz-progress {
  margin-top: 24px;
  height: 4px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}
.quiz-progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  transition: width .4s cubic-bezier(.4,0,.2,1);
}

/* ── Calculating screen ── */
.calc-wrap {
  min-height: 100%;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}

.calc-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 40px 28px;
  width: 100%; max-width: 460px;
  text-align: center;
  box-shadow: var(--shadow-lg);
}

.calc-emoji {
  font-size: 3rem; margin-bottom: 16px;
  display: block;
  animation: spin 2s linear infinite;
}
@keyframes spin {
  0%  { transform: rotate(0deg); }
  100%{ transform: rotate(360deg); }
}

.calc-title {
  font-family: var(--font-display);
  font-size: 1.3rem; font-weight: 700;
  color: var(--text); margin-bottom: 8px;
}

.calc-status {
  font-family: var(--font-mono);
  font-size: .72rem; letter-spacing: .06em;
  color: var(--muted); margin-bottom: 28px;
  min-height: 1.4em;
  transition: opacity .3s;
}

.calc-bar {
  height: 8px; background: var(--border);
  border-radius: 8px; overflow: hidden;
  margin-bottom: 10px;
}
.calc-bar-fill {
  height: 100%; background: var(--accent);
  border-radius: 8px;
  transition: width .6s cubic-bezier(.4,0,.2,1);
}
.calc-percent {
  font-family: var(--font-mono);
  font-size: .64rem; color: var(--muted);
}

/* ── Result screen ── */
.result-wrap {
  min-height: 100%;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}

.result-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 36px 28px;
  width: 100%; max-width: 480px;
  text-align: center;
  box-shadow: var(--shadow-lg);
}

.result-label {
  font-family: var(--font-mono);
  font-size: .64rem; letter-spacing: .14em;
  text-transform: uppercase; color: var(--accent);
  margin-bottom: 8px;
}

.result-date {
  font-family: var(--font-display);
  font-size: 2.6rem; font-weight: 700;
  color: var(--text); line-height: 1.1;
  margin-bottom: 6px;
  letter-spacing: -.02em;
}

.result-era {
  font-family: var(--font-mono);
  font-size: .72rem; color: var(--muted);
  margin-bottom: 20px;
  letter-spacing: .04em;
}

.result-verdict {
  background: var(--accent-lt);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  font-size: .88rem; color: var(--text2);
  line-height: 1.6; margin-bottom: 20px;
  text-align: left;
}

.result-karma {
  display: flex; gap: 8px; justify-content: center;
  margin-bottom: 24px; flex-wrap: wrap;
}
.karma-chip {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 5px 12px;
  font-family: var(--font-mono);
  font-size: .64rem; letter-spacing: .06em;
  text-transform: uppercase; color: var(--muted);
}

.result-tearrific {
  font-family: var(--font-display);
  font-size: 1.1rem; font-weight: 700;
  color: var(--accent);
  margin-bottom: 20px;
  letter-spacing: -.01em;
}

.result-actions {
  display: flex; gap: 10px; justify-content: center; flex-wrap: wrap;
}
