/* =========================================================================
   PENTEST ATLAS — DESIGN TOKENS & PRIMITIVES (assets/css/tokens.css)
   Hỗ trợ Light / Dark × Terminal Việt / Á Đông Cổ Điển × Learn (Jade) / Audit (Cinnabar)
   ========================================================================= */

:root,
:root[data-theme="light"],
body[data-theme="light"] {
  --paper: #ece2cb;
  --raised: #f6efdf;
  --sunk: #e0d3b4;
  --line: #c6b48c;
  --btn-border: #a5926b;
  --ink: #1c1712;
  --ink-2: #625444;
  --cinnabar: #b5301c;
  --cin-text: #9e2714;
  --on-cin: #fff7ea;
  --gold: #78560a;
  --gold-deco: #c79f24;
  --jade: #1e6b54;
  --jade-text: #185845;
  --azure: #275375;
  --chrome: #faf5e9;
  --plate: #faf5e9;
  --plate-ink: #1c1712;
  --plate-flag: #b5301c;
  --accent: var(--cinnabar);
  --accent-text: var(--cin-text);
  --on-accent: var(--on-cin);
  --tint-danger: rgba(181, 48, 28, 0.11);
  --tint-ok: rgba(30, 107, 84, 0.11);
  --tint-azure: rgba(39, 83, 117, 0.09);
  --tint-gold: rgba(199, 159, 36, 0.14);
  --dot-grid: radial-gradient(rgba(140, 122, 86, 0.28) 1px, transparent 1px) 12px 12px / 24px 24px;
  --shadow: none;
  --shadow-lg: 0 10px 26px rgba(28, 23, 18, 0.14);
  color-scheme: light;
}

:root[data-theme="dark"],
body[data-theme="dark"] {
  --paper: #111318;
  --raised: #191c23;
  --sunk: #0b0c10;
  --line: #33353d;
  --btn-border: #4b556b;
  --ink: #eee5cf;
  --ink-2: #a89e86;
  --cinnabar: #de543d;
  --cin-text: #f3836d;
  --on-cin: #160c09;
  --gold: #e3ba5c;
  --gold-deco: #e3ba5c;
  --jade: #55b28f;
  --jade-text: #74cba9;
  --azure: #8ab4dc;
  --chrome: #13161d;
  --plate: #ece2cb;
  --plate-ink: #1c1712;
  --plate-flag: #b5301c;
  --accent: var(--cinnabar);
  --accent-text: var(--cin-text);
  --on-accent: var(--on-cin);
  --tint-danger: rgba(222, 84, 61, 0.22);
  --tint-ok: rgba(85, 178, 143, 0.20);
  --tint-azure: rgba(138, 180, 220, 0.16);
  --tint-gold: rgba(227, 186, 92, 0.18);
  --dot-grid: radial-gradient(rgba(169, 159, 137, 0.12) 1px, transparent 1px) 12px 12px / 24px 24px;
  --shadow: none;
  --shadow-lg: 0 14px 34px rgba(0, 0, 0, 0.48);
  color-scheme: dark;
}

:root {
  --f-mono: ui-monospace, "Cascadia Mono", Consolas, Menlo, "JetBrains Mono", monospace;
  --f-head: Cambria, "Times New Roman", "Source Serif 4", Georgia, serif;
  --f-serif: var(--f-head);
  --f-body: "Segoe UI", system-ui, -apple-system, Roboto, "Be Vietnam Pro", Arial, sans-serif;
  --radius-sm: 3px;
  --radius-md: 6px;
  --radius: var(--radius-md);
}

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

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

html {
  overflow-x: clip;
  max-width: 100vw;
  scrollbar-color: var(--line) transparent;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: clip;
  background: var(--dot-grid), var(--paper);
  color: var(--ink);
  font-family: var(--f-body);
  font-size: 14.5px;
  line-height: 1.6;
  caret-color: var(--accent);
}

::selection { background: var(--accent); color: var(--on-accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }

button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
select option { background: var(--raised); color: var(--ink); }
a { color: var(--azure); text-underline-offset: 3px; }
a:hover { color: var(--ink); }
h1, h2, h3, h4 { margin: 0; font-weight: 700; color: var(--ink); }
p { margin: 0; }

/* Utilities */
.hidden { display: none !important; }
.mono { font-family: var(--f-mono); }
.sans { font-family: var(--f-body); }
.serif { font-family: var(--f-head); }
.tabular { font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-2); }
.ink { color: var(--ink); }
.ok { color: var(--jade-text); }
.red { color: var(--cin-text); }
.blue { color: var(--azure); }
.blood { color: var(--gold); }

