/*
 * app/static/css/layout.css
 *
 * Responsive layout styles for Toofan Express News.
 *
 * ALL values use var(--token-name) from tokens.css.
 * No hardcoded colors, font-family names, or pixel values that have a
 * corresponding design token.
 * Exception: media query breakpoints use px literals as required by the CSS spec.
 */


/* =========================================================================
   1. Global reset and base styles
   ========================================================================= */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-ui);
  color: var(--color-text);
  background: var(--color-surface);
  line-height: var(--leading-normal);
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* ── Article card images: strict 16:9, no portrait bleed ── */
.article-card__image-wrap,
.article-card-link {
  display: block;
  position: relative;
  width: 100%;
  padding-top: 56.25%;   /* 9/16 = 56.25% — bulletproof 16:9 hack */
  overflow: hidden;
  background: #e5e7eb;
}

.article-card__image-wrap > img,
.article-card__image-wrap > a > img,
.article-card__image,
.article-card-link > img,
.article-card-thumb {
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
  object-position: center !important;
  display: block !important;
}

a {
  color: inherit;
  text-decoration: none;
}

/* Screen-reader-only utility — hides visually but remains accessible */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}


/* =========================================================================
   2. Container utility
   ========================================================================= */

.container {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 var(--space-4);
}

@media (min-width: 768px) {
  .container {
    padding: 0 var(--space-6);
  }
}


/* =========================================================================
   3. Sticky site header
   ========================================================================= */

.site-header {
  position: sticky;
  top: 0;
  z-index: var(--z-header);
  background: var(--color-secondary);
  box-shadow: var(--shadow-md);
}

/* Utility bar (date, social links) */
.header-utility {
  background: rgba(0, 0, 0, 0.2);
  height: 32px;
  font-size: var(--text-xs);
  color: var(--color-text-inverse);
  display: flex;
  align-items: center;
}

.header-utility .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.utility-left {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

/* LIVE badge with blinking dot */
.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--color-primary);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  padding: 2px 7px 2px 5px;
  border-radius: 3px;
  text-transform: uppercase;
  flex-shrink: 0;
}

.live-dot {
  width: 6px;
  height: 6px;
  background: #fff;
  border-radius: 50%;
  display: inline-block;
  animation: live-blink 1.2s ease-in-out infinite;
}

@keyframes live-blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.15; }
}

#header-clock {
  color: var(--color-text-inverse);
  font-size: var(--text-xs);
  opacity: 0.85;
  font-family: var(--font-ui);
  letter-spacing: 0.3px;
}

.utility-date {
  color: var(--color-text-inverse);
  font-size: var(--text-xs);
  opacity: 0.8;
}

