/* ============================================================
   site-nav.css · Shared sidebar + breadcrumb pattern
   Source-of-truth aesthetic extracted from weapon-hok-kong-chakra.html
   (user-approved). Applied uniformly site-wide — no per-page anchors.
   ============================================================ */

/* ── shared design tokens (fallbacks; pages may override in :root) ── */
:root {
  --sn-dark-bg:    #0A0806;
  --sn-dark-2:     #140E06;
  --sn-cream:      #E8DFB8;
  --sn-gold:       #C9A227;
  --sn-gold-light: #F0D060;
  --sn-accent:     #C84B1A;        /* karma orange */
  --sn-holy:       #A8D8FF;
  --sn-border:     rgba(201, 162, 39, 0.20);
  --sn-border-soft:rgba(201, 162, 39, 0.12);
  --sn-hover-bg:   rgba(201, 162, 39, 0.08);
  --sn-active-bg:  rgba(200, 75, 26, 0.10);
}

/* ── PAGE SHELL: sidebar column + main column ── */
.page-shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}
@media (max-width: 900px) {
  .page-shell { grid-template-columns: 1fr; }
}

/* Breathing room between the sidebar and page content. Content wrappers carry
   their own inner padding (24–36px), but with the sidebar flush to the grid edge
   that felt cramped — this adds a uniform gutter on every page. */
.page-main { padding-inline: 32px; }
@media (max-width: 900px) { .page-main { padding-inline: 0; } }

/* ── SIDEBAR (desktop ≥901px) ── */
.site-sidebar {
  box-sizing: border-box;
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  width: 260px;
  padding: 24px 18px;
  background: rgba(10, 8, 6, 0.97);
  border-right: 1px solid var(--sn-border);
  font-family: 'Sarabun', sans-serif;
  font-size: 16px;
  color: var(--sn-cream);
  z-index: 9000;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
  overflow: hidden; /* sidebar itself clips; the nav below scrolls so brand+search stay pinned */
  /* Firefox scrollbar */
  scrollbar-width: thin;
  scrollbar-color: rgba(201, 162, 39, 0.35) rgba(10, 8, 6, 0.0);
}
/* WebKit scrollbar — subtle, theme-matched */
.site-sidebar::-webkit-scrollbar {
  width: 8px;
}
.site-sidebar::-webkit-scrollbar-track {
  background: transparent;
}
.site-sidebar::-webkit-scrollbar-thumb {
  background: rgba(201, 162, 39, 0.25);
  border-radius: 4px;
  border: 2px solid rgba(10, 8, 6, 0.0);
  background-clip: padding-box;
}
.site-sidebar::-webkit-scrollbar-thumb:hover {
  background: rgba(201, 162, 39, 0.5);
  background-clip: padding-box;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: 'Mitr', sans-serif;
  font-size: 17px;
  color: var(--sn-gold-light);
  letter-spacing: 1px;
  border-bottom: 1px solid var(--sn-border);
  padding-bottom: 10px;
}
.sidebar-brand-icon {
  font-size: 22px;
  line-height: 1;
}
.sidebar-brand-th {
  font-family: 'Mitr', sans-serif;
  font-size: 17px;
  color: var(--sn-gold-light);
  letter-spacing: 1px;
}
.sidebar-brand-en {
  margin-top: 2px;
  font-family: 'Chakra Petch', sans-serif;
  font-size: 13px;
  letter-spacing: 3px;
  color: rgba(201, 162, 39, 0.5);
  font-weight: 400;
}
.sidebar-brand small {
  display: block;
  margin-top: 4px;
  font-family: 'Chakra Petch', sans-serif;
  font-size: 13px;
  letter-spacing: 3px;
  color: rgba(201, 162, 39, 0.5);
  font-weight: 400;
}

.sidebar-section-label {
  font-family: 'Chakra Petch', sans-serif;
  font-size: 13px;
  letter-spacing: 3px;
  color: rgba(201, 162, 39, 0.5);
  margin-bottom: 4px;
  text-transform: uppercase;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1 1 0;
  min-height: 0;        /* allow the nav to shrink below content so its own scroll engages */
  overflow-y: auto;
  padding-bottom: 24px; /* clearance so the last menu item is fully reachable */
  scrollbar-width: thin;
  scrollbar-color: rgba(201, 162, 39, 0.35) transparent;
}

/* sidebar groups (collapsible categories) */
.sidebar-group { display: flex; flex-direction: column; }
.sidebar-group-toggle,
.sidebar-group-header {
  appearance: none;
  background: transparent;
  border: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
  padding: 9px 12px;
  font-family: 'Mitr', sans-serif;
  font-size: 16px;
  color: var(--sn-gold-light);
  letter-spacing: 0.5px;
  border-left: 2px solid transparent;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  transition: background .15s, border-color .15s, color .15s;
}
.sidebar-group-toggle:hover,
.sidebar-group-header:hover {
  background: var(--sn-hover-bg);
  border-left-color: rgba(201, 162, 39, 0.5);
  color: #fff;
}
.sidebar-group-toggle::after,
.sidebar-group-header::after {
  content: '▾';
  font-size: 14px;
  color: rgba(201, 162, 39, 0.5);
  transition: transform .2s;
}
.sidebar-group[aria-expanded="false"] .sidebar-group-toggle::after,
.sidebar-group[aria-expanded="false"] .sidebar-group-header::after {
  transform: rotate(-90deg);
}
.sidebar-group[aria-expanded="false"] .sidebar-group-items {
  display: none;
}
.sidebar-group-items {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding-left: 6px;
}

