﻿/* ==========================================================================
   NotedPace - Responsive Styles & Mobile Navigation
   Screen breakpoints: 1200px, 992px, 768px, 576px
   ========================================================================== */

/* Mobile Drawer Overlay */
.mobile-nav-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(3, 7, 18, 0.85);
  backdrop-filter: blur(16px);
  z-index: 999;
  display: none;
  opacity: 0;
  transition: opacity var(--transition-normal);
}

.mobile-nav-backdrop.active {
  display: block;
  opacity: 1;
}

.mobile-nav-drawer {
  position: fixed;
  top: 0;
  right: -320px;
  width: 300px;
  height: 100vh;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border-medium);
  z-index: 1000;
  padding: 2rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  transition: right 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: var(--shadow-lg);
  overflow-y: auto;
}

.mobile-nav-drawer.active {
  right: 0;
}

.mobile-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-subtle);
}

.mobile-drawer-close {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
}

.mobile-nav-links {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.mobile-nav-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-md);
  font-weight: 600;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}

.mobile-nav-link:hover, .mobile-nav-link.active {
  background: rgba(139, 92, 246, 0.15);
  color: #ffffff;
}

.mobile-nav-footer {
  margin-top: auto;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* --- Breakpoint: 1200px --- */
@media (max-width: 1200px) {
  .hero-slide {
    min-height: 400px;
  }
  .hero-content {
    padding: 2.5rem 2.25rem 2.25rem 2.25rem;
  }
  .hero-title {
    font-size: 1.85rem;
  }
  .editorial-layout {
    grid-template-columns: 1.15fr 1fr;
    gap: 1.5rem;
  }
  .categories-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem 1.25rem;
  }
  .footer-top {
    grid-template-columns: 1.4fr 1fr 1fr 1fr;
    gap: 2rem;
  }
}

/* --- Compact desktop: full nav, but trimmed to avoid horizontal overflow --- */
@media (min-width: 901px) and (max-width: 1100px) {
  .header-container {
    gap: 1rem;
  }
  .nav-menu {
    gap: 1rem;
  }
  .search-kbd {
    display: none;
  }
  .search-trigger-btn {
    min-width: 150px;
    padding-left: 1rem;
    padding-right: 1rem;
  }
}

/* --- Breakpoint: 900px (Tablet & below) --- */
@media (max-width: 900px) {
  .nav-menu {
    display: none;
  }
  .search-kbd {
    display: none;
  }
  .mobile-menu-btn {
    display: flex;
  }
  .btn-admin-nav span {
    display: none;
  }
  
  .hero-slide {
    min-height: 390px;
  }
  .hero-content {
    padding: 2rem 1.5rem 2rem 1.5rem;
    max-width: 100%;
  }
  .hero-title {
    font-size: 1.55rem;
  }
  .hero-3d-chip {
    top: 1rem;
    right: 1rem;
    padding: 0.35rem 0.75rem;
  }
  .carousel-controls {
    bottom: 1.25rem;
    right: 1.25rem;
  }
  .carousel-indicators {
    bottom: 1.5rem;
    right: 6.25rem;
  }

  .editorial-layout {
    grid-template-columns: 1fr;
  }
  .featured-card-img-wrap {
    height: 260px;
  }

  .footer-top {
    grid-template-columns: 1fr 1fr;
    gap: 2.5rem;
  }
}

