@font-face {
  font-family: "Estedad";
  src: url("../assets/etedadFont.ttf") format("truetype");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

/* anything marked lang="fa" (e.g. the Persian team names) */
:lang(fa) {
  font-family: "Estedad", "DM Sans", system-ui, sans-serif;
}

/* =========================================================
   Base
   ========================================================= */
:root {
  /* one shared easing for every animation: fast start, long soft landing */
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 72px; /* sticky header height, so anchors don't hide under it */
}

body {
  min-width: 320px;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible {
  outline: 2px solid #3f7d3a;
  outline-offset: 4px;
}

/* =========================================================
   Contact modal
   (open/close state is still set by the script via inline styles)
   ========================================================= */
.contact-btn {
  font-family: serif;
  margin-top: 24px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: none;
  border-radius: 16px;
  background: #f8f6ee;
  padding: 14px 28px;
  font-weight: 600;
  color: #0a2f24;
  cursor: pointer;
}

.contact-btn__icon {
  width: 18px;
  height: 18px;
}

/* dark overlay */
.contact-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  box-sizing: border-box;
  z-index: 99999;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    opacity 0.25s ease,
    visibility 0.25s ease;
}

#contactOverlay[aria-hidden="true"] {
  pointer-events: none;
}

#contactOverlay[aria-hidden="false"] {
  pointer-events: auto;
}

/* card */
.contact-card {
  position: relative;
  width: 100%;
  max-width: 380px;
  box-sizing: border-box;
  padding: 32px;
  background: #f8f6ee;
  color: #0a2f24;
  border-radius: 24px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
  transform: translateY(12px);
  transition: transform 0.25s ease;
}

#contactCard {
  max-height: calc(100dvh - 40px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.contact-close {
  position: absolute;
  top: 14px;
  right: 16px;
  border: none;
  background: transparent;
  color: #0a2f24;
  font-size: 28px;
  cursor: pointer;
  line-height: 1;
}

.contact-title {
  font-family: serif;
  font-size: 28px;
  margin: 0 0 8px;
  color: #0a2f24;
}

.contact-desc {
  margin: 0 0 28px;
  color: #69766e;
  font-size: 14px;
  line-height: 1.6;
}

.contact-item {
  padding: 16px;
  background: #ffffff;
  border-radius: 14px;
}

.contact-item--spaced {
  margin-bottom: 12px;
}

.contact-label {
  margin: 0 0 8px;
  font-size: 12px;
  color: #7b867e;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.contact-link {
  color: #0a2f24;
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  overflow-wrap: anywhere;
}

/* =========================================================
   Arrow buttons: two arrows stacked in a clipped box.
   Hover: the first slides out, the second slides in behind it.
   (the hover motion itself is in the motion section below)
   ========================================================= */
.arrow {
  display: inline-grid;
  width: 1.15em;
  height: 1.2em;
  overflow: hidden;
  place-items: center;
  line-height: 1;
  vertical-align: middle;
}

.arrow > i {
  grid-area: 1 / 1;
  display: block;
  font-style: normal;
}

/* the waiting arrow sits just outside the box */
.arrow > i:last-child {
  translate: -170% 0;
}

.arrow--back > i:last-child {
  translate: 170% 0;
}

/* =========================================================
   Brand experience carousel
   ========================================================= */
#work-list {
  scrollbar-width: none;
  -ms-overflow-style: none;
  /* room so a hovered (enlarged) card is not clipped by the scroller */
  padding: 1rem 0.75rem;
  margin-block: -1rem;
  scroll-padding-inline: 0.75rem;
}

#work-list::-webkit-scrollbar {
  display: none;
}

.work-card {
  position: relative;
  display: flex;
  height: 10rem;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 0.375rem;
  background: #ffffff;
  padding: 0.75rem 1rem;
}

.work-card:focus-visible {
  outline-offset: 4px;
}

/* touch devices have no hover: logo sits a little high and the name is always visible */
.work-logo {
  width: 100%;
  translate: 0 -10px;
}

.work-logo img {
  display: block;
  height: 5rem;
  width: 100%;
  object-fit: contain;
}

.work-name {
  position: absolute;
  inset: auto 0 0 0;
  margin: 0;
  padding: 0.65rem 0.5rem;
  text-align: center;
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.2;
  color: #f8f6ee;
  background: #3f7d3a;
}

/* mouse devices: name is hidden until hover / keyboard focus */
@media (hover: hover) {
  .work-logo {
    translate: 0 0;
  }

  .work-name {
    translate: 0 100%;
  }

  .work-card:hover,
  .work-card:focus-visible {
    scale: 1.08;
    z-index: 2;
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
  }

  .work-card:hover .work-name,
  .work-card:focus-visible .work-name {
    translate: 0 0;
  }

  .work-card:hover .work-logo,
  .work-card:focus-visible .work-logo {
    translate: 0 -16px;
  }
}

