/* ==========================================================================
   mobile-fixes.css  ·  phones (portrait + landscape)
   Loaded LAST on every page (after how-cards.css), so it wins over style.css / v9.css / phone.css / nav-global.css.

   1. Header: logo on one side, hamburger button ALWAYS at the top right (top left in the FA / RTL pages).
   2. Scroll-progress bar: glued to the very top edge of the screen, above everything.
   3. Opened menu: sections + language switch + "Get started" are all visible (two columns on a landscape phone).
   4. 04 — Services on a landscape phone: nothing under the button, nothing cut, bigger topic names.

   "Landscape phone" = a short screen: (orientation:landscape) and (max-height:520px).
   This covers a phone held sideways with OR without the full-screen button (the browser bars eat ~50px).
   ========================================================================== */

:root{
  /* height of the compact phone header (without the notch / status-bar inset) */
  --m-bar:56px;
  --m-hdr:calc(var(--m-bar) + env(safe-area-inset-top,0px));
}

/* --------------------------------------------------------------------------
   1 + 2.  Header, hamburger and progress bar  (any phone, any orientation)
   -------------------------------------------------------------------------- */
@media (max-width:820px), (hover:none) and (pointer:coarse) and (max-height:520px){

  /* the thin "how far have I scrolled" bar: very top, full width, above the header */
  .scroll-progress{
    position:fixed !important;
    top:0 !important;
    left:0 !important;
    right:0 !important;
    width:100% !important;
    height:3px !important;
    margin:0 !important;
    padding:0 !important;
    transform:none !important;
    z-index:2147483000 !important;
    pointer-events:none;
  }
  .scroll-progress > i{display:block;height:100% !important}

  /* header: one compact row. Logo on the start side, hamburger on the end side (= right in English). */
  .topbar{
    display:flex !important;
    flex-direction:row !important;
    align-items:center !important;
    justify-content:space-between !important;
    box-sizing:border-box !important;
    min-height:var(--m-bar) !important;
    padding-top:calc(env(safe-area-inset-top,0px) + 8px) !important;
    padding-bottom:8px !important;
    padding-left:max(var(--pad,20px),env(safe-area-inset-left,0px)) !important;
    padding-right:max(var(--pad,20px),env(safe-area-inset-right,0px)) !important;
  }
  .topbar-right{
    display:flex !important;
    align-items:center !important;
    justify-content:flex-end !important;
    gap:0 !important;
    margin-inline-start:auto !important;
    flex:none !important;
  }
  /* desktop navigation is replaced by the hamburger on phones (also when the phone is wider than 820px) */
  .topbar .segmented,
  .topbar .topbar-auth{display:none !important}

  .topbar .hamburger{
    display:inline-flex !important;
    align-items:center !important;
    justify-content:center !important;
    flex:none !important;
    width:44px !important;
    height:44px !important;
    margin:0 !important;
    position:relative;
  }
}

/* landscape phone: tighter side gutters so the hamburger really sits in the corner (notch-safe) */
@media (orientation:landscape) and (max-height:520px){
  .topbar{
    padding-left:max(20px,env(safe-area-inset-left,0px)) !important;
    padding-right:max(20px,env(safe-area-inset-right,0px)) !important;
  }
}

/* --------------------------------------------------------------------------
   3.  The opened menu
   -------------------------------------------------------------------------- */
@media (max-width:820px), (hover:none) and (pointer:coarse) and (max-height:520px){
  .mobile-menu{
    overflow-y:auto;
    overscroll-behavior:contain;
    -webkit-overflow-scrolling:touch;
    max-height:100vh;
    max-height:100dvh;
    box-sizing:border-box;
  }
  .mobile-menu-auth{
    padding-bottom:max(16px,env(safe-area-inset-bottom,0px));
  }
  .mobile-menu *{box-sizing:border-box}
}