/* Button Primitives */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 14px;
  min-height: 36px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--btn-border);
  background: var(--raised);
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.25;
  text-decoration: none;
  white-space: nowrap;
  max-width: 100%;
  transition: border-color 0.14s ease, background-color 0.14s ease, color 0.14s ease;
}
.btn:hover:not(:disabled) { border-color: var(--ink); background: var(--sunk); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary {
  background: var(--cinnabar);
  border-color: var(--cinnabar);
  color: var(--on-cin);
  font-weight: 600;
}
.btn-primary:hover:not(:disabled) { filter: brightness(1.06); background: var(--cinnabar); border-color: var(--cinnabar); color: var(--on-cin); }
.btn-outline { background: var(--paper); border: 1.5px solid var(--btn-border); color: var(--ink); }
.btn-outline:hover:not(:disabled) { border-color: var(--ink); color: var(--ink); background: var(--sunk); }
.btn-ghost { background: var(--paper); border: 1px solid var(--line); color: var(--ink-2); }
.btn-ghost:hover:not(:disabled) { background: var(--sunk); color: var(--ink); border-color: var(--btn-border); }
.btn-sm { padding: 6px 11px; min-height: 32px; font-size: 12.5px; }
.btn-grow { flex: 1 1 auto; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 16px; align-items: center; }

/* LakeCTF × Aged Paper Seals & Window Chrome Primitives */
.seal {
  display: inline-grid;
  place-items: center;
  border: 2px solid var(--cinnabar);
  border-radius: 3px;
  color: var(--cin-text);
  font-family: var(--f-head);
  font-weight: 700;
  font-size: 10.5px;
  line-height: 1.05;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 3px 6px;
  transform: rotate(-3.5deg);
  user-select: none;
  background: transparent;
}
.seal-top { font-size: 9.5px; line-height: 1.12; padding: 2px 6px; transform: rotate(-2.5deg); }
.seal-bar { font-size: 10px; padding: 2px 6px; transform: rotate(-2deg); }
.seal-large {
  font-size: 16px;
  letter-spacing: 0.14em;
  padding: 6px 12px;
  border-width: 2.5px;
  transform: rotate(-5deg);
}

.win {
  background: var(--raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.win-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 14px;
  border-bottom: 1px dashed var(--line);
  background: var(--sunk);
  font-family: var(--f-mono);
  font-size: 12px;
  color: var(--ink-2);
  flex-wrap: wrap;
}
.win-bar .win-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.win-bar strong { color: var(--ink); font-weight: 600; }
.win-body { padding: 18px 20px; }

.pill {
  padding: 6px 12px;
  border: 1.5px solid var(--btn-border);
  border-radius: 99px;
  background: var(--raised);
  color: var(--ink-2);
  font-size: 12.5px;
  font-weight: 500;
  white-space: nowrap;
  transition: border-color 0.14s, color 0.14s, background 0.14s;
}
.pill:hover { color: var(--ink); border-color: var(--ink); }
.pill.active,
.pill.on {
  background: var(--cinnabar);
  border-color: var(--cinnabar);
  color: var(--on-cin);
  font-weight: 600;
}
.pill-small { padding: 3px 9px; font-size: 11.5px; }

.term {
  margin-top: 10px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-family: var(--f-mono);
  font-size: 12.5px;
  line-height: 1.65;
  overflow-x: auto;
  word-break: break-word;
}
.term .p { color: var(--jade-text); font-weight: 700; }
.term .k { color: var(--azure); }

.flag-form {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.flag-form input {
  flex: 1 1 200px;
  font-family: var(--f-mono);
  font-size: 13px;
  padding: 8px 11px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--ink);
  min-width: 0;
}
.flag-form input:focus { outline: none; border-color: var(--cinnabar); }

.passed {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px;
  border: 1px solid var(--jade);
  background: var(--tint-ok);
  border-radius: var(--radius-sm);
}
.passed h4 {
  font-family: var(--f-head);
  color: var(--jade-text);
  font-size: 16px;
}

.search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--paper);
}
.search-bar span { color: var(--jade-text); font-family: var(--f-mono); font-weight: 700; font-size: 12.5px; }
.search-bar input {
  flex: 1 1 auto;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-family: var(--f-mono);
  font-size: 12.5px;
  outline: none;
}

