/* =========================================================================
   RESPONSIVE — بازچینش ترکیب‌بندی و انطباق کامل با تلفن‌های همراه و تبلت‌ها
   حالت‌ها از همین‌جا اعلام می‌شوند و JS آن‌ها را می‌خواند:
     --stage-mode  (در stage.css)   panels | stack
     --svc-mode                     3d | stack
     --svc-motion                   ضریب شدت حرکت کارت‌ها (۰..۱)
     --mode        (بخش پروژه‌ها)    3d | scroll
   ========================================================================= */

.panel--services {
  --svc-mode: '3d';
  --svc-motion: 1;
}

/* ==================================================== تبلت بزرگ (1200px) */
@media (max-width: 1200px) {
  /* پرونده باریک‌تر، آمار کوچک‌تر */
  .data__main {
    grid-template-columns: minmax(0, 1fr) clamp(260px, 30vw, 330px);
  }

  .stat__value {
    font-size: clamp(1.9rem, 3.4vw, 2.6rem);
  }

  .why__drone {
    max-width: 200px;
  }

  .why__list {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ========================================================= تبلت (1000px) */
@media (max-width: 1000px) {
  :root {
    --header-h: 74px;
  }

  /* نمونه‌کارها دوستونه، بدون حفره و با ارتفاع کافی جهت جلوگیری از برش متن */
  .portfolio__grid {
    --row: clamp(230px, 32vw, 300px);
  }

  .portfolio__grid[data-layout='bento'] {
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(4, var(--row));
    grid-template-areas:
      'a a'
      'b c'
      'd e'
      'f f';
  }

  .pf-tile {
    min-height: var(--row);
    overflow: hidden;
  }

  .pf-tile__body {
    max-height: calc(100% - 24px);
    overflow: hidden;
  }

  .pf-tile__result {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.6;
    font-size: 0.8125rem;
    max-height: none !important;
    opacity: 1 !important;
  }

  /* گالری دوستونه با ارتفاع استاندارد برای نمایش کامل تصاویر و کپشن‌ها */
  .gallery__grid {
    --row: clamp(200px, 28vw, 260px);
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(5, var(--row));
    grid-template-areas:
      'a a'
      'b c'
      'b e'
      'd f'
      'd g';
  }

  .gal {
    min-height: var(--row);
    overflow: hidden;
  }

  .catalog__inner {
    grid-template-columns: 1fr;
    gap: var(--sp-6);
  }

  .catalog__cover {
    max-width: 240px;
    justify-self: center;
    margin: 0 auto;
  }
}

/* ============================================== وضوح و نور تصاویر در لمسی و موبایل */
@media (hover: none), (max-width: 900px) {
  /* تصاویر گالری و نمونه‌کارها نباید در لمسی و موبایل تاریک یا بی‌رنگ بمانند */
  .gal img,
  .pf-tile img {
    filter: saturate(0.95) brightness(0.92) !important;
  }

  .gal::after {
    opacity: 0.75;
    background: linear-gradient(to top, rgba(4, 9, 16, 0.92) 0%, rgba(4, 9, 16, 0.4) 45%, transparent 75%);
  }

  .gal__caption {
    opacity: 1 !important;
    transform: none !important;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.5;
    font-size: 0.78rem;
    background: rgba(3, 7, 13, 0.85);
    padding: 6px 12px;
    border-radius: var(--radius-sm, 6px);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(240, 163, 46, 0.25);
  }
}

/* ====================== پنل‌ها → بخش‌های عادی (موبایل/تبلت/کاهش حرکت <= 900px) */
@media (max-width: 900px), (prefers-reduced-motion: reduce) {
  /* حذف پهپاد تزئینی در ریسپانسیو — نیازی به وجودش نیست */
  .global-drone {
    display: none !important;
  }
  /* ---------------------------------------------------- خدمات */
  .panel--services {
    --svc-mode: 'stack';
    --svc-motion: 0.45;
    padding-block: var(--section-py);
    gap: var(--sp-5);
  }

  .services__stage {
    position: relative;
    height: auto;
    perspective: none;
  }

  .services__track {
    position: static;
    display: flex;
    gap: var(--sp-4);
    padding-inline: var(--gutter);
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    transform-style: flat;
  }

  .services__track::-webkit-scrollbar {
    display: none;
  }

  .svc-card {
    --lit: 0.18;
    position: static;
    flex: 0 0 min(84vw, 340px);
    height: auto;
    min-height: clamp(480px, 64vh, 550px);
    margin: 0;
    transform: none !important;
    opacity: 1 !important;
    scroll-snap-align: center;
    display: flex;
  }

  .svc-card.is-active {
    --lit: 1;
  }

  .svc-card__link {
    width: 100%;
    min-height: inherit;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 28px 20px 22px;
    box-sizing: border-box;
    overflow: visible;
  }

  .svc-card__body {
    margin-block: 8px 14px;
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 0;
  }

  /* ------------------------------------------------- توپوگرافی در ریسپانسیو */
  /* نوار آمار و اطلاعات لیدار بالا سمت راست — با فاصله از منوی بالای صفحه */
  .terrain__hud-tr {
    display: flex !important;
    position: absolute;
    top: calc(var(--dock-h, 54px) + max(14px, env(safe-area-inset-top, 14px)));
    right: max(12px, var(--gutter));
    left: auto;
    padding: 6px 12px;
    gap: 2px;
    align-items: flex-start;
    background: rgba(3, 7, 13, 0.94);
    border: 1px solid rgba(240, 163, 46, 0.35);
    border-radius: var(--radius-sm);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.7);
    z-index: 10;
  }

  .terrain__hud-tr .mono--accent {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--accent-bright);
    direction: ltr;
  }

  .terrain__hud-tr .coord {
    font-size: 0.625rem;
    color: var(--fg-300);
  }

  .terrain__meter {
    width: 76px;
    height: 3px;
    margin-top: 3px;
  }

  /* بلوک مختصات فنی بالا سمت چپ — با فاصله از منوی بالای صفحه */
  .terrain__hud-tl {
    display: flex !important;
    position: absolute;
    top: calc(var(--dock-h, 54px) + max(14px, env(safe-area-inset-top, 14px)));
    left: max(12px, var(--gutter));
    right: auto;
    padding: 6px 10px;
    gap: 2px;
    font-size: 0.625rem;
    background: rgba(3, 7, 13, 0.94);
    border: 1px solid rgba(240, 163, 46, 0.25);
    border-radius: var(--radius-sm);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.7);
    z-index: 10;
  }

  /* نشان مرکزی: در پایین کوهستان، بالاتر از کپشن متنی */
  .terrain__hud-center {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    top: auto;
    bottom: clamp(74px, 12vh, 98px);
    padding: 6px 16px;
    gap: 2px;
    background: rgba(3, 7, 13, 0.94);
    border: 1px solid rgba(240, 163, 46, 0.35);
    border-radius: var(--radius-sm);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.7);
    z-index: 10;
  }

  .terrain__watermark {
    font-size: 1rem;
  }

  .terrain__subcode {
    font-size: 0.65rem;
  }

  /* کپشن پایینی: در کف کادر با حاشیه امن بدون پوشاندن کوهستان */
  .terrain__caption {
    position: absolute;
    inset-inline: 0;
    bottom: clamp(14px, 2.5vh, 22px);
    padding-inline: var(--gutter);
    max-width: min(100%, 480px);
    margin-inline: auto;
    font-size: 0.8125rem;
    line-height: 1.5;
    text-align: center;
    z-index: 10;
  }

  /* ---------------------------------------------------- پروژه‌ها */
  .data {
    --mode: 'scroll';
  }

  .data__rail {
    height: auto !important;
  }

  .data__sticky {
    position: static;
    height: auto;
    overflow: visible;
  }

  .data__inner {
    height: auto;
    padding-block: var(--section-py);
  }

  .data__head {
    flex-direction: column;
    align-items: stretch;
    gap: var(--sp-4);
  }

  .data__main {
    grid-template-columns: 1fr;
  }

  .pstage {
    overflow: visible;
    perspective: none;
    -webkit-mask-image: none;
    mask-image: none;
    margin-inline: calc(var(--gutter) * -1);
  }

  .pstage__track {
    position: static;
    display: flex;
    gap: var(--sp-3);
    padding: 4px var(--gutter) 12px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    transform-style: flat;
  }

  .pstage__track::-webkit-scrollbar {
    display: none;
  }

  .data__caption {
    min-height: 2.8em;
  }

  .pcard {
    position: static;
    flex: 0 0 min(86%, 520px);
    width: auto;
    height: clamp(260px, 60vw, 360px);
    margin: 0;
    transform: none !important;
    opacity: 1 !important;
    scroll-snap-align: center;
    cursor: pointer;
  }

  .pcard .pcard__frame {
    inset: 12px !important;
    animation: none !important;
  }

  .pcard.is-active .pcard__frame {
    opacity: 1 !important;
    animation: none !important;
  }

  .pcard__info {
    opacity: 1;
    transform: none;
    inset-inline: 16px;
    bottom: 16px;
  }

  .pcard__cat {
    font-size: 0.75rem;
    padding: 3px 8px;
  }

  .pcard__loc {
    font-size: 0.75rem;
  }

  .pcard__video-ctrls {
    top: 12px;
    right: 14px;
    gap: 6px;
  }

  .pcard__video-badge {
    font-size: 0.7rem;
    padding: 3px 8px;
  }

  .pdoc {
    width: 100%;
    max-width: 100%;
    margin-block: 0;
    padding: clamp(16px, 2.5vw, 24px);
    min-height: 540px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
  }

  .pdoc__summary {
    -webkit-line-clamp: 4;
    line-height: 1.85;
  }

  .data__arrow {
    display: none;
  }

  /* -------------------------------------------- گواهی‌ها و مقالات */
  .credentials__strip {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--sp-3);
  }

  .articles__grid {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--sp-4);
  }
}

