/* ══ Mobil va planshet ════════════════════════════════════════════════════
   Alohida fayl — chunki responsive qoidalar bir joyda turgani ma'qul:
   telefonda nima o'zgarishini bitta faylni ochib ko'rish mumkin.
   Kamchiligi bor: komponent uslubi ikki faylga bo'linadi. Loyiha
   kattalashsa har komponentning o'z faylida saqlash to'g'riroq bo'ladi.

   Yuklanish tartibi: tokens → base → components → motion → responsive
   ═══════════════════════════════════════════════════════════════════════ */

/* -- Project carousel ---------------------------------------------------
   One markup, two modes (carousel.js sets [data-carousel-mode]):
     swipe (< 900px):  native scroll-snap strip, neighbours peek in
     stage (>= 900px): coverflow, front card with its neighbours behind;
                       positions rotate on a timer */

.carousel { position: relative; }

/* Controls, both modes */
.carousel__nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.85rem;
  margin-top: 1.25rem;
}
.carousel__btn {
  width: 44px; height: 44px;
  border-radius: 50%;
  display: grid; place-items: center;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease),
              border-color var(--dur) var(--ease), transform var(--dur-fast) var(--ease);
}
.carousel__btn svg { width: 18px; height: 18px; }
.carousel__btn:hover { background: var(--text); color: var(--bg); border-color: var(--text); }
.carousel__btn:active { transform: scale(0.92); }

.carousel__dots { display: flex; gap: 0.4rem; }
.carousel__dot {
  position: relative;
  overflow: hidden;
  width: 7px; height: 7px;
  padding: 0;
  border-radius: 4px;
  background: var(--border-strong);
  transition: width 320ms var(--ease-out);
}
.carousel__dot[aria-current="true"] { width: 26px; }
.carousel__dot[aria-current="true"]::after {
  content: "";
  position: absolute; inset: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--turquoise), var(--indigo));
  transform-origin: 0 50%;
}
[data-playing="true"] .carousel__dot[aria-current="true"]::after {
  animation: carousel-fill var(--autoplay, 4s) linear both;
}
@keyframes carousel-fill {
  from { transform: scaleX(0); }
  to   { transform: scaleX(1); }
}

.carousel__counter {
  font-family: var(--font-mono);
  font-size: var(--step--2);
  color: var(--text-faint);
  min-width: 5.5ch;
  text-align: center;
}

/* Swipe mode */
@media (max-width: 899px) {
  .carousel__track {
    display: flex !important;
    grid-template-columns: none !important;
    gap: 0.9rem;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    padding-inline: 8vw;
    scroll-padding-inline: 8vw;
    padding-block: 0.75rem 1.25rem;
    margin-inline: calc(var(--gutter) * -1);
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
  }
  .carousel__track::-webkit-scrollbar { display: none; }
  .carousel__track:focus-visible { outline-offset: -2px; }

  .carousel__item {
    flex: 0 0 84vw;
    max-width: 420px;
    min-width: 0;               /* the nowrap chip row must not widen the card */
    scroll-snap-align: center;
    transform: scale(0.93);
    opacity: 0.55;
    transition: transform 420ms var(--ease-out), opacity 420ms var(--ease-out);
  }
  .carousel__item.is-active { transform: scale(1); opacity: 1; }
  .carousel__item > .card { height: 100%; }
}

/* Stage mode (coverflow)
   Every card has the same height (--stage-h, measured by carousel.js), so
   the row stays calm whichever card is in front. Side cards sit flat behind
   the front one: smaller, dimmed and slightly blurred, so they read as
   depth rather than as half-cut text. No 3D rotation. The ease-in-out
   curve starts and ends softly; 1.2s keeps the change unhurried. */