/* wrapper added by script around team photos so the hover zoom is clipped */
.img-wrap {
  overflow: hidden;
  border-radius: 0.375rem;
}

/* =========================================================
   MOTION
   Everything below only runs when the visitor has NOT asked for
   reduced motion. It uses the individual `translate` / `scale`
   properties so it never fights Tailwind's `transform` utilities.
   ========================================================= */
@media (prefers-reduced-motion: no-preference) {
  /* ---------- shared keyframes ---------- */
  @keyframes rise {
    from {
      opacity: 0;
      translate: 0 28px;
    }
  }

  @keyframes wipe-in {
    from {
      opacity: 0;
      clip-path: inset(0 100% -0.25em 0);
    }
    to {
      opacity: 1;
      clip-path: inset(0 0 -0.25em 0);
    }
  }

  @keyframes header-in {
    from {
      opacity: 0;
      translate: 0 -100%;
    }
  }

  @keyframes menu-in {
    from {
      opacity: 0;
      translate: 0 -8px;
    }
  }

  @keyframes failsafe {
    to {
      visibility: visible;
    }
  }

  /* ---------- header: drops in, hides on scroll down, returns on scroll up ---------- */
  body > header {
    transition:
      translate 0.6s var(--ease),
      box-shadow 0.3s ease;
    animation: header-in 0.9s var(--ease) backwards;
  }

  body > header.is-hidden {
    translate: 0 -100%;
  }

  body > header.is-scrolled {
    box-shadow: 0 8px 28px rgba(10, 47, 36, 0.08);
  }

  body > header:focus-within {
    translate: 0 0;
  }

  /* ---------- desktop nav: underline draws in on hover ---------- */
  #nav-desktop a {
    position: relative;
  }

  #nav-desktop a:not(.border-b-2)::after {
    content: "";
    position: absolute;
    inset: auto 0 -4px 0;
    height: 2px;
    background: currentColor;
    scale: 0 1;
    transform-origin: right;
    transition: scale 0.45s var(--ease);
  }

  #nav-desktop a:not(.border-b-2):hover::after {
    scale: 1 1;
    transform-origin: left;
  }

  /* ---------- mobile menu: panel fades down, links stagger in ---------- */
  #mobile-nav:not(.hidden) {
    animation: menu-in 0.45s var(--ease) backwards;
  }

  #mobile-nav:not(.hidden) #nav-mobile li {
    animation: rise 0.6s var(--ease) calc(var(--i, 0) * 45ms + 90ms) backwards;
  }

  /* ---------- hero ---------- */
  :root {
    --hero-scale: 1;
  }

  @media (min-width: 1024px) {
    :root {
      --hero-scale: 1.15; /* headroom for the scroll parallax */
    }
  }

  .hero-img {
    scale: var(--hero-scale);
    animation: hero-zoom 2s var(--ease) backwards;
    will-change: translate, scale;
  }

  @keyframes hero-zoom {
    from {
      scale: calc(var(--hero-scale) + 0.18);
    }
  }

  .hero-rise {
    animation: rise 1.1s var(--ease) var(--d, 0ms) backwards;
  }

  /* PowerPoint "Wipe from left" for the hero sentence */
  .hero-wipe {
    animation: wipe-in 1.4s var(--ease) var(--d, 0ms) backwards;
  }

  /* title is split into words by script; hidden until then.
     The failsafe keyframe shows it after 2.5s even if the script never runs. */
  html.js .hero-title:not(.is-split) {
    visibility: hidden;
    animation: failsafe 0s linear 2.5s forwards;
  }

  /* ---------- headings: PowerPoint "Fly In by word" (each word rises out of a mask) ---------- */
  .w {
    display: inline-block;
    overflow: hidden;
    vertical-align: top;
    padding: 0 0.04em 0.16em;
    margin: 0 -0.04em -0.16em;
  }

  .wi {
    display: inline-block;
    translate: 0 110%;
    transition: translate 1.1s var(--ease);
    transition-delay: calc(var(--i, 0) * 70ms + var(--d, 0ms));
  }

  .split.is-in .wi {
    translate: 0 0;
  }

  /* ---------- paragraphs: PowerPoint "Wipe from left", line by line when the text has line breaks ---------- */
  .line {
    display: block;
  }

  .wipe {
    opacity: 0;
    clip-path: inset(0 100% -0.25em 0);
    transition:
      clip-path 1.2s var(--ease) var(--d, 0ms),
      opacity 0.6s ease var(--d, 0ms);
  }

  .wipe.is-in {
    opacity: 1;
    clip-path: inset(0 0 -0.25em 0);
  }

  /* ---------- small texts: PowerPoint "Fly In from left", one after another ---------- */
  .fly {
    opacity: 0;
    translate: -28px 0;
    transition:
      opacity 0.7s ease var(--d, 0ms),
      translate 0.95s var(--ease) var(--d, 0ms);
  }

  .fly.is-in {
    opacity: 1;
    translate: 0 0;
  }

  /* ---------- cards: rise + settle as they scroll into view ---------- */
  .reveal {
    opacity: 0;
    translate: 0 56px;
    scale: 0.97;
    transition:
      opacity 1s var(--ease) var(--d, 0ms),
      translate 1.1s var(--ease) var(--d, 0ms),
      scale 1.1s var(--ease) var(--d, 0ms) !important;
  }

  .reveal.is-in {
    opacity: 1;
    translate: 0 0;
    scale: 1;
  }

  .reveal-img {
    clip-path: inset(0 0 100% 0 round 0.5rem);
    scale: 1.12;
    transition:
      clip-path 1.3s var(--ease) var(--d, 0ms),
      scale 1.6s var(--ease) var(--d, 0ms) !important;
  }

  .reveal-img.is-in {
    clip-path: inset(0 0 0 0 round 0.5rem);
    scale: 1;
  }

  /* brand cards: grow + show name */
  .work-card {
    transition:
      scale 0.6s var(--ease),
      box-shadow 0.6s var(--ease);
  }

  .work-logo,
  .work-name {
    transition: translate 0.6s var(--ease);
  }
}

