/* ==========================================================================
   Responsive & Mobile-First PWA Stylesheet (css/responsive.css)
   스마트폰/태블릿 100% 핏 & 단일 컬럼 완벽 최적화
   ========================================================================== */

/* Tablet & Intermediate Screens (≤ 1024px) */
@media (max-width: 1024px) {
  .main-layout {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 100%;
    gap: 2rem;
    padding: 1rem 0 3rem;
  }

  .content-stream {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  .sidebar {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    gap: 1.5rem;
  }

  .sidebar-widget,
  #sidebar-dynamic-widget,
  #sidebar-ad-slot {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
  }

  .ad-banner-hero {
    flex-direction: column;
    text-align: center;
    padding: 1.2rem;
    gap: 0.8rem;
  }
}

/* Mobile & Small Screens (≤ 768px) */
@media (max-width: 768px) {
  html {
    font-size: 14px;
  }

  body {
    overflow-x: hidden !important;
    width: 100% !important;
    max-width: 100% !important;
  }

  .app-wrapper {
    overflow-x: hidden !important;
    width: 100% !important;
    max-width: 100vw !important;
  }

  .container {
    width: 100% !important;
    max-width: 100% !important;
    padding: 0 0.85rem !important;
    box-sizing: border-box !important;
  }

  /* 0. Mobile Bottom Safe Area (하단 고정 배너에 콘텐츠가 절대 가려지지 않도록 넉넉한 바닥 여백 확보) */
  .main-layout {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    gap: 1.5rem !important;
    padding: 0.6rem 0 130px !important;
    box-sizing: border-box !important;
  }

  .content-stream {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
  }

  .site-footer {
    padding-bottom: 140px !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }

  /* 1. Header & Brand */
  .site-header {
    height: 56px;
    width: 100% !important;
    max-width: 100% !important;
  }

  .header-inner {
    height: 56px;
    gap: 0.4rem;
    width: 100% !important;
  }

  .brand-logo {
    font-size: 1.2rem;
    gap: 0.35rem;
    flex-shrink: 0;
  }

  .brand-logo-icon {
    width: 30px;
    height: 30px;
    font-size: 0.95rem;
  }

  .search-container {
    flex: 1;
    max-width: 180px;
    min-width: 0;
  }

  .search-input {
    padding: 0.45rem 0.6rem 0.45rem 1.9rem;
    font-size: 0.8rem;
    width: 100%;
  }

  .search-icon {
    left: 0.55rem;
    font-size: 0.8rem;
  }

  .btn-icon {
    width: 34px;
    height: 34px;
    font-size: 0.95rem;
    flex-shrink: 0;
  }

  /* 2. Master Admin Bar */
  .admin-master-inner {
    flex-direction: column;
    align-items: stretch;
    gap: 0.4rem;
  }

  .admin-master-actions {
    width: 100%;
    display: flex;
    overflow-x: auto;
    padding-bottom: 2px;
    gap: 0.35rem;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .admin-master-actions::-webkit-scrollbar {
    display: none;
  }

  .btn-master-action {
    padding: 0.35rem 0.6rem;
    font-size: 0.75rem;
    white-space: nowrap;
    flex-shrink: 0;
  }

  /* 3. Ticker */
  .trend-ticker-bar {
    padding: 0.35rem 0;
    width: 100% !important;
  }

  .trend-ticker-inner {
    width: 100% !important;
    gap: 0.5rem;
  }

  .ticker-badge {
    font-size: 0.68rem;
    padding: 0.2rem 0.45rem;
    flex-shrink: 0;
  }

  .ticker-content {
    font-size: 0.75rem;
    gap: 0.8rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* 4. Category Tabs (가로 스크롤 매끄럽게) */
  .category-tabs-wrapper {
    display: flex !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    width: 100% !important;
    max-width: 100% !important;
    gap: 0.45rem !important;
    padding: 0.2rem 0 0.9rem !important;
    scrollbar-width: none;
  }

  .category-tabs-wrapper::-webkit-scrollbar {
    display: none;
  }

  .cat-tab-btn {
    padding: 0.45rem 0.85rem !important;
    font-size: 0.8rem !important;
    flex-shrink: 0 !important;
  }

  /* 5. Posts Grid & Cards (100% 단일 컬럼) */
  .posts-grid {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    gap: 1.2rem !important;
  }

  .post-card {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    border-radius: var(--radius-md);
    box-sizing: border-box !important;
  }

  .post-thumb-wrapper {
    height: 180px;
    width: 100%;
  }

  .post-card-body {
    padding: 1.1rem;
    width: 100%;
    box-sizing: border-box;
  }

  .post-card-title {
    font-size: 1.08rem;
    line-height: 1.45;
    word-break: keep-all;
    overflow-wrap: break-word;
  }

  .post-card-snippet {
    font-size: 0.85rem;
    line-height: 1.5;
    word-break: keep-all;
    overflow-wrap: break-word;
  }

  /* 6. Sidebar (모바일에서는 무조건 100% 너비 단일 세로 스택) */
  .sidebar {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    gap: 1.2rem !important;
  }

  .sidebar-widget,
  #sidebar-dynamic-widget,
  #sidebar-ad-slot {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
  }

  .tag-cloud-wrapper {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    width: 100%;
  }

  .tag-bubble {
    font-size: 0.78rem;
    padding: 0.28rem 0.6rem;
  }

  .ranking-list {
    width: 100%;
  }

  .ranking-item {
    width: 100%;
  }

  .ranking-title {
    font-size: 0.82rem;
  }

  /* 7. Mobile Native Bottom Sheet Modal */
  .detail-modal-overlay {
    padding: 0;
    align-items: flex-end;
  }

  .detail-modal-box {
    max-width: 100%;
    width: 100%;
    max-height: 92vh;
    border-radius: 22px 22px 0 0;
    border-bottom: none;
    padding-bottom: 2rem;
  }

  .modal-mobile-header-bar {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.8rem 1.1rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-glass);
    backdrop-filter: blur(14px);
  }

  .btn-close-modal {
    position: static;
    width: 32px;
    height: 32px;
    font-size: 1.1rem;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-glass);
  }

  .post-detail-hero {
    height: 190px;
  }

  .post-detail-content {
    padding: 1.2rem 1rem 4rem;
  }

  .post-detail-title {
    font-size: 1.35rem;
    line-height: 1.38;
    word-break: keep-all;
  }

  .summary-box {
    padding: 1rem;
    margin-bottom: 1.4rem;
  }

  .summary-list {
    padding-left: 1rem;
    font-size: 0.88rem;
    word-break: keep-all;
  }

  .post-detail-body {
    font-size: 0.96rem;
    word-break: keep-all;
  }

  .post-detail-body h3 {
    font-size: 1.18rem;
    margin: 1.5rem 0 0.6rem;
  }

  .affiliate-widget-card {
    flex-direction: column;
    text-align: center;
    padding: 1.2rem;
    gap: 0.9rem;
    margin: 1.5rem 0;
  }

  .affiliate-thumb {
    width: 90px;
    height: 90px;
  }

  .affiliate-product-title {
    font-size: 1rem;
    word-break: keep-all;
  }

  .affiliate-price-row {
    justify-content: center;
  }

  .affiliate-buy-btn {
    width: 100%;
    justify-content: center;
    padding: 0.75rem;
  }

  .post-interaction-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
  }

  .social-share-btns {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 0.4rem;
  }

  .btn-share {
    justify-content: center;
    padding: 0.6rem;
    font-size: 0.78rem;
  }

  /* 8. Mobile Bottom Floating Ad Bar */
  .bottom-floating-ad {
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
    height: 52px;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    z-index: 100;
  }

  .floating-ad-info {
    min-width: 0;
    flex: 1;
    overflow: hidden;
  }

  .floating-ad-info p {
    max-width: 160px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.76rem;
  }

  /* 9. PWA Install Banner for Mobile (하단 플로팅 배너 위에 깔끔하게 거치) */
  .pwa-install-banner {
    position: fixed;
    bottom: 58px;
    left: 0.6rem;
    right: 0.6rem;
    max-width: calc(100% - 1.2rem);
    z-index: 95;
    background: linear-gradient(135deg, #1e1b4b 0%, #4338ca 100%);
    color: #fff;
    padding: 0.55rem 0.8rem;
    border-radius: var(--radius-sm);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    box-sizing: border-box;
  }

  .form-row-2 {
    grid-template-columns: 1fr !important;
    gap: 0.6rem !important;
  }

  .policy-modal-box {
    padding: 1.4rem 1.1rem !important;
  }

  .policy-nav-tabs {
    gap: 0.35rem !important;
  }

  .policy-tab-btn {
    padding: 0.45rem 0.75rem !important;
    font-size: 0.78rem !important;
  }
}

@media (max-width: 440px) {
  .search-container {
    max-width: 120px;
  }

  .brand-logo span:not(.gradient-text) {
    display: inline;
  }

  .floating-ad-info p {
    max-width: 120px;
  }
}