@media (min-width: 900px) {
  .carousel { --ease-stage: cubic-bezier(0.45, 0, 0.25, 1); }

  .carousel__track.projects {
    display: block;
    position: relative;
    height: 640px;                  /* replaced with the exact value by JS */
  }

  .carousel__item {
    position: absolute;
    top: 24px;
    left: 50%;
    width: min(560px, 44%);
    height: var(--stage-h, auto);
    display: flex;
    opacity: 0;
    pointer-events: none;
    transform: translateX(-50%) scale(0.78);
    transition: transform 1000ms var(--ease-stage),
                opacity 800ms var(--ease-stage),
                filter 800ms var(--ease-stage);
    will-change: transform, opacity;
  }
  .carousel__item > .card { flex: 1; min-width: 0; height: 100%; }

  .carousel__item[data-pos="center"] {
    z-index: 3;
    opacity: 1;
    pointer-events: auto;
    transform: translateX(-50%) scale(1);
  }
  .carousel__item[data-pos="center"] > .card { box-shadow: var(--shadow-lg); }

  .carousel__item[data-pos="left"],
  .carousel__item[data-pos="right"] {
    z-index: 2;
    opacity: 0.42;
    filter: blur(2px) saturate(0.85);
    pointer-events: auto;
    cursor: pointer;
  }
  .carousel__item[data-pos="left"]  { transform: translateX(-118%) scale(0.86); }
  .carousel__item[data-pos="right"] { transform: translateX(18%) scale(0.86); }
  .carousel__item[data-pos="left"]:hover,
  .carousel__item[data-pos="right"]:hover { opacity: 0.7; filter: none; }

  .carousel__item[data-pos="far-left"]  { z-index: 1; transform: translateX(-170%) scale(0.75); }
  .carousel__item[data-pos="far-right"] { z-index: 1; transform: translateX(70%) scale(0.75); }

  /* Side cards are previews: no lift or glow of their own */
  .carousel__item:not([data-pos="center"]) > .card:hover { transform: none; box-shadow: none; }
  .carousel__item:not([data-pos="center"]) > .card::before,
  .carousel__item:not([data-pos="center"]) > .card::after { opacity: 0 !important; }

  /* Text-only cards: title on top, tech and link at the bottom */
  .carousel__item .card--text .card__body { justify-content: space-between; }
}

/* ══ Tipografika ═════════════════════════════════════════════════════════ */
@media (max-width: 720px) {
  :root {
    --header-h: 58px;
    /* Telefonda sarlavhalar kichikroq — 4rem li sarlavha ekranning
       yarmini yeb qo'yadi va o'qishga emas, tomosha qilishga majbur qiladi */
    --step-4: clamp(1.95rem, 8.5vw, 2.6rem);
    --step-3: clamp(1.6rem, 6.5vw, 2.1rem);
    --step-2: clamp(1.35rem, 5.2vw, 1.7rem);
  }

  h1, h2 { letter-spacing: -0.03em; }
  .lead { font-size: var(--step-0); }
  .section { padding-block: clamp(2.5rem, 8vw, 4rem); }
  .hero { padding-block: 2rem 2.5rem; }
  .hero h1 { max-width: none; }
  .hero__intro { max-width: none; }
}

/* ══ Barmoq uchun o'lcham ════════════════════════════════════════════════
   WCAG 2.2 bo'yicha bosiladigan element kamida 24×24px bo'lishi kerak.
   Amalda 44px qulayroq — o'rtacha barmoq izi shuncha. */
@media (pointer: coarse) {
  .btn { padding: 0.9rem 1.4rem; min-height: 46px; }
  .icon-btn { width: 44px; height: 44px; }
  .lang__btn { min-height: 40px; padding-inline: 12px; }
  .lang__menu a { padding: 12px; }
  .filter { padding: 0.55rem 1rem; }
  .chip { padding: 0.3rem 0.7rem; }
  .gallery__thumb { min-height: 76px; }
  .footer a { display: inline-block; padding-block: 4px; }
}

/* ══ Mobil menyu ═════════════════════════════════════════════════════════
   To'liq ekran o'rniga o'ng yuqori burchakdagi ixcham panel.

   Nega shunday: to'liq ekran menyuda to'rtta havola markazda suzib turadi
   va atrofi bo'm-bo'sh qoladi. Panel esa burger tugmasidan "o'sib chiqadi" —
   foydalanuvchi qayerni bosgani va nima ochilgani o'rtasidagi bog'liqlik
   ko'rinib turadi. Ortidagi sahifa ham yo'qolmaydi, faqat xiralashadi. */