.select-lake {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--ink);
  padding: 6px 10px;
  font-size: 12.5px;
}
.select-lake:focus { outline: none; border-color: var(--cinnabar); }

.chall-name {
  font-family: var(--f-head);
  font-size: clamp(21px, 2.5vw, 27px);
  line-height: 1.24;
  color: var(--ink);
}

.copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--raised);
  color: var(--ink-2);
  font-family: var(--f-mono);
  font-size: 11.5px;
  font-weight: 600;
}
.copy-btn:hover { border-color: var(--accent); color: var(--ink); }

/* Inputs & Selects */
.input-clean,
.select-clean {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--raised);
  color: var(--ink);
  padding: 6px 10px;
  font-size: 13px;
}
.input-clean:focus,
.select-clean:focus {
  outline: none;
  border-color: var(--accent);
}

/* Badges & Chips */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 99px;
  border: 1px solid var(--line);
  background: var(--sunk);
  color: var(--ink-2);
  font-family: var(--f-mono);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  max-width: 100%;
}

.sev-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--f-mono);
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}
.sev-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}

.tier-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 3px;
  border: 1px solid var(--gold-deco);
  color: var(--gold);
  font-family: var(--f-mono);
  font-size: 10.5px;
  font-weight: 700;
  vertical-align: middle;
}

.lang-pill {
  padding: 1px 6px;
  border-radius: 3px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink-2);
  font-family: var(--f-mono);
  font-size: 11px;
  font-weight: 600;
}

.code-chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 9px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--raised);
  color: var(--azure);
  font-family: var(--f-mono);
  font-size: 12px;
  font-weight: 600;
}
.code-chip:hover { border-color: var(--accent); color: var(--ink); }

/* Safe Inline Markdown Code Pill */
.inline-code {
  display: inline;
  padding: 1px 5px;
  border-radius: 3px;
  border: 1px solid var(--line);
  background: var(--sunk);
  color: var(--azure);
  font-family: var(--f-mono);
  font-size: 0.88em;
  word-break: break-word;
}

/* Surface Cards & Shared Layout Primitives */
.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
.section-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.section-title {
  font-family: var(--f-head);
  font-size: 19px;
  color: var(--ink);
}
.prose-title {
  font-family: var(--f-mono);
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.filter-pill {
  padding: 4px 9px;
  border: 1px solid var(--line);
  border-radius: 99px;
  background: var(--paper);
  color: var(--ink-2);
  font-family: var(--f-mono);
  font-size: 11.5px;
  white-space: nowrap;
}
.filter-pill:hover { color: var(--ink); border-color: var(--ink-2); }
.filter-pill.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
  font-weight: 700;
}
.empty-banner {
  border: 1px dashed var(--cinnabar);
  border-radius: var(--radius-sm);
  background: var(--paper);
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 13px;
}
.note-area {
  width: 100%;
  min-height: 92px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--paper);
  padding: 9px 11px;
  font-family: var(--f-mono);
  font-size: 12.5px;
  resize: vertical;
}
.note-area:focus { outline: none; border-color: var(--accent); }
.table-scroll {
  width: 100%;
  max-width: 100%;
  max-height: 590px;
  overflow: auto;
}

.card {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--raised);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card-head {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--sunk);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-family: var(--f-mono);
  font-size: 12.5px;
  color: var(--ink-2);
}
.card-body { padding: 16px; }

