/* Astuce prototype — design tokens
   Layout concept: fixed top meta-bar (prototype harness) + per-role chrome:
   public = top marketing nav; app roles = left sidebar + content. */
:root {
  /* Candle Digital Solutions brand: charcoal, off-white, flame orange */
  --bg: #f1f2f2;
  --surface: #FFFFFF;
  --surface-sunken: #E4E5E5;
  --border: #D3D4D4;
  --ink: #333333;
  --ink-muted: #6E6E6E;
  --primary: #ef762b;
  --primary-ink: #FFFFFF;
  --primary-soft: #FCE6D7;
  --accent: #ef762b;
  --accent-ink: #FFFFFF;
  --accent-soft: #FCE6D7;
  --good: #3C7A4E;
  --good-soft: #E1EFE4;
  --warn: #B8862E;
  --warn-soft: #F5E9D3;
  --bad: #A23B3B;
  --bad-soft: #F3DEDE;
  --shadow: 0 1px 2px rgba(51,51,51,0.08), 0 4px 12px rgba(51,51,51,0.06);
  --radius: 10px;
  --font-display: "Zain", "Segoe UI", system-ui, sans-serif;
  --font-body: "Poppins", "Segoe UI", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1C1C1C;
    --surface: #282828;
    --surface-sunken: #333333;
    --border: #3F3F3F;
    --ink: #f1f2f2;
    --ink-muted: #ADADAD;
    --primary: #F2914F;
    --primary-ink: #231304;
    --primary-soft: #3A2616;
    --accent: #F2914F;
    --accent-ink: #231304;
    --accent-soft: #3A2616;
    --good: #6FBC84;
    --good-soft: #1F3324;
    --warn: #D9AE5E;
    --warn-soft: #3A2E14;
    --bad: #D98080;
    --bad-soft: #3A2222;
    --shadow: 0 1px 2px rgba(0,0,0,0.3), 0 4px 16px rgba(0,0,0,0.35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1C1C1C;
  --surface: #282828;
  --surface-sunken: #333333;
  --border: #3F3F3F;
  --ink: #f1f2f2;
  --ink-muted: #ADADAD;
  --primary: #F2914F;
  --primary-ink: #231304;
  --primary-soft: #3A2616;
  --accent: #F2914F;
  --accent-ink: #231304;
  --accent-soft: #3A2616;
  --good: #6FBC84;
  --good-soft: #1F3324;
  --warn: #D9AE5E;
  --warn-soft: #3A2E14;
  --bad: #D98080;
  --bad-soft: #3A2222;
  --shadow: 0 1px 2px rgba(0,0,0,0.3), 0 4px 16px rgba(0,0,0,0.35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
}
h1, h2, h3, h4 { font-family: var(--font-display); text-wrap: balance; margin: 0; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; }
[hidden] { display: none !important; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }


.brand { display: flex; align-items: center; gap: 8px; font-family: var(--font-display); font-weight: 700; font-size: 19px; flex-shrink: 0; }
.brand .mark { width: 20px; height: 30px; flex-shrink: 0; display: block; }

/* ---------- Access gate (prototype only, not product UI) ---------- */
#proto-gate {
  position: fixed; inset: 0; z-index: 10000;
  background: #262626; color: #f1f2f2;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.proto-gate-card {
  width: 100%; max-width: 360px; text-align: center;
  background: #1C1C1C; border: 1px solid #3F3F3F; border-radius: 14px;
  padding: 32px 28px;
}
.proto-gate-flame { width: 34px; height: 51px; margin: 0 auto 14px; }
.proto-gate-flame svg { width: 100%; height: 100%; }
.proto-gate-card h1 { font-family: var(--font-display); font-size: 19px; margin-bottom: 6px; }
.proto-gate-card p { color: #ADADAD; font-size: 13.5px; margin-bottom: 18px; }
.proto-gate-card form { display: flex; gap: 8px; }
.proto-gate-card input {
  flex: 1; padding: 10px 12px; border-radius: 8px; border: 1px solid #3F3F3F;
  background: #262626; color: #f1f2f2; font-size: 14px; font-family: var(--font-body);
}
.proto-gate-card button {
  padding: 10px 16px; border-radius: 8px; border: none; background: #ef762b; color: #fff;
  font-weight: 600; font-size: 14px; cursor: pointer; font-family: var(--font-body);
}
#proto-gate-error { color: #D98080 !important; margin: 10px 0 0; font-size: 13px; }

/* ---------- Top bar (every page — brand, section nav, role switch) ---------- */
.topnav {
  display: flex; align-items: center; gap: 20px;
  padding: 0 24px; height: 56px; border-bottom: 1px solid var(--border); background: var(--surface);
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 50;
}
.topnav .topnav-nav { display: flex; gap: 20px; font-size: 13.5px; color: var(--ink-muted); white-space: nowrap; }
.topnav .topnav-right { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.topnav .map-link { font-size: 12px; color: var(--ink-muted); white-space: nowrap; }
.topnav .map-link:hover { color: var(--primary); }

.role-switch { position: relative; }
.role-switch summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px;
  padding: 6px 10px; border-radius: 8px; border: 1px solid var(--border); font-size: 13px; white-space: nowrap;
}
.role-switch summary::-webkit-details-marker { display: none; }
.role-switch summary:hover { border-color: var(--primary); }
.role-switch .role-tag { color: var(--ink-muted); font-size: 12px; }
.role-switch .caret { margin-left: 2px; color: var(--ink-muted); font-size: 11px; }
.role-switch[open] summary { border-color: var(--primary); }
.role-menu {
  position: absolute; top: calc(100% + 6px); right: 0; min-width: 220px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: var(--shadow); padding: 6px; z-index: 60;
}
.role-menu .role-menu-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-muted); padding: 7px 9px 4px; }
.role-menu a { display: block; padding: 8px 9px; border-radius: 7px; font-size: 13.5px; color: var(--ink); }
.role-menu a:hover { background: var(--surface-sunken); }
.role-menu a.current-role { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.topnav .avatar-sm { width: 22px; height: 22px; border-radius: 999px; background: var(--primary-soft); color: var(--primary); display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; flex-shrink: 0; }

/* ---------- Content hub / block editor (Tiptap-style) ---------- */
.editor-toolbar {
  display: flex; align-items: center; gap: 2px; padding: 6px; border: 1px solid var(--border);
  border-radius: 10px 10px 0 0; background: var(--surface-sunken); flex-wrap: wrap;
}
.editor-toolbar button {
  width: 30px; height: 30px; border-radius: 6px; border: none; background: transparent;
  color: var(--ink); font-family: var(--font-body); font-size: 13px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.editor-toolbar button:hover { background: var(--surface); }
.editor-toolbar button.is-active { background: var(--primary-soft); color: var(--primary); }
.editor-toolbar .editor-sep { width: 1px; height: 20px; background: var(--border); margin: 0 4px; }
.editor-surface {
  border: 1px solid var(--border); border-top: none; border-radius: 0 0 10px 10px;
  padding: 16px 18px; min-height: 160px; background: var(--surface); font-size: 14.5px; line-height: 1.6;
}
.editor-surface[contenteditable]:focus { outline: 2px solid var(--primary-soft); outline-offset: -2px; }
.editor-surface h2 { font-size: 18px; margin: 0 0 8px; }
.editor-surface p { margin: 0 0 10px; }
.editor-surface ul { margin: 0 0 10px; padding-left: 20px; }

.block-card { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); margin-bottom: 14px; overflow: hidden; }
.block-card-head {
  display: flex; align-items: center; justify-content: space-between; padding: 9px 14px;
  background: var(--surface-sunken); font-size: 12.5px; color: var(--ink-muted); font-weight: 600;
}
.block-card-head .drag-handle { cursor: grab; color: var(--ink-muted); font-size: 14px; }
.block-card-body { padding: 16px; }
.video-embed {
  aspect-ratio: 16/9; background: #000; border-radius: 8px; display: flex; align-items: center;
  justify-content: center; color: #fff; position: relative; overflow: hidden;
}
.video-embed img { width: 100%; height: 100%; object-fit: cover; opacity: 0.75; }
.video-embed .play-badge {
  position: absolute; width: 52px; height: 52px; border-radius: 999px; background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center; font-size: 18px;
}
.qcm-choice-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.qcm-choice-row input[type="text"] { flex: 1; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border-radius: 8px; border: 1px solid transparent;
  font-size: 14px; font-weight: 600; cursor: pointer; font-family: var(--font-body);
}
.btn-primary { background: var(--primary); color: var(--primary-ink); }
.btn-accent { background: var(--accent); color: var(--accent-ink); }
.btn-outline { background: transparent; border-color: var(--border); color: var(--ink); }
.btn-ghost { background: transparent; color: var(--ink-muted); }
.btn-sm { padding: 6px 11px; font-size: 13px; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }

/* ---------- Layout shells ---------- */
.page { max-width: 1120px; margin: 0 auto; padding: 32px; }
.app-shell { display: flex; min-height: calc(100vh - 56px); }
.sidebar {
  width: 240px; flex-shrink: 0; background: var(--surface); border-right: 1px solid var(--border);
  padding: 20px 14px; display: flex; flex-direction: column; gap: 4px;
}
.sidebar .brand { padding: 0 8px 18px; }
.sidebar a.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px;
  font-size: 14px; color: var(--ink-muted); font-weight: 500;
}
.sidebar a.nav-item.active { background: var(--primary-soft); color: var(--primary); font-weight: 700; }
.sidebar .section-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-muted); padding: 14px 10px 4px; }
.sidebar .who { margin-top: auto; padding: 10px; border-top: 1px solid var(--border); font-size: 12.5px; color: var(--ink-muted); }
.content { flex: 1; min-width: 0; padding: 28px 36px; }
.content-header { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.eyebrow { font-size: 12px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--ink-muted); font-weight: 600; }