/* ── 2-LEVEL NESTING · subgroups (collapsible sub-categories) ── */
.sidebar-subgroup {
  display: flex;
  flex-direction: column;
}
.sidebar-subgroup-header {
  appearance: none;
  background: transparent;
  border: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
  padding: 6px 10px 6px 14px;
  margin-left: 4px;
  font-family: 'Chakra Petch', sans-serif;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 1.5px;
  color: rgba(201, 162, 39, 0.75);
  border-left: 1px solid rgba(201, 162, 39, 0.18);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  transition: background .15s, border-color .15s, color .15s;
  text-transform: uppercase;
}
.sidebar-subgroup-header:hover {
  background: var(--sn-hover-bg);
  border-left-color: rgba(201, 162, 39, 0.55);
  color: var(--sn-gold-light);
}
.sidebar-subgroup-header::after {
  content: '▾';
  font-size: 13px;
  color: rgba(201, 162, 39, 0.4);
  transition: transform .2s;
}
.sidebar-subgroup[aria-expanded="false"] .sidebar-subgroup-header::after {
  transform: rotate(-90deg);
}
.sidebar-subgroup[aria-expanded="false"] .sidebar-subgroup-items {
  display: none;
}
.sidebar-subgroup-items {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding-left: 14px;
  margin-left: 4px;
  border-left: 1px solid rgba(201, 162, 39, 0.08);
}

/* placeholder line for empty subgroups */
.sidebar-empty {
  display: block;
  padding: 6px 12px;
  font-family: 'Sarabun', sans-serif;
  font-size: 15px;
  font-style: italic;
  color: rgba(232, 223, 184, 0.35);
  letter-spacing: 0.5px;
}

/* sidebar links (uniform site-nav only — no per-page anchors) */
.sidebar-link {
  display: block;
  padding: 8px 12px;
  color: var(--sn-cream);
  text-decoration: none;
  border-left: 2px solid transparent;
  transition: background .15s, border-color .15s, color .15s;
  font-size: 16px;
  font-family: 'Sarabun', sans-serif;
  word-break: break-word;
  line-height: 1.5;
}
.sidebar-link:hover {
  background: var(--sn-hover-bg);
  border-left-color: rgba(201, 162, 39, 0.5);
  color: #fff;
}
.sidebar-link[aria-current="page"],
.sidebar-link.is-active {
  background: var(--sn-active-bg);
  border-left-color: var(--sn-accent);
  color: var(--sn-gold-light);
  font-weight: 600;
}

/* ── MOBILE: hamburger + off-canvas drawer (≤900px) ── */
.sidebar-toggle {
  display: none;
  position: sticky;
  top: 0;
  z-index: 9500;
  width: 100%;
  padding: 10px 14px;
  background: rgba(10, 8, 6, 0.97);
  border: none;
  border-bottom: 1px solid var(--sn-border);
  color: var(--sn-gold-light);
  font-family: 'Chakra Petch', sans-serif;
  font-size: 15px;
  letter-spacing: 2px;
  text-align: left;
  cursor: pointer;
}
.sidebar-toggle:hover { background: var(--sn-hover-bg); }

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 8500;
}
.sidebar-backdrop.is-visible { display: block; }

@media (max-width: 900px) {
  .site-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    height: 100vh;
    transform: translateX(-100%);
    transition: transform .25s ease;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.6);
  }
  .site-sidebar.is-open { transform: translateX(0); }
  .sidebar-toggle { display: block; }
  body.sidebar-locked { overflow: hidden; }
}

/* ── BREADCRUMB BACK (top of main content) ── */
#breadcrumb-back {
  padding: 16px 24px 0 48px;
  font-family: 'Sarabun', sans-serif;
  font-size: 16px;
  line-height: 1.6;
}
@media (max-width: 900px) { #breadcrumb-back { padding-left: 24px; } }
#breadcrumb-back:empty { display: none; }

.breadcrumb-back-link {
  display: inline-block;
  color: var(--sn-holy);
  text-decoration: none;
  padding: 4px 10px;
  border: 1px solid rgba(168, 216, 255, 0.25);
  border-radius: 3px;
  background: rgba(40, 100, 200, 0.06);
  transition: background .15s, color .15s, border-color .15s;
  word-break: break-word;
}
.breadcrumb-back-link:hover {
  color: #fff;
  background: rgba(40, 100, 200, 0.14);
  border-color: rgba(168, 216, 255, 0.5);
}

/* ── GLOBAL: keyboard focus visibility (additive; benefits all pages) ── */
:focus-visible {
  outline: 2px solid var(--sn-gold, #C9A227);
  outline-offset: 2px;
}

/* ── SKIP LINK: WCAG bypass-blocks; visually hidden until focused ── */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 2000;
  background: var(--sn-gold, #C9A227);
  color: #0D0A06;
  padding: 10px 16px;
  font-family: 'Sarabun', sans-serif;
  font-weight: 600;
  text-decoration: none;
  border-radius: 0 0 6px 0;
}
.skip-link:focus { left: 0; }
