/* ==========================================================================
   05 — How it works  ·  pinned, scroll-driven flip cards
   Loaded AFTER v3.css / v9.css / polish.css so it can override them.
   ========================================================================== */

/* the old section used overflow:hidden, which would break position:sticky */
.v3-how{
  overflow:visible !important;
  padding:0 !important;
  background:var(--c-cream);
  color:var(--c-ink);
}

/* ---- scroll track (its height = how long the section stays locked) ---- */
.hwc{
  --hwc-r:clamp(14px,1.5vw,22px);
  --hwc-gap:clamp(12px,1.6vw,24px);
  position:relative;
  height:420vh;
  height:420svh;
}
.hwc-pin{
  position:sticky;
  top:0;
  height:100vh;
  height:100svh;
  overflow:hidden;
  display:flex;
  flex-direction:column;
  padding:clamp(120px,17vh,168px) var(--pad) clamp(40px,7vh,64px);
  box-sizing:border-box;
}

/* ---- heading (re-uses the original .hw-head typography) ---- */
.hwc .hw-head{
  flex:none;
  margin:0 0 clamp(16px,3.4vh,34px);
}
.hwc .hw-head .v3-eyebrow{margin-bottom:clamp(12px,2vh,20px)}
.hwc .hw-head .v3-h{font-size:clamp(2rem,4.2vw,3.8rem)}

/* ---- the row of cards ---- */
.hwc-row{
  flex:1 1 auto;
  min-height:0;
  display:grid;
  grid-template-columns:repeat(4,minmax(0,1fr));
  grid-template-rows:minmax(0,1fr);
  gap:var(--hwc-gap);
}
.hwc-slot{
  position:relative;
  min-width:0;
  min-height:0;
  container-type:size;
  display:grid;
  place-items:center;
}

/* a vertical rectangle that always fits its slot */
.hwc-card{
  grid-area:1/1;
  width:min(100cqw,calc(100cqh / 1.3));
  height:min(100cqh,calc(100cqw * 1.55));
}

/* ---- one card ---- */
.hwc-card{
  --t:1;
  position:relative;
  container-type:inline-size;
  perspective:1600px;
  outline:none;
  cursor:pointer;
  -webkit-tap-highlight-color:transparent;
  transform:translate3d(0,calc((1 - var(--t)) * 115vh),0) scale(calc(.9 + .1 * var(--t)));
  opacity:min(1,calc(var(--t) * 3));
  will-change:transform;
}

.hwc-inner{
  position:absolute;
  inset:0;
  transform-style:preserve-3d;
  -webkit-transform-style:preserve-3d;
  transition:transform 1.1s cubic-bezier(.25,.8,.25,1);
}
.hwc-card.is-flipped .hwc-inner{transform:rotateY(180deg)}

.hwc-face{
  position:absolute;
  inset:0;
  display:flex;
  flex-direction:column;
  box-sizing:border-box;
  padding:clamp(16px,8cqw,28px);
  border-radius:var(--hwc-r);
  overflow:hidden;
  -webkit-backface-visibility:hidden;
  backface-visibility:hidden;
}
/* dashed inner frame, a nod to the original column dividers */
.hwc-face:before{
  content:"";
  position:absolute;
  inset:7px;
  border-radius:calc(var(--hwc-r) - 6px);
  pointer-events:none;
}

/* front */
.hwc-front{
  background-image:none;
  background:#fffdf9;
  border:1px solid rgba(38,38,38,.12);
  color:var(--c-ink);
  box-shadow:0 36px 60px -36px rgba(38,38,38,.4),0 2px 0 rgba(255,255,255,.7) inset;
}
.hwc-front:before{border:1px dashed rgba(38,38,38,.16)}

/* back */
.hwc-back{
  background-image:none;
  background:#262626;
  color:var(--c-cream);
  transform:rotateY(180deg);
  box-shadow:0 36px 60px -30px rgba(38,38,38,.55);
}
.hwc-back:before{border:1px dashed rgba(246,243,238,.2)}

