/* ============================================
   SAJAL ARYAN — MOBILE OPTIMIZATION
   Comprehensive responsive fixes for mobile devices
   Layers on top of design-system, components, pages, premium
   ============================================ */

/* ============================================
   TOUCH & INTERACTION FOUNDATIONS
   ============================================ */

/* Prevent text selection flash on rapid tap */
@media (hover: none) and (pointer: coarse) {
  .btn, .nav-link, .gallery-filter-btn, .directory-filter-btn,
  .filter-tab, .pagination-btn, .size-option, .batch-option,
  .cart-icon, .menu-toggle, .back-to-top a, .lightbox-nav,
  .lightbox-close, .footer-social a, .image-accordion-item,
  .gallery-item, .instagram-item, .featured-gallery-item {
    -webkit-tap-highlight-color: transparent;
  }

  /* Disable hover effects that feel broken on touch */
  .hover-lift:hover {
    transform: none;
    box-shadow: none;
  }

  .hover-scale:hover {
    transform: none;
  }

  .card:hover,
  .course-card:hover,
  .product-card:hover,
  .print-card:hover,
  .blog-card:hover,
  .blog-card-dynamic:hover,
  .reserve-card:hover,
  .media-card:hover,
  .card-premium:hover,
  .service-card:hover {
    transform: none;
  }

  /* Show captions by default on touch (no hover) */
  .gallery-caption,
  .featured-gallery-caption {
    opacity: 1;
    transform: translateY(0);
  }

  /* Instagram overlay hidden on touch — no hover */
  .instagram-item-overlay {
    display: none;
  }
}

/* ============================================
   SAFE AREAS (Notch / Home Indicator)
   ============================================ */
@supports (padding: env(safe-area-inset-bottom)) {
  .footer-bottom {
    padding-bottom: calc(var(--space-6) + env(safe-area-inset-bottom));
  }

  .mobile-menu-overlay {
    padding-bottom: env(safe-area-inset-bottom);
  }

  .back-to-top {
    bottom: calc(var(--space-8) + env(safe-area-inset-bottom));
  }

  .toast-container {
    bottom: calc(var(--space-8) + env(safe-area-inset-bottom));
  }
}

/* ============================================
   TABLET — 1024px
   ============================================ */
@media (max-width: 1024px) {
  /* Book showcase text section */
  .book-info {
    max-width: 100%;
  }

  /* Calendar info sticky */
  .calendar-info {
    position: static;
  }
}

/* ============================================
   MOBILE — 768px
   ============================================ */