/* landscape phone: sections on one side, language + Get started on the other, all visible at once */
@media (orientation:landscape) and (max-height:520px){
  :is(.mobile-menu[aria-hidden="false"],
      .mobile-menu.open,.mobile-menu.is-open,.mobile-menu.active,
      body:has(#hamburgerBtn[aria-expanded="true"]) .mobile-menu){
    display:grid !important;
    grid-template-columns:minmax(0,1.35fr) minmax(0,1fr);
    grid-template-rows:minmax(0,auto);
    align-content:center;
    align-items:center;
    column-gap:clamp(24px,7vw,72px);
    padding-top:calc(var(--m-hdr) + 4px) !important;
    padding-bottom:max(12px,env(safe-area-inset-bottom,0px)) !important;
    padding-left:max(28px,env(safe-area-inset-left,0px)) !important;
    padding-right:max(28px,env(safe-area-inset-right,0px)) !important;
  }
  .mobile-menu .mobile-menu-nav{
    grid-column:1;
    display:flex !important;
    flex-direction:column !important;
    justify-content:center;
    width:100%;
    margin:0 !important;
    padding:0 !important;
    min-width:0;
  }
  .mobile-menu .mobile-menu-link{
    display:flex !important;
    align-items:center;
    justify-content:space-between;
    width:100%;
    box-sizing:border-box;
    margin:0 !important;
    padding-top:clamp(6px,2vh,12px) !important;
    padding-bottom:clamp(6px,2vh,12px) !important;
    font-size:clamp(1.2rem,6.4vh,1.85rem) !important;
    line-height:1.15 !important;
  }
  .mobile-menu .mobile-menu-num{font-size:.62em}
  .mobile-menu .mobile-menu-auth{
    grid-column:2;
    display:flex !important;
    flex-direction:column !important;
    align-items:stretch !important;
    justify-content:center;
    gap:14px !important;
    width:100%;
    margin:0 !important;
    padding:0 !important;
    min-width:0;
  }
  .mobile-menu .mobile-menu-auth .btn{
    display:flex !important;
    align-items:center;
    justify-content:center;
    width:100% !important;
    max-width:100% !important;
    box-sizing:border-box !important;
    min-height:46px;
    margin:0 !important;
    padding-left:16px !important;
    padding-right:16px !important;
    font-size:1rem;
    white-space:nowrap;
  }
  .mobile-menu .mobile-menu-auth .lang-toggle{align-self:center;flex:none}
}

/* --------------------------------------------------------------------------
   4.  04 — Services on a landscape phone
       left column : the five topics (big) + "All services" button
       middle      : the picture, always a whole 4:3 frame, never cut
       right       : title + text of the active topic
   -------------------------------------------------------------------------- */
@media (orientation:landscape) and (max-height:520px){
  .svc2-pin{
    box-sizing:border-box !important;
    height:100vh !important;
    height:100svh !important;
    overflow:hidden !important;
    display:grid !important;
    grid-template-columns:minmax(0,1.2fr) minmax(0,1.4fr) minmax(0,1.1fr) !important;
    grid-template-rows:auto minmax(0,1fr) auto !important;
    column-gap:clamp(14px,2.6vw,32px) !important;
    row-gap:6px !important;
    padding-top:calc(var(--m-hdr) + 6px) !important;
    padding-bottom:max(10px,env(safe-area-inset-bottom,0px)) !important;
    padding-left:max(var(--pad,20px),env(safe-area-inset-left,0px)) !important;
    padding-right:max(var(--pad,20px),env(safe-area-inset-right,0px)) !important;
    align-content:stretch !important;
  }
  .svc2-top{
    grid-column:1 / -1 !important;
    grid-row:1 !important;
    display:flex !important;
    align-items:center;
    justify-content:space-between;
    margin:0 !important;
    padding:0 !important;
  }

  /* the hidden <h2> must never take a grid cell */
  .svc2-pin > .visually-hidden{
    position:absolute !important;
    width:1px !important;
    height:1px !important;
    margin:-1px !important;
    padding:0 !important;
    overflow:hidden !important;
    clip:rect(0 0 0 0) !important;
    clip-path:inset(50%) !important;
    white-space:nowrap !important;
    border:0 !important;
  }

  /* wrappers dissolve so list / picture / text / button sit directly on the pin's grid */
  .svc2-body,
  .svc2-detail{display:contents !important}

  /* topics */
  .svc2-list{
    grid-column:1 !important;
    grid-row:2 !important;
    display:flex !important;
    flex-direction:column !important;
    justify-content:space-between !important;
    gap:0 !important;
    min-height:0 !important;
    height:100% !important;
    margin:0 !important;
    padding:0 !important;
    list-style:none !important;
  }
  .svc2-item{
    flex:1 1 0 !important;
    min-height:0 !important;
    display:flex !important;
    align-items:center;
    margin:0 !important;
    padding:0 !important;
  }
  .svc2-item button{
    display:flex !important;
    align-items:baseline;
    gap:.45em;
    width:100%;
    min-width:0;
    height:auto !important;
    margin:0 !important;
    padding:2px 0 !important;
    text-align:start;
    /* one line per topic, always: the size follows both the free height and the column width */
    font-size:clamp(.88rem,min(5.6vh,2.5vw),1.55rem) !important;
    line-height:1.15 !important;
    white-space:nowrap;
  }
  html[lang="fa"] .svc2-item button{line-height:1.3 !important}
  .svc2-item button small{
    flex:none;
    font-size:.5em !important;
    line-height:1;
    letter-spacing:.08em;
  }

  /* button under the topics (never on top of anything) */
  .svc2-more{
    grid-column:1 !important;
    grid-row:3 !important;
    justify-self:start;
    align-self:end;
    position:static !important;
    margin:0 !important;
    transform:none !important;
    height:auto !important;
    min-height:0 !important;
    padding:8px 16px !important;
    font-size:.82rem !important;
    line-height:1.1 !important;
  }
  .svc2-more svg{width:16px !important;height:16px !important}

  /* picture: a whole 4:3 frame that always fits the free height */
  .svc2-figs{
    grid-column:2 !important;
    grid-row:2 / span 2 !important;
    justify-self:center;
    align-self:center;
    position:relative !important;
    width:min(100%,calc((100svh - var(--m-hdr) - 58px) * 4 / 3)) !important;
    max-height:calc(100svh - var(--m-hdr) - 58px);
    height:auto !important;
    aspect-ratio:4 / 3;
    margin:0 !important;
    overflow:hidden;
  }
  .svc2-fig{
    position:absolute !important;
    inset:0 !important;
    width:100% !important;
    height:100% !important;
    margin:0 !important;
  }
  .svc2-fig img{
    width:100% !important;
    height:100% !important;
    object-fit:contain !important;
    object-position:center !important;
  }

  /* text of the active topic: its own column, so it can never slide under a button */
  .svc2-texts{
    grid-column:3 !important;
    grid-row:2 / span 2 !important;
    align-self:center;
    position:relative !important;
    display:grid !important;
    width:100% !important;
    height:auto !important;
    margin:0 !important;
    padding:0 !important;
    min-width:0;
  }
  .svc2-text{
    grid-area:1 / 1 !important;
    position:relative !important;
    inset:auto !important;
    margin:0 !important;
    padding:0 !important;
    min-width:0;
  }
  .svc2-text h3{
    margin:0 0 .4em !important;
    font-size:clamp(1.1rem,5.4vh,1.6rem) !important;
    line-height:1.15 !important;
  }
  .svc2-text p{
    margin:0 !important;
    font-size:clamp(.78rem,3.9vh,.95rem) !important;
    line-height:1.45 !important;
    max-width:none !important;
  }
  html[lang="fa"] .svc2-text p{line-height:1.8 !important}
}

/* =====================================================================================================
   v12 — 07 Testimonials
   1. the pinned scene is as tall as the *visible* screen (dvh), so when the browser bars slide away
      the split picture never ends early and leaves a black strip underneath
   2. landscape phone (with or without full screen): one wide, readable card instead of a tiny
      portrait card, text sized from the screen height, nothing overlapping
   ===================================================================================================== */
.v3-voices .vo-pin{ height:100vh; height:100svh; height:100dvh; }
.v3-voices .vo-half{ top:-1px; bottom:-1px; }
.v3-voices .vo-half img{ height:100%; min-height:100%; }

@media (orientation:landscape) and (max-height:520px){
  html .vo-back{
    padding:calc(var(--m-hdr,56px) + 2px) max(var(--pad),env(safe-area-inset-right,0px)) max(10px,env(safe-area-inset-bottom,0px)) max(var(--pad),env(safe-area-inset-left,0px));
    row-gap:6px;
  }
  html .vo-eyebrow{ font-size:10px; letter-spacing:.2em; }
  html .vo-stack{
    --cw:min(620px,100%);
    width:var(--cw);
    height:min(calc(100vh - var(--m-hdr,56px) - 54px),300px);
    height:min(calc(100svh - var(--m-hdr,56px) - 54px),300px);
    height:min(calc(100dvh - var(--m-hdr,56px) - 54px),300px);
    min-height:150px;
    perspective:1200px;
  }
  html .vc{
    padding:clamp(12px,4.4vh,24px) clamp(16px,3.2vw,30px);
    padding:clamp(12px,4.4dvh,24px) clamp(16px,3.2vw,30px);
    border-radius:16px;
    gap:8px;
  }
  html .vc blockquote{
    font-size:clamp(12.5px,4.8vh,21px);
    font-size:clamp(12.5px,4.8dvh,21px);
    line-height:1.32; letter-spacing:-.012em;
  }
  html[lang=fa] .vc blockquote{ line-height:1.75; letter-spacing:0; }
  html .vc-by{
    flex-direction:row; flex-wrap:wrap; align-items:baseline; gap:1px 10px;
    font-size:clamp(10.5px,3.5vh,13px);
    font-size:clamp(10.5px,3.5dvh,13px);
    line-height:1.3;
  }
}