/* ======================================================== تبلت و موبایل متوسط (<= 768px) */
@media (max-width: 768px) {
  /* درباره ما — چیدمان عمودی تمیز تا متن فشرده نشود و ویدیو بریده نشود */
  .why__top-row {
    flex-direction: column;
    align-items: center;
    text-align: right;
    gap: var(--sp-4);
  }

  .why__head {
    width: 100%;
    max-width: 100%;
    text-align: right;
  }

  .why__drone {
    width: clamp(160px, 46vw, 220px);
    max-width: 220px;
    margin: 0 auto var(--sp-2);
    order: -1;
  }

  .catalog__cover {
    max-width: 220px;
    justify-self: center;
    margin: 0 auto;
  }

  .catalog__body {
    text-align: right;
  }

  .catalog__actions {
    display: flex;
    flex-direction: row;
    gap: var(--sp-3);
    width: 100%;
  }

  .catalog__actions .btn {
    flex: 1 1 0;
  }
}

/* ======================================================== موبایل استاندارد (<= 720px) */
@media (max-width: 720px) {
  .hero__title {
    font-size: clamp(2rem, 8.5vw, 2.9rem);
    line-height: 1.25;
  }

  .hero__lead {
    font-size: var(--fs-base);
    line-height: 1.8;
  }

  .terrain__scale {
    display: none;
  }

  .terrain__pin-label {
    display: none;
  }

  .gallery__grid {
    --row: 42vw;
  }

  /* نمونه‌کارها یک ستون با ارتفاع متناسب برای نمایش بدون کراپ متن */
  .portfolio__grid[data-layout] {
    grid-template-columns: 1fr;
    grid-template-rows: none;
    grid-template-areas: none;
    grid-auto-rows: clamp(300px, 78vw, 380px);
  }

  .pf-tile {
    min-height: 290px;
  }

  .pf-tile[data-slot] {
    grid-area: auto;
  }

  .pf-tile__body {
    inset-inline: 14px;
    bottom: 12px;
    gap: 4px;
    max-width: calc(100% - 28px);
  }

  .pf-tile__title {
    font-size: 1.05rem;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .pf-tile__result {
    font-size: 0.8125rem;
    line-height: 1.6;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    max-height: none !important;
    opacity: 1 !important;
  }

  .section__head--split > .shot-label {
    align-self: stretch;
  }

  .gal__frame {
    inset: 12px;
    --l: 12px;
  }

  .why__list {
    grid-template-columns: 1fr;
  }

  .section__head--split {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--sp-4);
  }

  /* فیلترهای نمونه‌کار به نوار لغزان افقی تمیز */
  .portfolio__filters {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    width: 100%;
    margin-inline: calc(var(--gutter) * -1);
    padding-inline: var(--gutter);
    padding-bottom: 6px;
  }

  .portfolio__filters::-webkit-scrollbar {
    display: none;
  }

  .portfolio__filters .chip {
    flex: 0 0 auto;
    scroll-snap-align: start;
  }

  /* پاورقی در موبایل */
  .ftr-info__grid {
    grid-template-columns: 1fr;
    gap: 32px;
  }

  .ftr-nav {
    grid-template-columns: 1fr 1fr;
    gap: 24px;
  }

  .ftr-brand__title {
    font-size: clamp(1.35rem, 5.5vw, 1.7rem);
    line-height: 1.35;
  }

  .ftr-bottom {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 14px;
    padding-bottom: clamp(100px, 14vh, 130px);
  }
}