/* Style Split: Terminal (Kỹ thuật sắc nét) vs Á Đông (Giấy cổ, Ấn triện, Nét đứt) */
body[data-style="terminal"] {
  font-family: var(--f-body);
}
body[data-style="terminal"] .card-head,
body[data-style="terminal"] .win-bar,
body[data-style="terminal"] .module-meta,
body[data-style="terminal"] .course-num,
body[data-style="terminal"] .prose-title,
body[data-style="terminal"] .modal-title,
body[data-style="terminal"] .section-title {
  font-family: var(--f-mono);
  letter-spacing: -0.01em;
}
body[data-style="terminal"] .seal,
body[data-style="terminal"] .seal-top,
body[data-style="terminal"] .seal-bar,
body[data-style="terminal"] .seal-large {
  transform: none;
  font-family: var(--f-mono);
  border-width: 1.5px;
  letter-spacing: 0.06em;
}
body[data-style="terminal"] .win-bar,
body[data-style="terminal"] .card-head {
  border-bottom-style: solid;
}
body[data-style="terminal"] .primer-banner,
body[data-style="terminal"] .deepdive-box,
body[data-style="terminal"] .casestudy-box,
body[data-style="terminal"] .module-extra-fold {
  border-style: solid;
}

body[data-style="adong"] .logo-plate,
body[data-style="adong"] .section-title,
body[data-style="adong"] .cluster-title,
body[data-style="adong"] .module-name,
body[data-style="adong"] .chall-name,
body[data-style="adong"] .minilab-title,
body[data-style="adong"] .card-head,
body[data-style="adong"] .win-bar,
body[data-style="adong"] .modal-title,
body[data-style="adong"] .glossary-term {
  font-family: var(--f-head);
}
body[data-style="adong"] .card-head,
body[data-style="adong"] .win-bar {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--ink);
  border-bottom-style: dashed;
}
body[data-style="adong"] .card,
body[data-style="adong"] .win,
body[data-style="adong"] .syllabus-hero,
body[data-style="adong"] .syllabus-arch,
body[data-style="adong"] .module-card,
body[data-style="adong"] .studio-stage,
body[data-style="adong"] .minilab-card,
body[data-style="adong"] .audit-header,
body[data-style="adong"] .audit-list-card,
body[data-style="adong"] .inspector-card {
  box-shadow: none;
}
body[data-style="adong"] .studio-header {
  padding-bottom: 10px;
  border-bottom: 1px dashed var(--line);
}
body[data-style="adong"] .primer-banner,
body[data-style="adong"] .deepdive-box,
body[data-style="adong"] .casestudy-box {
  border-top-style: dashed;
  border-right-style: dashed;
  border-bottom-style: dashed;
}
body[data-style="adong"] .module-extra-fold {
  border-style: dashed;
}
body[data-style="adong"] .step-num,
body[data-style="adong"] .lab-step-num,
body[data-style="adong"] .precept-num {
  font-family: var(--f-head);
  border-radius: 2px;
}
body[data-style="adong"] .step-tab.active .step-num,
body[data-style="adong"] .lab-step-num {
  box-shadow: inset 0 0 0 1px var(--on-accent);
}
body[data-style="adong"] .course-num {
  font-family: var(--f-head);
  letter-spacing: 0.08em;
}

/* Shared Aged-Paper Artwork Frame & Live SVG Containers */
.atlas-art-frame {
  margin: 0;
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--paper);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.atlas-art-img {
  width: 100%;
  height: auto;
  aspect-ratio: 640 / 357;
  display: block;
  object-fit: cover;
  transition: filter 0.2s ease, opacity 0.2s ease;
}
body[data-theme="dark"] .atlas-art-img {
  filter: invert(0.89) hue-rotate(180deg) saturate(1.12) contrast(0.95);
  opacity: 0.92;
}
.atlas-art-tag {
  position: absolute;
  top: 7px;
  right: 7px;
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  background: var(--raised);
  border: 1px solid var(--line);
  color: var(--ink);
  font-family: var(--f-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  white-space: nowrap;
}
.atlas-art-caption {
  padding: 6px 10px;
  border-top: 1px dashed var(--line);
  background: var(--sunk);
  font-family: var(--f-mono);
  font-size: 11px;
  color: var(--ink-2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  flex-wrap: wrap;
}
body[data-style="terminal"] .atlas-art-caption {
  border-top-style: solid;
}
.viz-svg-wrap {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
}
.viz-svg-wrap svg {
  width: 100%;
  max-width: 100%;
  height: auto;
  display: block;
}
.viz-legend {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}
.viz-legend-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-family: var(--f-mono);
  font-size: 11.5px;
  color: var(--ink);
}
.viz-swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  display: inline-block;
  flex: none;
}
.cat-icon {
  width: 13px;
  height: 13px;
  flex: none;
  display: inline-block;
  vertical-align: middle;
}
