/* =========================================================
   MOBILE.CSS — Enhanced mobile experience for Maulik Gajjar
   Breakpoints: 900px (tablet), 600px (phone), 400px (small phone)
   Load this AFTER all other CSS files.
   ========================================================= */

/* =========================================================
   SHARED MOBILE UTILITIES
   ========================================================= */
@media (max-width: 900px) {

  /* Smoother touch scrolling */
  html {
    scroll-behavior: smooth;
    -webkit-tap-highlight-color: transparent;
  }

  /* Better tap targets */
  a, button, [role="button"] {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }

  /* Tighter section padding */
  .section {
    padding: clamp(64px, 10vh, 96px) var(--pad);
  }

  .section-title {
    font-size: clamp(36px, 8.5vw, 64px);
  }

  .section-lead {
    font-size: 15px;
    max-width: 100%;
  }
}


/* =========================================================
   NAV — Floating pill with hamburger on small screens
   ========================================================= */
@media (max-width: 900px) {

  /* Always show as a compact pill on mobile */
  .nav {
    top: 12px !important;
    left: 50% !important;
    right: auto !important;
    transform: translateX(-50%) !important;
    width: calc(100% - 28px) !important;
    max-width: calc(100% - 28px) !important;
    padding: 10px 16px !important;
    border-radius: 100px !important;
    background: color-mix(in oklch, var(--bg) 72%, transparent) !important;
    -webkit-backdrop-filter: blur(20px) saturate(180%) !important;
    backdrop-filter: blur(20px) saturate(180%) !important;
    border: 1px solid color-mix(in oklch, var(--ink) 14%, transparent) !important;
    box-shadow:
      0 1px 0 color-mix(in oklch, #fff 18%, transparent) inset,
      0 8px 24px -8px rgba(0,0,0,0.45) !important;
    gap: 0 !important;
    justify-content: space-between !important;
    align-items: center !important;
  }

  .nav .links {
    display: none !important;
  }

  .nav .brand {
    order: 1;
  }

  .nav .brand img {
    height: 28px;
    width: auto;
  }

  .nav .theme-toggle {
    order: 3;
    transform: scale(0.8);
    transform-origin: right center;
  }

  /* Hamburger button — injected via mobile.js, or use :after trick */
  .nav-mobile-menu {
    order: 2;
    margin-left: auto;
    margin-right: 10px;
    width: 34px;
    height: 34px;
    background: transparent;
    border: 1px solid color-mix(in oklch, var(--ink) 20%, transparent);
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    cursor: pointer;
    padding: 0;
  }

  .nav-mobile-menu span {
    width: 14px;
    height: 1.2px;
    background: var(--ink);
    border-radius: 2px;
    transition: transform 0.35s var(--ease), opacity 0.3s, width 0.3s;
    display: block;
  }

  .nav-mobile-menu.open span:nth-child(1) {
    transform: translateY(6.2px) rotate(45deg);
  }

  .nav-mobile-menu.open span:nth-child(2) {
    opacity: 0;
    width: 0;
  }

  .nav-mobile-menu.open span:nth-child(3) {
    transform: translateY(-6.2px) rotate(-45deg);
  }

  /* Mobile nav drawer */
  .nav-drawer {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 99;
    padding: 80px 28px 36px;
    background: color-mix(in oklch, var(--bg) 94%, transparent);
    -webkit-backdrop-filter: blur(32px) saturate(200%);
    backdrop-filter: blur(32px) saturate(200%);
    border-bottom: 1px solid var(--line);
    transform: translateY(-100%);
    transition: transform 0.6s cubic-bezier(0.22, 1, 0.36, 1);
    display: flex;
    flex-direction: column;
    gap: 6px;
  }

  .nav-drawer.open {
    opacity: 1;
    transform: translateY(0);
  }

  .nav-drawer a {
    font-family: "Instrument Serif", serif;
    font-size: clamp(32px, 7vw, 48px);
    font-style: italic;
    color: var(--ink-3);
    text-decoration: none;
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: color 0.3s, padding-left 0.3s;
    line-height: 1;
    min-height: unset;
  }

  .nav-drawer a:last-child { border-bottom: none; }

  .nav-drawer a .ix {
    font-family: "JetBrains Mono", monospace;
    font-size: 10px;
    font-style: normal;
    color: var(--accent);
    letter-spacing: 0.14em;
  }

  .nav-drawer.open a:nth-child(1) { transition-delay: 0.10s; }
  .nav-drawer.open a:nth-child(2) { transition-delay: 0.15s; }
  .nav-drawer.open a:nth-child(3) { transition-delay: 0.20s; }
  .nav-drawer.open a:nth-child(4) { transition-delay: 0.25s; }
  .nav-drawer.open a:nth-child(5) { transition-delay: 0.30s; }

  .nav-drawer a:hover {
    color: var(--accent);
    padding-left: 8px;
  }
}


/* =========================================================
   HERO — Immersive mobile treatment
   ========================================================= */
@media (max-width: 900px) {

  .hero {
    min-height: 100svh;
    padding-top: clamp(80px, 14vh, 110px);
    padding-bottom: 40px;
    gap: 20px;
    grid-template-rows: auto 1fr auto;
  }

  /* Make the WebGL ball slightly more visible on mobile */
  .hero-canvas.ready {
    opacity: 0.5;
  }

  /* Stronger scrim on mobile for legibility */
  .hero::before {
    background:
      linear-gradient(100deg, var(--bg) 0%, color-mix(in oklch, var(--bg) 75%, transparent) 35%, transparent 65%),
      linear-gradient(0deg, var(--bg) 0%, color-mix(in oklch, var(--bg) 60%, transparent) 30%, transparent 58%);
  }

  .hero-meta {
    flex-direction: row;
    justify-content: space-between;
    gap: 0;
    align-items: center;
    font-size: 10px;
  }

  .hero-meta .row:last-child {
    text-align: right;
  }

  .hero-meta .row {
    flex-direction: column;
    gap: 3px;
  }

  .hero-title {
    font-size: clamp(60px, 14.5vw, 110px);
    line-height: 0.84;
    letter-spacing: -0.035em;
  }

  .hero-title .small {
    font-size: 0.6em;
  }

  .hero-title .sub-line {
    gap: 0.22em;
  }

  .hero-title .star {
    font-size: 0.45em;
    transform: translateY(-0.32em);
  }

  .hero-bottom {
    grid-template-columns: 1fr;
    gap: 28px;
    align-items: start;
  }

  .hero-bottom .lede {
    font-size: clamp(16px, 4.2vw, 20px);
    max-width: 100%;
  }

  .status-chip {
    font-size: 11px;
    padding: 9px 16px;
  }

  .status-chip .rotator {
    min-width: 12ch;
  }

  .hero-cta {
    padding: 15px 22px;
    font-size: 14px;
  }

  /* Facts grid — horizontal on mobile */
  .hero-bottom .facts {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    border: 1px solid var(--line);
    border-radius: 12px;
    overflow: hidden;
    background: color-mix(in oklch, var(--bg-2) 80%, transparent);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
  }

  .hero-bottom .facts .row {
    flex-direction: column;
    gap: 3px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
    border-right: 1px solid var(--line);
    font-size: 12px;
    justify-content: flex-start;
    align-items: flex-start;
    min-height: unset;
  }

  .hero-bottom .facts .row:nth-child(even) {
    border-right: none;
  }

  .hero-bottom .facts .row:nth-last-child(-n+2) {
    border-bottom: none;
  }

  .hero-bottom .facts .row b {
    font-size: 13px;
    color: var(--ink);
  }

  .scroll-hint {
    bottom: 14px;
    font-size: 10px;
  }
}


/* =========================================================
   TICKER — Slightly smaller on mobile
   ========================================================= */
@media (max-width: 600px) {
  .ticker .track {
    font-size: clamp(28px, 8vw, 48px);
    gap: clamp(20px, 5vw, 48px);
    animation-duration: 22s;
  }

  .ticker .track span {
    gap: clamp(20px, 5vw, 48px);
  }

  .ticker {
    padding: 14px 0;
  }
}


/* =========================================================
   ABOUT — Stack portrait on top, copy below
   ========================================================= */
@media (max-width: 900px) {

  .about {
    grid-template-columns: 1fr;
    gap: 40px;
  }

  /* Dossier becomes wide landscape card */
  .dossier {
    max-width: 100%;
    aspect-ratio: unset;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto 1fr auto;
  }

  .dossier .topbar {
    grid-column: span 2;
  }

  .dossier .field {
    grid-row: 2;
    grid-column: 1;
    min-height: 280px;
  }

  .dossier .fields {
    grid-row: 2;
    grid-column: 2;
    border-top: none;
    border-left: 1px solid var(--line);
    align-content: center;
  }

  .dossier .strip {
    grid-column: span 2;
  }

  .about .copy {
    font-size: clamp(18px, 4.8vw, 24px);
    max-width: 100%;
  }

  .about .sig {
    font-size: clamp(28px, 6vw, 38px);
  }
}

@media (max-width: 600px) {

  .dossier {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto auto;
    aspect-ratio: unset;
  }

  .dossier .topbar,
  .dossier .field,
  .dossier .fields,
  .dossier .strip {
    grid-column: 1;
    grid-row: auto;
  }

  .dossier .field {
    min-height: 240px;
  }

  .dossier .fields {
    border-left: none;
    border-top: 1px solid var(--line);
    grid-template-columns: 1fr 1fr;
  }
}


/* =========================================================
   PRACTICE — Full-width accordion on mobile
   ========================================================= */
@media (max-width: 900px) {

  .practice .wrap {
    grid-template-columns: 1fr;
    gap: 0;
  }

  /* Preview stage: taller, sticky at top while scrolling discs */
  .practice .stage {
    position: relative;
    top: 0;
    order: -1;
    margin-bottom: 0;
    border-radius: 0;
    border-left: none;
    border-right: none;
    aspect-ratio: 16/10;
    border-bottom: 1px solid var(--line);
  }

  .practice .index {
    padding-top: 0;
  }

  .practice .disc {
    padding: clamp(16px, 3.5vw, 24px) 0;
    gap: 16px;
  }

  .practice .disc .name {
    font-size: clamp(26px, 5.5vw, 40px);
  }

  .practice .disc .sub {
    font-size: 13px;
  }

  .practice .disc.on .sub {
    max-height: 100px;
  }
}


/* =========================================================
   PROCESS — Vertical card stack on mobile (already handled by no-pin)
   Enhance the no-pin appearance
   ========================================================= */

   .process.no-pin .m-card {
    position: sticky;
    top: max(100px, 12vh); /* Sticks near the top, under the nav */
    transform-origin: top center;
    box-shadow: 0 -10px 30px rgba(0,0,0,0.05); /* Adds shadow to separate stacked cards */
  }

  /* Slight top offsets so they look like a layered deck */
  .process.no-pin .m-card:nth-child(1) { top: 10vh; }
  .process.no-pin .m-card:nth-child(2) { top: calc(10vh + 10px); }
  .process.no-pin .m-card:nth-child(3) { top: calc(10vh + 20px); }
  .process.no-pin .m-card:nth-child(4) { top: calc(10vh + 30px); }
  .process.no-pin .m-card:nth-child(5) { top: calc(10vh + 40px); }

@media (max-width: 900px) {

  .process.no-pin .process-pin {
    padding: clamp(64px, 10vh, 96px) var(--pad) clamp(48px, 8vh, 72px);
  }

  .process.no-pin .m-card {
    padding: 24px 0;
    position: relative;
    overflow: hidden;
  }

  .process.no-pin .m-card .card-in {
    padding-top: 0;
  }

  .process.no-pin .m-card .ghost {
    font-size: clamp(72px, 16vw, 120px);
    opacity: 0.7;
    right: -10px;
    left: auto;
    transform: translateY(-40%);
  }

  .process.no-pin .m-card h4 {
    font-size: clamp(38px, 9vw, 62px);
  }

  .process.no-pin .m-card .desc {
    font-size: 15px;
    max-width: 100%;
  }

  .process.no-pin .m-card.active {
    background: color-mix(in oklch, var(--bg-2) 50%, transparent);
    border-radius: 12px;
    border-top: none;
    padding: 20px 18px;
    margin-bottom: 6px;
  }

  /* Step counter visible as pill above each card */
  .process.no-pin .m-card .no {
    font-size: 10px;
    letter-spacing: 0.2em;
    color: var(--accent);
    margin-bottom: 8px;
    display: block;
  }

  .process-head .ttl {
    font-size: clamp(26px, 6.5vw, 44px);
  }

  .process-head .lead {
    text-align: left;
    font-size: 13px;
  }
}


/* =========================================================
   WORK — Full-width cases on mobile
   ========================================================= */
@media (max-width: 900px) {

  .work .case {
    grid-template-columns: 1fr;
    gap: 24px;
    padding: clamp(40px, 7vw, 64px) 0;
  }

  /* Always show narrative first */
  .work .case .narrative,
  .work .case.flip .narrative {
    order: 1;
  }

  .work .case .showcase,
  .work .case.flip .showcase {
    order: 2;
  }

  .work .narrative h3 {
    font-size: clamp(34px, 8.5vw, 56px);
    margin: 10px 0 14px;
  }

  .work .narrative .story {
    font-size: 15px;
  }

  .work .narrative .metrics {
    gap: 20px;
    margin-top: 22px;
  }

  .work .narrative .metrics .m b {
    font-size: clamp(28px, 7vw, 42px);
  }

  .work .narrative .visit {
    margin-top: 20px;
  }

  /* Browser mock — no tilt on mobile, just a clean frame */
  .browser.tilt {
    transform: none !important;
    transition: none !important;
  }

  .browser .viewport {
    aspect-ratio: 16/10;
  }

  /* More grid — 1 col */
  .work .more-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .work .mini {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    aspect-ratio: unset;
    border-radius: 10px;
  }

  .work .mini .scr {
    aspect-ratio: unset;
    min-height: 120px;
    border-right: 1px solid var(--line);
  }

  .work .mini .meta {
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 8px;
    padding: 14px;
  }

  .work .mini .meta .go {
    margin-top: auto;
  }
}


/* =========================================================
   PROOF — Simplified counter layout on mobile
   ========================================================= */
@media (max-width: 760px) {

  .proof .row {
    grid-template-columns: auto 1fr;
    gap: 16px 24px;
    padding: clamp(20px, 4vw, 32px) 0;
    align-items: start;
  }

  .proof .row .ix {
    display: block;
    font-size: 10px;
    padding-top: 12px;
  }

  .proof .row .n {
    font-size: clamp(52px, 14vw, 88px);
    line-height: 0.9;
  }

  .proof .row .l {
    grid-column: 2;
    font-size: 14px;
    margin-top: -4px;
  }
}

@media (max-width: 480px) {
  .proof .row .ix {
    display: none;
  }

  .proof .row {
    grid-template-columns: 1fr;
  }

  .proof .row .l {
    grid-column: 1;
    max-width: 100%;
  }
}


/* =========================================================
   VOICES — Full width stack
   ========================================================= */
@media (max-width: 900px) {

  .voices .wrap {
    grid-template-columns: 1fr;
    gap: 32px;
  }

  .voices .stack {
    height: 300px;
    perspective: 900px;
  }

  .voices .vcard {
    border-radius: 12px;
    padding: clamp(20px, 4vw, 30px);
  }

  .voices .vcard .body {
    font-size: clamp(18px, 4.5vw, 24px);
    line-height: 1.35;
  }

  /* More visible swipe affordance on mobile */
  .voices .vcard[data-pos="0"]::after {
    content: "← swipe";
    position: absolute;
    bottom: 16px;
    right: 20px;
    font-family: "JetBrains Mono", monospace;
    font-size: 9px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--ink-3);
    opacity: 0.5;
  }

  .voices .stack-nav {
    gap: 12px;
    margin-top: 20px;
  }

  .voices .stack-nav .next-card {
    padding: 12px 20px;
    font-size: 12px;
    flex: 1;
    justify-content: center;
  }
}


