/* ==========================================================================
   Technoblade Wiki — layout.css
   Page chrome: header, search, sidebar, drawer overlay, footer and the
   responsive content grid. Footer is pinned to the bottom via flex layout
   (see body rules in style.css).
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Header
   -------------------------------------------------------------------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  min-height: var(--header-height);
  padding-block: var(--space-2);
}

/* Brand / logo */
.brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  color: var(--color-heading);
  flex-shrink: 0;
}

.brand:hover {
  text-decoration: none;
  color: var(--color-heading);
}

.brand-logo {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
}

.brand-name {
  display: block;
  font-size: var(--text-md);
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
}

.brand-tagline {
  display: block;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  line-height: 1.3;
  white-space: nowrap;
}

/* Header search */
.header-search {
  position: relative;
  flex: 1 1 auto;
  max-width: 460px;
  min-width: 0;
}

.search-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 0.75rem;
  width: 16px;
  height: 16px;
  color: var(--color-text-muted);
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 0.5rem 2.25rem 0.5rem 2.4rem;
  font-size: var(--text-sm);
  background-color: var(--color-bg-subtle);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.search-input:focus {
  outline: none;
  border-color: var(--color-accent);
  background-color: var(--color-surface);
}

.search-input::-webkit-search-cancel-button {
  cursor: pointer;
}

.search-kbd {
  position: absolute;
  right: 0.6rem;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 0 0.4rem;
  background-color: var(--color-surface);
  pointer-events: none;
  display: none;
}

@media (min-width: 768px) {
  .search-kbd {
    display: inline;
  }
}

/* Search results dropdown */
.search-panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  max-height: 380px;
  overflow-y: auto;
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  z-index: 110;
}

.search-panel[hidden] {
  display: none;
}

.search-result {
  border-bottom: 1px solid var(--color-border);
}

.search-result:last-child {
  border-bottom: none;
}

.search-result a {
  display: block;
  padding: var(--space-3) var(--space-4);
  color: inherit;
}

.search-result a:hover,
.search-result a.is-active {
  background-color: var(--color-bg-muted);
  text-decoration: none;
}

.result-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: 2px;
}

.result-title {
  font-weight: 600;
  font-size: var(--text-sm);
  color: var(--color-heading);
}

.result-category {
  flex-shrink: 0;
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--color-accent);
  background-color: var(--color-accent-soft);
  border: 1px solid var(--color-accent-border);
  border-radius: 999px;
  padding: 0.05rem 0.5rem;
}

.result-desc {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  line-height: 1.45;
}

.search-empty {
  padding: var(--space-4);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.search-empty strong {
  color: var(--color-heading);
}

.search-empty .search-empty-links {
  margin-top: var(--space-2);
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

/* Header primary nav */
.header-nav {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin-left: auto;
  flex-shrink: 0;
}

.header-nav a {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text);
  padding: 0.35rem 0.1rem;
  border-bottom: 2px solid transparent;
}

.header-nav a:hover {
  color: var(--color-accent);
  text-decoration: none;
  border-bottom-color: var(--color-accent);
}

.header-nav a[aria-current="page"] {
  color: var(--color-accent);
  border-bottom-color: var(--color-accent);
}

/* Icon buttons (theme toggle, mobile menu) */
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  color: var(--color-text);
  border: 1px solid transparent;
  flex-shrink: 0;
}

.icon-button:hover {
  background-color: var(--color-bg-muted);
  color: var(--color-accent);
}

.icon-button svg {
  width: 20px;
  height: 20px;
}

/* Theme toggle: show sun in dark mode, moon in light mode */
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }

