/* public/css/mobile.css — Global mobile optimization stylesheet.
 * Owns: responsive fixes, touch UX, mobile performance for all breakpoints.
 * Does NOT own: page-specific component styles (those live inline in each EJS template).
 * Breakpoints: 320px (iPhone SE), 375px (iPhone 12), 390px (iPhone 14), 428px (iPhone 14 Pro Max), 768px (tablet)
 */

/* ===== BASE MOBILE FIXES ===== */

/* Prevent horizontal overflow globally */
html, body {
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}

/* Minimum readable body text on mobile */
@media (max-width: 768px) {
  body { font-size: 16px; }
}

/* Touch target minimum 44x44px — per Apple/Google HIG */
@media (max-width: 768px) {
  a, button, input[type="submit"], input[type="button"],
  select, [role="button"], .clickable {
    min-height: 44px;
    min-width: 44px;
  }
  /* Exception: inline text links shouldn't be forced to 44px height blocks */
  p a, span a, li a:not([class]), .footer-links a {
    min-height: auto;
    min-width: auto;
    padding-top: 0.3rem;
    padding-bottom: 0.3rem;
  }
}

/* ===== NAV MOBILE IMPROVEMENTS ===== */
@media (max-width: 768px) {
  .ys-nav-inner {
    padding: 0.65rem 1rem;
  }
  .ys-nav-wordmark {
    font-size: 0.95rem;
  }
  /* Ensure hamburger is always 44x44 touch target */
  .ys-hbg {
    width: 44px;
    height: 44px;
    padding: 10px;
  }
  /* Drawer links need adequate spacing */
  .ys-drawer-links li a {
    padding: 0.85rem 1rem;
    font-size: 1.05rem;
    min-height: 48px;
    display: flex;
    align-items: center;
  }
  .ys-drawer-cta {
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    padding: 0.85rem 1.5rem;
  }
  .ys-drawer-close {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
  }
}

/* ===== HERO MOBILE ===== */
@media (max-width: 768px) {
  .hero {
    min-height: auto;
    padding: 4rem 1.25rem 2.5rem;
  }
  .hero h1 {
    font-size: clamp(1.8rem, 8vw, 2.8rem);
    line-height: 1.1;
  }
  .hero-sub {
    font-size: 1rem;
    line-height: 1.6;
  }
  .hero-metrics {
    grid-template-columns: 1fr;
    max-width: 100%;
  }
  .metric {
    padding: 1rem;
  }
  .metric-value {
    font-size: 1.4rem;
  }
}

@media (max-width: 375px) {
  .hero {
    padding: 3.5rem 1rem 2rem;
  }
  .hero h1 {
    font-size: 1.65rem;
  }
  .hero-sub {
    font-size: 0.92rem;
  }
}

/* ===== FOOTER MOBILE ===== */
@media (max-width: 768px) {
  .footer {
    padding: 2.5rem 1.25rem;
  }
  .footer-inner {
    flex-direction: column;
    gap: 1.25rem;
    text-align: center;
  }
  .footer-links {
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
  }
  .footer-links a {
    padding: 0.35rem 0.5rem;
    font-size: 0.72rem;
  }
  /* Investor footer variant */
  .inv-footer-inner {
    flex-direction: column;
    text-align: center;
  }
  .inv-footer-links {
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.75rem;
  }
}

/* ===== SECTIONS MOBILE ===== */
@media (max-width: 768px) {
  .layers, .convergence, .closing, .security {
    padding: 3rem 1.25rem;
  }
  .section-title {
    font-size: clamp(1.4rem, 5vw, 1.8rem);
  }
  .layer-card {
    grid-template-columns: 1fr;
    gap: 1rem;
    padding: 1.5rem;
  }
  .layer-icon {
    width: 44px;
    height: 44px;
    font-size: 1.2rem;
  }
  .security-list {
    grid-template-columns: 1fr;
  }
  .security-item {
    padding: 1.25rem;
  }
  .convergence-visual {
    flex-direction: column;
    gap: 0.6rem;
  }
  .conv-arrow {
    transform: rotate(90deg);
  }
}

/* ===== METRICS BAR MOBILE ===== */
@media (max-width: 768px) {
  .metrics-bar {
    padding: 2rem 1.25rem;
  }
  .metrics-bar-inner {
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
  }
  .metrics-divider {
    display: none;
  }
  .metrics-bar-item {
    padding: 0;
  }
}

