/* Shared shell, collapsible navigation rail, and tournament components — ui-polish-v6.css */

/* =========================================================================
   Header & Navigation Shell (224px collapsible rail >=1280px, drawer <1280px)
   ========================================================================= */
.site-header {
  container-type: inline-size;
  min-height: 4rem;
}
.site-header > div {
  padding: 0.55rem 1rem 0.55rem 0.75rem;
}
.site-header .site-header-primary {
  flex: 1;
  min-width: 0;
  gap: 0.35rem;
}
.site-header .site-logo {
  flex: none;
  width: max-content;
  min-width: 0;
  margin-left: 0.15rem;
  margin-right: 0.75rem;
  align-items: center;
}
.site-header .site-header-search {
  flex: 0 1 22rem;
  min-width: 0;
  padding-left: 0.5rem;
}
.site-header .site-header-search.is-home-search {
  display: none !important;
}
.site-header .site-header-search-field {
  width: 100%;
  min-width: 0;
  margin-top: 0;
}
.site-header #topbar-search {
  min-height: 38px;
  padding-top: 0.45rem;
  padding-bottom: 0.45rem;
}
.site-header .site-header-controls {
  flex: none;
  gap: 0.25rem;
}
.site-header #toggleSidebarMobile,
.site-header #toggleSidebarMobileSearch,
.site-header #theme-toggle {
  flex: none;
  width: 38px;
  height: 38px;
  min-width: 38px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.site-header #toggleSidebarMobileSearch {
  display: none;
}
@media (max-width: 767.98px) {
  .site-header .site-header-search {
    display: none !important;
  }
  .site-header #toggleSidebarMobileSearch {
    display: inline-flex;
  }
  .site-header #toggleSidebarMobile,
  .site-header #toggleSidebarMobileSearch,
  .site-header #theme-toggle {
    width: 42px;
    height: 42px;
    min-width: 42px;
  }
}
@media (min-width: 768px) {
  .site-header .site-header-search:not(.is-home-search) {
    display: block !important;
  }
}
.dark .site-header .site-logo img {
  filter: invert(1);
}
@container (max-width: 22rem) {
  .site-header .site-logo span {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
}
.site-header #tooltip-toggle {
  max-width: calc(100vw - 24px);
}
.site-header #tooltip-toggle.invisible {
  display: none;
}

/* Shell spacing */
.site-shell {
  padding-top: var(--site-header-height, 4rem);
}

/* Sidebar base & responsive modes */
#sidebar {
  width: 224px;
  padding-top: var(--site-header-height, 4rem);
}
#sidebar > div {
  background: #ffffff;
}
.dark #sidebar > div {
  background: #1f2937;
}
.site-sidebar-scroll {
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, 0.35) transparent;
}
.site-sidebar-scroll::-webkit-scrollbar {
  width: 5px;
}
.site-sidebar-scroll::-webkit-scrollbar-track {
  background: transparent;
}
.site-sidebar-scroll::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.35);
  border-radius: 999px;
}
.site-sidebar-scroll::-webkit-scrollbar-thumb:hover {
  background: rgba(100, 116, 139, 0.55);
}

/* Wide desktop (>=1280px), normal pages: pinned 224px rail unless user collapsed */
@media (min-width: 1280px) {
  html:not(.compact-navigation):not(.page-hide-sidebar):not(.sidebar-collapsed) #sidebar {
    display: flex !important;
    width: 224px;
    box-shadow: none;
  }
  html:not(.compact-navigation):not(.page-hide-sidebar):not(.sidebar-collapsed) #main-content {
    margin-left: 224px;
  }
  html:not(.compact-navigation):not(.page-hide-sidebar).sidebar-collapsed #sidebar {
    display: none !important;
  }
  html:not(.compact-navigation):not(.page-hide-sidebar).sidebar-collapsed #main-content {
    margin-left: 0;
  }
}