/* =========================================================
   CONTACT — Better stacking on mobile
   ========================================================= */
@media (max-width: 900px) {

  .contact {
    padding: clamp(64px, 10vw, 96px) var(--pad) clamp(32px, 5vw, 48px);
  }

  .contact .big {
    font-size: clamp(38px, 9.5vw, 72px);
    line-height: 0.96;
    margin-bottom: 12px;
  }

  .contact-form {
    grid-template-columns: 1fr;
    gap: 14px 0;
    padding: 22px 0 32px;
    margin-top: 20px;
  }

  .contact-form .col-2,
  .contact-form .submit {
    grid-column: span 1;
  }

  .contact-form .submit {
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
    padding-top: 8px;
  }

  .contact-form .fine {
    font-size: 11px;
    max-width: 100%;
  }

  .contact-form button[type="submit"] {
    width: 100%;
    justify-content: center;
    padding: 17px 24px;
    font-size: 15px;
    border-radius: 12px;
  }

  .contact-form input,
  .contact-form select,
  .contact-form textarea {
    font-size: 16px; /* Prevents iOS zoom on focus */
  }

  .contact .grid {
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    padding-top: 36px;
  }

  .contact .grid a {
    font-size: 15px;
    margin-bottom: 6px;
  }

  .contact .credit {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    padding-top: 20px;
    margin-top: 36px;
  }
}