@media (max-width: 480px) {
  .metrics-bar-inner {
    grid-template-columns: 1fr;
    gap: 1.25rem;
  }
}

/* ===== WAITLIST / FORMS MOBILE ===== */
@media (max-width: 768px) {
  .waitlist, .waitlist-cta {
    padding: 3rem 1.25rem;
  }
  .waitlist-form {
    flex-direction: column;
  }
  .waitlist-input {
    font-size: 16px; /* Prevents iOS zoom on focus */
    padding: 0.9rem 1rem;
  }
  .waitlist-btn {
    justify-content: center;
    padding: 0.9rem 1.5rem;
    font-size: 1rem;
    min-height: 48px;
  }
  .waitlist-trust {
    gap: 1rem;
  }
}

/* ===== CROWDFUND TRACKER MOBILE ===== */
@media (max-width: 768px) {
  .cf-tracker {
    padding: 2rem 1.25rem;
  }
  .cf-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }
  .cf-disclaimer {
    text-align: left;
  }
  .cf-stats {
    flex-direction: column;
    gap: 0;
  }
  .cf-stat {
    padding: 0.75rem 0;
  }
  .cf-stat-divider {
    width: 100%;
    height: 1px;
  }
  .cf-cta-row {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }
  .cf-cta-btn {
    justify-content: center;
    min-height: 48px;
    padding: 0.85rem 1.5rem;
    font-size: 1rem;
  }
}

/* ===== SHOP PAGE MOBILE ===== */
@media (max-width: 768px) {
  /* Tier grids — single column on mobile */
  .tier-grid {
    grid-template-columns: 1fr !important;
    gap: 0.75rem;
  }
  .tier-card {
    padding: 1.25rem;
  }
  /* Counter cards */
  .counters {
    grid-template-columns: 1fr 1fr 1fr;
    gap: 0.5rem;
  }
  .counter-value {
    font-size: 1.3rem;
  }
  .counter-label {
    font-size: 0.68rem;
  }
  /* Funding section */
  .funding-section {
    padding: 0 1rem 1.5rem;
  }
  /* Batch scarcity box */
  .batch-scarcity {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }
  .countdown-block {
    text-align: left;
  }
  /* Payment buttons */
  .pay-btn {
    flex-direction: column;
    gap: 0.5rem;
    align-items: stretch;
  }
  .pay-btn a, .pay-btn button {
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  /* Proof grid */
  .proof-grid {
    grid-template-columns: 1fr 1fr !important;
    gap: 0.75rem;
  }
  /* Scarcity banner */
  .scarcity-bar {
    padding: 0.5rem 1rem;
    font-size: 0.78rem;
  }
  /* Activity ticker */
  .activity-ticker {
    padding: 0.4rem 1rem;
  }
  /* Breakdown tables */
  .breakdown {
    grid-template-columns: 1fr !important;
  }
}

@media (max-width: 480px) {
  .proof-grid {
    grid-template-columns: 1fr !important;
  }
  .counters {
    grid-template-columns: repeat(3, 1fr);
    gap: 0.35rem;
  }
  .counter-card {
    padding: 0.75rem 0.5rem;
  }
  .counter-value {
    font-size: 1.1rem;
  }
}

@media (max-width: 375px) {
  .hero h1 {
    font-size: 1.6rem !important;
  }
  .hero-sub {
    font-size: 0.88rem;
  }
}

/* ===== INVEST PAGE MOBILE ===== */
@media (max-width: 768px) {
  .hero-kpis {
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
  }
  .hero-proof {
    gap: 1rem;
  }
  .section {
    padding: 3rem 1.25rem;
  }
  .econ-grid {
    grid-template-columns: 1fr;
  }
  .phase-track {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }
  .phase-arrow {
    display: none;
  }
  .poc-stats {
    grid-template-columns: 1fr;
  }
  .invest-section {
    padding: 4rem 1.25rem;
  }
  .invest-form {
    padding: 1.5rem 1rem;
  }
  .form-row {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }
  /* ZEC price feed */
  .price-feed-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 1rem;
  }
  .price-scenarios {
    width: 100%;
    flex-wrap: wrap;
    gap: 0.4rem;
  }
  .scenario-chip {
    min-width: 70px;
    padding: 0.4rem 0.6rem;
  }
  /* Calculator */
  .calc-body {
    grid-template-columns: 1fr !important;
    padding: 1.25rem 1rem;
  }
  .calc-divider {
    display: none;
  }
  /* Proof revenue grid */
  .proof-revenue-grid {
    grid-template-columns: 1fr !important;
  }
  .proof-rev-main {
    border-right: none;
    border-bottom: 1px solid var(--border-subtle);
  }
}