/* ---------- Cards / surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 20px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
@media (max-width: 860px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } .app-shell { flex-direction: column; } .sidebar { width: auto; flex-direction: row; overflow-x: auto; } .sidebar .who, .sidebar .section-label { display: none; } }

.stat { display: flex; flex-direction: column; gap: 6px; }
.stat .num { font-family: var(--font-display); font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .lbl { font-size: 12.5px; color: var(--ink-muted); }

/* ---------- Badges / pills ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge-primary { background: var(--primary-soft); color: var(--primary); }
.badge-accent { background: var(--accent-soft); color: var(--accent); }
.badge-good { background: var(--good-soft); color: var(--good); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-bad { background: var(--bad-soft); color: var(--bad); }
.badge-neutral { background: var(--surface-sunken); color: var(--ink-muted); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-muted); padding: 9px 12px; border-bottom: 1px solid var(--border); }
td { padding: 11px 12px; border-bottom: 1px solid var(--border); }
tr:last-child td { border-bottom: none; }

/* ---------- Forms ---------- */
label { font-size: 13px; font-weight: 600; display: block; margin-bottom: 5px; }
input, select, textarea {
  width: 100%; padding: 9px 11px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--ink); font-size: 14px; font-family: var(--font-body);
}
.field { margin-bottom: 14px; }
.field-row { display: flex; gap: 12px; }
.field-row > .field { flex: 1; }
.help { font-size: 12.5px; color: var(--ink-muted); margin-top: 4px; }