.utility-social {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.social-link {
  color: var(--color-text-inverse);
  font-size: var(--text-xs);
  opacity: 0.75;
  transition: opacity var(--transition-fast);
}

.social-link:hover {
  opacity: 1;
}

/* Main header row: logo + search */
.header-main {
  background: var(--color-secondary);
  padding: var(--space-3) 0;
}

.header-main-inner {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

/* Logo */
.site-logo {
  text-decoration: none;
  flex-shrink: 0;
}

.logo-text-main {
  font-family: var(--font-headline);
  font-weight: var(--weight-black);
  font-size: var(--text-2xl);
  color: var(--color-primary);
  letter-spacing: 2px;
}

.logo-text-sub {
  font-family: var(--font-ui);
  font-weight: var(--weight-semibold);
  font-size: var(--text-sm);
  color: var(--color-accent);
  letter-spacing: 4px;
  display: block;
}

/* Search bar */
.header-search {
  display: flex;
  margin-left: auto;
  gap: var(--space-2);
}

.search-input {
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-border-dark);
  background: rgba(255, 255, 255, 0.1);
  color: var(--color-text-inverse);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-family: var(--font-ui);
  width: 240px;
  outline: none;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}

.search-input::placeholder {
  color: rgba(255, 255, 255, 0.5);
}

.search-input:focus {
  background: rgba(255, 255, 255, 0.15);
  border-color: var(--color-accent);
}

.search-btn {
  background: var(--color-primary);
  color: var(--color-text-inverse);
  border: none;
  padding: var(--space-2);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
}

.search-btn:hover {
  background: var(--color-primary-dark);
}

/* Hamburger button — hidden on desktop, shown on mobile */
.hamburger-btn {
  display: none;
}


/* =========================================================================
   4. Navigation bar
   ========================================================================= */

.header-nav {
  background: var(--color-surface-dark);
  border-top: 1px solid var(--color-border-dark);
}

.nav-list {
  display: flex;
  list-style: none;
  gap: 0;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.nav-list::-webkit-scrollbar {
  display: none;
}

.nav-link {
  display: block;
  padding: var(--space-3) var(--space-4);
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  font-family: var(--font-ui);
  text-decoration: none;
  white-space: nowrap;
  transition: color var(--transition-fast);
  border-bottom: 3px solid transparent;
}

.nav-link:hover,
.nav-link--active {
  color: var(--color-text-inverse);
  border-bottom: 3px solid var(--color-primary);
}


/* =========================================================================
   5. Breaking news ticker
   ========================================================================= */

.ticker-bar {
  display: flex;
  align-items: center;
  background: var(--color-ticker-bg);
  color: var(--color-ticker-text);
  height: 38px;
  overflow: hidden;
}

.ticker-label {
  background: var(--color-primary-dark);
  padding: 0 var(--space-4);
  height: 100%;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.ticker-label-text {
  font-family: var(--font-ui);
  font-weight: var(--weight-bold);
  font-size: var(--text-xs);
  letter-spacing: 1px;
  color: var(--color-ticker-text);
  text-transform: uppercase;
  white-space: nowrap;
}

.ticker-track {
  flex: 1;
  overflow: hidden;
  display: flex;
  align-items: center;
  position: relative;
}

.ticker-content {
  display: inline-flex;
  white-space: nowrap;
  animation: ticker-scroll 60s linear infinite;
}

@keyframes ticker-scroll {
  0%   { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

.ticker-text {
  font-size: var(--text-sm);
  font-family: var(--font-ui);
  color: var(--color-ticker-text);
  white-space: nowrap;
  display: inline-block;
}

.ticker-separator {
  font-size: var(--text-sm);
  font-family: var(--font-ui);
  color: var(--color-accent);
  white-space: nowrap;
  display: inline-block;
  padding: 0 var(--space-3);
}


/* =========================================================================
   6. Page layout (desktop: main content + sidebar)
   ========================================================================= */

.page-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--sidebar-width);
  gap: var(--space-8);
  max-width: var(--container-max);
  margin: auto;
  padding: var(--space-8) var(--space-6);
}

.main-content {
  min-width: 0;
}

.sidebar {
  min-width: 0;
}


/* =========================================================================
   7. Article grid
   ========================================================================= */

.article-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-6);
}

.article-grid--2col {
  grid-template-columns: repeat(2, 1fr);
}


/* =========================================================================
   8. Mobile nav overlay
   ========================================================================= */

.mobile-nav-overlay {
  position: fixed;
  inset: 0;
  background: var(--color-overlay);
  z-index: var(--z-overlay);
  display: none;
}

.mobile-nav-overlay.is-open {
  display: flex;
}

.mobile-nav-inner {
  background: var(--color-surface-dark);
  width: 280px;
  height: 100%;
  padding: var(--space-6);
  overflow-y: auto;
}

.mobile-nav-close {
  background: none;
  border: none;
  color: var(--color-text-inverse);
  font-size: var(--text-2xl);
  cursor: pointer;
  margin-bottom: var(--space-6);
  display: block;
}

.mobile-nav-list {
  list-style: none;
}

.mobile-nav-link {
  display: block;
  padding: var(--space-4) 0;
  color: var(--color-text-inverse);
  text-decoration: none;
  font-size: var(--text-lg);
  font-family: var(--font-ui);
  border-bottom: 1px solid var(--color-border-dark);
  transition: color var(--transition-fast);
}

.mobile-nav-link:hover {
  color: var(--color-accent);
}


/* =========================================================================
   9. Section headers
   ========================================================================= */

.section-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-6);
  padding-bottom: var(--space-3);
  border-bottom: 2px solid var(--color-primary);
}

.section-header__title {
  font-family: var(--font-headline);
  font-size: var(--text-2xl);
  font-weight: var(--weight-bold);
  color: var(--color-text);
}

/* Legacy alias kept for compatibility */
.section-title {
  font-family: var(--font-headline);
  font-size: var(--text-2xl);
  font-weight: var(--weight-bold);
  color: var(--color-text);
}