@media (max-width: 480px) {
  .hero-kpis {
    grid-template-columns: 1fr;
  }
  .kpi {
    padding: 1rem;
  }
  .price-value {
    font-size: 1.3rem;
  }
}

/* ===== PLAY PAGE MOBILE ===== */
@media (max-width: 540px) {
  .stats-row {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ===== SWARM PAGE MOBILE ===== */
@media (max-width: 680px) {
  .grid-3, .grid-2, .grid-6 {
    grid-template-columns: 1fr;
  }
  .page {
    padding: 1rem;
  }
}

@media (max-width: 900px) {
  .health-hero {
    grid-template-columns: 1fr 1fr;
  }
  .mi-header-tiles {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 500px) {
  .health-hero {
    grid-template-columns: 1fr;
  }
}

/* ===== ARENA PAGES MOBILE ===== */
@media (max-width: 768px) {
  .arena-grid {
    grid-template-columns: 1fr !important;
  }
  .arena-card {
    padding: 1.25rem;
  }
}

/* ===== TABLES MOBILE — Horizontal scroll wrapper ===== */
@media (max-width: 768px) {
  table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
  }
  /* Keep headers visible */
  table thead {
    white-space: nowrap;
  }
  table td, table th {
    min-width: 100px;
    padding: 0.75rem 0.5rem;
    font-size: 0.82rem;
  }
  /* Proof tables in invest/shop */
  .proof-table-header, .proof-table-row {
    font-size: 0.78rem !important;
  }
  .proof-table-row > div, .proof-table-header > div {
    min-width: 80px;
  }
}

/* ===== INLINE STYLE GRID OVERRIDES ===== */
/* Fix inline grid-template-columns that break on mobile (e.g., repeat(4,1fr) pool stats) */
@media (max-width: 768px) {
  [style*="grid-template-columns:repeat(4"] {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  [style*="grid-template-columns: repeat(4"] {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

@media (max-width: 480px) {
  [style*="grid-template-columns:repeat(4"] {
    grid-template-columns: 1fr !important;
  }
  [style*="grid-template-columns: repeat(4"] {
    grid-template-columns: 1fr !important;
  }
}

/* ===== FORM INPUT OPTIMIZATION ===== */
/* Prevent iOS zoom on input focus (requires 16px min) */
@media (max-width: 768px) {
  input[type="text"],
  input[type="email"],
  input[type="tel"],
  input[type="number"],
  input[type="url"],
  input[type="search"],
  input[type="password"],
  textarea,
  select {
    font-size: 16px !important;
    -webkit-appearance: none;
    border-radius: 8px;
  }
  /* Full-width inputs on mobile */
  input, textarea, select {
    max-width: 100%;
    width: 100%;
  }
  /* Better select styling */
  select {
    min-height: 48px;
    padding: 0.75rem 1rem;
  }
}

/* ===== STICKY BOTTOM CTA BAR ===== */
.mobile-sticky-cta {
  display: none;
}

@media (max-width: 768px) {
  .mobile-sticky-cta {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 190;
    background: rgba(8, 9, 13, 0.97);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid rgba(0, 255, 136, 0.2);
    padding: 0.75rem 1rem;
    gap: 0.75rem;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.5);
  }
  .mobile-sticky-cta .sticky-info {
    flex: 1;
    min-width: 0;
  }
  .mobile-sticky-cta .sticky-title {
    font-size: 0.82rem;
    font-weight: 700;
    color: #eceef5;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .mobile-sticky-cta .sticky-sub {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.68rem;
    color: #8b8fa3;
  }
  .mobile-sticky-cta .sticky-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    background: #00ff88;
    color: #08090d;
    font-weight: 700;
    font-size: 0.85rem;
    padding: 0.75rem 1.25rem;
    border-radius: 10px;
    text-decoration: none;
    white-space: nowrap;
    min-height: 44px;
    flex-shrink: 0;
    transition: opacity 0.2s;
  }
  .mobile-sticky-cta .sticky-btn:active {
    opacity: 0.85;
  }
  /* Add padding to body so content isn't hidden behind sticky bar */
  body.has-sticky-cta {
    padding-bottom: 72px;
  }
  /* Move toasts above sticky CTA */
  body.has-sticky-cta #toast-container {
    bottom: 80px;
  }
}

/* ===== NATIVE SHARE BUTTON ===== */
.share-native-btn {
  display: none;
}

@media (max-width: 768px) {
  .share-native-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #e8eaf0;
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.82rem;
    font-weight: 600;
    padding: 0.6rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    min-height: 44px;
    transition: background 0.2s;
  }
  .share-native-btn:active {
    background: rgba(255, 255, 255, 0.1);
  }
}

/* ===== HOVER STATES → TAP STATES ON MOBILE ===== */
/* Suppress transform/box-shadow on hover for touch — :active handles tap feedback */
@media (max-width: 768px) {
  .layer-card:hover,
  .security-item:hover,
  .waitlist-btn:hover,
  .cf-cta-btn:hover,
  .ys-nav-cta:hover,
  .ys-btn-primary:hover,
  .ys-btn-secondary:hover,
  .ys-btn-cyan:hover,
  .ys-btn-amber:hover,
  .ys-card-interactive:hover,
  .ys-scroll-top:hover {
    transform: none;
    box-shadow: none;
  }
  .layer-card:active {
    background: var(--bg-elevated);
  }
  .security-item:active {
    background: var(--bg-elevated);
  }
  .waitlist-btn:active {
    opacity: 0.85;
  }
  .cf-cta-btn:active {
    opacity: 0.85;
  }
}

/* ===== IMAGES RESPONSIVE ===== */
img {
  max-width: 100%;
  height: auto;
}

/* ===== PRINT HIDE MOBILE-ONLY ELEMENTS ===== */
@media print {
  .mobile-sticky-cta,
  .share-native-btn,
  .ys-hbg,
  .ys-drawer,
  .ys-overlay {
    display: none !important;
  }
}

/* ===== VERY SMALL SCREENS (320px — iPhone SE) ===== */
@media (max-width: 340px) {
  .hero {
    padding: 3rem 0.75rem 1.5rem;
  }
  .hero h1 {
    font-size: 1.5rem !important;
  }
  .hero-tag {
    font-size: 0.65rem;
    padding: 0.3rem 0.75rem;
  }
  .metric-value {
    font-size: 1.1rem;
  }
  .metric-label {
    font-size: 0.68rem;
  }
  .ys-nav-wordmark {
    font-size: 0.85rem;
  }
  .layers, .convergence, .closing, .security,
  .waitlist, .waitlist-cta {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }
  .cf-tracker {
    padding: 1.25rem 0.75rem;
  }
  .footer {
    padding: 2rem 0.75rem;
  }
}

/* ===== LANDSCAPE PHONE ===== */
@media (max-height: 500px) and (orientation: landscape) {
  .hero {
    min-height: auto;
    padding-top: 2rem;
    padding-bottom: 2rem;
  }
  .ys-nav-inner {
    padding: 0.5rem 1rem;
  }
}

/* ===== iOS SAFE AREA (notch / Dynamic Island / home indicator) ===== */
/* Requires viewport-fit=cover in the <meta name="viewport"> tag */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  /* Sticky bottom CTA — clear home indicator bar */
  @media (max-width: 768px) {
    .mobile-sticky-cta {
      padding-bottom: calc(0.75rem + env(safe-area-inset-bottom));
    }
    body.has-sticky-cta {
      padding-bottom: calc(72px + env(safe-area-inset-bottom));
    }
  }

  /* Cookie consent banner — clear home indicator */
  .ys-cookie-banner {
    padding-bottom: calc(1rem + env(safe-area-inset-bottom));
  }

  /* Toast container — clear notch on top */
  #toast-container {
    top: calc(1rem + env(safe-area-inset-top));
    right: calc(1rem + env(safe-area-inset-right));
  }

  /* Scroll-to-top — keep above home bar */
  .ys-scroll-top {
    bottom: calc(2rem + env(safe-area-inset-bottom));
    right: calc(2rem + env(safe-area-inset-right));
  }

  /* Mobile nav drawer — respect top/bottom notch area */
  .ys-drawer {
    padding-top: calc(1.5rem + env(safe-area-inset-top));
    padding-bottom: calc(1.5rem + env(safe-area-inset-bottom));
  }
}