/* --- Breakpoint: 768px --- */
@media (max-width: 768px) {
  .announcement-bar {
    font-size: 0.775rem;
    padding: 0.4rem 0.75rem;
  }
  .announcement-badge {
    display: none;
  }

  .header-container {
    gap: 0.75rem;
  }

  .brand-name {
    font-size: 1.25rem;
  }

  .search-trigger-btn span {
    display: none;
  }
  .search-trigger-btn {
    padding: 0.45rem;
    border-radius: var(--radius-sm);
  }

  .hero-slide {
    min-height: 380px;
  }
  .hero-title {
    font-size: 1.35rem;
  }
  .hero-summary {
    font-size: 0.875rem;
    -webkit-line-clamp: 2;
  }
  .hero-content {
    padding: 1.5rem 1.25rem;
    gap: 0.65rem;
  }

  .section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

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

  /* Recent articles: compact 2-column grid on mobile */
  .recent-articles-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
  }
  .recent-articles-grid .article-card-cover {
    height: 105px;
  }
  .recent-articles-grid .article-card-badge {
    top: 0.5rem;
    left: 0.5rem;
  }
  .recent-articles-grid .article-bookmark-btn {
    width: 26px;
    height: 26px;
    top: 0.5rem;
    right: 0.5rem;
  }
  .recent-articles-grid .article-card-body {
    padding: 0.75rem;
    gap: 0.45rem;
  }
  .recent-articles-grid .article-card-title {
    font-size: 0.82rem;
  }
  .recent-articles-grid .article-card-summary {
    font-size: 0.72rem;
    line-height: 1.45;
    -webkit-line-clamp: 2;
  }
  .recent-articles-grid .article-card-footer {
    padding-top: 0.5rem;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.35rem;
  }
  .recent-articles-grid .article-card-meta {
    font-size: 0.66rem;
    gap: 0.3rem;
  }
  .recent-articles-grid .article-read-more {
    font-size: 0.66rem;
  }

  .categories-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 1.25rem 0.65rem;
  }
  .category-circle-disc {
    width: 88px;
    height: 88px;
    border-width: 2.5px;
  }
  .category-circle-badge {
    width: 28px;
    height: 28px;
    bottom: -1px;
    right: -1px;
  }
  .category-circle-badge svg {
    width: 13px;
    height: 13px;
  }
  .category-circle-name {
    font-size: 0.92rem;
  }
  .category-circle-count {
    font-size: 0.7rem;
    padding: 0.12rem 0.5rem;
  }
  .category-circle-card {
    padding: 1.1rem 0.4rem 0.95rem;
  }

  .side-article-card {
    grid-template-columns: 100px 1fr;
    gap: 1rem;
    padding: 1rem;
  }

  .newsletter-card {
    padding: 1rem 1.25rem;
    text-align: left;
  }
  .newsletter-content {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.45rem;
  }
  .newsletter-desc {
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }
  .newsletter-form {
    grid-column: auto;
    grid-row: auto;
    flex-direction: column;
    width: 100%;
    margin-top: 0.35rem;
  }
  .newsletter-status {
    grid-column: auto;
    grid-row: auto;
  }
  .newsletter-input-wrap, .newsletter-form .btn {
    width: 100%;
  }

  /* App-style fixed bottom navigation; hide footer on mobile */
  .mobile-bottom-nav {
    display: flex;
  }
  .site-footer {
    display: none;
  }
  body {
    padding-bottom: 4.25rem;
  }
  .mobile-nav-drawer {
    padding-bottom: 5rem;
  }

  .footer-top {
    grid-template-columns: 1fr;
    gap: 2rem;
  }
  .footer-bottom {
    flex-direction: column;
    gap: 1rem;
    text-align: center;
  }
}

/* --- Breakpoint: 480px --- */
@media (max-width: 480px) {
  .hero-slide {
    min-height: 360px;
  }
  .hero-content {
    padding: 1.25rem 1rem;
  }
  .hero-title {
    font-size: 1.18rem;
  }
  .categories-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1.25rem 0.75rem;
  }
  .category-circle-disc {
    width: 100px;
    height: 100px;
  }
  .category-circle-name {
    font-size: 1rem;
  }
  .category-circle-card {
    padding: 1.25rem 0.5rem 1rem;
  }
  .side-article-card {
    grid-template-columns: 1fr;
  }
  .side-article-thumb-wrap {
    height: 140px;
  }
}

/* ==========================================================================
   Mobile polish (<=768px)
   Header logo/search + hero carousel only. Desktop & tablet untouched.
   ========================================================================== */
