/* Nền tảng chung cho không gian học trên web (/thuc-hanh/…): bảng màu sáng/tối, chữ, thanh trên, nút.
   Màu theo thương hiệu Solia (night, ivory, champagne). Mọi cặp chữ/nền đều đạt WCAG AA ở cả hai nền. */

/* Đăng ký các token màu là <color> để khi đổi nền, mọi màu trên trang chuyển dần cùng một nhịp
   (kể cả nền gradient), thay vì nhảy tức thì. */
@property --bg { syntax: '<color>'; inherits: true; initial-value: transparent; }
@property --bg-glow { syntax: '<color>'; inherits: true; initial-value: transparent; }
@property --surface { syntax: '<color>'; inherits: true; initial-value: transparent; }
@property --surface-2 { syntax: '<color>'; inherits: true; initial-value: transparent; }
@property --line { syntax: '<color>'; inherits: true; initial-value: transparent; }
@property --line-soft { syntax: '<color>'; inherits: true; initial-value: transparent; }
@property --text { syntax: '<color>'; inherits: true; initial-value: transparent; }
@property --text-2 { syntax: '<color>'; inherits: true; initial-value: transparent; }
@property --text-3 { syntax: '<color>'; inherits: true; initial-value: transparent; }
@property --accent { syntax: '<color>'; inherits: true; initial-value: transparent; }
@property --btn-bg { syntax: '<color>'; inherits: true; initial-value: transparent; }
@property --btn-bg-hover { syntax: '<color>'; inherits: true; initial-value: transparent; }
@property --btn-text { syntax: '<color>'; inherits: true; initial-value: transparent; }
@property --tag-bg { syntax: '<color>'; inherits: true; initial-value: transparent; }
@property --tag-text { syntax: '<color>'; inherits: true; initial-value: transparent; }
@property --best { syntax: '<color>'; inherits: true; initial-value: transparent; }
@property --best-bg { syntax: '<color>'; inherits: true; initial-value: transparent; }
@property --ok { syntax: '<color>'; inherits: true; initial-value: transparent; }
@property --ok-bg { syntax: '<color>'; inherits: true; initial-value: transparent; }
@property --notyet { syntax: '<color>'; inherits: true; initial-value: transparent; }
@property --notyet-bg { syntax: '<color>'; inherits: true; initial-value: transparent; }
@property --focus { syntax: '<color>'; inherits: true; initial-value: transparent; }

:root, :root[data-theme='dark'] {
  color-scheme: dark;
  --bg: #07111e;
  --bg-glow: #10203a;
  --surface: #0d1a2b;
  --surface-2: #13233a;
  --line: #ddc79e2e;
  --line-soft: #d0dce41f;
  --text: #f3f1e9;
  --text-2: #c2ced5;
  --text-3: #a3b2bd;
  --accent: #ddc79e;
  --btn-bg: #ddc79e;
  --btn-bg-hover: #e8d6b2;
  --btn-text: #0b1522;
  --tag-bg: #f1e2bd;
  --tag-text: #4f3b10;
  --best: #8fd3b2;  --best-bg: #12302b;
  --ok: #e3c27c;    --ok-bg: #2a2615;
  --notyet: #f0a594; --notyet-bg: #2e1c1d;
  --focus: #ddc79e;
}
:root[data-theme='light'] {
  color-scheme: light;
  --bg: #f5f1e8;
  --bg-glow: #fffdf8;
  --surface: #fffdf9;
  --surface-2: #f1ebdf;
  --line: #8a6d3338;
  --line-soft: #15202c1a;
  --text: #15202c;
  --text-2: #3f4b57;
  --text-3: #55616c;
  --accent: #7a5a1c;
  --btn-bg: #15202c;
  --btn-bg-hover: #26364a;
  --btn-text: #f5f1e8;
  --tag-bg: #efe0bb;
  --tag-text: #4f3b10;
  --best: #1d6146;  --best-bg: #e5f1e9;
  --ok: #6a4e10;    --ok-bg: #f6edd5;
  --notyet: #8a3a2c; --notyet-bg: #f8e8e4;
  --focus: #7a5a1c;
}
:root {
  --serif: 'Noto Serif Display', Georgia, serif;
  --sans: 'Be Vietnam Pro', system-ui, sans-serif;
  --ja: 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', 'Noto Sans JP', 'Noto Sans CJK JP', 'Yu Gothic', 'Meiryo', sans-serif;
  --ease: cubic-bezier(.19, 1, .22, 1);
  --theme-ease: cubic-bezier(.65, 0, .35, 1);
  --theme-speed: .6s;
  transition: --bg var(--theme-speed) var(--theme-ease), --bg-glow var(--theme-speed) var(--theme-ease), --surface var(--theme-speed) var(--theme-ease), --surface-2 var(--theme-speed) var(--theme-ease), --line var(--theme-speed) var(--theme-ease), --line-soft var(--theme-speed) var(--theme-ease), --text var(--theme-speed) var(--theme-ease), --text-2 var(--theme-speed) var(--theme-ease), --text-3 var(--theme-speed) var(--theme-ease), --accent var(--theme-speed) var(--theme-ease), --btn-bg var(--theme-speed) var(--theme-ease), --btn-bg-hover var(--theme-speed) var(--theme-ease), --btn-text var(--theme-speed) var(--theme-ease), --tag-bg var(--theme-speed) var(--theme-ease), --tag-text var(--theme-speed) var(--theme-ease), --best var(--theme-speed) var(--theme-ease), --best-bg var(--theme-speed) var(--theme-ease), --ok var(--theme-speed) var(--theme-ease), --ok-bg var(--theme-speed) var(--theme-ease), --notyet var(--theme-speed) var(--theme-ease), --notyet-bg var(--theme-speed) var(--theme-ease), --focus var(--theme-speed) var(--theme-ease);
}
@media (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }
}