@media (max-width: 768px) {

  /* --- Base Touch Sizing --- */
  .btn {
    min-height: 48px;
    padding: var(--space-3) var(--space-6);
    font-size: var(--text-sm);
  }

  .btn-sm {
    min-height: 44px;
    padding: var(--space-2) var(--space-4);
  }

  .btn-lg {
    min-height: 52px;
    padding: var(--space-4) var(--space-8);
    width: 100%;
    max-width: 340px;
  }

  /* --- Header Mobile --- */
  .header {
    padding: var(--space-3) 0;
  }

  .header.is-scrolled {
    padding: var(--space-2) 0;
  }

  .logo {
    font-size: 1.2rem;
  }

  /* --- Mobile Menu Overlay — smoother transition --- */
  .mobile-menu-overlay {
    flex-direction: column;
    gap: var(--space-6);
    padding: var(--space-16) var(--space-6);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .mobile-menu-overlay .nav-links {
    display: flex;
    width: 100%;
  }

  .mobile-menu-overlay .nav-link {
    font-size: var(--text-lg);
    padding: var(--space-4) var(--space-6);
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  }

  .mobile-menu-overlay .nav-link:last-child {
    border-bottom: none;
  }

  /* --- Hero Section --- */
  .hero {
    min-height: 85vh;
    height: auto;
  }

  .hero-content {
    padding: var(--space-20) var(--space-5) var(--space-16);
  }

  .hero-title {
    font-size: clamp(2rem, 6vw, 3rem);
    letter-spacing: var(--tracking-normal);
  }

  .hero-subtitle {
    font-size: var(--text-sm);
    line-height: var(--leading-relaxed);
    max-width: 45ch;
  }

  .hero-scroll {
    bottom: var(--space-6);
  }

  .hero-scroll-line {
    height: 35px;
  }

  /* --- Page Hero --- */
  .page-hero {
    height: 35vh;
    min-height: 250px;
  }

  .page-hero-content h1 {
    font-size: var(--text-3xl);
  }

  .page-title-section {
    padding: calc(var(--header-height) + var(--space-10)) 0 var(--space-10);
  }

  .page-title-section h1 {
    font-size: var(--text-3xl);
  }

  /* --- Section Spacing --- */
  .section {
    padding: var(--space-14) 0;
  }

  .section-header {
    margin-bottom: var(--space-8);
  }

  .heading-section {
    font-size: var(--text-2xl);
  }

  /* --- Image Accordion mobile fix --- */
  .image-accordion {
    flex-direction: column;
    height: auto;
    gap: var(--space-2);
  }

  .image-accordion-item {
    height: 180px;
    flex: none;
  }

  .image-accordion-item:hover {
    flex: none;
    height: 180px;
  }

  .image-accordion-content {
    opacity: 1;
    transform: translateY(0);
    padding: var(--space-4) var(--space-4);
  }

  .image-accordion-content h3 {
    font-size: var(--text-base);
  }

  /* --- About Split --- */
  .about-split {
    gap: var(--space-8);
  }

  .about-content {
    max-width: 100%;
  }

  .about-content h2 {
    font-size: var(--text-3xl);
  }

  .about-content p {
    text-align: left;
  }

  /* --- Stats Grid --- */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-5);
    padding: var(--space-8) 0;
  }

  .stat-number {
    font-size: var(--text-3xl);
  }

  /* --- Book Showcase --- */
  .book-showcase {
    gap: var(--space-8);
    text-align: center;
  }

  .book-3d-inner {
    width: 240px;
    height: 330px;
  }

  .book-info {
    max-width: 100%;
  }

  .book-info h2 {
    font-size: var(--text-3xl);
  }

  .book-features li {
    text-align: left;
  }

  .price {
    justify-content: center;
  }

  /* --- Featured Gallery --- */
  .featured-gallery-track {
    padding: 0 var(--space-5);
    gap: var(--space-3);
  }

  .featured-gallery-item {
    width: 280px;
    height: 370px;
  }

  /* --- Course Cards --- */
  .course-card-body {
    padding: var(--space-5);
  }

  .course-card-footer {
    flex-wrap: wrap;
    gap: var(--space-3);
  }

  .course-card-footer .btn {
    width: 100%;
    text-align: center;
  }

  /* --- Testimonial Cards --- */
  .testimonial-card {
    padding: var(--space-6);
  }

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

  /* --- Contact Page --- */
  .contact-split {
    gap: var(--space-8);
  }

  .contact-form-section h2 {
    font-size: var(--text-3xl);
  }

  /* --- Newsletter form --- */
  .newsletter-form {
    flex-direction: column;
    align-items: center;
    max-width: 100%;
    gap: var(--space-2);
  }

  .newsletter-form input {
    width: 100%;
    max-width: 340px;
    height: 48px;
    font-size: var(--text-sm);
    text-align: center;
  }

  .newsletter-form .btn {
    width: 100%;
    max-width: 340px;
    height: 48px;
  }

  /* --- Footer --- */
  .footer {
    padding: var(--space-10) 0 var(--space-6);
  }

  .footer-brand p {
    max-width: 100%;
  }

  .footer-social {
    justify-content: flex-start;
  }

  .footer-social a {
    width: 44px;
    height: 44px;
  }

  .footer-newsletter {
    margin-top: var(--space-4) !important;
  }

  /* --- Cart Items --- */
  .cart-page, .checkout-page {
    padding-top: calc(var(--header-height) + var(--space-8));
  }

  .cart-item {
    grid-template-columns: 60px 1fr;
    gap: var(--space-3);
    padding: var(--space-4);
  }

  .cart-item-image {
    width: 60px;
    height: 60px;
  }

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

  .cart-item-remove {
    position: absolute;
    top: var(--space-3);
    right: var(--space-3);
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .cart-item {
    position: relative;
  }

  .cart-summary {
    padding: var(--space-6);
  }

  /* --- Checkout Form --- */
  .form-row {
    grid-template-columns: 1fr;
    gap: var(--space-4);
  }

  /* --- Gallery Grid — single column w/ larger items --- */
  .gallery-grid {
    grid-template-columns: 1fr;
    gap: var(--space-3);
  }

  .gallery-item {
    aspect-ratio: 16/10;
  }

  /* --- Lightbox Mobile --- */
  .lightbox-close {
    top: var(--space-3);
    right: var(--space-3);
    width: 48px;
    height: 48px;
    font-size: 1.8rem;
  }

  .lightbox-nav {
    width: 48px;
    height: 48px;
    font-size: 1.8rem;
  }

  .lightbox-prev {
    left: var(--space-2);
  }

  .lightbox-next {
    right: var(--space-2);
  }

  .lightbox-caption {
    bottom: var(--space-4);
    font-size: var(--text-xs);
    padding: 0 var(--space-4);
  }

  /* --- Diary Entries --- */
  .diary-entry {
    padding: var(--space-8) 0;
  }

  .diary-entry-content h3 {
    font-size: var(--text-xl);
  }

  .diary-entry-meta {
    flex-wrap: wrap;
    gap: var(--space-2);
  }

  .diary-entry-content p {
    text-align: left;
  }

  /* --- Workshop Cards --- */
  .workshop-card-body {
    padding: var(--space-6);
  }

  .workshop-card-title {
    font-size: var(--text-xl);
  }

  .workshop-card-footer {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-3);
  }

  .workshop-card-footer .btn {
    width: 100%;
    text-align: center;
  }

  /* --- Print Cards — 2-column on tablet, single on phone --- */
  .shop-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-4);
  }

  .print-card-body {
    padding: var(--space-4);
  }

  /* --- Blog --- */
  .blog-featured {
    margin-bottom: var(--space-6);
  }

  .blog-featured-content {
    padding: var(--space-6);
  }

  /* --- Blog Post (single) --- */
  .post-header {
    padding: var(--space-10) var(--space-4) var(--space-6);
  }

  .post-content {
    padding: 0 var(--space-4);
    font-size: var(--text-base);
    line-height: 1.75;
  }

  .post-cover {
    aspect-ratio: 16/9;
    margin-bottom: var(--space-8);
  }

  .post-share {
    padding: 0 var(--space-4);
    flex-wrap: wrap;
  }

  .post-share a {
    min-width: 44px;
    min-height: 44px;
  }

  .post-nav {
    padding: var(--space-6) var(--space-4);
    margin-top: var(--space-10);
  }

  /* --- Media Page --- */
  .media-card {
    padding: var(--space-5);
  }

  /* --- Award Items --- */
  .award-item {
    gap: var(--space-4);
    padding: var(--space-5);
  }

  /* --- Back to Top — reposition for mobile --- */
  .back-to-top {
    left: auto;
    right: var(--space-4);
    bottom: var(--space-4);
  }

  .back-to-top a {
    flex-direction: row;
    gap: var(--space-1);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    padding: var(--space-2) var(--space-3);
  }

  .back-to-top a span:last-child {
    font-size: var(--text-base);
  }

  /* --- Toast on mobile — full width --- */
  .toast-container {
    left: var(--space-3);
    right: var(--space-3);
    bottom: var(--space-3);
  }

  .toast {
    min-width: auto;
    max-width: none;
    font-size: var(--text-xs);
  }

  /* --- Modals on mobile --- */
  .modal-backdrop {
    padding: 0;
    align-items: flex-end;
  }

  .modal {
    max-width: 100%;
    max-height: 92vh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }

  .modal-header {
    padding: var(--space-4) var(--space-5);
  }

  .modal-body {
    padding: var(--space-6) var(--space-5);
  }

  .modal-footer {
    padding: var(--space-4) var(--space-5);
    flex-direction: column;
  }

  .modal-footer .btn {
    width: 100%;
  }

  /* --- Enrollment Sidebar --- */
  .enrollment-sidebar {
    padding: var(--space-6);
  }

  .enrollment-price-display .price-current {
    font-size: var(--text-3xl);
  }

  /* --- Stepper horizontal scroll fix --- */
  .stepper {
    padding: var(--space-4);
    justify-content: flex-start;
  }

  /* --- Filter tabs wrap --- */
  .filter-tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: var(--space-2);
  }

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

  .filter-tab {
    flex-shrink: 0;
    min-height: 40px;
    display: flex;
    align-items: center;
  }

  /* --- Gallery filter buttons on mobile --- */
  .gallery-filters {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 0 var(--space-4) var(--space-2);
    justify-content: flex-start;
    gap: var(--space-1);
  }

  .gallery-filters::-webkit-scrollbar {
    display: none;
  }

  .gallery-filter-btn {
    flex-shrink: 0;
    min-height: 40px;
    padding: var(--space-2) var(--space-4);
  }

  /* --- Directory filters on mobile --- */
  .directory-filters {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    justify-content: flex-start;
    padding-bottom: var(--space-2);
  }

  .directory-filters::-webkit-scrollbar {
    display: none;
  }

  .directory-filter-btn {
    flex-shrink: 0;
    min-height: 40px;
    display: flex;
    align-items: center;
  }

  /* --- Calendar page --- */
  .calendar-showcase {
    gap: var(--space-8);
  }

  .calendar-gallery {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-2);
  }

  .calendar-info h1 {
    font-size: var(--text-3xl);
  }

  /* --- Qty selector touch-friendly --- */
  .qty-btn {
    width: 48px;
    height: 48px;
    font-size: var(--text-xl);
  }

  .qty-input {
    width: 56px;
    height: 48px;
    font-size: var(--text-lg);
  }

  /* --- Size selector mobile --- */
  .size-selector {
    flex-wrap: wrap;
  }

  .size-option {
    min-height: 44px;
    min-width: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* --- Timeline mobile --- */
  .timeline {
    padding-left: var(--space-6);
  }

  .timeline-item {
    padding-left: var(--space-4);
  }

  /* --- Admin table scroll --- */
  .admin-table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* --- Pagination mobile --- */
  .pagination {
    gap: var(--space-1);
  }

  .pagination-btn {
    width: 40px;
    height: 40px;
    font-size: var(--text-xs);
  }

  /* --- Service cards --- */
  .service-card-label {
    padding: var(--space-4);
    font-size: var(--text-lg);
  }

  .service-card-content {
    padding: var(--space-4) var(--space-5);
  }
}