/* Drawer mode: <1280px (compact-navigation) OR immersive hide_sidebar pages (/game/*, /live/*) */
html.compact-navigation #sidebar,
html.page-hide-sidebar #sidebar {
  width: min(260px, 86vw);
  max-width: 100vw;
  z-index: 25;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.18);
}
html.dark.compact-navigation #sidebar,
html.dark.page-hide-sidebar #sidebar {
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.55);
}
html.compact-navigation #sidebar:not(.hidden),
html.page-hide-sidebar #sidebar:not(.hidden) {
  display: flex !important;
}
html.compact-navigation #sidebar.hidden,
html.page-hide-sidebar #sidebar.hidden {
  display: none !important;
}
html.compact-navigation #main-content,
html.page-hide-sidebar #main-content {
  margin-left: 0 !important;
}
#sidebarBackdrop {
  z-index: 19;
}

/* Hide drawer mobile search when header search is visible (>=768px) */
.site-nav-mobile-search {
  display: none;
  margin-bottom: 0.5rem;
}
@media (max-width: 767.98px) {
  .site-nav-mobile-search {
    display: block;
  }
  .site-nav-mobile-search form {
    display: block !important;
  }
}

/* Navigation items, section headers, unified outline icons & submenu tree */
.site-nav-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  list-style: none;
  margin: 0;
  padding: 0 0 8px;
}
.site-nav-section {
  font-size: 0.675rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #94a3b8;
  padding: 12px 10px 4px;
  user-select: none;
}
.dark .site-nav-section {
  color: #64748b;
}
.site-nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 36px;
  padding: 6px 10px;
  border-radius: 8px;
  border: 0;
  background: transparent;
  font-size: 0.84rem;
  font-weight: 500;
  line-height: 1.25;
  color: #334155;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}
.dark .site-nav-link {
  color: #e2e8f0;
}
.site-nav-link:hover {
  background: #f1f5f9;
  color: #0f172a;
}
.dark .site-nav-link:hover {
  background: #334155;
  color: #ffffff;
}
.site-nav-icon {
  width: 18px;
  height: 18px;
  flex: none;
  color: #64748b;
  transition: color 0.12s ease;
}
.dark .site-nav-icon {
  color: #94a3b8;
}
.site-nav-link:hover .site-nav-icon {
  color: #0f172a;
}
.dark .site-nav-link:hover .site-nav-icon {
  color: #f8fafc;
}
#sidebar .sidebar-group-arrow {
  width: 16px;
  height: 16px;
  flex: none;
  color: #94a3b8;
  transform: rotate(-90deg);
  transition: transform 0.15s ease;
}
#sidebar .sidebar-group-toggle[aria-expanded="true"] .sidebar-group-arrow {
  transform: rotate(0deg);
}
@media (prefers-reduced-motion: reduce) {
  #sidebar .sidebar-group-arrow {
    transition: none;
  }
}

/* Submenu tree with subtle vertical guide line */
#sidebar .sidebar-group-links {
  list-style: none;
  margin: 2px 0 4px 18px;
  padding: 2px 0 2px 10px;
  border-left: 1px solid #e2e8f0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
#sidebar .sidebar-group-links.hidden {
  display: none;
}
.dark #sidebar .sidebar-group-links {
  border-left-color: #334155;
}
.site-nav-sublink {
  display: flex;
  align-items: center;
  min-height: 31px;
  padding: 4px 9px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 500;
  color: #475569;
  text-decoration: none;
  transition: background 0.12s ease, color 0.12s ease;
}
.dark .site-nav-sublink {
  color: #cbd5e1;
}
.site-nav-sublink:hover {
  background: #f1f5f9;
  color: #0f172a;
}
.dark .site-nav-sublink:hover {
  background: #334155;
  color: #ffffff;
}

/* Active navigation state */
#sidebar a[aria-current="page"],
#sidebar button[data-active="true"] {
  background: #ecfdf5;
  color: #065f46;
  font-weight: 600;
}
#sidebar a[aria-current="page"] > svg,
#sidebar button[data-active="true"] > svg {
  color: #047857;
}
.dark #sidebar a[aria-current="page"],
.dark #sidebar button[data-active="true"] {
  background: #064e3b;
  color: #a7f3d0;
}
.dark #sidebar a[aria-current="page"] > svg,
.dark #sidebar button[data-active="true"] > svg {
  color: #6ee7b7;
}
#sidebar a:focus-visible,
#sidebar button:focus-visible {
  outline: 2px solid #059669;
  outline-offset: 1px;
}