@media (max-width: 768px) {
  /* The closed off-canvas drawer must not extend the document width */
  html,
  body {
    overflow-x: clip;
  }

  /* --- Header: logo mark instead of wordmark, compact icon actions --- */
  .site-header .brand-name {
    display: none;
  }
  .site-header .brand-logo {
    gap: 0;
    flex-shrink: 0;
  }
  .header-container {
    gap: 0.5rem;
    justify-content: space-between;
  }
  .header-actions {
    gap: 0.45rem;
  }

  /* Search bar becomes a clean single icon button.
     The existing click handler still opens the search modal. */
  .search-trigger-btn {
    flex: 0 0 40px;
    width: 40px;
    min-width: 0;
    height: 40px;
    padding: 0;
    gap: 0;
    justify-content: center;
    border-radius: 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
  }
  .search-trigger-btn svg {
    width: 18px;
    height: 18px;
  }
  .search-trigger-btn span,
  .search-trigger-btn .search-kbd {
    display: none;
  }

  /* --- Hero carousel: image-led, title + small category badge only --- */
  .hero-section {
    padding: 0.85rem 0 1.35rem;
    perspective: none;
  }
  .hero-section > .container {
    padding-left: 1rem;
    padding-right: 1rem;
  }
  .hero-carousel-wrapper {
    border-radius: 16px;
    box-shadow: 0 14px 30px -12px rgba(0, 0, 0, 0.65);
  }
  .hero-slide {
    min-height: 300px;
  }
  /* Graceful branded backdrop when a featured story has no cover image.
     (Missing covers currently render src="null" and would show raw alt text.) */
  .hero-bg-media {
    background:
      radial-gradient(circle at 18% 22%, rgba(139, 92, 246, 0.42), transparent 60%),
      radial-gradient(circle at 82% 72%, rgba(6, 182, 212, 0.32), transparent 62%),
      linear-gradient(160deg, #151b33 0%, #0b1020 100%);
  }
  .hero-bg-img[src="null"],
  .hero-bg-img[src=""],
  .hero-bg-img[src="undefined"],
  .hero-bg-img:not([src]) {
    display: none;
  }
  .hero-content {
    max-width: 100%;
    padding: 1.15rem 1.15rem 3.35rem;
    gap: 0.55rem;
  }
  .hero-3d-chip,
  .hero-summary,
  .hero-author,
  .hero-actions,
  .hero-meta-top .hero-reading-time,
  .hero-meta-top > span:not(.category-badge) {
    display: none;
  }
  .hero-meta-top {
    gap: 0.4rem;
  }
  .hero-meta-top .category-badge[data-empty="true"] {
    display: none;
  }
  .hero-meta-top .category-badge {
    font-size: 0.62rem;
    padding: 0.2rem 0.55rem;
    letter-spacing: 0.05em;
  }
  .hero-title {
    font-size: 1.2rem;
    line-height: 1.24;
    letter-spacing: -0.02em;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    overflow-wrap: break-word;
    text-shadow: 0 2px 12px rgba(0, 0, 0, 0.55);
  }
  .hero-title a {
    display: block;
  }

  /* Dots bottom-left, arrows bottom-right so they never sit on the text */
  .carousel-indicators {
    left: 1.15rem;
    right: auto;
    bottom: 1.05rem;
    gap: 0.35rem;
  }
  .indicator-dot {
    width: 16px;
    height: 3px;
  }
  .indicator-dot.active {
    width: 26px;
  }
  .carousel-controls {
    right: 1rem;
    bottom: 0.9rem;
    gap: 0.4rem;
  }
  .carousel-btn {
    width: 32px;
    height: 32px;
  }
  .carousel-btn svg {
    width: 16px;
    height: 16px;
  }

  /* Missing covers in article cards: no raw alt text, subtle gradient instead */
  .article-card-cover {
    background: linear-gradient(150deg, rgba(139, 92, 246, 0.28), rgba(6, 182, 212, 0.18) 55%, rgba(15, 23, 42, 0.4));
  }
  .article-card-cover img[src="null"],
  .article-card-cover img[src=""],
  .article-card-cover img[src="undefined"] {
    display: none;
  }
}

@media (max-width: 480px) {
  .hero-slide {
    min-height: 270px;
  }
  .hero-content {
    padding: 1rem 1rem 3.2rem;
  }
  .hero-title {
    font-size: 1.12rem;
  }
}