.section-link {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-primary);
  margin-left: auto;
  transition: color var(--transition-fast);
}

.section-link:hover {
  color: var(--color-primary-dark);
}


/* =========================================================================
   10. Footer
   ========================================================================= */

.site-footer {
  background: var(--color-surface-dark);
  color: var(--color-text-inverse);
  margin-top: var(--space-16);
}

.footer-top {
  padding: var(--space-12) 0 var(--space-8);
}

.footer-top-inner {
  display: grid;
  grid-template-columns: 1.8fr repeat(4, 1fr);
  gap: var(--space-8);
  align-items: start;
}

.footer-brand {
  max-width: 300px;
}

/* Footer logo — same styling as header logo */
.footer-logo-link {
  text-decoration: none;
  display: inline-block;
  margin-bottom: var(--space-3);
}

.footer-tagline {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  line-height: var(--leading-relaxed);
  margin-top: var(--space-3);
}

.footer-nav-heading {
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--color-accent);
  margin-bottom: var(--space-3);
}

.footer-nav-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

/* Scrollable variant for long lists (States & UTs — 36 items) */
.footer-nav-list--scroll {
  max-height: 260px;
  overflow-y: auto;
  padding-right: var(--space-2);
  scrollbar-width: thin;
  scrollbar-color: var(--color-border-dark) transparent;
}

.footer-nav-list--scroll::-webkit-scrollbar {
  width: 4px;
}

.footer-nav-list--scroll::-webkit-scrollbar-track {
  background: transparent;
}

.footer-nav-list--scroll::-webkit-scrollbar-thumb {
  background: var(--color-border-dark);
  border-radius: 2px;
}

.footer-link,
.footer-legal-link {
  color: var(--color-text-muted);
  text-decoration: none;
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
  transition: color var(--transition-fast);
}

.footer-link:hover,
.footer-legal-link:hover {
  color: var(--color-text-inverse);
}

.footer-bottom {
  border-top: 1px solid var(--color-border-dark);
  padding: var(--space-4) 0;
}

.footer-bottom-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.footer-copyright {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.footer-legal-links {
  display: flex;
  gap: var(--space-4);
}


/* =========================================================================
   11. Pagination
   ========================================================================= */

.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-8) 0;
  margin-top: var(--space-6);
}

.pagination-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-text);
  background: var(--color-surface);
  transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
  text-decoration: none;
}

.pagination-btn:hover,
.pagination-btn--active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: var(--color-text-inverse);
}

.pagination-btn:disabled,
.pagination-btn[disabled] {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}


/* =========================================================================
   12. Utility / misc
   ========================================================================= */

.text-muted {
  color: var(--color-text-muted);
}

.text-sm {
  font-size: var(--text-sm);
}


/* =========================================================================
   13. Responsive breakpoints
   ========================================================================= */

/* --- Mobile: ≤ 767px --- */
@media (max-width: 767px) {

  /* Show hamburger button — minimum 44×44px touch target */
  .hamburger-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    width: 44px;
    height: 44px;
    background: transparent;
    border: 1px solid var(--color-border-dark);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: var(--text-xl);
    color: var(--color-text-inverse);
    flex-shrink: 0;
  }

  /* Hide desktop search and utility bar on mobile */
  .header-search {
    display: none;
  }

  .header-utility {
    display: none;
  }

  /* Page layout: single column, no sidebar */
  .page-layout {
    grid-template-columns: 1fr;
    padding: var(--space-4);
  }

  .sidebar {
    display: none;
  }

  /* Article grids collapse to single column */
  .article-grid {
    grid-template-columns: 1fr;
  }

  .article-grid--2col {
    grid-template-columns: 1fr;
  }

  /* Footer: 2 columns on mobile with brand spanning full width */
  .footer-top-inner {
    grid-template-columns: 1fr 1fr;
  }

  .footer-brand {
    grid-column: 1 / -1;
  }

  .footer-bottom-inner {
    flex-direction: column;
    gap: var(--space-2);
    text-align: center;
  }
}

/* --- Tablet: 768px – 1023px --- */
@media (min-width: 768px) and (max-width: 1023px) {

  /* Two-column article grid on tablet */
  .article-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Sidebar hidden on tablet, full-width layout */
  .page-layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    display: none;
  }

  .footer-top-inner {
    grid-template-columns: 1fr 1fr;
    gap: var(--space-6);
  }

  .footer-brand {
    grid-column: 1 / -1;
  }
}