* { box-sizing: border-box; }
html { background: var(--bg); -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; min-height: 100svh; display: flex; flex-direction: column;
  color: var(--text); font-family: var(--sans); font-size: 1rem; line-height: 1.65;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  background: radial-gradient(ellipse 90% 40% at 50% 0%, var(--bg-glow) 0%, transparent 70%) var(--bg);
}
a { color: inherit; }
button { font: inherit; color: inherit; }
h1, h2, h3, h4, p, ul, ol { margin: 0; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; border-radius: 8px; }
[hidden] { display: none !important; }
.skip { position: absolute; z-index: 60; top: 8px; left: 8px; padding: 12px 16px; border-radius: 6px; background: var(--text); color: var(--bg); transform: translateY(-200%); }
.skip:focus { transform: none; }

/* Thanh trên: logo · (liên kết quay lại) · nút đổi nền */
.bar {
  display: flex; align-items: center; gap: 8px;
  width: min(100%, 880px); margin: 0 auto; padding: max(14px, env(safe-area-inset-top)) 16px 0;
}
.bar-brand { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; margin-right: auto; text-decoration: none; font-weight: 500; letter-spacing: -.02em; white-space: nowrap; }
.bar-brand img { width: 34px; height: 34px; border-radius: 10px; box-shadow: 0 0 0 1px var(--line); }
.bar-brand b { font-weight: 300; }
.bar-link { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 10px; border-radius: 999px; color: var(--text-2); font-size: .875rem; text-decoration: none; white-space: nowrap; }
.bar-link:hover { color: var(--text); }
/* Nút gạt sáng/tối. Núm trượt + biểu tượng xoay đổi, cùng nhịp với màu trang (--theme-speed). */
.theme-switch {
  flex: none; display: grid; place-items: center; width: 72px; height: 44px; padding: 0;
  border: 0; background: none; cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.theme-switch:focus-visible { outline: none; }
.theme-switch:focus-visible .switch-track { outline: 2px solid var(--focus); outline-offset: 3px; }
.switch-track {
  position: relative; display: block; width: 64px; height: 34px; border-radius: 999px; overflow: hidden;
  background: #13233a; box-shadow: inset 0 0 0 1px #ddc79e40, inset 0 2px 6px #0006;
  transition: background-color var(--theme-speed) var(--theme-ease), box-shadow var(--theme-speed) var(--theme-ease);
}
/* Vài vì sao trên rãnh tối; trôi nhẹ đi khi chuyển sang sáng. */
.switch-stars {
  position: absolute; inset: 0;
  background-image:
    radial-gradient(1.2px 1.2px at 14px 10px, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 24px 22px, #fffc 50%, transparent 51%),
    radial-gradient(1.4px 1.4px at 9px 24px, #f3e6c7 50%, transparent 51%),
    radial-gradient(1px 1px at 30px 8px, #fffa 50%, transparent 51%);
  transition: opacity var(--theme-speed) var(--theme-ease), transform var(--theme-speed) var(--theme-ease);
}
/* Vầng sáng ấm trên rãnh sáng. */
.switch-glow {
  position: absolute; inset: 0; opacity: 0;
  background: radial-gradient(circle at 18px 50%, #fff7e0 0%, #f6e7c4 45%, #ecd9ad 100%);
  transition: opacity var(--theme-speed) var(--theme-ease);
}
.switch-knob {
  position: absolute; top: 4px; left: 4px; width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center;
  background: #ddc79e; color: #13233a; box-shadow: 0 2px 6px #0007, inset 0 -2px 3px #0002;
  transform: translateX(30px);
  transition: transform var(--theme-speed) cubic-bezier(.6, -0.15, .3, 1.15), background-color var(--theme-speed) var(--theme-ease), box-shadow var(--theme-speed) var(--theme-ease);
}
.switch-knob svg {
  position: absolute; width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
  transition: opacity calc(var(--theme-speed) * .7) var(--theme-ease), transform var(--theme-speed) var(--theme-ease);
}
.switch-knob .i-moon { fill: currentColor; stroke: none; }
.switch-knob .i-sun { opacity: 0; transform: rotate(-90deg) scale(.4); }
:root[data-theme='light'] .switch-track { background: #ecd9ad; box-shadow: inset 0 0 0 1px #8a6d3340, inset 0 2px 6px #8a6d3326; }
:root[data-theme='light'] .switch-stars { opacity: 0; transform: translateX(14px); }
:root[data-theme='light'] .switch-glow { opacity: 1; }
:root[data-theme='light'] .switch-knob { transform: translateX(0); background: #fffdf8; color: #9a6b12; box-shadow: 0 2px 6px #8a6d3359, inset 0 -2px 3px #8a6d331f; }
:root[data-theme='light'] .switch-knob .i-sun { opacity: 1; transform: none; }
:root[data-theme='light'] .switch-knob .i-moon { opacity: 0; transform: rotate(90deg) scale(.4); }
.theme-switch:hover .switch-knob { box-shadow: 0 2px 10px #000a, 0 0 0 3px #ddc79e33; }
:root[data-theme='light'] .theme-switch:hover .switch-knob { box-shadow: 0 2px 8px #8a6d3366, 0 0 0 3px #8a6d3326; }
@media (max-width: 379px) { .bar-brand span { display: none; } }

/* Chữ & nút dùng chung */
.eyebrow { color: var(--accent); font-size: .8125rem; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; }
.title-serif { font-family: var(--serif); font-weight: 500; letter-spacing: -.025em; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 48px; padding: 0 24px; border: 1px solid transparent; border-radius: 999px;
  font-size: .9375rem; font-weight: 500; line-height: 1.3; text-align: center; text-decoration: none; cursor: pointer;
  transition: background-color .25s, border-color .25s, color .25s;
}
.btn-primary { background: var(--btn-bg); color: var(--btn-text); }
.btn-primary:hover { background: var(--btn-bg-hover); }
.btn-ghost { border-color: var(--line); color: var(--text); background: transparent; }
.btn-ghost:hover { border-color: var(--accent); }
.btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.link { display: inline-flex; align-items: center; min-height: 44px; padding: 0 2px; border: 0; background: none; color: var(--accent); font-size: .9375rem; text-decoration: underline; text-underline-offset: 4px; cursor: pointer; }
.tag { display: inline-flex; align-items: center; padding: 2px 10px; border-radius: 999px; background: var(--tag-bg); color: var(--tag-text); font-size: .75rem; font-weight: 500; line-height: 1.6; white-space: nowrap; vertical-align: middle; }

/* Chân trang */
.foot {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 0 20px;
  margin-top: auto; padding: 12px 16px max(20px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line-soft);
}
.foot a { display: inline-flex; align-items: center; min-height: 44px; color: var(--text-3); font-size: .8125rem; text-underline-offset: 3px; overflow-wrap: anywhere; }
.foot a:hover { color: var(--text); }

@media (prefers-reduced-motion: reduce) {
  :root { --theme-speed: 0s; }
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: .01ms !important; animation: none !important; }
}
.bar-brand { min-width: 44px; }