@media (max-width: 480px) {
  .contact .grid {
    grid-template-columns: 1fr;
  }

  .contact .big {
    font-size: clamp(34px, 11vw, 52px);
  }
}


/* =========================================================
   SMALL PHONE TWEAKS (≤ 400px)
   ========================================================= */
@media (max-width: 400px) {

  :root {
    --pad: 16px;
  }

  .hero-title {
    font-size: 13.5vw;
  }

  .section-title {
    font-size: clamp(30px, 9vw, 44px);
  }

  .hero-bottom .facts {
    grid-template-columns: 1fr;
  }

  .hero-bottom .facts .row:nth-child(even) {
    border-right: 1px solid var(--line);
  }

  .hero-bottom .facts .row:nth-last-child(-n+2) {
    border-bottom: 1px solid var(--line);
  }

  .hero-bottom .facts .row:last-child {
    border-bottom: none;
  }

  .dossier .fields {
    grid-template-columns: 1fr;
  }
}


/* =========================================================
   MOBILE-SPECIFIC TOUCH ENHANCEMENTS
   ========================================================= */

   @media (hover: none) {
    /* ... keep your existing overrides ... */
    
    /* Premium touch squish */
    .work .mini,
    .hero-cta,
    .contact-form button[type="submit"],
    .r-beli .dish .add {
      transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), 
                  filter 0.3s ease; /* Bouncy spring curve */
    }

    .work .mini:active,
    .hero-cta:active,
    .contact-form button[type="submit"]:active,
    .r-beli .dish .add:active {
      transform: scale(0.94); /* Deeper press */
      filter: brightness(0.9); /* Subtle dimming */
      transition: transform 0.1s ease, filter 0.1s ease; /* Instant reaction on tap */
    }
  }