/* top bar: number + flip icon */
.hwc-top{
  position:relative;
  z-index:1;
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  flex:none;
}
.hwc-card .num{
  display:inline-flex;
  align-items:baseline;
  font-family:var(--mono);
  font-size:clamp(1.05rem,7cqw,1.6rem);
  line-height:1;
  letter-spacing:.02em;
}
.hwc-card .num i{font-style:normal;color:var(--c-ember);margin-inline-end:2px}
.hwc-hint{
  width:clamp(28px,11cqw,38px);
  aspect-ratio:1;
  border-radius:50%;
  display:grid;
  place-items:center;
  border:1px solid currentColor;
  opacity:.4;
  transition:transform .8s cubic-bezier(.32,.86,.24,1),opacity .4s ease,background .4s ease,color .4s ease,border-color .4s ease;
}
.hwc-hint svg{width:52%;height:52%;display:block}
.hwc-card.is-flipped .hwc-hint,
.hwc-card:focus-visible .hwc-hint{opacity:1;transform:rotate(180deg);background:var(--c-ember);border-color:var(--c-ember);color:#fff}

/* front: icon + title */
.hwc-ico{
  position:relative;
  z-index:1;
  flex:1 1 auto;
  min-height:0;
  display:flex;
  align-items:center;
  justify-content:center;
}
.hwc-ico img{
  position:absolute;
  inset:0;
  width:100%;
  height:100%;
  object-fit:contain;
  object-position:center;
  display:block;
  pointer-events:none;
  -webkit-user-drag:none;
  user-select:none;
}

.hwc-title{
  position:relative;
  z-index:1;
  flex:none;
  margin:0;
  font-family:inherit;
  font-size:clamp(1.12rem,8.4cqw,1.75rem);
  font-weight:600;
  line-height:1.12;
  letter-spacing:-.025em;
  max-width:15ch;
}
html[lang=fa] .hwc-title{font-weight:700;letter-spacing:0;line-height:1.6;max-width:none}

/* "written" reveal — each line is wiped in once the card has landed */
.hwc-title .ln{
  display:block;
  -webkit-clip-path:inset(0 100% 0 0);
  clip-path:inset(0 100% 0 0);
  transition:clip-path 1.05s var(--ease) calc(.12s + var(--l,0) * .2s),opacity .5s ease calc(.12s + var(--l,0) * .2s);
  opacity:.2;
}
html[dir=rtl] .hwc-title .ln{
  -webkit-clip-path:inset(0 0 0 100%);
  clip-path:inset(0 0 0 100%);
}
.hwc-card.landed .hwc-title .ln{
  -webkit-clip-path:inset(0 0 0 0);
  clip-path:inset(0 0 0 0);
  opacity:1;
}

/* back: description */
.hwc-body{
  position:relative;
  z-index:1;
  flex:1 1 auto;
  min-height:0;
  display:flex;
  flex-direction:column;
  justify-content:flex-end;
  gap:clamp(8px,3.4cqw,14px);
  overflow:hidden auto;
  scrollbar-width:none;
}
.hwc-body::-webkit-scrollbar{display:none}
.hwc-btitle{
  margin:0;
  font-family:inherit;
  font-size:clamp(1rem,6.4cqw,1.3rem);
  font-weight:600;
  line-height:1.2;
  letter-spacing:-.02em;
  color:#fff;
}
html[lang=fa] .hwc-btitle{font-weight:700;letter-spacing:0;line-height:1.6}
.hwc-btitle:before{
  content:"";
  display:block;
  width:28px;
  height:2px;
  margin-bottom:clamp(8px,3cqw,12px);
  background:var(--c-ember);
}
.hwc-body p{
  margin:0;
  font-size:clamp(.78rem,4.3cqw,.98rem);
  line-height:1.55;
  color:rgba(246,243,238,.78);
}
html[lang=fa] .hwc-body p{line-height:1.9}
.hwc-body ul{
  list-style:none;
  margin:0;
  padding:0;
  display:grid;
  gap:0;
}
.hwc-body li{
  position:relative;
  padding:clamp(6px,2.3cqw,10px) 0;
  padding-inline-start:16px;
  border-top:1px dashed rgba(246,243,238,.22);
  font-size:clamp(.74rem,4cqw,.9rem);
  line-height:1.4;
  color:var(--c-cream);
}
html[lang=fa] .hwc-body li{line-height:1.7}
.hwc-body li:before{
  content:"";
  position:absolute;
  inset-inline-start:0;
  top:calc(clamp(6px,2.3cqw,10px) + .5em);
  width:6px;
  height:6px;
  background:var(--c-ember);
  transform:rotate(45deg);
}

/* back text rises in a touch after the flip starts */
.hwc-body > *{
  opacity:0;
  transform:translateY(10px);
  transition:opacity .5s ease,transform .7s var(--ease);
}
.hwc-card.is-flipped .hwc-body > *{
  opacity:1;
  transform:none;
  transition-delay:calc(.34s + var(--b,0) * .08s);
}
.hwc-body > :nth-child(1){--b:0}
.hwc-body > :nth-child(2){--b:1}
.hwc-body > :nth-child(3){--b:2}

/* caption under the cards */
.hwc-cap{
  position:absolute;
  inset-inline:0;
  bottom:clamp(12px,2.4vh,24px);
  text-align:center;
  font-family:var(--mono);
  font-size:.7rem;
  letter-spacing:.14em;
  text-transform:uppercase;
  color:rgba(38,38,38,.55);
  opacity:0;
  transition:opacity .6s ease;
  pointer-events:none;
}
html[lang=fa] .hwc-cap{letter-spacing:0;text-transform:none;font-size:.78rem}
.hwc.all-in .hwc-cap{opacity:1}
.hwc-cap .t{display:none}
@media (hover:none){
  .hwc-cap .h{display:none}
  .hwc-cap .t{display:inline}
}

/* keyboard focus */
.hwc-card:focus-visible .hwc-front,
.hwc-card:focus-visible .hwc-back{outline:2px solid var(--c-ember);outline-offset:3px}

/* ---- tablets / phones in portrait: 2 x 2 ---- */
@media (max-width:820px) and (orientation:portrait){
  .hwc-row{
    grid-template-columns:repeat(2,minmax(0,1fr));
    grid-template-rows:repeat(2,minmax(0,1fr));
  }
  /* the cards stop well above the caption; the caption sits low, under the cards (not over them) */
  .hwc-pin{padding-top:clamp(96px,calc(var(--m-hdr,64px) + 20px),128px);padding-bottom:calc(68px + env(safe-area-inset-bottom,0px))}
  .hwc-cap{bottom:calc(18px + env(safe-area-inset-bottom,0px))}
  .hwc .hw-head{margin-bottom:14px;gap:10px}
  .hwc .hw-head .v3-eyebrow{margin-bottom:10px}
  .hwc .hw-head .v3-h{font-size:clamp(1.9rem,9vw,2.6rem)}
  .hwc .hw-head p:not(.v3-eyebrow){font-size:.82rem;line-height:1.5;max-width:none}
  .hwc-body ul{display:none}
}

/* short landscape screens (phone held sideways, with or without the full-screen button):
   a compact heading line, then ONE row of four cards that uses all the remaining height */
@media (orientation:landscape) and (max-height:520px){
  .hwc-pin{
    padding-top:calc(var(--m-hdr,60px) + 6px);
    padding-bottom:max(10px,env(safe-area-inset-bottom,0px));
    padding-left:max(var(--pad),env(safe-area-inset-left,0px));
    padding-right:max(var(--pad),env(safe-area-inset-right,0px));
  }
  .hwc .hw-head{display:block;margin:0 0 8px}
  .hwc .hw-head > div{display:flex;align-items:baseline;gap:14px;flex-wrap:wrap}
  .hwc .hw-head p:not(.v3-eyebrow){display:none}
  .hwc .hw-head .v3-eyebrow{margin:0}
  .hwc .hw-head .v3-h{font-size:clamp(1.3rem,7vh,1.8rem);margin:0;line-height:1.1}
  .hwc-cap{display:none}
  .hwc-row{gap:clamp(8px,1.6vw,14px)}
  .hwc{--hwc-r:14px}

  /* cards: tighter padding, smaller type so front and back both fit a short card */
  .hwc-face{padding:10px;border-radius:14px}
  .hwc-face:before{inset:5px;border-radius:9px}
  .hwc-card .num{font-size:clamp(.9rem,6.4cqw,1.2rem)}
  .hwc-hint{width:clamp(24px,13cqw,30px)}
  .hwc-title{font-size:clamp(.88rem,min(8cqw,5.4vh),1.2rem);line-height:1.12;max-width:none}
  .hwc-ico{margin:2px 0}
  .hwc-body{gap:6px;justify-content:center}
  .hwc-btitle{font-size:clamp(.88rem,min(7.4cqw,5vh),1.12rem)}
  .hwc-btitle:before{width:22px;margin-bottom:6px}
  .hwc-body p{font-size:clamp(.66rem,min(4.9cqw,3.7vh),.84rem);line-height:1.4}
  html[lang=fa] .hwc-body p{line-height:1.7}
  .hwc-body ul{display:none}
}

/* ---- no JS / reduced motion: calm static grid, cards still flip ---- */
.hwc:not(.js),
.hwc.static{height:auto}
.hwc:not(.js) .hwc-pin,
.hwc.static .hwc-pin{
  position:relative;
  height:auto;
  min-height:0;
  overflow:visible;
  padding-top:clamp(124px,18vh,180px);
  padding-bottom:clamp(60px,9vh,110px);
}
.hwc:not(.js) .hwc-slot,
.hwc.static .hwc-slot{height:clamp(380px,62vh,540px)}
.hwc:not(.js) .hwc-title .ln,
.hwc.static .hwc-title .ln{clip-path:none;-webkit-clip-path:none;opacity:1}
.hwc.static .hwc-cap{position:static;margin-top:18px;opacity:1}
.hwc:not(.js) .hwc-cap{display:none}
@media (max-width:820px) and (orientation:portrait){
  .hwc:not(.js) .hwc-slot,
  .hwc.static .hwc-slot{height:clamp(300px,46vh,420px)}
}
@media (prefers-reduced-motion:reduce){
  .hwc-inner{transition-duration:.01ms}
  .hwc-title .ln,.hwc-body > *{transition-duration:.01ms;transition-delay:0s}
  .hwc-card{will-change:auto}
}

/* ==========================================================================
   02 — Selected work : the picture frame is an exact 4:3 box (same ratio as work-01…04),
   so every image fills it completely: nothing is cut and nothing is blurred.
   .work-cell is the grid cell (it measures the free space), .work-stage is the 4:3 frame inside it.
   ========================================================================== */
.work-cell{
  position:relative;
  z-index:1;
  min-width:0;
  min-height:0;
  container-type:size;
  display:grid;
  place-items:center;
}
.work-stage{
  width:min(100cqw,calc(100cqh * 4 / 3));
  height:min(100cqh,calc(100cqw * 3 / 4));
  background:#1c1c1c;
}
@media (max-width:860px){ .work-cell{grid-row:2} }
@media (orientation:landscape) and (max-height:500px){ .work-cell{grid-row:auto} }

.work-slide{overflow:hidden}
.work-slide:before{content:none !important;display:none !important}
.work-slide img{
  z-index:1;
  inset:0;
  width:100%;
  height:100%;
  object-fit:contain;
  object-position:center;
  /* reveal zoom only: the outgoing picture is never shrunk, so no edge ever shows */
  transform:translate3d(0,calc((1 - var(--t,1)) * 16%),0) scale(calc(1.2 - .2 * var(--t,1)));
}
.work-slide:after{z-index:2}

/* section words: same size and weight family as the other section headings (How it works / Who we are) */
.work-title-row .v3-display{
  font-size:clamp(2rem,4.2vw,3.8rem);
  font-weight:700;
  line-height:1.02;
  letter-spacing:-.035em;
}
html[lang=fa] .work-title-row .v3-display{
  font-size:clamp(2rem,4.2vw,3.8rem);
  font-weight:800;
  line-height:1.3;
  letter-spacing:0;
}
.work-count b{
  font-size:clamp(2rem,3.4vw,3rem);
  font-weight:700;
  letter-spacing:-.03em;
}
.team-head .v3-h{
  font-size:clamp(2rem,4.2vw,3.8rem);
  font-weight:700;
  letter-spacing:-.035em;
  line-height:1.02;
}
html[lang=fa] .team-head .v3-h{font-weight:800;letter-spacing:0;line-height:1.3}
@media (max-width:860px){
  .work-title-row .v3-display,
  html[lang=fa] .work-title-row .v3-display{font-size:clamp(1.9rem,9vw,2.6rem)}
  .team-head .v3-h{font-size:clamp(1.9rem,9vw,2.6rem)}
}
@media (orientation:landscape) and (max-height:500px){
  .work-title-row .v3-display,
  html[lang=fa] .work-title-row .v3-display{font-size:clamp(1.5rem,9vh,2.3rem)}
  .work-count b{font-size:clamp(1.3rem,7vh,1.8rem)}
  .team-head .v3-h{font-size:clamp(1.5rem,9vh,2.3rem)}
}

/* ==========================================================================
   06 — Our Team : full-colour portraits, framed so faces are never cut
   ========================================================================== */
.tm{--u:clamp(84px,min(13.2vw,17vh),210px)}
.tm-board{grid-template-rows:calc(var(--u)*2.5) var(--u)}
.tm-photo{background:#1f3a30}
.tm-photo canvas,.tm-photo img,
.tm-th canvas,.tm-th img{
  image-rendering:auto !important;
  object-fit:cover;
}
.tm-photo img,.tm-photo canvas{object-position:50% 0% !important}
.tm-th img,.tm-th canvas{object-position:50% 0% !important}
.tm-th img{opacity:.9}
.tm-th:hover img,.tm-th:focus-visible img{opacity:1}
@media (max-width:900px){
  .tm-board{grid-template-rows:none}
  .tm-photo{aspect-ratio:4/5;max-height:74vh;max-height:74svh}
}
@media (orientation:landscape) and (max-height:500px){
  .tm{--u:clamp(70px,min(13vw,20vh),120px)}
  .tm-board{grid-template-rows:calc(var(--u)*2.2) var(--u)}
  .tm-photo{aspect-ratio:auto;max-height:none}
}

/* ==========================================================================
   Section labels (02 … 08): one identical size / weight / spacing everywhere
   ========================================================================== */
.v3-eyebrow,.sec-eyebrow{
  font-size:12px;
  font-weight:500;
  letter-spacing:.2em;
  line-height:normal;
}
html[lang=fa] .v3-eyebrow,html[lang=fa] .sec-eyebrow{font-size:13px;letter-spacing:0}
@media (orientation:landscape) and (max-height:500px){
  .v3-eyebrow,.sec-eyebrow{font-size:10.5px}
  html[lang=fa] .v3-eyebrow,html[lang=fa] .sec-eyebrow{font-size:12px}
}

/* 06 — team names: a bit smaller */
.tm-name{font-size:clamp(1.4rem,2.9vw,2.7rem)}
@media (orientation:landscape) and (max-height:500px){
  .tm-name{font-size:clamp(1.1rem,min(2.7vw,7.4vh),2rem)}
}
@media (max-width:900px){
  .tm-name{font-size:clamp(1.3rem,6vw,1.9rem)}
}

/* team photo + thumbnails: no fade delay when switching */
.tm.swap .tm-id>*,.tm.swap .tm-bio p,.tm.swap .tm-count{transition-duration:0s}

/* 02 — Selected work: the whole picture, always. No zoom, no dark overlay, no blur, nothing cropped. */
.work-slide img{
  transform:translate3d(0,calc((1 - var(--t,1)) * 16%),0) !important;
  object-fit:contain !important;
  inset:0 !important;
  width:100% !important;
  height:100% !important;
}
.work-slide:after{content:none !important;display:none !important}
.work-slide .veil{display:none !important}
.work-tag{display:none !important}