/* ======================================================== موبایل متوسط (<= 640px) */
@media (max-width: 640px) {
  /* جدول مشخصات پروژه تک‌ستونه برای رفع بریدگی و کراپ متون فارسی */
  .pdoc__facts {
    grid-template-columns: 1fr;
  }

  .pdoc__fact {
    padding-inline: 0 !important;
    border-inline-start: none !important;
    padding-block: 8px;
  }

  .stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    width: 100%;
  }

  .stat {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    padding: 0;
  }

  .stat + .stat {
    padding-inline-start: 0;
    border-inline-start: none;
    border-top: none;
  }

  .stat__value {
    font-size: clamp(1.4rem, 4.8vw, 1.9rem);
  }

  .stat__label {
    font-size: 0.75rem;
  }

  /* گالری در موبایل: تک‌ستونه با ارتفاع استاندارد جهت شفافیت و عدم کات شدن تصاویر */
  .gallery__grid {
    grid-template-columns: 1fr;
    grid-template-rows: none;
    grid-template-areas: none;
    grid-auto-rows: clamp(230px, 60vw, 320px);
    gap: 14px;
  }

  .gallery__grid > .gal:nth-child(n) {
    grid-area: auto;
  }
}

/* ======================================================== مقالات تک‌ستونه (<= 580px) */
@media (max-width: 580px) {
  .articles__grid {
    grid-template-columns: 1fr;
    gap: var(--sp-4);
  }
}

