/* ============================================================
   cemwebstudio — MOBILE & TABLET OPTIMIZATIONS
   Loaded LAST so overrides cleanly cascade
   ============================================================ */

/* ---------- viewport-safe baselines ---------- */
html, body { -webkit-text-size-adjust: 100%; }
img, video, svg { max-width: 100%; height: auto; }

/* prevent body scroll when mobile nav is open */
body.nav-locked { overflow: hidden; touch-action: none; }

/* ============================================================
   NAV TOGGLE (hamburger) — hidden on desktop, shown on mobile
   ============================================================ */
.nav-toggle {
  display: none;
  appearance: none;
  background: transparent;
  border: 1px solid var(--border);
  width: 38px;
  height: 38px;
  padding: 0;
  cursor: pointer;
  position: relative;
  border-radius: 2px;
  align-items: center;
  justify-content: center;
  transition: border-color 0.2s;
}
.nav-toggle:hover { border-color: var(--text-dim); }
.nav-toggle span {
  position: absolute;
  left: 8px;
  right: 8px;
  height: 2px;
  background: var(--text);
  transition: transform 0.3s, opacity 0.2s, top 0.3s;
}
.nav-toggle span:nth-child(1) { top: 12px; }
.nav-toggle span:nth-child(2) { top: 18px; }
.nav-toggle span:nth-child(3) { top: 24px; }
.nav-toggle.is-open span { background: var(--accent); }
.nav-toggle.is-open span:nth-child(1) { top: 18px; transform: rotate(45deg); }
.nav-toggle.is-open span:nth-child(2) { opacity: 0; }
.nav-toggle.is-open span:nth-child(3) { top: 18px; transform: rotate(-45deg); }

/* ============================================================
   TABLET (≤ 1024px) — light tweaks
   ============================================================ */
@media (max-width: 1024px) {
  section { padding: 5rem 0; }
  .section-head { gap: 1.25rem; margin-bottom: 3rem; }
  .hero { padding-top: 7.5rem; }
}

/* ============================================================
   MOBILE (≤ 720px) — heavy lift
   ============================================================ */
