/* ==========================================================================
   HotTea Official Website - Advanced Mobile & Responsive Stylesheet
   Meticulously optimized for iPhones (SE up to 16/17 Pro Max), Android,
   tablets, safe areas, touch targets, and mobile keyboards.
   ========================================================================== */

/* Base Viewport & Touch Safeguards */
html, body {
  overflow-x: hidden;
  width: 100%;
  max-width: 100vw;
  -webkit-text-size-adjust: 100%;
}

/* Touch Target Minimum (44x44px for accessible mobile ergonomics) */
button, 
.btn, 
.nav-link, 
.cli-tab-btn, 
.copy-btn {
  touch-action: manipulation;
}

/* ==========================================================================
   Large Tablets & Laptops (<= 1024px)
   ========================================================================== */
@media (max-width: 1024px) {
  .hero-title {
    font-size: clamp(2.5rem, 5vw, 3.25rem);
  }

  .mockup-viewport {
    grid-template-columns: 1fr 260px;
  }

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

  .docs-layout {
    grid-template-columns: 240px 1fr;
    gap: 32px;
  }

  .docs-toc {
    display: none;
  }
}

/* ==========================================================================
   Tablets & Mobile Viewports (<= 768px)
   ========================================================================== */
@media (max-width: 768px) {
  /* Site Header & Mobile Navigation */
  .site-header {
    height: 64px;
    padding-top: env(safe-area-inset-top);
  }

  .mobile-menu-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
  }

  .nav-menu {
    position: fixed;
    top: calc(64px + env(safe-area-inset-top));
    left: 0;
    right: 0;
    background: rgba(19, 21, 28, 0.98);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-strong);
    display: flex;
    flex-direction: column;
    padding: 20px 24px 32px 24px;
    gap: 6px;
    box-shadow: 0 16px 32px rgba(0, 0, 0, 0.8);
    z-index: 99;
    max-height: calc(100vh - 70px);
    overflow-y: auto;
    transform: translateY(-110%);
    opacity: 0;
    visibility: hidden;
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s ease, visibility 0.28s;
  }

  [data-theme="light"] .nav-menu {
    background: rgba(255, 255, 255, 0.98);
  }

  .nav-menu.open {
    transform: translateY(0);
    opacity: 1;
    visibility: visible;
  }

  .nav-link {
    font-size: 1.05rem;
    font-weight: 600;
    width: 100%;
    padding: 12px 14px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 48px;
  }

  .nav-link:hover, .nav-link.active {
    background: var(--bg-tertiary);
    color: var(--accent-primary);
  }

  /* Section Spacing on Mobile */
  .section {
    padding: 56px 0;
  }

  .section-header {
    margin-bottom: 40px;
  }

  .section-title {
    font-size: clamp(1.75rem, 4vw, 2.1rem);
  }

  .section-subtitle {
    font-size: 1rem;
    line-height: 1.55;
  }

  /* Hero Section */
  .hero-section {
    padding: 48px 0 36px 0;
  }

  .hero-title {
    font-size: clamp(2.1rem, 6.5vw, 2.75rem);
    letter-spacing: -0.025em;
  }

  .hero-description {
    font-size: 1.05rem;
    line-height: 1.6;
    margin-bottom: 28px;
    padding: 0 8px;
  }

  .hero-actions {
    flex-direction: column;
    width: 100%;
    max-width: 340px;
    margin: 0 auto 40px auto;
    gap: 12px;
  }

  .hero-actions .btn {
    width: 100%;
    min-height: 48px;
    font-size: 1rem;
  }

  /* Browser Mockup on Mobile */
  .mockup-wrapper {
    margin: 0 4px;
  }

  .mockup-viewport {
    grid-template-columns: 1fr;
  }

  .mockup-webview {
    padding: 20px;
    border-right: none;
    border-bottom: 1px solid var(--border-subtle);
  }

  .mockup-sidebar {
    padding: 16px;
    background: var(--bg-tertiary);
  }

  .mockup-titlebar {
    padding: 0 12px;
    height: 38px;
  }

  .mockup-tab-strip {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .mockup-tab-strip::-webkit-scrollbar {
    display: none;
  }

  .mockup-tab {
    padding: 4px 10px;
    font-size: 0.72rem;
    white-space: nowrap;
  }

  .mockup-toolbar {
    padding: 8px 12px;
  }

  .mockup-addressbar {
    font-size: 0.78rem;
    padding: 0 10px;
    height: 34px;
    overflow: hidden;
  }

  .mockup-addressbar span:nth-child(3) {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* Grids Stack cleanly */
  .feature-grid, 
  .privacy-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .feature-card,
  .privacy-card {
    padding: 22px;
  }

  .platform-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
  }

  .platform-card {
    padding: 20px 14px;
  }

  .platform-icon {
    width: 40px;
    height: 40px;
    margin-bottom: 10px;
  }

  .platform-name {
    font-size: 1.05rem;
  }

  /* Architecture Diagram on Mobile */
  .arch-diagram {
    padding: 20px;
  }

  .arch-components {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .arch-node {
    padding: 10px 12px;
  }

  /* Downloads Portal on Mobile */
  .empty-release-banner {
    flex-direction: column;
    text-align: center;
    padding: 24px 20px;
    gap: 16px;
  }

  .empty-release-actions {
    justify-content: center;
    width: 100%;
  }

  .empty-release-actions .btn {
    width: 100%;
  }

  .download-cards-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .cli-tabs {
    padding-bottom: 6px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .cli-tabs::-webkit-scrollbar {
    display: none;
  }

  .cli-tab-btn {
    padding: 8px 14px;
    font-size: 0.85rem;
  }

  /* Contributors Grid on Mobile */
  .contributors-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .contributor-card, 
  .contributor-cta-card {
    padding: 18px;
  }

  .contributor-avatar, 
  .contributor-cta-icon {
    width: 48px;
    height: 48px;
  }

  /* Documentation Hub on Mobile */
  .docs-layout {
    grid-template-columns: 1fr;
    gap: 0;
    padding-top: 16px;
  }

  .docs-sidebar {
    position: static;
    max-height: none;
    margin-bottom: 28px;
    border-bottom: 1px solid var(--border-subtle);
    padding-bottom: 24px;
    padding-right: 0;
  }

  .docs-search-input {
    /* 16px base font-size prevents unwanted iOS Safari zoom */
    font-size: 16px !important;
    height: 46px;
  }

  .docs-title {
    font-size: 2rem;
  }

  .docs-header {
    padding-bottom: 16px;
    margin-bottom: 24px;
  }

  .docs-body h2 {
    font-size: 1.5rem;
    margin-top: 36px;
  }

  .docs-body h3 {
    font-size: 1.15rem;
    margin-top: 24px;
  }

  .docs-table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
  }

  /* Terminal Blocks on Mobile */
  .terminal-block {
    margin: 16px 0;
  }

  .terminal-body {
    padding: 14px;
    font-size: 0.82rem;
    line-height: 1.6;
  }

  .terminal-line {
    gap: 8px;
  }

  /* Footer on Mobile */
  .site-footer {
    padding: 48px 0 calc(24px + env(safe-area-inset-bottom)) 0;
  }

  .footer-grid {
    grid-template-columns: 1fr;
    gap: 28px;
    margin-bottom: 36px;
  }

  .footer-bottom {
    flex-direction: column;
    gap: 10px;
    text-align: center;
    font-size: 0.78rem;
  }
}

/* ==========================================================================
   Small Mobile Screens (<= 480px, e.g. iPhone SE, mini, compact phones)
   ========================================================================== */
@media (max-width: 480px) {
  .container {
    padding-left: 16px;
    padding-right: 16px;
  }

  .brand-link span {
    font-size: 1.15rem;
  }

  .brand-badge {
    display: none; /* Hide badge on very small screens to preserve navbar space */
  }

  .hero-title {
    font-size: 1.95rem;
  }

  .hero-badge {
    font-size: 0.75rem;
    padding: 5px 12px;
  }

  .platform-grid {
    grid-template-columns: 1fr; /* Single column on narrow phones */
  }

  .btn-lg {
    padding: 12px 20px;
  }

  .callout-box {
    padding: 16px 18px;
  }
}

/* ==========================================================================
   Smallest Devices (<= 360px)
   ========================================================================== */
@media (max-width: 360px) {
  .hero-title {
    font-size: 1.75rem;
  }

  .section-title {
    font-size: 1.5rem;
  }

  .hero-actions .btn {
    font-size: 0.9rem;
    padding: 10px 16px;
  }
}