/* =========================================================
   Hover motion (mouse devices only)
   ========================================================= */
@media (prefers-reduced-motion: no-preference) and (hover: hover) {
  /* arrow buttons: no colour change â€” the arrow leaves and a new one arrives */
  .arrow > i {
    transition: translate 0.6s var(--ease);
  }

  button:hover .arrow > i:first-child,
  button:focus-visible .arrow > i:first-child {
    translate: 170% 0;
  }

  button:hover .arrow--back > i:first-child,
  button:focus-visible .arrow--back > i:first-child {
    translate: -170% 0;
  }

  button:hover .arrow > i:last-child,
  button:focus-visible .arrow > i:last-child {
    translate: 0 0;
  }

  /* cards: lift */
  #lifecycle-list > li,
  #eco-list > li,
  #service-list > li {
    transition:
      translate 0.5s var(--ease),
      box-shadow 0.5s var(--ease),
      background-color 0.25s ease;
  }

  #lifecycle-list > li:hover,
  #eco-list > li:hover,
  #service-list > li:hover {
    translate: 0 -6px;
  }

  #lifecycle-list > li:hover {
    box-shadow: 0 14px 34px rgba(12, 58, 44, 0.14);
  }

  /* team photos: slow zoom */
  #team-list img {
    transition: scale 0.8s var(--ease);
  }

  #team-list li:hover img {
    scale: 1.05;
  }
}

/* =========================================================
   Buttons: colour swap on hover (green <-> cream).
   The arrow uses the text colour, so it swaps with the button.
   The 1px inset ring keeps the button visible once it takes
   the colour of the surface behind it (no layout shift).
   ========================================================= */
.invert-to-cream {
  box-shadow: inset 0 0 0 1px #0a2f24;
}

.invert-to-forest {
  box-shadow: inset 0 0 0 1px #f8f6ee;
}

@media (hover: hover) {
  .invert-to-cream:hover:not(:disabled),
  .invert-to-cream:focus-visible:not(:disabled) {
    background-color: #f8f6ee;
    color: #0a2f24;
  }

  .invert-to-forest:hover:not(:disabled),
  .invert-to-forest:focus-visible:not(:disabled) {
    background-color: #0a2f24;
    color: #f8f6ee;
  }

  /* the Contact Us phone icon is an image, so turn it cream when the button goes green */
  .contact-btn:hover > .contact-btn__icon,
  .contact-btn:focus-visible > .contact-btn__icon {
    filter: brightness(0) invert(1);
  }
}

@media (prefers-reduced-motion: no-preference) {
  .invert-to-cream,
  .invert-to-forest {
    transition:
      background-color 0.4s var(--ease),
      color 0.4s var(--ease);
  }

  .contact-btn > .contact-btn__icon {
    transition: filter 0.4s var(--ease);
  }
}

/* =========================================================
   Reduced motion
   ========================================================= */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