@media (max-width: 720px) {

  /* ---------- type & spacing ---------- */
  html, body { font-size: 13px; }
  section { padding: 3.5rem 0; }
  .wrap { padding: 0 1rem; }

  .section-head {
    grid-template-columns: 1fr;
    gap: 0.75rem;
    padding-bottom: 1.25rem;
    margin-bottom: 2.25rem;
  }
  .section-head .title {
    font-size: clamp(2rem, 10vw, 3.25rem);
    line-height: 0.95;
  }
  .section-head .title .num {
    font-size: 0.5em;
    top: 0.2em;
    margin-right: 0.4em;
  }
  .section-head .meta-block { text-align: left; font-size: 10px; }

  /* ---------- status bar — drop noisy bits ---------- */
  .statusbar { font-size: 9px; height: 24px; letter-spacing: 0.12em; }
  .statusbar .wrap { gap: 0.75rem; padding: 0 0.75rem; }
  .statusbar .status-item:nth-child(2),  /* loc */
  .statusbar .status-item:nth-child(3),  /* tz + time */
  .statusbar .status-item:nth-child(5),  /* uptime */
  .statusbar .status-item:nth-child(6) { /* build id */
    display: none;
  }

  /* ---------- nav ---------- */
  .nav { top: 24px; height: 52px; }
  .nav .wrap { gap: 0.75rem; padding: 0 0.75rem; }
  .brand { font-size: 12px; }
  .brand .mark { width: 18px; height: 18px; }
  .brand .mark .dot { width: 6px; height: 6px; }

  /* hide desktop cta + contrast on mobile (move to drawer) */
  .nav-right .contrast-btn,
  .nav-right .cta-pill {
    display: none;
  }
  .nav-right { gap: 0.6rem; }
  .lang-switch button { padding: 0.3rem 0.5rem; font-size: 9.5px; }

  /* show hamburger */
  .nav-toggle { display: inline-flex; }

  /* MOBILE DRAWER ------------------------------------------------ */
  .nav-links {
    display: flex;
    position: fixed;
    top: 76px;                /* statusbar (24) + nav (52) */
    left: 0; right: 0;
    bottom: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 1.5rem 1rem 3rem;
    background: rgba(10, 10, 13, 0.97);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    z-index: 40;
    transform: translateY(-110%);
    transition: transform 0.45s cubic-bezier(0.22, 1, 0.36, 1);
    overflow-y: auto;
    border-top: 1px solid var(--border);
  }
  .nav-links.is-open {
    transform: translateY(0);
  }
  .nav-links a {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.05rem 0.25rem;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    font-size: 16px;
    letter-spacing: 0.06em;
  }
  .nav-links a .idx {
    font-size: 11px;
    color: var(--accent);
  }
  .nav-links a:hover { color: var(--accent); }

  /* an inline "hire me" CTA inside the drawer */
  .nav-links::after {
    content: '';
    /* spacer */
  }

  /* ---------- HERO ---------- */
  .hero { padding-top: 6rem; padding-bottom: 2rem; min-height: 92vh; }
  .hero-meta-row {
    grid-template-columns: 1fr;
    gap: 1rem;
    padding-bottom: 1.5rem;
    margin-bottom: 2rem;
  }
  .hero-meta-row .label { font-size: 9.5px; }
  .hero-meta-row .v { font-size: 13px; }
  .hero-headline {
    font-size: clamp(3.4rem, 19vw, 6rem);
    letter-spacing: -0.05em;
    line-height: 0.86;
  }
  .hero-bottom {
    grid-template-columns: 1fr;
    gap: 1.25rem;
    margin-top: 2rem;
    padding-top: 1.5rem;
  }
  .hero-tagline { font-size: 14px; max-width: none; }
  .hero-stat-card { padding: 0.85rem 1rem; }
  .hero-stat-card .big { font-size: 22px; }
  .hero-scroll { justify-self: start; font-size: 10px; }
  .crosshair { width: 8px; height: 8px; }
  .crosshair.tl, .crosshair.tr { top: 26px; }
  .crosshair.tl, .crosshair.bl { left: 0.5rem; }
  .crosshair.tr, .crosshair.br { right: 0.5rem; }

  /* ---------- ABOUT ---------- */
  .about-grid { grid-template-columns: 1fr; gap: 1.75rem; }
  .about-lede { font-size: 1.15rem; line-height: 1.4; max-width: none; }
  .about-body { font-size: 13px; }
  .about-body p + p { margin-top: 0.9rem; }
  .about-cards {
    grid-template-columns: 1fr 1fr;
    margin-top: 2.5rem;
  }
  .about-card { padding: 1rem 0.85rem; }
  .about-card .n { font-size: 1.5rem; }

  /* ---------- SERVICES ---------- */
  .service-row {
    grid-template-columns: 30px 1fr;
    grid-template-areas:
      "num name"
      "num desc";
    column-gap: 0.85rem;
    row-gap: 0.5rem;
    padding: 1.4rem 0.25rem;
  }
  .service-row .num  { grid-area: num;  font-size: 10px; padding-top: 0.5rem; }
  .service-row .name { grid-area: name; font-size: 1.15rem; line-height: 1.15; }
  .service-row .desc { grid-area: desc; font-size: 12px; display: block; }
  .service-row .desc .chip { display: inline-block; margin-top: 0.35rem; }
  .service-row .arr  { display: none; }
  .service-row:hover { padding-left: 0.25rem; background: none; }

  /* ---------- WORK / TV SHOWCASE ---------- */
  /* on mobile the pinned TV becomes a simpler stacked viewer */
  #work { padding-bottom: 2.5rem; }
  .tv-stage { height: 340vh; }
  .tv-pin { min-height: 0; padding-top: 1rem; }
  .tv-stage-inner {
    grid-template-columns: 1fr;
    gap: 1rem;
    padding: 0 1rem;
  }
  .tv-rail-l {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
  }
  .tv-rail-l .label { display: none; }
  .tv-counter .now { font-size: 2.1rem; }
  .tv-counter .sep { font-size: 1.1rem; }
  .tv-counter .total { font-size: 1rem; }
  .tv-ch-list {
    display: flex;
    flex-direction: row;
    gap: 0.5rem;
    border-left: 0;
    flex: 1;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .tv-ch-list::-webkit-scrollbar { display: none; }
  .tv-ch-list li {
    padding: 0.25rem 0.6rem;
    border: 1px solid var(--border);
    font-size: 10px;
    letter-spacing: 0.1em;
    white-space: nowrap;
  }
  .tv-ch-list li::before { display: none; }
  .tv-ch-list li.active {
    padding-left: 0.6rem;
    border-color: var(--accent);
    background: rgba(45,98,255,0.1);
  }
  .tv-ch-list li .ch-no { margin-right: 0.3rem; }

  .tv-set { aspect-ratio: 16 / 11; }
  .tv-bezel { padding: 22px 18px 30px 18px; border-radius: 14px; }
  .tv-bezel::before { width: 50%; bottom: 10px; height: 8px; }
  .tv-bezel::after { right: 14px; bottom: 12px; }
  .tv-label { top: 8px; left: 14px; font-size: 8.5px; gap: 0.5rem; }
  .tv-knob { width: 10px; height: 10px; }
  .tv-knob.k1 { top: 10px; right: 14px; }
  .tv-knob.k2 { top: 10px; right: 30px; }

  .tv-hud { top: 10px; left: 10px; right: 10px; font-size: 8.5px; letter-spacing: 0.14em; }
  .tv-hud .rec .dot { width: 5px; height: 5px; }
  .tv-hud-b { bottom: 10px; left: 10px; right: 10px; font-size: 8.5px; }
  .tv-hud-b .bars { height: 10px; }

  .tv-shot .corner { font-size: 8px; letter-spacing: 0.12em; }
  .tv-shot .word-mark {
    font-size: clamp(1.5rem, 8vw, 2.4rem);
  }

  .tv-rail-r {
    border-left: 0;
    padding-left: 0;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    gap: 0.85rem;
  }
  .tv-info .val.lg { font-size: 1.35rem; }
  .tv-info .label { font-size: 9px; }
  .tv-info .val { font-size: 13px; }

  .tv-progress { width: calc(100% - 2rem); bottom: 0.5rem; font-size: 9px; gap: 0.5rem; }
  .tv-scroll-hint { top: 0.5rem; font-size: 8.5px; letter-spacing: 0.18em; }

  /* ---------- STACK ---------- */
  .stack-grid { grid-template-columns: 1fr 1fr; }
  .stack-cell { padding: 1rem 0.85rem; min-height: 90px; }
  .stack-cell .name { font-size: 15px; }
  .stack-cell { font-size: 10px; }

  /* ---------- PROCESS ---------- */
  .process-grid { grid-template-columns: 1fr; border: 0; }
  .process-step {
    padding: 1.6rem 0;
    border-right: 0;
    border-bottom: 1px solid var(--border);
    min-height: 0;
    gap: 0.8rem;
  }
  .process-step:last-child { border-bottom: 0; }
  .process-step .ttl { font-size: 1.3rem; }
  .process-step .body { font-size: 12.5px; }
  .process-step .head { font-size: 10px; }

  /* ---------- NUMBERS / AWARDS ---------- */
  .numbers-grid { grid-template-columns: 1fr; gap: 2rem; }
  .numbers-list .row {
    grid-template-columns: 40px 1fr;
    grid-template-areas:
      "yr award"
      "nm nm";
    row-gap: 0.4rem;
    padding: 1rem 0;
  }
  .numbers-list .row .yr    { grid-area: yr;    font-size: 10px; }
  .numbers-list .row .award { grid-area: award; font-size: 9.5px; justify-self: end; }
  .numbers-list .row .nm    { grid-area: nm;    font-size: 14px; }
  .numbers-list .row .nm .sub { display: block; margin-left: 0; font-size: 12px; margin-top: 0.2rem; }
  .numbers-side { padding: 1.25rem; }
  .numbers-side .big { font-size: 2.7rem; }

  /* ---------- CTA ---------- */
  .cta { padding: 6rem 0 3rem; }
  .cta-eyebrow { font-size: 10px; margin-bottom: 1.25rem; gap: 0.6rem; }
  .cta-eyebrow::before { width: 24px; }
  .cta-headline {
    font-size: clamp(2.5rem, 13vw, 4.5rem);
    line-height: 0.9;
  }
  .cta-actions {
    margin-top: 2rem;
    padding-top: 1.5rem;
    gap: 1rem;
    flex-direction: column;
    align-items: flex-start;
  }
  .cta-mail { font-size: 1.05rem; }
  .cta-socials {
    margin-left: 0;
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  .cta-socials a { padding: 0.4rem 0.65rem; font-size: 10px; }

  /* ---------- CONTACT FORM ---------- */
  .contact-grid {
    grid-template-columns: 1fr;
    margin-top: 2.5rem;
  }
  .contact-form {
    border-right: 0;
    border-bottom: 1px solid var(--border);
    padding: 1.4rem 1rem;
    gap: 1.4rem;
  }
  .form-head { font-size: 9.5px; padding-bottom: 0.85rem; }
  .field input,
  .field textarea { font-size: 16px; /* prevents iOS zoom */ padding: 0.65rem 0; }
  .field textarea { min-height: 120px; }
  .field > label { font-size: 9.5px; }
  .radios { gap: 0.4rem; }
  .radio {
    padding: 0.55rem 0.7rem;
    font-size: 10.5px;
    flex: 1 1 calc(50% - 0.4rem);
    justify-content: center;
    min-width: 0;
  }
  .form-foot { padding-top: 1.1rem; flex-direction: column; align-items: stretch; gap: 0.85rem; }
  .submit-btn {
    width: 100%;
    justify-content: center;
    padding: 1rem 1.2rem;
    font-size: 13px;
    min-height: 48px;
  }
  .form-meta { font-size: 9.5px; justify-content: center; }
  .form-meta::before { display: none; }
  .form-status { font-size: 10.5px; line-height: 1.5; padding: 0.5rem 0; }

  .contact-info { padding: 1.4rem 1rem; gap: 1.1rem; }
  .contact-info-head { font-size: 9.5px; padding-bottom: 0.85rem; }
  .info-block .k { font-size: 9.5px; }
  .info-block .v { font-size: 14px; }
  .info-key { font-size: 9px; padding-top: 1rem; }

  /* ---------- FOOTER ---------- */
  .footer { padding: 2rem 0 3rem; }
  .footer-grid {
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 2.25rem;
  }
  .footer-col h4 { font-size: 9.5px; margin-bottom: 0.65rem; }
  .footer-col li { font-size: 12px; }
  .footer-bottom { flex-direction: column; align-items: flex-start; gap: 1rem; }
  .footer-mark { font-size: clamp(2.4rem, 13vw, 4rem); }
  .footer-meta { text-align: left; font-size: 9.5px; }

  /* ---------- MARQUEES ---------- */
  .binary-marquee { font-size: 9.5px; padding: 0.7rem 0; }
  .binary-marquee .track { gap: 1.25rem; }

  /* tighten section padding around #work where marquee lives */
  #work .binary-marquee { margin-top: 2rem; }
}

/* ============================================================
   VERY SMALL (≤ 380px) — extra squeeze
   ============================================================ */
@media (max-width: 380px) {
  .wrap { padding: 0 0.75rem; }
  .hero-headline { font-size: clamp(2.8rem, 20vw, 4.5rem); }
  .section-head .title { font-size: 2rem; }
  .about-cards { grid-template-columns: 1fr; }
  .radio { flex: 1 1 100%; }
  .stack-grid { grid-template-columns: 1fr; }
  .nav-right .lang-switch { padding: 0; }
  .nav-right .lang-switch button { padding: 0.25rem 0.4rem; }
}

/* ============================================================
   LANDSCAPE PHONES — avoid hero swallowing whole screen
   ============================================================ */
@media (max-width: 920px) and (max-height: 540px) and (orientation: landscape) {
  .hero { min-height: 0; padding-top: 6rem; padding-bottom: 2rem; }
  .hero-headline { font-size: clamp(3rem, 12vw, 6rem); }
  .tv-pin { height: auto; min-height: 0; padding: 1rem 0; }
}

/* ============================================================
   TOUCH-OPTIMISED HIT TARGETS (any pointer:coarse)
   ============================================================ */
@media (pointer: coarse) {
  .nav-links a,
  .lang-switch button,
  .contrast-btn,
  .submit-btn,
  .cta-pill,
  .radio { min-height: 44px; }
  .submit-btn { min-height: 48px; }

  /* on touch devices, hide cursor-only animations that don't apply */
  .work-preview { display: none !important; }
}

/* ============================================================
   REDUCED MOTION
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .tv-scansweep, .tv-static::before { display: none; }
  .binary-marquee .track { animation: none !important; }
}