/* Prevent text selection during swipe gestures */
.voices .stack {
  -webkit-user-select: none;
  user-select: none;
}

/* Larger touch targets for interactive elements */
@media (hover: none) {
  .practice .disc {
    padding: 20px 0;
  }

  .r-beli .dish .add {
    width: 32px;
    height: 32px;
    font-size: 16px;
  }

  .r-beli .tab {
    padding: 8px 14px;
    font-size: 10px;
  }

  /* Remove hover-only effects */
  .browser.tilt:hover {
    transform: none;
  }

  .work .mini:hover {
    transform: none;
  }

  /* Active states for touch */
  .work .mini:active {
    transform: scale(0.98);
    transition: transform 0.15s;
  }

  .hero-cta:active {
    transform: scale(0.96);
    transition: transform 0.15s;
  }

  .contact-form button[type="submit"]:active {
    transform: scale(0.97);
    transition: transform 0.15s;
  }
}


/* =========================================================
   MOBILE SCROLL PROGRESS — Thicker on mobile
   ========================================================= */
@media (max-width: 900px) {
  .scroll-progress {
    height: 2.5px;
  }
}


/* =========================================================
   LANDSCAPE PHONE TREATMENT
   ========================================================= */
@media (max-width: 900px) and (orientation: landscape) and (max-height: 500px) {

  .hero {
    min-height: 100vw;
  }

  .hero-title {
    font-size: 9vw;
  }

  .nav {
    padding: 7px 14px !important;
  }
}


/* =========================================================
   SAFE AREA (notched phones — iPhone X and beyond)
   ========================================================= */
@supports (padding-bottom: env(safe-area-inset-bottom)) {

  .contact {
    padding-bottom: max(clamp(32px, 5vw, 48px), env(safe-area-inset-bottom));
  }

  .nav {
    /* Ensure nav pill clears the notch/status bar area */
    top: max(12px, env(safe-area-inset-top)) !important;
  }
}