/* =========================================================================
   14. Dropdown navigation (States / Cities)
   ========================================================================= */

/* nav item with dropdown */
.nav-item--dropdown {
  position: relative;
}

.nav-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  background: var(--color-surface-dark);
  border: 1px solid var(--color-border-dark);
  border-top: 2px solid var(--color-primary);
  min-width: 200px;
  max-height: 420px;
  overflow-y: auto;
  z-index: calc(var(--z-header) + 10);
  list-style: none;
  padding: var(--space-2) 0;
  box-shadow: var(--shadow-lg);
  scrollbar-width: thin;
  scrollbar-color: var(--color-border-dark) transparent;
}

/* For dropdowns near the right edge, open to the left */
.nav-item--dropdown:last-child .nav-dropdown,
.nav-item--dropdown:nth-last-child(2) .nav-dropdown {
  left: auto;
  right: 0;
}

.nav-item--dropdown:hover .nav-dropdown,
.nav-item--dropdown:focus-within .nav-dropdown {
  display: block;
}

.nav-dropdown-link {
  display: block;
  padding: var(--space-2) var(--space-4);
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  font-family: var(--font-ui);
  text-decoration: none;
  white-space: nowrap;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.nav-dropdown-link:hover {
  background: rgba(255,255,255,0.08);
  color: var(--color-text-inverse);
}

/* Mobile section headings in nav overlay */
.mobile-nav-section-heading {
  display: block;
  padding: var(--space-3) 0 var(--space-1);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--color-accent);
  font-family: var(--font-ui);
  border-top: 1px solid var(--color-border-dark);
  margin-top: var(--space-2);
}

.mobile-nav-link--sub {
  font-size: var(--text-base);
  padding: var(--space-3) var(--space-4);
  color: rgba(255,255,255,0.7);
  border-bottom-color: rgba(255,255,255,0.08);
}

/* Footer: 5 columns — brand + Categories + States + Cities + Company */


/* =========================================================================
   Mobile App Experience — PWA-style bottom nav for screens < 768px
   ========================================================================= */

@media (max-width: 767px) {
  /* Bottom navigation bar */
  .mobile-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: var(--color-secondary);
    border-top: 1px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    justify-content: space-around;
    z-index: 150;
    padding: 0 var(--space-2);
  }

  .mobile-bottom-nav__item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    color: rgba(255,255,255,0.6);
    text-decoration: none;
    font-size: 10px;
    font-family: var(--font-ui);
    font-weight: 500;
    padding: var(--space-2);
    min-width: 48px;
    text-align: center;
    transition: color 0.15s;
  }

  .mobile-bottom-nav__item--active,
  .mobile-bottom-nav__item:hover {
    color: var(--color-primary);
  }

  .mobile-bottom-nav__icon {
    width: 22px;
    height: 22px;
  }

  /* Add padding to body so content is not hidden behind bottom nav */
  body {
    padding-bottom: 60px;
  }

  /* Compact header on mobile */
  .header-main {
    padding: var(--space-2) 0;
  }
}

/* Hide bottom nav on desktop */
@media (min-width: 768px) {
  .mobile-bottom-nav {
    display: none !important;
  }
}

/* =========================================================================
   Language Selector
   ========================================================================= */

.lang-selector { position: relative; }

.lang-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 4px;
  color: var(--color-text-inverse);
  font-size: var(--text-xs);
  font-family: var(--font-ui);
  padding: 3px 7px;
  cursor: pointer;
  transition: background 0.15s;
}

.lang-btn:hover { background: rgba(255,255,255,0.2); }

.lang-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--color-surface-dark);
  border: 1px solid var(--color-border-dark);
  border-radius: 6px;
  min-width: 140px;
  box-shadow: var(--shadow-lg);
  z-index: calc(var(--z-header) + 20);
  overflow: hidden;
}

.lang-option {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 14px;
  font-size: var(--text-sm);
  font-family: var(--font-ui);
  color: var(--color-text-muted);
  background: none;
  border: none;
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
}

.lang-option:hover {
  background: rgba(255,255,255,0.08);
  color: var(--color-text-inverse);
}

/* Reading progress bar for article pages */
.reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  background: var(--color-primary);
  z-index: 999;
  width: 0%;
  transition: width 0.1s;
}