/* Touch devices keep generous 42px tap targets */
@media (pointer: coarse) {
  .site-nav-link {
    min-height: 42px;
  }
  .site-nav-sublink {
    min-height: 38px;
  }
}

/* =========================================================================
   Featured Tournament Cards (preserved from v5)
   ========================================================================= */
.featured-heading { font-size: 1.0625rem; line-height: 1.4; }
.featured-intro { line-height: 1.6; }
.featured-card { container: featured-game-card / inline-size; padding: 16px; border-color: #dbe3eb; border-radius: 10px; }
.featured-card h3 { font-size: 1rem; line-height: 1.4; margin: 0.65rem 0 0.3rem; overflow-wrap: anywhere; }
.featured-section { font-size: 0.8125rem; line-height: 1.5; color: #64748b; margin: 0 0 0.7rem; overflow-wrap: anywhere; }
.featured-card-meta { gap: 8px; color: #64748b; }
.featured-card-meta > span { display: inline-flex; align-items: center; padding: 3px 7px; border-radius: 4px; background: #f1f5f9; font-size: 0.6875rem; }
.featured-card-meta > time { font-variant-numeric: tabular-nums; font-size: 0.75rem; }
.featured-round { padding: 0 0 0.65rem; line-height: 1.5; }
.featured-round a { display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.75rem; color: #526175; }
.featured-round[data-state="live"] a { color: #047857; }
.featured-round[data-state="live"] a::before { content: ''; width: 0.45rem; height: 0.45rem; border-radius: 50%; background: currentColor; flex: none; }
.featured-players { line-height: 1.6; margin: 8px 0 0; color: #64748b; }
.featured-players-label { font-weight: 600; }
.featured-results { border-color: #e2e8f0; }
.featured-result { padding: 10px 0; grid-template-columns: minmax(0, 1fr) 38px minmax(0, 1fr); gap: 8px; line-height: 1.5; font-size: 0.75rem; }
.featured-result:last-child { border-bottom: 0; }
.featured-result strong { color: #047857; font-size: 0.8125rem; white-space: nowrap; }
.featured-result strong[data-result="Live"] { color: #047857; }
.featured-result strong[data-result="½–½"], .featured-result strong[data-result="1/2-1/2"] { color: #64748b; }
.featured-footer { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 12px; }
.featured-footer .featured-all { margin: 0; font-size: 0.75rem; display: inline-flex; align-items: center; min-height: 44px; }

.dark .featured-card { border-color: #374151; }
.dark .featured-card-meta > span { background: #334155; color: #cbd5e1; }
.dark .featured-card-meta > time, .dark .featured-round a, .dark .featured-players, .dark .featured-section { color: #9ca3af; }
.dark .featured-results { border-color: #374151; }
.dark .featured-result strong { color: #6ee7b7; }
.dark .featured-round[data-state="live"] a, .dark .featured-result strong[data-result="Live"] { color: #6ee7b7; }
.dark .featured-result strong[data-result="½–½"], .dark .featured-result strong[data-result="1/2-1/2"] { color: #9ca3af; }

@container featured-game-card (max-width: 30rem) {
  .featured-result { grid-template-columns: minmax(0, 1fr) auto; gap: 0.25rem 0.5rem; padding: 0.625rem 0; }
  .featured-result > span { display: flex; align-items: baseline; gap: 0.375rem; text-align: left; min-width: 0; }
  .featured-result > span:first-child { grid-column: 1; grid-row: 1; }
  .featured-result > span:last-child { grid-column: 1; grid-row: 2; }
  .featured-result > strong { grid-column: 2; grid-row: 1 / span 2; align-self: center; min-width: 2.125rem; }
  .featured-result > span::before { content: ''; display: inline-block; flex: 0 0 0.4375rem; width: 0.4375rem; height: 0.4375rem; border: 1px solid #64748b; border-radius: 50%; background: #fff; }
  .featured-result > span:last-child::before { background: #334155; }
}

.live-playing { font-size: 0.625rem; }

/* =========================================================================
   Site Footer
   ========================================================================= */
.site-footer { margin: 2.5rem 0 0; padding: 1.25rem 1.75rem 1.75rem; border-top: 1px solid #e2e8f0; color: #64748b; font-size: 0.8125rem; line-height: 1.5; }
.site-footer-inner { max-width: 1350px; margin: 0 auto; display: flex; flex-direction: column; gap: 0.5rem; }
.site-footer-links { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-start; gap: 0.15rem 1.25rem; max-width: 100%; min-width: 0; }
.site-footer-meta { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.4rem 1.5rem; padding-top: 0.55rem; border-top: 1px solid #edf2f7; }
.site-footer-legal { display: flex; flex-wrap: wrap; align-items: center; gap: 0.15rem 1.25rem; max-width: 100%; min-width: 0; }
.site-footer-copyright { margin: 0; color: #64748b; }
.site-footer-copyright a { color: inherit; text-decoration: none; }
.site-footer-copyright a:hover { text-decoration: underline; }
.site-footer-contact { display: inline-flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 0.25rem 0.5rem; min-height: 36px; max-width: 100%; text-decoration: none; }
.site-footer-contact-label { color: #007d68; font-weight: 600; text-underline-offset: 3px; }
.site-footer-email { color: #64748b; overflow-wrap: anywhere; min-width: 0; }
.site-footer-contact:hover .site-footer-contact-label { text-decoration: underline; }
.site-footer a:focus-visible { outline: 2px solid #008568; outline-offset: 4px; border-radius: 3px; }
.site-footer-policy { display: inline-flex; align-items: center; min-height: 36px; color: inherit; text-decoration: none; text-underline-offset: 3px; }
.site-footer-policy:hover { text-decoration: underline; color: #0f172a; }
.dark .site-footer { border-color: #374151; color: #9ca3af; }
.dark .site-footer-meta { border-color: #1f2937; }
.dark .site-footer-copyright { color: #9ca3af; }
.dark .site-footer-policy:hover { color: #f8fafc; }
.dark .site-footer-contact-label { color: #78d8bf; }
.dark .site-footer-email { color: #9ca3af; }
@media (max-width: 640px) {
  .site-footer { margin-top: 2rem; padding: 1.1rem 1rem 1.5rem; }
  .site-footer-links { justify-content: center; gap: 0.2rem 1rem; }
  .site-footer-meta { flex-direction: column; justify-content: center; text-align: center; gap: 0.35rem; }
  .site-footer-legal { justify-content: center; gap: 0.2rem 1rem; }
  .site-footer-contact { column-gap: 0.45rem; }
}

/* Theme toggle icons driven purely by html.dark from Frame 0 (zero blank-icon flash). */
#theme-toggle-dark-icon,
#theme-toggle-light-icon { display: none; }
html.dark #theme-toggle-dark-icon { display: block; }
html:not(.dark) #theme-toggle-light-icon { display: block; }

/* Reserve width for Sign in -> avatar transition without shifting header controls. */
.auth-header-slot { min-width: 74px; justify-content: flex-end; }

/* Prevent mobile navbar brand/search overlap on 360px-448px viewports. */
@container (max-width: 28rem) {
  .site-header > div { padding-left: 8px; padding-right: 8px; }
  .site-header .site-logo { margin-left: 2px; margin-right: 6px; }
  .site-header .site-logo img { width: 26px; height: 26px; margin-right: 6px; }
  .site-header .site-logo span { font-size: 1.0625rem; }
  .site-header .auth-header-slot { margin-left: 2px; min-width: 0; }
  .site-header .auth-signin-btn { padding: 0.35rem 0.6rem; font-size: 0.8125rem; }
  .site-header .auth-user-name { display: none; }
  .site-header .auth-user-btn { padding: 0.2rem; }
}