/* ======================================================== موبایل کوچک (<= 480px) */
@media (max-width: 480px) {
  .gcam {
    width: 44px;
    height: 44px;
  }

  .shot-label {
    gap: 12px;
  }

  /* مخفی‌کردن سطرهای اضافه مختصات در توپوگرافی جهت خلوت ماندن نوار */
  .terrain__hud-tl span:nth-child(n+2) {
    display: none;
  }

  .ftr-nav {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .catalog__actions {
    flex-direction: column;
  }

  .catalog__actions .btn {
    width: 100%;
  }
}

/* ======================================================== موبایل بسیار کوچک (<= 420px) */
@media (max-width: 420px) {
  :root {
    --gutter: 14px;
  }

  .credentials__strip {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .stats {
    grid-template-columns: 1fr;
    gap: var(--sp-2);
  }

  .stat {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    padding-block: 8px;
    border-top: 1px solid var(--border);
  }

  .stat:first-child {
    border-top: none;
  }

  /* گالری تک ستونه منظم برای صفحه‌های کوچک */
  .gallery__grid {
    grid-auto-rows: clamp(210px, 64vw, 290px);
  }
}

/* ================================== موبایل‌های فشرده و تاشو (<= 380px) */
@media (max-width: 380px) {
  .hero__title {
    font-size: clamp(1.75rem, 8vw, 2.1rem);
  }

  .hero__lead {
    font-size: var(--fs-base);
  }

  .svc-card {
    flex: 0 0 min(90vw, 300px);
    min-height: 480px;
  }

  .svc-card__link {
    padding: 22px 14px 18px;
  }

  .svc-card__icon-badge {
    width: 82px;
    height: 82px;
  }

  .svc-card__icon-badge svg {
    width: 48px;
  }

  .svc-card__title {
    font-size: 1.12rem;
  }

  .terrain__hud-center {
    padding: 5px 12px;
  }

  .terrain__watermark {
    font-size: 0.9rem;
  }
}

/* ========================== کاهش حرکت: بخش پروژه‌ها هم ساده می‌شود */
@media (prefers-reduced-motion: reduce) {
  .data {
    --mode: 'static';
  }
}
