/* ===========================================================================
   AUDIKUNG canonical site nav + footer  —  single source of truth
   Generated into pages by build-nav.py. Edit nav.config.json, not the markup.
   Scoped to .aknav* / .akfoot* so it never collides with legacy page CSS.
   =========================================================================== */
:root {
  --aknav-bg: var(--bg, #030712);
  --aknav-gold: var(--gold, #c9a84c);
  --aknav-gold-light: var(--gold-light, #E5C586);
  --aknav-text: var(--text, #f0f0f5);
  --aknav-muted: var(--text-muted, #8888a0);
  --aknav-border: var(--border, rgba(255,255,255,0.08));
  --aknav-focus: #f7c548;
  --aknav-head: var(--font-head, 'Outfit', 'Mitr', sans-serif);
  --aknav-body: var(--font-body, 'Plus Jakarta Sans', 'Sarabun', sans-serif);
}

:where(a, button, input, select, textarea, [tabindex]):focus-visible {
  outline: 3px solid var(--aknav-focus);
  outline-offset: 3px;
}

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

/* ---- bar ---- */
.aknav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: space-between;
  height: 64px; padding: 0 5%;
  background: rgba(3, 7, 18, 0.85);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--aknav-border);
  font-family: var(--aknav-body);
}
.aknav * { box-sizing: border-box; }
.aknav-logo {
  display: flex; align-items: center; gap: 0.5rem;
  font-family: var(--aknav-head); font-size: 1.4rem; font-weight: 700;
  letter-spacing: 3px; color: var(--aknav-gold); text-decoration: none;
  text-shadow: 0 0 20px rgba(201,168,76,0.5); white-space: nowrap; flex-shrink: 0;
}
.aknav-logo img { height: 32px; width: 32px; border-radius: 50%; object-fit: cover; object-position: center top; flex-shrink: 0; }

/* ---- desktop menu ---- */
.aknav-menu { display: flex; align-items: center; gap: 1.5rem; list-style: none; margin: 0; padding: 0; flex-wrap: nowrap; white-space: nowrap; }
.aknav-group { position: relative; }
.aknav-link {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 0.95rem; color: var(--aknav-muted); text-decoration: none;
  background: none; border: none; cursor: pointer; font-family: var(--aknav-body);
  padding: 20px 4px; transition: color 0.2s;  /* tall hit area spanning the bar */
}
.aknav-link:hover, .aknav-group.is-open .aknav-link { color: var(--aknav-text); }
.aknav-link.is-active { color: var(--aknav-gold); }
.aknav-link.is-current { position: relative; color: var(--aknav-text); }
.aknav-link.is-current::after {
  content: '';
  position: absolute;
  right: 14px;
  bottom: 0;
  left: 14px;
  height: 2px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--aknav-gold), var(--aknav-shrimp, #fb7185));
}
.aknav-caret { width: 9px; height: 9px; fill: none; stroke: currentColor; stroke-width: 2.2; transition: transform 0.2s; }
.aknav-group.is-open .aknav-caret { transform: rotate(180deg); }

/* ---- dropdown ---- */
.aknav-drop {
  position: absolute; top: 100%; left: 50%; transform: translateX(-50%) translateY(8px);
  min-width: 200px; padding: 8px;
  background: rgba(7,13,36,0.97); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--aknav-border); border-radius: 12px;
  box-shadow: 0 16px 40px rgba(0,0,0,0.45);
  opacity: 0; visibility: hidden; pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  display: flex; gap: 4px;
}
.aknav-group.is-open .aknav-drop {
  opacity: 1; visibility: visible; pointer-events: auto; transform: translateX(-50%) translateY(6px);
}
.aknav-col { display: flex; flex-direction: column; min-width: 168px; }
.aknav-drop.is-mega {
  position: fixed; top: 64px; left: 50%; right: auto;
  transform: translateX(-50%) translateY(8px);
  max-width: min(940px, 94vw); flex-wrap: wrap;
  padding: 16px; gap: 8px 22px;
}
.aknav-group.is-open .aknav-drop.is-mega { transform: translateX(-50%) translateY(0); }
.aknav-colhead { font-family: var(--aknav-head); font-size: 0.72rem; font-weight: 600; letter-spacing: 1px; text-transform: uppercase; color: var(--aknav-gold); padding: 6px 12px 4px; opacity: 0.85; }
.aknav-drop a {
  display: block; padding: 8px 12px; border-radius: 8px;
  font-size: 0.9rem; color: var(--aknav-muted); text-decoration: none; white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}
.aknav-drop a:hover { background: rgba(255,255,255,0.06); color: var(--aknav-text); }
.aknav-drop a.is-active { color: var(--aknav-gold); }

/* ---- right side ---- */
.aknav-right { display: flex; align-items: center; gap: 1.2rem; }
.aknav-products { font-size: 0.95rem; color: var(--aknav-muted); text-decoration: none; transition: color 0.2s; }
.aknav-products:hover { color: var(--aknav-text); }
.aknav-products-hl {
  color: var(--aknav-gold); border: 1px solid rgba(201,168,76,0.55);
  padding: 0.42rem 0.95rem; border-radius: 6px; font-weight: 600;
  transition: background 0.2s, box-shadow 0.2s, color 0.2s;
}
.aknav-products-hl:hover { color: var(--aknav-gold-light); background: rgba(201,168,76,0.12); box-shadow: 0 0 14px rgba(201,168,76,0.25); }
.aknav-cta {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 0.9rem; font-weight: 600; color: #030712; background: var(--aknav-gold);
  padding: 0.45rem 1.2rem; border-radius: 6px; text-decoration: none;
  transition: background 0.2s, box-shadow 0.2s;
}
.aknav-cta:hover { background: var(--aknav-gold-light); box-shadow: 0 0 18px rgba(201,168,76,0.5); }
.aknav-cta svg { vertical-align: -2px; }

/* ---- hamburger ---- */
.aknav-burger {
  display: none; flex-direction: column; align-items: center; justify-content: center; gap: 5px;
  min-width: 44px; min-height: 44px; padding: 6px;
  background: none; border: none; cursor: pointer;
}
.aknav-burger span { width: 24px; height: 2px; background: var(--aknav-text); transition: transform 0.25s, opacity 0.25s; }
.aknav.is-open .aknav-burger span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.aknav.is-open .aknav-burger span:nth-child(2) { opacity: 0; }
.aknav.is-open .aknav-burger span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ---- mobile panel ---- */
.aknav-mobile {
  position: fixed; top: 64px; left: 0; right: 0; bottom: 0; z-index: 999;
  background: rgba(3,7,18,0.98); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  padding: 18px 5% 60px; overflow-y: auto;
  opacity: 0; transition: opacity 0.2s ease; display: none;
  visibility: hidden; pointer-events: none;
}
.aknav-mobile.is-open { opacity: 1; visibility: visible; pointer-events: auto; }
.akm-group { border-bottom: 1px solid var(--aknav-border); }
.akm-head {
  display: flex; align-items: center; justify-content: space-between; width: 100%;
  min-height: 44px;
  padding: 16px 4px; background: none; border: none; cursor: pointer;
  font-family: var(--aknav-body); font-size: 1.05rem; color: var(--aknav-text); text-align: left; text-decoration: none;
}
.akm-head:hover { color: var(--aknav-text); }
.akm-head.is-current { color: var(--aknav-text); background: rgba(201,168,76,0.1); }
.akm-head .aknav-caret { width: 12px; height: 12px; }
.akm-head.is-open .aknav-caret { transform: rotate(180deg); }
.akm-sub { max-height: 0; overflow: hidden; transition: max-height 0.3s ease; }
.akm-sub.is-open { max-height: 800px; }
.akm-sub a { display: flex; align-items: center; min-height: 44px; padding: 11px 16px; font-size: 0.95rem; color: var(--aknav-muted); text-decoration: none; }
.akm-sub a:hover, .akm-sub a.is-active { color: var(--aknav-gold); }
.akm-colhead { padding: 12px 16px 2px; font-size: 0.72rem; font-weight: 600; letter-spacing: 1px; text-transform: uppercase; color: var(--aknav-gold); opacity: 0.8; }
.akm-cta { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 22px; padding: 14px; font-weight: 600; color: #030712; background: var(--aknav-gold); border-radius: 8px; text-decoration: none; }

@media (max-width: 1080px) {
  .aknav-menu, .aknav-right { display: none; }
  .aknav-burger { display: flex; }
  .aknav-mobile { display: block; }
}
@media (max-width: 600px) {
  .aknav { height: 60px; padding: 0 16px; }
  .aknav-logo { gap: 0.38rem; font-size: clamp(1rem, 5vw, 1.2rem); letter-spacing: 1px !important; }
  .aknav-logo img { width: 28px; height: 28px; }
  .aknav-mobile { top: 60px; }
}

/* ---- post-hero morph (desktop): full bar → floating glass pill ----
   site-nav.js toggles .is-compact via an IntersectionObserver sentinel (no scroll
   listener). Only the bar's own box animates; page layout never moves. */
@media (min-width: 1081px) {
  .aknav {
    transition: top 0.6s cubic-bezier(0.22,1,0.36,1), left 0.6s cubic-bezier(0.22,1,0.36,1),
                right 0.6s cubic-bezier(0.22,1,0.36,1), height 0.6s cubic-bezier(0.22,1,0.36,1),
                padding 0.6s cubic-bezier(0.22,1,0.36,1), border-radius 0.6s cubic-bezier(0.22,1,0.36,1),
                background-color 0.4s ease, border-color 0.4s ease, box-shadow 0.6s ease;
  }
  .aknav.is-compact {
    top: 10px; height: 54px; padding: 0 22px;
    left: max(16px, calc(50% - 640px)); right: max(16px, calc(50% - 640px));
    border-radius: 999px;
    background: rgba(7, 13, 36, 0.72);
    backdrop-filter: blur(18px) saturate(1.3); -webkit-backdrop-filter: blur(18px) saturate(1.3);
    border: 1px solid rgba(255,255,255,0.10);
    box-shadow: 0 10px 34px rgba(0,0,0,0.38), inset 0 1px 0 rgba(255,255,255,0.06);
  }
  .ak-shell :is(.aknav, .aknav.is-compact) {
    position: relative !important;
    top: auto !important;
    left: auto !important;
    right: auto !important;
    width: 100% !important;
    border-radius: 0 !important;
    background: none !important;
    border: 0 !important;
    box-shadow: none !important;
  }
  .aknav-logo img, .aknav-logo { transition: height 0.6s cubic-bezier(0.22,1,0.36,1), width 0.6s cubic-bezier(0.22,1,0.36,1), font-size 0.6s cubic-bezier(0.22,1,0.36,1); }
  .aknav.is-compact .aknav-logo { font-size: 1.22rem; }
  .aknav.is-compact .aknav-logo img { height: 28px; width: 28px; }
  .aknav.is-compact .aknav-link { padding-top: 17px; padding-bottom: 17px; }
  .aknav.is-compact .aknav-cta, .aknav.is-compact .aknav-products-hl { border-radius: 999px; }}
@media (prefers-reduced-motion: reduce) {
  .aknav, .aknav-logo, .aknav-logo img { transition: none !important; }
}
/* App pages with their own header (html[data-aknav-yield]) once the owner is signed in — see site-nav.js */
html.aknav-yielded .aknav, html.aknav-yielded .aknav-mobile { display: none !important; }
html.aknav-yielded [data-aknav-own] > #auth-nav-btn { margin-left: 14px; flex-shrink: 0; }
/* keep the header's last item next to the profile button (space-between would push it to the middle) */
html.aknav-yielded [data-aknav-own] > :has(+ #auth-nav-btn) { margin-left: auto; }
html.aknav-yielded .pd-wrap { top: var(--ak-own-head, 68px) !important; }
@media (max-width: 720px) {
  html.aknav-yielded [data-aknav-own] > #auth-nav-btn .auth-nav-username { display: none; }
  /* top-right corner when it's free (site-nav.js measures first), otherwise stays in the row */
  html.aknav-yielded [data-aknav-own].ak-own-abs > #auth-nav-btn { position: absolute; top: 12px; right: 14px; margin: 0; }
}

/* ===========================================================================
   FOOTER
   =========================================================================== */
.akfoot {
  background: var(--aknav-bg); border-top: 1px solid var(--aknav-border);
  padding: 56px 5% 32px; font-family: var(--aknav-body); color: var(--aknav-muted);
}
.akfoot-top { display: grid; grid-template-columns: minmax(300px,.9fr) minmax(0,1.2fr); column-gap: clamp(72px,8vw,140px); row-gap: 48px; max-width: 1680px; margin: 0 auto; }
.akfoot-brand { min-width: 0; max-width: 340px; }
.akfoot-brand .akfoot-logo { display: flex; align-items: center; gap: 0.5rem; width: max-content; max-width: 100%; white-space: nowrap; font-family: var(--aknav-head); font-size: 1.3rem; font-weight: 700; letter-spacing: 2px; color: var(--aknav-gold); text-decoration: none; }
.akfoot-brand img { height: 30px; width: 30px; border-radius: 50%; }
.akfoot-brand p { margin-top: 12px; font-size: 0.9rem; line-height: 1.7; }
.akfoot-cols { display: grid; grid-template-columns: repeat(3,minmax(130px,1fr)); gap: 32px clamp(36px,4vw,72px); min-width: 0; }
.akfoot-col h4 { font-family: var(--aknav-head); font-size: 0.8rem; font-weight: 600; letter-spacing: 1px; text-transform: uppercase; color: var(--aknav-text); margin-bottom: 14px; }
.akfoot-col a { display: block; padding: 5px 0; font-size: 0.9rem; color: var(--aknav-muted); text-decoration: none; transition: color 0.15s; }
.akfoot-col a[aria-label] {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; padding: 0; box-sizing: border-box;
  border-radius: 999px;
}
.akfoot-col a:hover { color: var(--aknav-gold); }
.akfoot-bottom { max-width: 1680px; margin: 48px auto 0; padding-top: 22px; border-top: 1px solid var(--aknav-border); font-size: 0.82rem; text-align: center; }
@media (max-width: 820px) { .akfoot-top { grid-template-columns: 1fr; row-gap: 42px; } .akfoot-brand { max-width: 360px; } .akfoot-cols { grid-template-columns: repeat(3,minmax(120px,1fr)); } }
@media (max-width: 600px) { .akfoot { padding-inline: 20px; } .akfoot-top { row-gap: 36px; } .akfoot-cols { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 30px 24px; } .akfoot-brand .akfoot-logo { gap: .38rem; font-size: clamp(1rem, 5.2vw, 1.14rem); letter-spacing: .5px !important; } .akfoot-brand img { width: 27px; height: 27px; flex: none; } }

/* ───────────────────────────────────────────────────────────────
   THAI DIACRITIC FIX (2026-06-20)
   letter-spacing pushes วรรณยุกต์/สระ off their base consonant on
   iOS Safari (and is non-idiomatic in Thai typography anyway). Every
   page is <html lang="th">, so zero tracking globally, then restore it
   only on the Latin wordmarks/display headings that should keep it.
   ─────────────────────────────────────────────────────────────── */
:lang(th) { letter-spacing: normal !important; }
.aknav-logo  { letter-spacing: 3px !important; }
.akfoot-logo { letter-spacing: 2px !important; }
.hero-name   { letter-spacing: 4px !important; }

/* Long English tokens in article summaries must wrap instead of widening mobile pages. */
.article-body .key-takeaway li { overflow-wrap: anywhere; }

/* ===========================================================================
   MOBILE OVERFLOW SAFETY NET (2026-07-05)
   Site-wide fix for pages that scrolled sideways on phones. Two layers:
   1. Wide data tables scroll inside their own box instead of pushing the page
      (!important beats legacy per-page .sector-table / .rating-table / etc.).
      Real content stays reachable via horizontal swipe — reflow, not clip.
   2. The page itself never scrolls sideways on any viewport. Real wide content
      already reflows (tables above, stacked boxes on their pages); this only
      catches sub-pixel / off-canvas residue. overflow-x:clip (not hidden) keeps
      position:sticky / fixed working; hidden is the fallback for old browsers.
   =========================================================================== */
@media (max-width: 640px) {
  /* Shared mobile action target contract */
  :where(
    .auth-modal-close,
    .setup-av-opt,
    .follow-popup-close,
    .grat-arrow,
    .modal-close,
    .wbtn.dig,
    #sys-cash-cur,
    .cur-chip,
    button.del,
    .quote-icon-btn,
    #vpc-toggle-btn,
    .log-arrow,
    .jm-close,
    #calendar-prev,
    #calendar-next,
    .filter-chip,
    .map-icon-btn,
    .calendar-panel-close
  ) {
    min-width: 44px !important;
    min-height: 44px !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  table {
    display: block;
    max-width: 100%;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
  }
}
html {
  overflow-x: hidden;   /* fallback for browsers without clip */
  overflow-x: clip;
}

@media (prefers-reduced-motion: reduce) {
  .aknav *, .aknav-mobile *, .akfoot * {
    transition: none !important;
    animation: none !important;
  }
}