/* ============================================
   SMALL MOBILE — 480px
   ============================================ */
@media (max-width: 480px) {

  /* Even tighter containers */
  .container, .container-narrow, .container-wide {
    padding: 0 var(--space-3);
  }

  /* Hero */
  .hero {
    min-height: 80vh;
  }

  .hero-title {
    font-size: clamp(1.75rem, 7vw, 2.5rem);
  }

  .hero-subtitle {
    font-size: var(--text-xs);
  }

  .hero-actions {
    flex-direction: column;
    gap: var(--space-2);
  }

  .hero-actions .btn {
    width: 100%;
    max-width: 280px;
  }

  /* Headings */
  .heading-section {
    font-size: var(--text-xl);
    letter-spacing: var(--tracking-normal);
  }

  h1 {
    font-size: var(--text-3xl);
  }

  h2 {
    font-size: var(--text-2xl);
  }

  h3 {
    font-size: var(--text-xl);
  }

  /* Section spacing */
  .section {
    padding: var(--space-10) 0;
  }

  .section-sm {
    padding: var(--space-8) 0;
  }

  /* Book 3D */
  .book-3d-inner {
    width: 200px;
    height: 280px;
  }

  /* Shop grid single column on phone */
  .shop-grid {
    grid-template-columns: 1fr;
  }

  /* Featured gallery */
  .featured-gallery-item {
    width: 240px;
    height: 320px;
  }

  .featured-gallery-track {
    padding: 0 var(--space-3);
  }

  /* Image accordion items */
  .image-accordion-item {
    height: 150px;
  }

  .image-accordion-item:hover {
    height: 150px;
  }

  /* Instagram grid */
  .instagram-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-1);
  }

  /* Stats */
  .stat-number {
    font-size: var(--text-2xl);
  }

  /* Gear grid */
  .gear-grid {
    grid-template-columns: 1fr;
    gap: var(--space-3);
  }

  /* Testimonial */
  .testimonial-card {
    padding: var(--space-5);
  }

  .testimonial-stars {
    font-size: var(--text-xs);
  }

  /* Blog card */
  .blog-card-body {
    padding: var(--space-4);
  }

  .blog-card-title {
    font-size: var(--text-base);
  }

  /* Course card */
  .course-card-title {
    font-size: var(--text-base);
  }

  /* Cart */
  .cart-item {
    grid-template-columns: 50px 1fr;
    gap: var(--space-2);
    padding: var(--space-3);
  }

  .cart-item-image {
    width: 50px;
    height: 50px;
  }

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

  /* Calendar months */
  .calendar-gallery {
    grid-template-columns: 1fr;
  }

  /* Contact info */
  .contact-info-list li {
    font-size: var(--text-xs);
  }

  /* Back to top position */
  .back-to-top {
    right: var(--space-3);
    bottom: var(--space-3);
  }

  /* Diary entries */
  .diary-entry-content h3 {
    font-size: var(--text-lg);
  }

  /* Post title */
  .post-title {
    font-size: var(--text-2xl);
  }

  /* Workshop card */
  .workshop-card-title {
    font-size: var(--text-lg);
  }

  .workshop-card-body {
    padding: var(--space-5);
  }

  /* Media cards */
  .media-card-title {
    font-size: var(--text-base);
  }

  /* Footer */
  .footer-bottom {
    font-size: 0.55rem;
    gap: var(--space-2);
  }
}