/* ---------- Progress / timers ---------- */
.bar-track { height: 8px; border-radius: 999px; background: var(--surface-sunken); overflow: hidden; }
.bar-fill { height: 100%; background: var(--primary); border-radius: 999px; }
.timer { display: inline-flex; align-items: center; gap: 6px; font-family: var(--font-mono); font-size: 14px; padding: 5px 10px; border-radius: 7px; background: var(--surface-sunken); }

/* ---------- Quiz ---------- */
.quiz-option {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 9px;
  border: 1px solid var(--border); margin-bottom: 8px; cursor: pointer; background: var(--surface);
}
.quiz-option:hover { border-color: var(--primary); }
.quiz-option.selected { border-color: var(--primary); background: var(--primary-soft); }
.quiz-option.correct { border-color: var(--good); background: var(--good-soft); }
.quiz-option.incorrect { border-color: var(--bad); background: var(--bad-soft); }
.quiz-option input { width: auto; }

/* ---------- Misc ---------- */
.divider { height: 1px; background: var(--border); border: none; margin: 20px 0; }
.muted { color: var(--ink-muted); }
.small { font-size: 12.5px; }
.flex { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8 { gap: 8px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; }
.hero {
  background: linear-gradient(180deg, var(--primary-soft), transparent);
  border-bottom: 1px solid var(--border);
}
.avatar {
  width: 32px; height: 32px; border-radius: 999px; background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; flex-shrink: 0;
}