[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* Hamburger is hidden on desktop */
.nav-toggle { display: none; }

/* --------------------------------------------------------------------------
   2. Body grid: sidebar + main
   -------------------------------------------------------------------------- */
.site-body {
  flex: 1 0 auto;
}

.layout-grid {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  gap: var(--space-6);
  padding-block: var(--space-5) var(--space-7);
  align-items: start;
}

/* Sidebar */
.sidebar {
  position: sticky;
  top: calc(var(--header-height) + 16px);
  max-height: calc(100vh - var(--header-height) - 32px);
  overflow-y: auto;
  padding-right: var(--space-2);
}

.sidebar-section {
  margin-bottom: var(--space-5);
}

.sidebar-title {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
  border-bottom: 1px solid var(--color-border);
  padding-bottom: var(--space-2);
  margin-bottom: var(--space-2);
}

.sidebar-list li + li {
  border-top: 1px solid transparent;
}

.sidebar-link {
  display: block;
  padding: 0.4rem 0.6rem;
  margin-inline: -0.6rem;
  font-size: var(--text-sm);
  color: var(--color-text);
  border-left: 3px solid transparent;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.sidebar-link:hover {
  color: var(--color-accent);
  background-color: var(--color-bg-subtle);
  text-decoration: none;
}

.sidebar-link[aria-current="page"] {
  color: var(--color-accent);
  font-weight: 600;
  background-color: var(--color-accent-soft);
  border-left-color: var(--color-accent);
}

.sidebar-note {
  background-color: var(--color-bg-subtle);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  line-height: 1.5;
}

.sidebar-note-title {
  font-weight: 600;
  color: var(--color-heading);
  margin-bottom: var(--space-1);
}

.sidebar-note a {
  font-weight: 600;
}

/* Drawer overlay (mobile only) */
.sidebar-overlay {
  display: none;
}

/* --------------------------------------------------------------------------
   3. Footer (stays pinned to the bottom of every page)
   -------------------------------------------------------------------------- */
.site-footer {
  flex-shrink: 0;
  margin-top: auto;
  background-color: var(--color-bg-subtle);
  border-top: 1px solid var(--color-border);
}

.footer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-6);
  padding-block: var(--space-6) var(--space-5);
}

.footer-brand .footer-logo {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: 700;
  color: var(--color-heading);
  margin-bottom: var(--space-2);
}

.footer-brand .footer-logo svg {
  width: 22px;
  height: 22px;
}

.footer-tagline {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  max-width: 30ch;
}

.footer-title {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-heading);
  margin-bottom: var(--space-3);
}

.footer-list li + li {
  margin-top: var(--space-2);
}

.footer-list a {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.footer-list a:hover {
  color: var(--color-accent);
}

.footer-bottom {
  border-top: 1px solid var(--color-border);
  padding-block: var(--space-4);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.footer-bottom p + p {
  margin-top: var(--space-1);
}

.footer-memorial {
  font-style: italic;
}

/* --------------------------------------------------------------------------
   4. Responsive breakpoints
   -------------------------------------------------------------------------- */

/* Below 1024px: sidebar becomes an off-canvas drawer */
@media (max-width: 1023.98px) {
  .header-nav {
    display: none;
  }

  .nav-toggle {
    display: inline-flex;
  }

  .layout-grid {
    display: block;
    padding-block: var(--space-5) var(--space-7);
  }

  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(320px, 86vw);
    max-height: none;
    z-index: 120;
    background-color: var(--color-bg);
    border-right: 1px solid var(--color-border);
    padding: var(--space-5) var(--space-4);
    transform: translateX(-103%);
    transition: transform 0.25s ease;
    overscroll-behavior: contain;
  }

  body.nav-open .sidebar {
    transform: none;
    box-shadow: var(--shadow-md);
  }

  .sidebar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 110;
    background-color: rgba(0, 0, 0, 0.45);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
  }

  body.nav-open .sidebar-overlay {
    opacity: 1;
    pointer-events: auto;
  }
}

/* Brand tagline only fits on wide screens */
@media (max-width: 1079.98px) {
  .brand-tagline {
    display: none;
  }
}

/* Below 768px: search moves to its own full-width row */
@media (max-width: 767.98px) {
  .header-inner {
    flex-wrap: wrap;
    row-gap: var(--space-2);
    padding-block: var(--space-3);
  }

  .header-search {
    order: 3;
    flex-basis: 100%;
    max-width: none;
  }

  .footer-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 479.98px) {
  .footer-grid {
    grid-template-columns: 1fr;
  }
}