/* ===== SCROLL-TO-TOP TOUCH & SIZE FIX ===== */
/* Default 40px is under the 44px Apple HIG minimum — bump to 44px */
/* z-index raised above mobile-sticky-cta (190) so it's always tappable */
@media (max-width: 768px) {
  .ys-scroll-top {
    width: 44px;
    height: 44px;
    z-index: 200;
    bottom: calc(80px + env(safe-area-inset-bottom, 0px)); /* above sticky CTA */
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }
  .ys-scroll-top:active {
    background: rgba(0, 255, 136, 0.15);
    border-color: rgba(0, 255, 136, 0.3);
    color: var(--accent-green);
  }
}

/* ===== NAV CTA :active TAP FEEDBACK ===== */
/* :hover has transform on desktop — suppress on touch and use :active instead */
@media (max-width: 900px) {
  .ys-nav-cta:active {
    transform: none;
    opacity: 0.85;
    background: #00e67a;
  }
  /* Drawer CTA */
  .ys-drawer-cta:active {
    opacity: 0.85;
  }
  /* Drawer links */
  .ys-drawer-links li a:active {
    background: rgba(255, 255, 255, 0.1);
    color: var(--ys-text-primary, #e8eaf0);
  }
  /* Drawer close button */
  .ys-drawer-close {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    min-width: 44px;
    min-height: 44px;
  }
  .ys-drawer-close:active {
    color: #e8eaf0;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 8px;
  }
}

/* ===== COOKIE BANNER :active FEEDBACK ===== */
@media (max-width: 768px) {
  .ys-cookie-accept:active {
    transform: none;
    opacity: 0.85;
  }
  .ys-cookie-decline:active {
    border-color: rgba(255, 255, 255, 0.3);
    color: #e8eaf0;
  }
}

/* ===== TOOLTIP TOUCH FALLBACK ===== */
/* CSS tooltips are hover-only and invisible on touch. The JS below (injected via
   global.css or the EJS layout) handles touchstart. This CSS adds a visible
   focus-within fallback so keyboard + screen reader users also see them. */
[data-ys-tooltip]:focus::after,
[data-ys-tooltip].ys-tooltip-show::after {
  opacity: 1;
}

/* ===== REDUCED MOTION ===== */
@media (prefers-reduced-motion: reduce) {
  .mobile-sticky-cta,
  .share-native-btn,
  .ys-drawer {
    transition: none;
  }
  .ticker-inner {
    animation: none;
  }
}

/* ===== PWA INSTALL BANNER ===== */

#pwa-install-banner,
#pwa-ios-hint {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  padding: 0 0 env(safe-area-inset-bottom, 0);
  background: #111118;
  border-top: 1px solid rgba(0, 255, 136, 0.2);
  transform: translateY(100%);
  transition: transform 0.3s ease;
  box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.6);
}

#pwa-install-banner.pwa-banner-visible,
#pwa-ios-hint.pwa-banner-visible {
  transform: translateY(0);
}

.pwa-banner-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  max-width: 600px;
  margin: 0 auto;
}

.pwa-banner-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.pwa-banner-text strong {
  font-size: 14px;
  font-weight: 600;
  color: #e5e7eb;
}

.pwa-banner-text span {
  font-size: 12px;
  color: #9ca3af;
}

.pwa-banner-btn {
  background: #00ff88;
  color: #000;
  border: none;
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
  min-height: 36px;
  min-width: 44px;
}

.pwa-banner-btn:active {
  opacity: 0.85;
}

.pwa-banner-close {
  background: transparent;
  border: none;
  color: #6b7280;
  cursor: pointer;
  font-size: 16px;
  padding: 4px 8px;
  flex-shrink: 0;
  min-height: 36px;
  min-width: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pwa-banner-close:active {
  color: #9ca3af;
}

@media (prefers-reduced-motion: reduce) {
  #pwa-install-banner,
  #pwa-ios-hint {
    transition: none;
  }
}
