/* ==========================================================================
   Wici brand shell — dùng chung cho Coffee / Fuji / Music (layouts/wici-brand.blade.php)
   Token theo theme ở body[data-brand-theme]; CSS riêng từng brand nằm ở wx/coffee|fuji|music.css.
   Thiết kế: docs/design/*.DESIGN.md
   ========================================================================== */

.wx-body {
  --wx-font-body: 'Be Vietnam Pro', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --wx-font-display: var(--wx-font-body);
  --wx-font-mono: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', Consolas, monospace;
  --wx-ease: cubic-bezier(.16, 1, .3, 1);
  --wx-container: 1240px;
  --wx-gutter: 20px;
  --wx-topbar-h: 72px;
  --wx-radius-card: 20px;
  --wx-radius-btn: 999px;

  /* light defaults (Coffee) */
  --wx-bg: #edf0ea;
  --wx-surface: #f8f9f5;
  --wx-surface-2: #e3e8e0;
  --wx-ink: #13201a;
  --wx-ink-2: #4a5850;
  --wx-line: rgba(19, 32, 26, .14);
  --wx-primary: #1e3b2d;
  --wx-primary-hover: #11241a;
  --wx-on-primary: #e9efe8;
  --wx-accent: #e3a33b;
  --wx-on-accent: #13201a;
  --wx-focus: #c27f12;
  --wx-shadow: 0 18px 40px -24px rgba(17, 36, 26, .35);

  margin: 0;
  min-height: 100vh;
  background: var(--wx-bg);
  color: var(--wx-ink);
  font-family: var(--wx-font-body);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

.wx-body[data-brand-theme="coffee"] {
  --wx-font-display: 'Bricolage Grotesque', var(--wx-font-body);
}

.wx-body[data-brand-theme="fujifilm"] {
  --wx-font-display: 'Archivo', var(--wx-font-body);
  --wx-container: 1320px;
  --wx-radius-card: 8px;
  --wx-radius-btn: 8px;
  --wx-bg: #0e0d0c;
  --wx-surface: #171614;
  --wx-surface-2: #211f1c;
  --wx-ink: #f1eee8;
  --wx-ink-2: #a19d95;
  --wx-line: rgba(241, 238, 232, .12);
  --wx-primary: #ff4a3d;
  --wx-primary-hover: #ff6a5f;
  --wx-on-primary: #140a09;
  --wx-accent: #ff4a3d;
  --wx-on-accent: #140a09;
  --wx-focus: #ff4a3d;
  --wx-shadow: 0 30px 60px -30px rgba(0, 0, 0, .8);
  color-scheme: dark;
}

.wx-body[data-brand-theme="music"] {
  --wx-font-display: 'Unbounded', var(--wx-font-body);
  --wx-container: 1280px;
  --wx-radius-card: 18px;
  --wx-bg: #0b0b0e;
  --wx-surface: #15151a;
  --wx-surface-2: #1e1e25;
  --wx-ink: #f5f5f7;
  --wx-ink-2: #a6a6b0;
  --wx-line: rgba(245, 245, 247, .10);
  --wx-primary: #d4f74a;
  --wx-primary-hover: #e2fb7a;
  --wx-on-primary: #11140a;
  --wx-accent: #d4f74a;
  --wx-on-accent: #11140a;
  --wx-focus: #d4f74a;
  --wx-shadow: 0 16px 40px -12px rgba(0, 0, 0, .6);
  color-scheme: dark;
}

/* Cầu nối token cho partial dùng chung (menu tài khoản, toast, chat) vốn đọc --b-* */
.wx-body {
  --b-bg: var(--wx-bg);
  --b-bg-soft: var(--wx-surface-2);
  --b-paper: var(--wx-surface);
  --b-primary: var(--wx-ink);
  --b-primary-soft: var(--wx-ink-2);
  --b-accent: var(--wx-accent);
  --b-line: var(--wx-line);
  --b-ink: var(--wx-ink);
  --b-mute: var(--wx-ink-2);
}

.wx-body *, .wx-body *::before, .wx-body *::after { box-sizing: border-box; }
.wx-body img, .wx-body video, .wx-body canvas, .wx-body svg { max-width: 100%; }
.wx-body img { image-orientation: from-image; height: auto; }
:where(.wx-body) a { color: inherit; }
.wx-body :focus-visible { outline: 2px solid var(--wx-focus); outline-offset: 3px; border-radius: 4px; }
.wx-body ::selection { background: var(--wx-accent); color: var(--wx-on-accent); }

/* layouts.brand cũ có thể để lại brand.css sau soft-nav — vô hiệu khung cũ trên shell mới */
.brand-shell.wx-shell { max-width: none; margin: 0; padding: 0; position: relative; z-index: 1; }

.wx-container {
  width: min(var(--wx-container), 100% - var(--wx-gutter) * 2);
  margin-inline: auto;
}

.wx-skip {
  position: fixed; left: 16px; top: 12px; z-index: 10002; transform: translateY(-200%);
  padding: 10px 16px; border-radius: 8px;
  background: var(--wx-ink); color: var(--wx-bg); text-decoration: none; font-weight: 600;
  transition: transform .2s;
}
.wx-skip:focus { transform: none; }

.wx-sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* --------------------------------------------------------------------------
   Brand switcher (pill cố định góc trái) — biến thể tối cho Fuji/Music
   -------------------------------------------------------------------------- */
.brand-switcher--dark {
  background: rgba(24, 24, 26, .72);
  border-color: rgba(255, 255, 255, .08);
  box-shadow: 0 8px 24px -12px rgba(0, 0, 0, .7);
}
.brand-switcher--dark .brand-switcher-btn { color: rgba(245, 245, 247, .6); }
.brand-switcher--dark .brand-switcher-btn:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.brand-switcher--dark .brand-switcher-btn.is-active {
  background: var(--wx-primary, #f5f5f7); color: var(--wx-on-primary, #111);
  box-shadow: none;
}
.wx-body .brand-switcher--coffee .brand-switcher-btn.is-active { background: var(--wx-primary); color: var(--wx-on-primary); }

/* --------------------------------------------------------------------------
   Topbar
   -------------------------------------------------------------------------- */
.wx-topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 24px;
  height: var(--wx-topbar-h);
  padding: 0 max(var(--wx-gutter), calc((100% - var(--wx-container)) / 2));
  padding-left: max(196px, calc((100% - var(--wx-container)) / 2));
  background: color-mix(in srgb, var(--wx-bg) 82%, transparent);
  -webkit-backdrop-filter: saturate(150%) blur(16px);
  backdrop-filter: saturate(150%) blur(16px);
  border-bottom: 1px solid transparent;
  transition: border-color .3s, background .3s;
}
.wx-topbar.is-scrolled { border-bottom-color: var(--wx-line); }

.wx-logo {
  display: inline-flex; align-items: baseline; gap: 6px;
  text-decoration: none; color: var(--wx-ink); white-space: nowrap;
  font-family: var(--wx-font-display);
}
.wx-logo-mark { font-size: 22px; font-weight: 800; letter-spacing: -0.04em; line-height: 1; }
.wx-logo-sub {
  font-size: 13px; font-weight: 600; letter-spacing: 0.02em; color: var(--wx-ink-2);
}
.wx-body[data-brand-theme="coffee"] .wx-logo-mark { color: var(--wx-primary); }
.wx-logo-mark::after {
  content: ''; display: inline-block; width: 7px; height: 7px; margin-left: 3px;
  border-radius: 50%; background: var(--wx-accent); vertical-align: baseline;
}

.wx-nav { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.wx-nav a {
  position: relative; padding: 8px 14px; border-radius: 999px;
  font-size: 14.5px; font-weight: 500; color: var(--wx-ink-2); text-decoration: none; white-space: nowrap;
  transition: color .2s, background .2s;
}
.wx-nav a:hover { color: var(--wx-ink); background: color-mix(in srgb, var(--wx-ink) 6%, transparent); }
.wx-nav a.is-active { color: var(--wx-ink); }
.wx-nav a.is-active::after {
  content: ''; position: absolute; left: 50%; bottom: 2px; width: 4px; height: 4px; margin-left: -2px;
  border-radius: 50%; background: var(--wx-accent);
}

.wx-topbar-end { display: flex; align-items: center; gap: 8px; }
.wx-topbar .wici-account { margin-left: 0; }
.wx-body .wici-account-login {
  display: inline-flex; align-items: center; height: 40px; padding: 0 18px;
  border-radius: var(--wx-radius-btn); border: 1px solid var(--wx-line);
  color: var(--wx-ink); font-size: 14px; font-weight: 600; text-decoration: none;
  transition: background .2s, border-color .2s;
}
.wx-body .wici-account-login:hover { background: color-mix(in srgb, var(--wx-ink) 6%, transparent); border-color: color-mix(in srgb, var(--wx-ink) 30%, transparent); }

.wx-nav-toggle {
  display: none; position: relative; width: 44px; height: 44px; padding: 0;
  border: 1px solid var(--wx-line); border-radius: 999px; background: transparent; color: var(--wx-ink);
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.wx-nav-toggle span {
  position: absolute; left: 50%; top: 50%; width: 16px; height: 1.5px; margin-left: -8px;
  background: currentColor; border-radius: 2px; transition: transform .35s var(--wx-ease);
}
.wx-nav-toggle span:nth-child(1) { transform: translateY(-3.5px); }
.wx-nav-toggle span:nth-child(2) { transform: translateY(3.5px); }
.wx-nav-toggle[aria-expanded="true"] span:nth-child(1) { transform: rotate(45deg); }
.wx-nav-toggle[aria-expanded="true"] span:nth-child(2) { transform: rotate(-45deg); }

@media (max-width: 900px) {
  .wx-topbar { padding-left: 184px; padding-right: var(--wx-gutter); gap: 12px; --wx-topbar-h: 64px; }
  .wx-topbar-end { margin-left: auto; }
  .wx-nav-toggle { display: inline-block; }
  .wx-nav {
    position: absolute; top: 100%; left: 0; right: 0; margin: 0;
    flex-direction: column; align-items: stretch; gap: 2px;
    padding: 12px var(--wx-gutter) 20px;
    background: var(--wx-bg); border-bottom: 1px solid var(--wx-line);
    box-shadow: var(--wx-shadow);
    opacity: 0; visibility: hidden; transform: translateY(-8px);
    transition: opacity .25s, transform .3s var(--wx-ease), visibility .25s;
  }
  .wx-nav.is-open { opacity: 1; visibility: visible; transform: none; }
  .wx-nav a { padding: 14px 12px; border-radius: 12px; font-size: 16px; }
  .wx-nav a.is-active::after { left: auto; right: 16px; top: 50%; bottom: auto; margin-top: -2px; }
}
/* ≤640: brand-switcher.css biến pill thành dải riêng phía trên (body padding-top 44px) → topbar không cần chừa trái */
@media (max-width: 640px) {
  .wx-topbar { padding-left: var(--wx-gutter); padding-right: 16px; }
  .wx-body .wici-account-login { height: 40px; padding: 0 14px; }
}
@media (max-width: 360px) {
  .wx-logo-sub { display: none; }
}

/* --------------------------------------------------------------------------
   Nút dùng chung
   -------------------------------------------------------------------------- */
.wx-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 48px; padding: 0 24px; border-radius: var(--wx-radius-btn);
  border: 1px solid transparent; font: 600 15px/1 var(--wx-font-body); white-space: nowrap;
  text-decoration: none; cursor: pointer;
  transition: background .2s, color .2s, border-color .2s, transform .15s;
}
.wx-btn:active { transform: scale(.98); }
.wx-btn svg { width: 18px; height: 18px; flex-shrink: 0; transition: transform .25s var(--wx-ease); }
.wx-btn:hover svg.wx-arrow { transform: translateX(3px); }
.wx-btn--primary { background: var(--wx-primary); color: var(--wx-on-primary); }
.wx-btn--primary:hover { background: var(--wx-primary-hover); }
.wx-btn--ghost { background: transparent; color: var(--wx-ink); border-color: var(--wx-line); }
.wx-btn--ghost:hover { border-color: color-mix(in srgb, var(--wx-ink) 40%, transparent); }

/* Link có mũi tên trong nội dung */
.wx-link {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--wx-ink); font-weight: 600; text-decoration: none;
  background: linear-gradient(currentColor, currentColor) 0 100% / 0 1px no-repeat;
  transition: background-size .35s var(--wx-ease);
}
.wx-link:hover { background-size: 100% 1px; }

/* --------------------------------------------------------------------------
   Prose (bài viết / điều khoản) — dùng chung, màu theo token
   -------------------------------------------------------------------------- */
.wx-prose { max-width: 68ch; font-size: 17px; line-height: 1.75; color: var(--wx-ink); }
.wx-prose > * + * { margin-top: 1.1em; }
.wx-prose h2, .wx-prose h3 { font-family: var(--wx-font-display); line-height: 1.2; letter-spacing: -0.02em; margin-top: 2em; }
.wx-prose h2 { font-size: 1.6em; }
.wx-prose h3 { font-size: 1.25em; }
.wx-prose p, .wx-prose li { color: color-mix(in srgb, var(--wx-ink) 88%, var(--wx-bg)); }
.wx-prose a { color: var(--wx-ink); text-decoration-color: var(--wx-accent); text-underline-offset: 3px; text-decoration-thickness: 2px; }
.wx-prose img { border-radius: calc(var(--wx-radius-card) * .6); }
.wx-prose blockquote { margin-left: 0; padding-left: 20px; border-left: 3px solid var(--wx-accent); }
.wx-prose ul, .wx-prose ol { padding-left: 1.3em; }

/* Phân trang (partials.wx-pagination) */
.wx-pager { display: flex; align-items: center; justify-content: center; gap: 16px; margin: 56px auto 0; }
.wx-pager-btn {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 20px;
  border-radius: var(--wx-radius-btn); border: 1px solid var(--wx-line);
  color: var(--wx-ink); font-size: 14px; font-weight: 600; text-decoration: none;
  transition: background .2s, border-color .2s;
}
a.wx-pager-btn:hover { background: color-mix(in srgb, var(--wx-ink) 6%, transparent); }
.wx-pager-btn.is-disabled { opacity: .4; }
.wx-pager-info { font-size: 13.5px; color: var(--wx-ink-2); font-variant-numeric: tabular-nums; }

/* --------------------------------------------------------------------------
   Footer
   -------------------------------------------------------------------------- */
.wx-footer {
  margin-top: clamp(64px, 10vw, 128px);
  padding: 64px 0 32px;
  border-top: 1px solid var(--wx-line);
  color: var(--wx-ink-2);
  font-size: 14.5px;
}
.wx-body[data-brand-theme="coffee"] .wx-footer {
  background: var(--wx-primary-hover); color: rgba(233, 239, 232, .72); border-top: 0;
  --wx-line: rgba(233, 239, 232, .14);
}
.wx-body[data-brand-theme="coffee"] .wx-footer .wx-footer-name { color: #e9efe8; }
.wx-footer-grid { display: grid; grid-template-columns: 1.6fr repeat(3, 1fr); gap: 32px; }
.wx-footer-name { margin: 0; font: 700 22px/1.2 var(--wx-font-display); letter-spacing: -0.02em; color: var(--wx-ink); }
.wx-footer-tag { margin: 8px 0 0; max-width: 32ch; }
.wx-footer-col { display: flex; flex-direction: column; gap: 10px; }
.wx-footer-label { margin: 0 0 4px; font-size: 13px; font-weight: 600; color: inherit; opacity: .7; }
.wx-footer-col a { text-decoration: none; width: fit-content; transition: color .2s; }
.wx-footer-col a:hover { color: var(--wx-accent); }
.wx-footer-bottom {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px;
  margin-top: 48px; padding-top: 24px; border-top: 1px solid var(--wx-line); font-size: 13px;
}
.wx-footer-bottom p { margin: 0; }
.wx-footer-bottom a { text-decoration: none; }
.wx-footer-bottom a:hover { text-decoration: underline; }
@media (max-width: 768px) {
  .wx-footer-grid { grid-template-columns: 1fr 1fr; }
  .wx-footer-brand { grid-column: 1 / -1; }
}

/* --------------------------------------------------------------------------
   Reveal khi cuộn (wx/shell.js gắn .is-in). Không JS / reduced-motion → hiện ngay.
   -------------------------------------------------------------------------- */
.wx-js [data-reveal] { opacity: 0; transform: translateY(18px); transition: opacity .7s var(--wx-ease), transform .7s var(--wx-ease); transition-delay: calc(var(--i, 0) * 60ms); }
.wx-js [data-reveal].is-in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  .wx-js [data-reveal] { opacity: 1; transform: none; transition: none; }
}

/* Motion (GSAP, resources/js/wx/motion.js): ẩn trước khi GSAP nhận phần tử để không nháy nội dung */
.wx-m:not(.wx-m-ready) [data-m~="split"],
.wx-m [data-m~="rise"], .wx-m [data-m~="stagger"], .wx-m [data-m~="clip"], .wx-m [data-m~="line"] { visibility: hidden; }
.wx-m [data-m~="split"] { visibility: hidden; }
.wx-m-line { padding-bottom: .08em; margin-bottom: -.08em; } /* mặt nạ dòng không cắt dấu tiếng Việt / chân chữ g,y */
.wx-progress { position: fixed; left: 0; top: 0; z-index: 10003; width: 100%; height: 2px; background: var(--wx-accent); transform: scaleX(0); transform-origin: left; pointer-events: none; }
@media (prefers-reduced-motion: reduce) {
  .wx-m [data-m] { visibility: visible !important; }
}

/* Khung chứa canvas three.js: fallback ảnh tĩnh nằm dưới, canvas phủ lên khi sẵn sàng */
.wx-stage { position: relative; isolation: isolate; }
.wx-stage > canvas { position: absolute; inset: 0; width: 100% !important; height: 100% !important; display: block; z-index: 1; touch-action: pan-y; }
.wx-stage-fallback { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; transition: opacity .6s ease-out; }
.wx-stage.is-3d .wx-stage-fallback { opacity: 0; }

/* Trình phát nhạc persistent + chat nổi trên theme tối */
.wx-body .music-pp { z-index: 60; }


/* Fuji mobile header: Safari's visual viewport + the 44px brand switcher
   spacer could expose a strip of scrolling hero text above a sticky bar.
   Keep the navbar pinned, reserve its exact height in flow and cover the
   space behind the switcher. Scope to Fuji only (Coffee/Music unchanged). */
@media (max-width: 640px) {
  .wx-body[data-brand-theme="fujifilm"] {
    --wx-topbar-h: 64px;
  }
  .wx-body[data-brand-theme="fujifilm"] .brand-shell.wx-shell {
    padding-top: calc(var(--wx-topbar-h) + env(safe-area-inset-top, 0px));
  }
  .wx-body[data-brand-theme="fujifilm"] .brand-shell.wx-shell::before {
    content: "";
    position: fixed;
    inset: 0 0 auto;
    height: calc(44px + env(safe-area-inset-top, 0px));
    z-index: 49;
    background: var(--wx-bg);
    pointer-events: none;
  }
  .wx-body[data-brand-theme="fujifilm"] .wx-topbar {
    position: fixed;
    top: calc(44px + env(safe-area-inset-top, 0px));
    left: 0;
    right: 0;
    width: 100%;
    z-index: 50;
    transition: top .25s ease, border-color .3s, background .3s;
  }
  html.is-switcher-tucked .wx-body[data-brand-theme="fujifilm"] .wx-topbar {
    top: env(safe-area-inset-top, 0px);
  }
}
@media (max-width: 640px) and (prefers-reduced-motion: reduce) {
  .wx-body[data-brand-theme="fujifilm"] .wx-topbar {
    transition: border-color .3s, background .3s;
  }
}