@media (max-width: 780px) {
  .nav {
    position: fixed;
    top: calc(var(--header-h) + 8px);
    right: var(--gutter);
    left: auto;
    bottom: auto;
    z-index: 70;
    width: min(260px, calc(100vw - var(--gutter) * 2));
    height: auto;

    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 0.5rem;

    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;

    /* Burger tugmasi tomondan ochiladi */
    transform-origin: 100% 0;
    transform: scale(0.94) translateY(-6px);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 240ms var(--ease-out),
                transform 300ms var(--ease-out),
                visibility 300ms;
  }
  .nav[data-open="true"] {
    transform: none;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }

  /* backdrop-filter makes the header the containing block of its fixed
     children, so the panel and the scrim would be tied to the 64px header
     box. While the menu is open the header drops the filter and the
     fixed layers measure against the viewport again. */
  .header.is-menu-open {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: var(--bg);
  }
  /* Brand and the close button stay sharp above the scrim */
  .header.is-menu-open .brand,
  .header.is-menu-open .header__tools { position: relative; z-index: 71; }

  /* Ortidagi sahifani xiralashtiruvchi qatlam.
     Alohida <button> — bosilganda menyu yopiladi. */
  .nav-scrim {
    position: fixed;
    inset: 0;
    z-index: 69;
    display: block;
    width: 100%;
    padding: 0;
    border: none;
    cursor: default;
    background: color-mix(in srgb, var(--bg) 55%, transparent);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 240ms var(--ease-out), visibility 240ms;
  }
  .nav-scrim[data-open="true"] {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }

  .nav a {
    display: flex;
    align-items: center;
    position: relative;
    padding: 0.85rem 0.9rem;
    border-radius: var(--radius);
    border-bottom: none;
    font-size: var(--step-0);
    font-weight: 500;
    line-height: 1.3;
    color: var(--text-soft);
    /* Navbat bilan chiqadi */
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 300ms var(--ease-out), transform 300ms var(--ease-out),
                background var(--dur-fast) var(--ease);
  }
  .nav[data-open="true"] a { opacity: 1; transform: none; }
  .nav[data-open="true"] a:nth-child(1) { transition-delay: 40ms; }
  .nav[data-open="true"] a:nth-child(2) { transition-delay: 80ms; }
  .nav[data-open="true"] a:nth-child(3) { transition-delay: 120ms; }
  .nav[data-open="true"] a:nth-child(4) { transition-delay: 160ms; }

  .nav a:active { background: var(--surface-2); }

  /* Faol sahifa: fon va chapdan rangli chiziqcha */
  .nav a[aria-current="page"] {
    color: var(--text);
    font-weight: 600;
    background: var(--surface-2);
  }
  .nav a[aria-current="page"]::after {
    content: "";
    position: absolute;
    left: 0; top: 50%; right: auto; bottom: auto;
    width: 3px; height: 1.3em;
    border-radius: 0 3px 3px 0;
    transform: translateY(-50%);
  }

  /* Burger belgisi X ga aylanadi */
  .nav-toggle[aria-expanded="true"] .burger-open { display: none; }
  .nav-toggle[aria-expanded="false"] .burger-close { display: none; }

  .kbd-hint { display: none; }
}

/* ══ Loyihalar ro'yxati (/work/) ═════════════════════════════════════════ */
@media (max-width: 899px) {
  .row {
    grid-template-columns: 1fr;
    gap: 0.5rem;
    padding-block: 1.5rem;
  }
  .row__index { display: none; }        /* raqam mobil ekranda joy yeydi */
  .row__title { font-size: var(--step-1); }
  .row__tagline { font-size: var(--step--1); }
  .row__year {
    font-size: var(--step--2);
    order: -1;                           /* yilni sarlavhadan yuqoriga */
  }
  .row__tech { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-top: 0.3rem; }
  .row__thumb { margin-top: 1rem; }
}