/* ============================================
   EXTRA SMALL — 360px (budget Android phones)
   ============================================ */
@media (max-width: 360px) {
  :root {
    --header-height: 54px;
  }

  .container, .container-narrow, .container-wide {
    padding: 0 var(--space-2);
  }

  .logo {
    font-size: 1rem;
  }

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

  .heading-section {
    font-size: var(--text-lg);
  }

  .btn {
    font-size: var(--text-xs);
    padding: var(--space-2) var(--space-4);
    min-height: 44px;
  }

  .hero-actions .btn {
    max-width: 260px;
  }

  .book-3d-inner {
    width: 180px;
    height: 250px;
  }

  .featured-gallery-item {
    width: 220px;
    height: 290px;
  }

  .stat-number {
    font-size: var(--text-xl);
  }
}

/* ============================================
   LANDSCAPE MOBILE
   ============================================ */
@media (max-height: 500px) and (orientation: landscape) {
  .hero {
    min-height: 100vh;
    height: auto;
  }

  .hero-content {
    padding: var(--space-16) var(--space-5) var(--space-8);
  }

  .hero-title {
    font-size: var(--text-3xl);
  }

  .hero-scroll {
    display: none;
  }

  .page-hero {
    height: 100vh;
    min-height: auto;
  }

  .mobile-menu-overlay {
    padding-top: var(--space-8);
  }

  .mobile-menu-overlay .nav-link {
    font-size: var(--text-base);
    padding: var(--space-2) var(--space-4);
    min-height: 40px;
  }
}

/* ============================================
   REDUCED MOTION (accessibility)
   ============================================ */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .reveal,
  .reveal-left,
  .reveal-right,
  .reveal-scale,
  .reveal-fade {
    opacity: 1;
    transform: none;
  }

  .hero-bg img,
  .hero-bg .img-placeholder {
    animation: none;
  }
}

/* ============================================
   PRINT OPTIMIZATION (for blog posts)
   ============================================ */
@media print {
  .header,
  .footer,
  .back-to-top,
  .toast-container,
  .mobile-menu-overlay,
  .hero-scroll,
  .lightbox-overlay {
    display: none !important;
  }

  body {
    background: #fff;
    color: #000;
  }

  .post-content {
    max-width: 100%;
    padding: 0;
  }

  .post-content a {
    color: #000;
    text-decoration: underline;
  }

  .post-content a::after {
    content: ' (' attr(href) ')';
    font-size: 0.8em;
  }
}
