/* header.css - Top header with hamburger menu, search, and banner image */
:root {
  --bg: #000;
  --accent: #ffd400;
  --text: #ffffff;
  --muted: rgba(255, 255, 255, 0.7);
  --sidebar-width: 260px;
  --header-height: 60px;
}

/* ===== TOP HEADER ===== */
.top-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: var(--bg);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  z-index: 1001;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-height);
  padding: 0 20px;
}

/* Header Left - Hamburger + Title */
.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
}

.hamburger {
  display: flex;
  flex-direction: column;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  gap: 4px;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: background 0.2s;
}

.hamburger:hover {
  background: rgba(255, 255, 255, 0.05);
}

.hamburger span {
  width: 20px;
  height: 2px;
  background: var(--text);
  transition: all 0.3s ease;
  border-radius: 2px;
  display: block;
}

.hamburger[aria-expanded="true"] span:nth-child(1) {
  transform: rotate(45deg) translate(5px, 5px);
}

.hamburger[aria-expanded="true"] span:nth-child(2) {
  opacity: 0;
}

.hamburger[aria-expanded="true"] span:nth-child(3) {
  transform: rotate(-45deg) translate(5px, -5px);
}

.header-logo {
  display: flex;
  align-items: center;
  text-decoration: none;
  flex-shrink: 0;
}

.header-logo-img {
  height: 40px;
  width: auto;
  max-width: 180px;
  object-fit: contain;
  display: block;
}

/* Header Right - Search Button */
.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.search-container {
  position: relative;
}

.search-trigger {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text);
  width: 40px;
  height: 40px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 18px;
}

.search-trigger:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--accent);
}

/* ===== SEARCH PANEL ===== */
.search-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 12px);
  width: 450px;
  max-width: calc(100vw - 32px);
  background: rgba(10, 10, 10, 0.98);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
  transform-origin: top right;
  transform: scale(0.95);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.2s ease, opacity 0.2s ease;
  z-index: 1060;
}

.search-panel[hidden] {
  display: none !important;
}

.search-panel.open {
  transform: scale(1);
  opacity: 1;
  pointer-events: auto;
}

.search-panel-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.search-input {
  flex: 1;
  padding: 12px 16px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font-size: 15px;
  outline: none;
  transition: all 0.2s;
}

.search-input:focus {
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.08);
}

.search-close {
  background: rgba(255, 255, 255, 0.05);
  border: none;
  color: var(--text);
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 24px;
  transition: all 0.2s;
}

.search-close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--accent);
}

.search-results {
  max-height: 400px;
  overflow-y: auto;
  padding: 12px;
}

.search-result-item {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--text);
  transition: background 0.2s;
}

.search-result-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.story-cover {
  aspect-ratio: 2/3;
  width: 60px;
  object-fit: cover;
  border-radius: 6px;
  flex-shrink: 0;
}

.search-result-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 0;
}

.search-result-title {
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-result-sub {
  font-size: 12px;
  color: var(--muted);
}

/* ===== DESKTOP LAYOUT ===== */
@media (min-width: 769px) {
  .top-header {
    left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
  }
  
  main {
    margin-left: var(--sidebar-width);
    padding-top: var(--header-height);
  }
  
  /* Hide hamburger button on desktop */
  .hamburger {
    display: none !important;
  }
  
  /* Ensure sidebar is always visible and cannot be closed */
  .sidebar {
    transform: translateX(0) !important;
    visibility: visible !important;
    pointer-events: auto !important;
  }
  
  /* Hide sidebar overlay on desktop */
  .sidebar-overlay {
    display: none !important;
  }
  
  /* Prevent any transform animations on desktop */
  .sidebar.open {
    transform: translateX(0) !important;
  }
  
  /* Hide close button on desktop */
  .sidebar-close {
    display: none !important;
  }
}

/* ===== MOBILE RESPONSIVE ===== */
@media (max-width: 768px) {
  :root {
    --header-height: 56px;
  }
  
  .top-header {
    padding: 0 16px;
  }
  
  .header-left {
    gap: 12px;
  }
  
  .hamburger {
    width: 36px;
    height: 36px;
    padding: 6px;
    display: flex !important; /* Ensure hamburger is visible on mobile */
  }
  
  .hamburger span {
    width: 18px;
  }
  
  .header-logo-img {
    height: 32px;
    max-width: 120px;
  }
  
  .search-trigger {
    width: 36px;
    height: 36px;
    font-size: 16px;
  }
  
  /* Mobile: fullscreen search panel */
  .search-panel {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: 100%;
    height: 100%;
    border-radius: 0;
    background: rgba(0, 0, 0, 0.98);
    transform: translateX(100%);
    transition: transform 0.3s ease;
  }
  
  .search-panel.open {
    transform: translateX(0);
    opacity: 1;
  }
  
  .search-panel-inner {
    padding: 20px 16px;
    position: sticky;
    top: 0;
    background: rgba(0, 0, 0, 0.98);
    z-index: 1;
  }
  
  .search-input {
    font-size: 16px;
    padding: 14px 16px;
  }
  
  .search-close {
    width: 40px;
    height: 40px;
    font-size: 28px;
  }
  
  .search-results {
    max-height: calc(100vh - 80px);
    padding: 16px;
  }
  
  .search-result-item {
    padding: 14px;
    gap: 14px;
  }
  
  .story-cover {
    width: 70px;
  }
  
  .search-result-title {
    font-size: 15px;
    white-space: normal;
    word-break: break-word;
  }
  
  .search-result-sub {
    font-size: 13px;
  }
  
  /* Ensure sidebar overlay is visible on mobile */
  .sidebar-overlay {
    display: block !important;
  }
  
  /* Show close button on mobile */
  .sidebar-close {
    display: flex !important;
  }
}

@media (max-width: 480px) {
  .top-header {
    padding: 0 12px;
  }
  
  .header-logo-img {
    height: 28px;
    max-width: 100px;
  }
  
  .hamburger,
  .search-trigger {
    width: 32px;
    height: 32px;
  }
  
  .story-cover {
    width: 56px;
  }
}

/* ===== MAIN CONTENT OFFSET ===== */
main {
  padding-top: var(--header-height);
  margin-top: 0;
}

/* ===== ACCESSIBILITY ===== */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--accent);
  color: #000;
  padding: 8px 16px;
  z-index: 1002;
  text-decoration: none;
  font-weight: 600;
}

.skip-link:focus {
  top: 0;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}