/* Filtrlar — ko'p qatorga yoyilish o'rniga yon tomonga suriladi */
@media (max-width: 720px) {
  .filters {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    margin-inline: calc(var(--gutter) * -1);
    padding-inline: var(--gutter);
    padding-bottom: 1rem;
    mask-image: linear-gradient(90deg, #000 88%, transparent);
    -webkit-mask-image: linear-gradient(90deg, #000 88%, transparent);
  }
  .filters::-webkit-scrollbar { display: none; }
  .filter { flex: none; }
}

/* ══ Loyiha sahifasi ═════════════════════════════════════════════════════ */
@media (max-width: 979px) {
  .case { gap: 2rem; }
  /* Yon panel case study'dan oldin turadi — o'quvchi avval faktlarni
     ko'rib, keyin matnga kirsin */
  .case__aside {
    order: -1;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--sp-5);
  }
  .facts { grid-template-columns: repeat(2, 1fr); gap: 1rem; }
  .facts > div:last-child { grid-column: 1 / -1; }
}

@media (max-width: 720px) {
  .gallery__thumbs { grid-template-columns: repeat(3, 1fr); gap: 0.5rem; }
  .metrics { grid-template-columns: 1fr; }
  .pager { flex-direction: column; align-items: stretch; gap: 0.75rem; }
  .pager .btn { justify-content: center; }
}

/* ══ Lightbox ════════════════════════════════════════════════════════════ */
@media (max-width: 720px) {
  .lightbox { padding: 1rem; }
  .lightbox img { max-height: 68vh; }
  .lightbox__nav {
    top: auto;
    bottom: calc(1.5rem + env(safe-area-inset-bottom));
    transform: none;
    width: 48px; height: 48px;
  }
  .lightbox__nav--prev { left: 25%; }
  .lightbox__nav--next { right: 25%; }
  .lightbox__close { top: calc(1rem + env(safe-area-inset-top)); }
}

/* ══ Contact ═════════════════════════════════════════════════════════════ */
@media (max-width: 899px) {
  .contact { gap: 2rem; }
  .contact__aside { order: -1; }        /* "Keyin nima bo'ladi" formadan oldin */
  .facts { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 520px) {
  .facts { grid-template-columns: 1fr; }
  .field-row input, .field-row textarea {
    /* 16px dan kichik shrift iOS'da sahifani avtomatik kattalashtiradi */
    font-size: 16px;
    padding: 0.85rem 1rem;
  }
}

/* ══ Bosh sahifa ═════════════════════════════════════════════════════════ */
@media (max-width: 720px) {
  .stats { grid-template-columns: 1fr; }
  .stat { padding: 1.25rem var(--gutter); }
  .stat__value { font-size: var(--step-1); }
  .principles { gap: 0.9rem; }
  .cta { padding: 1.75rem 1.5rem; }
  .hero__actions { flex-direction: column; align-items: stretch; }
  .hero__actions .btn { justify-content: center; }
  .marquee { --marquee-duration: 26s; }
}


/* ══ CV ══════════════════════════════════════════════════════════════════ */
@media (max-width: 720px) {
  .cv__head { flex-direction: column; gap: 1rem; }
  .cv__contacts { text-align: left; }
  .cv__actions { flex-direction: column; }
  .cv__actions .btn { justify-content: center; }
}

/* ══ Sensorli qurilmalarda og'ir effektlarni o'chirish ═══════════════════
   Parallaks va katta blur telefonlarda kadr tezligini tushiradi.
   Bu tejamkorlik emas — sekin animatsiya animatsiya yo'qligidan yomonroq. */
@media (max-width: 720px) {
  .field { opacity: calc(var(--field-opacity) * 0.7); }
  .field__blob { filter: blur(60px); }
  .grain { display: none; }
}
/* ══ Header mobil ekranda ════════════════════════════════════════════════ */
@media (max-width: 780px) {
  /* Menyu ochiq bo'lganda header uning ustida turishi kerak —
     aks holda yopish tugmasi menyu ostida qolib bosilmaydi. */
  .header { z-index: 80; }

  .header__inner { gap: 0.5rem; }

  .brand {
    min-width: 0;
    font-size: var(--step--1);
    gap: 0.45rem;
  }
  .brand span:last-child {
    /* Ism ikki qatorga bo'linmasin — header balandligi o'zgarib ketadi */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .brand__mark { width: 24px; height: 24px; font-size: 10px; }
}

@media (max-width: 400px) {
  /* Juda tor ekranda faqat belgi qoladi */
  .brand span:last-child { display: none; }
}
/* Keng ekranda scrim umuman kerak emas */
@media (min-width: 781px) {
  .nav-scrim { display: none; }
}


/* Hero on phones: portrait on the left, name and status to its right,
   headline and text full width below. .hero__inner switches to
   display: contents so its children join the section grid directly. */
@media (max-width: 899px) {
  .hero--with-media {
    display: grid;
    grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr);
    grid-template-areas:
      "media   name"
      "media   status"
      "title   title"
      "intro   intro"
      "actions actions";
    column-gap: 1.1rem;
    row-gap: 0;
  }
  .hero--with-media .hero__inner { display: contents; }

  .hero--with-media .hero__media {
    grid-area: media;
    order: 0;
    width: 100%;
    aspect-ratio: 4 / 5;
    border-radius: 22px;
    margin: 0 0 1.75rem;
  }
  .hero--with-media .hero__media img { object-position: 50% 20%; }

  .hero--with-media .hero__name {
    grid-area: name;
    align-self: end;
    margin: 0 0 0.75rem;
    font-size: var(--step--2);
    letter-spacing: 0.1em;
    line-height: 1.7;
  }
  .hero--with-media .status {
    grid-area: status;
    align-self: start;
    justify-self: start;
    white-space: normal;
    border-radius: 14px;
    line-height: 1.45;
  }
  .hero--with-media h1 { grid-area: title; margin-top: 0; }
  .hero--with-media .hero__intro { grid-area: intro; }
  .hero--with-media .hero__actions { grid-area: actions; }
}

@media (max-width: 899px) {
  .hero--with-media .hero__name > span { display: block; }
  .hero--with-media .hero__loc::before { content: none; }
}

