/* ==========================================================================
   Foroughi | mortgages — design tokens
   System: DESIGN-apple.md (light canvases, single accent, no decorative
   chrome) with the accent swapped from Action Blue to Emerald.
   ========================================================================== */

:root {
  /* color */
  --emerald: #0e7a5c;        /* single interactive accent, light surfaces */
  --emerald-deep: #0a5c45;   /* pressed / hover step */
  --emerald-bright: #3ecf9a; /* links + focus on dark surfaces */
  --ink: #1d1d1f;
  --ink-80: #333333;
  --ink-48: #7a7a7a;
  --canvas: #ffffff;
  --parchment: #f5f5f7;
  --pearl: #fafafc;
  --hairline: #e0e0e0;
  --divider-soft: #f0f0f0;
  --tile-dark: #212423;      /* near-black with a green cast */
  --on-dark: #ffffff;
  --on-dark-muted: rgba(255, 255, 255, 0.64);
  --on-dark-faint: rgba(255, 255, 255, 0.4);
  --line-on-video: rgba(255, 255, 255, 0.34);

  /* type */
  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-fa: "Vazirmatn", "Inter", system-ui, sans-serif;

  /* radius */
  --r-sm: 8px;
  --r-md: 11px;
  --r-lg: 18px;
  --r-pill: 999px;

  /* motion */
  --ease-out: cubic-bezier(0.22, 0.8, 0.2, 1);

  /* hero geometry: the crosshair datum lines */
  --cx: 50%;
  --cy: 38%;
}

/* ==========================================================================
   Reset + base
   ========================================================================== */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.45;
  letter-spacing: -0.2px;
  color: var(--ink);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
}

img,
video {
  display: block;
  max-width: 100%;
}

a {
  color: inherit;
}

button {
  font: inherit;
  cursor: pointer;
  border: 0;
  background: none;
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--emerald);
  outline-offset: 3px;
}

.home :focus-visible {
  outline-color: var(--emerald-bright);
}

.skip {
  position: absolute;
  left: -9999px;
  top: 16px;
  z-index: 100;
  background: var(--canvas);
  color: var(--ink);
  padding: 10px 18px;
  border-radius: var(--r-pill);
}

.skip:focus {
  left: 16px;
}

/* ==========================================================================
   Home — full-viewport video hero, no scroll
   ========================================================================== */

.home {
  min-height: 100dvh;
  overflow-x: hidden;
  background: var(--tile-dark);
  color: var(--on-dark);
}

.hero-media {
  position: fixed;
  inset: 0;
  background: var(--tile-dark) url("../assets/hero-poster.jpg") center / cover no-repeat;
}

.hero-media video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 1.6s ease;
}

.hero-media video.is-playing {
  opacity: 1;
}

.hero-media .scrim {
  position: absolute;
  inset: 0;
  background: rgba(9, 12, 11, 0.52);
}

/* --- crosshair datum lines (signature element) ------------------------- */

.cross {
  position: fixed;
  z-index: 2;
  background: var(--line-on-video);
  pointer-events: none;
}

.cross-v {
  left: var(--cx);
  top: 0;
  bottom: 0;
  width: 1px;
  transform-origin: top;
}

.cross-h {
  top: var(--cy);
  left: 0;
  right: 0;
  height: 1px;
  transform-origin: left;
}

/* measurement ticks approaching the intersection — the surveyor's rule */
.ticks {
  position: fixed;
  z-index: 2;
  pointer-events: none;
  opacity: 0.55;
}

.ticks-h {
  top: var(--cy);
  left: calc(var(--cx) - 176px);
  width: 96px;
  height: 7px;
  background-image: repeating-linear-gradient(
    to right,
    var(--line-on-video) 0 1px,
    transparent 1px 12px
  );
}

.ticks-v {
  left: var(--cx);
  top: calc(var(--cy) + 80px);
  width: 7px;
  height: 96px;
  background-image: repeating-linear-gradient(
    to bottom,
    var(--line-on-video) 0 1px,
    transparent 1px 12px
  );
}

/* --- wordmark ----------------------------------------------------------- */

.wordmark {
  position: fixed;
  z-index: 3;
  left: 0;
  right: 0;
  bottom: calc(100% - var(--cy));
  display: flex;
  align-items: flex-end;
  pointer-events: none;
  padding-bottom: 16px;
}

/* the big word ends exactly at the vertical datum line */
.wm-left {
  flex: 0 0 var(--cx);
  display: flex;
  justify-content: flex-end;
  padding-right: 64px;
}

.wm-main {
  font-size: clamp(52px, 7.4vw, 112px);
  font-weight: 600;
  letter-spacing: -0.045em;
  line-height: 0.94;
  color: var(--on-dark);
}

.wm-sub {
  font-size: clamp(17px, 1.5vw, 22px);
  font-weight: 400;
  letter-spacing: -0.01em;
  color: var(--on-dark);
  align-self: flex-start;
  padding: 0.35em 0 0 36px;
}

/* --- right-rail nav ------------------------------------------------------ */

.rail {
  position: fixed;
  z-index: 5;
  top: 22px;
  left: 0;
  right: 0;
  width: max-content;
  margin-inline: auto;
  font-size: 15px;
  letter-spacing: -0.1px;
  padding: 7px 8px;
  background: rgba(9, 12, 11, 0.3);
  border: 1px solid var(--line-on-video);
  border-radius: var(--r-pill);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.rail ul {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 2px;
}

.rail > ul > li {
  margin-bottom: 0;
}

.rail a {
  display: block;
  padding: 7px 18px;
  border-radius: var(--r-pill);
  text-decoration: none;
  color: var(--on-dark-muted);
  transition: color 0.2s ease, background 0.2s ease;
}

.rail a:hover {
  color: var(--on-dark);
  background: rgba(255, 255, 255, 0.08);
}

.rail .is-current > a {
  color: var(--on-dark-faint);
  pointer-events: none;
}

/* Mortgages is a hover trigger only — it has no href and never navigates */
.rail .has-sub > a {
  cursor: default;
}

/* Mortgages hover dropdown — panel drops below the top-center pill */
.rail .sub {
  position: absolute;
  top: 100%;
  left: 50%;
  margin-top: 12px;
  transform: translateX(-50%) translateY(-6px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s var(--ease-out),
    visibility 0.2s;
  width: max-content;
  max-width: 92vw;
  padding: 22px 26px;
  background: rgba(9, 12, 11, 0.55);
  border: 1px solid var(--line-on-video);
  border-radius: 20px;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  text-align: left;
}

/* invisible bridge keeps :hover alive across the pill-to-panel gap */
.rail .sub::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: -22px;
  height: 22px;
}

.rail .has-sub:hover .sub,
.rail .has-sub:focus-within .sub {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}

.sub-inner {
  display: grid;
  grid-template-columns: repeat(4, max-content);
  gap: 20px 34px;
}

.sub-head {
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 1.4px;
  color: var(--on-dark-faint, rgba(255, 255, 255, 0.45));
  margin-bottom: 8px;
}

/* full dropdown open: everything behind the rail blurs (class set by js) */
.hero-media,
.home .wordmark,
.home .chip,
.home .intro,
.home .strip {
  transition: filter 0.35s ease;
}

.home.mega-open .hero-media,
.home.mega-open .wordmark,
.home.mega-open .chip,
.home.mega-open .intro,
.home.mega-open .strip {
  filter: blur(14px);
}

.rail .sub a {
  display: block;
  padding: 5px 0;
  font-size: 14px;
  white-space: nowrap;
  color: var(--on-dark-muted);
  background: none;
}

.rail .sub a:hover {
  color: var(--on-dark);
  background: none;
}

.rail .fa-link a {
  font-family: var(--font-fa);
}

/* --- intro block ---------------------------------------------------------- */

.chip {
  position: fixed;
  z-index: 4;
  left: var(--cx);
  top: var(--cy);
  transform: translate(-50%, -50%);
  background: var(--canvas);
  color: var(--ink);
  font-size: 14px;
  font-weight: 400;
  letter-spacing: -0.1px;
  padding: 8px 22px;
  border-radius: var(--r-pill);
}

.intro {
  position: fixed;
  z-index: 4;
  left: calc(var(--cx) + 32px);
  top: calc(var(--cy) + 52px);
  width: min(560px, 42vw);
}

.lede {
  font-size: clamp(20px, 2vw, 27px);
  font-weight: 300;
  line-height: 1.42;
  letter-spacing: -0.1px;
  color: var(--on-dark);
}

.cta-row {
  display: flex;
  align-items: center;
  gap: 28px;
  margin-top: 36px;
}

.btn-pill {
  background: var(--emerald);
  color: var(--on-dark);
  font-size: 17px;
  font-weight: 400;
  letter-spacing: -0.2px;
  padding: 14px 28px;
  border-radius: var(--r-pill);
  transition: background 0.2s ease, transform 0.15s ease;
}

.btn-pill:hover {
  background: var(--emerald-deep);
}

.btn-pill:active {
  transform: scale(0.96);
}

.link-quiet {
  font-size: 16px;
  color: var(--on-dark);
  text-decoration: none;
  border-bottom: 1px solid var(--on-dark-faint);
  padding-bottom: 3px;
  transition: border-color 0.2s ease, color 0.2s ease;
}

.link-quiet:hover {
  color: var(--emerald-bright);
  border-color: var(--emerald-bright);
}

/* --- bottom strip ---------------------------------------------------------- */

.strip {
  position: fixed;
  z-index: 4;
  left: 48px;
  right: 48px;
  bottom: 28px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 24px;
  font-size: 11.5px;
  letter-spacing: 0;
  color: var(--on-dark-muted);
}

/* ==========================================================================
   Callback panel (slide-in drawer)
   ========================================================================== */

.panel-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(9, 12, 11, 0.44);
  opacity: 0;
  transition: opacity 0.4s ease;
}

.panel-overlay.is-open {
  opacity: 1;
}

.panel {
  position: fixed;
  z-index: 50;
  top: 0;
  right: 0;
  height: 100dvh;
  width: min(480px, 100vw);
  background: var(--canvas);
  color: var(--ink);
  padding: 52px 48px 40px;
  overflow-y: auto;
  transform: translateX(102%);
  transition: transform 0.5s var(--ease-out);
}

.panel.is-open {
  transform: translateX(0);
}

.panel-close {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 44px;
  height: 44px;
  border-radius: var(--r-pill);
  font-size: 22px;
  line-height: 1;
  color: var(--ink-48);
  transition: color 0.2s ease, background 0.2s ease;
}

.panel-close:hover {
  color: var(--ink);
  background: var(--divider-soft);
}

.panel h2 {
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.panel-sub {
  margin-top: 12px;
  font-size: 15px;
  color: var(--ink-48);
  line-height: 1.5;
}

.panel form {
  margin-top: 36px;
}

.field {
  margin-bottom: 22px;
}

.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.1px;
  margin-bottom: 8px;
}

.field input,
.field select {
  width: 100%;
  font: inherit;
  font-size: 16px;
  color: var(--ink);
  background: var(--canvas);
  border: 1px solid var(--hairline);
  border-radius: 10px;
  padding: 13px 14px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  appearance: none;
}

.field select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%237a7a7a' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
}

.field input:focus,
.field select:focus {
  outline: none;
  border-color: var(--emerald);
  box-shadow: 0 0 0 3px rgba(14, 122, 92, 0.14);
}

.seg {
  display: flex;
  gap: 8px;
}

.seg input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.seg label {
  flex: 1;
  text-align: center;
  font-size: 14px;
  font-weight: 400;
  margin: 0;
  padding: 11px 0;
  border: 1px solid var(--hairline);
  border-radius: var(--r-pill);
  transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease;
  cursor: pointer;
}

.seg input:checked + label {
  border-color: var(--emerald);
  background: rgba(14, 122, 92, 0.08);
  color: var(--emerald-deep);
  font-weight: 600;
}

.seg input:focus-visible + label {
  outline: 2px solid var(--emerald);
  outline-offset: 2px;
}

.hp {
  position: absolute;
  left: -9999px;
  height: 0;
  overflow: hidden;
}

.panel .btn-pill {
  width: 100%;
  margin-top: 6px;
  text-align: center;
}

.panel-fine {
  margin-top: 16px;
  font-size: 12px;
  color: var(--ink-48);
  text-align: center;
}

.form-error {
  margin: 0 0 16px;
  font-size: 14px;
  line-height: 1.5;
  color: #b3261e;
}

button[type="submit"]:disabled {
  opacity: 0.6;
  cursor: default;
}

.panel-success {
  display: none;
  margin-top: 48px;
}

.panel.is-done form,
.panel.is-done .panel-sub {
  display: none;
}

.panel.is-done .panel-success {
  display: block;
}

.panel-success h3 {
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.panel-success p {
  margin-top: 14px;
  font-size: 16px;
  color: var(--ink-80);
  line-height: 1.55;
}

/* ==========================================================================
   Mobile menu + responsive
   ========================================================================== */

.menu-btn {
  display: none;
  position: fixed;
  z-index: 6;
  top: 20px;
  right: 20px;
  font-size: 14px;
  letter-spacing: 0;
  color: var(--on-dark);
  padding: 10px 20px;
  border: 1px solid var(--line-on-video);
  border-radius: var(--r-pill);
  background: rgba(9, 12, 11, 0.3);
  backdrop-filter: blur(12px);
}

@media (max-width: 900px) {
  :root {
    --cy: 30%;
  }

  .rail {
    display: none;
  }

  .rail.is-open {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    inset: 0;
    width: auto;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: rgba(9, 12, 11, 0.88);
    backdrop-filter: blur(16px);
    text-align: center;
    font-size: 24px;
  }

  .rail.is-open ul {
    flex-direction: column;
  }

  .rail.is-open > ul > li {
    margin-bottom: 22px;
  }

  .rail.is-open a {
    color: var(--on-dark);
  }

  .rail.is-open .sub {
    display: none;
  }

  .menu-btn {
    display: block;
  }

  .cross-v,
  .ticks-h,
  .ticks-v {
    display: none;
  }

  .wordmark {
    padding-bottom: 14px;
  }

  .wm-left {
    flex: none;
    padding: 0 0 0 24px;
  }

  .wm-main {
    font-size: clamp(44px, 13vw, 64px);
  }

  .wm-sub {
    padding-left: 16px;
  }

  .chip {
    left: 24px;
    top: calc(var(--cy) + 28px);
    transform: translateY(-50%);
  }

  .intro {
    left: 24px;
    right: 24px;
    width: auto;
    top: calc(var(--cy) + 88px);
  }

  .lede {
    font-size: 19px;
  }

  .cta-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 20px;
  }

  .strip {
    left: 24px;
    right: 24px;
    bottom: 18px;
    flex-direction: column;
    gap: 4px;
  }

  .strip .locale {
    display: none;
  }

  .panel {
    padding: 48px 24px 32px;
  }
}

/* ==========================================================================
   Load choreography — elements settle onto the datum lines
   ========================================================================== */

.home .cross-v {
  transform: scaleY(0);
  transition: transform 1.1s var(--ease-out) 0.15s;
}

.home .cross-h {
  transform: scaleX(0);
  transition: transform 1.1s var(--ease-out) 0.15s;
}

.home .wordmark,
.home .chip,
.home .intro,
.home .strip,
.home .rail,
.home .menu-btn,
.home .ticks {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.9s ease, transform 0.9s var(--ease-out);
}

.home .chip {
  transform: translate(-50%, calc(-50% + 14px));
}

.home.is-loaded .cross-v,
.home.is-loaded .cross-h {
  transform: none;
}

.home.is-loaded .wordmark,
.home.is-loaded .intro,
.home.is-loaded .strip,
.home.is-loaded .rail,
.home.is-loaded .menu-btn,
.home.is-loaded .ticks {
  opacity: 1;
  transform: none;
}

.home.is-loaded .chip {
  opacity: 1;
  transform: translate(-50%, -50%);
}

.home.is-loaded .wordmark {
  transition-delay: 0.35s;
}

.home.is-loaded .chip {
  transition-delay: 0.75s;
}

.home.is-loaded .intro {
  transition-delay: 0.9s;
}

.home.is-loaded .rail,
.home.is-loaded .menu-btn {
  transition-delay: 1.05s;
}

.home.is-loaded .strip,
.home.is-loaded .ticks {
  transition-delay: 1.2s;
}

@media (prefers-reduced-motion: reduce) {
  .home .cross-v,
  .home .cross-h,
  .home .wordmark,
  .home .chip,
  .home .intro,
  .home .strip,
  .home .rail,
  .home .menu-btn,
  .home .ticks,
  .hero-media video,
  .panel,
  .panel-overlay {
    transition: none !important;
    transform: none !important;
    opacity: 1 !important;
  }

  .home .chip {
    transform: translate(-50%, -50%) !important;
  }
}

/* mobile: chip is left-anchored, not centered on the (hidden) vertical line */
@media (max-width: 900px) {
  .home .chip {
    transform: translateY(calc(-50% + 14px));
  }

  .home.is-loaded .chip {
    transform: translateY(-50%);
  }

  @media (prefers-reduced-motion: reduce) {
    .home .chip,
    .home.is-loaded .chip {
      transform: translateY(-50%) !important;
    }
  }
}

/* ==========================================================================
   Home — scroll-scrubbed video story (GSAP ScrollTrigger, js/home-scroll.js)
   Three full-viewport copy chapters over ONE fixed background clip whose
   playhead is scrubbed to scroll position. GSAP owns its scale — no CSS
   transitions on transform.
   ========================================================================== */

.hero-media video.bgv-scrub {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform-origin: center;
  opacity: 1;
  will-change: transform;
  background: var(--tile-dark);
}

.hsec {
  position: relative;
  z-index: 4;
  min-height: 100dvh;
}

.hsec-copy {
  position: absolute;
  left: 48px;
  top: calc(38vh + 52px);
  width: min(560px, 42vw);
}

@media (max-width: 900px) {
  .hsec-copy {
    left: 24px;
    right: 24px;
    top: calc(30vh + 88px);
    width: auto;
  }
}

/* ==========================================================================
   Splash intro (once per session — js/intro-splash.js)
   ========================================================================== */

html.intro-lock,
html.intro-lock body {
  overflow: hidden;
  height: 100%;
}

/* while the splash plays, the fixed nav waits at opacity 0; GSAP fades it
   in near the end of the exit tween (inline style wins over this rule) */
html.intro-lock .home .rail,
html.intro-lock .home .menu-btn {
  opacity: 0;
  transition: none;
}

html.no-splash #intro-splash {
  display: none;
}

#intro-splash {
  position: fixed;
  inset: 0;
  height: 100svh;
  overflow: hidden;
  z-index: 9999;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  will-change: transform;
}

.splash-media {
  position: absolute;
  inset: 0;
}

/* the rapid-sequence slides stack on top of each other; the intro flashes
   through them by toggling opacity (js/intro-splash.js) */
.splash-media img,
.splash-slide {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.splash-scrim {
  position: absolute;
  inset: 0;
  z-index: 2; /* holds a constant dark wash above the flashing slides */
  background: rgba(6, 9, 8, 0.6);
}

/* logo overlay: centered by the flex parent, laid out in normal flow so the
   exit tween can transform it independently of the overlay */
.splash-logo {
  position: relative;
  display: flex;
  align-items: baseline;
  gap: 18px;
  padding: 0 24px;
  will-change: transform;
}

.splash-wm {
  font-size: clamp(44px, 7vw, 96px);
  font-weight: 600;
  letter-spacing: -0.045em;
  line-height: 1;
  color: #fff;
  text-shadow: 0 2px 34px rgba(0, 0, 0, 0.55); /* readable over any frame */
}

.splash-sub {
  font-size: clamp(15px, 1.6vw, 22px);
  font-weight: 300;
  letter-spacing: 0.02em;
  color: rgba(255, 255, 255, 0.82);
  text-shadow: 0 2px 24px rgba(0, 0, 0, 0.5);
}

@media (prefers-reduced-motion: reduce) {
  #intro-splash {
    display: none;
  }
}

/* ==========================================================================
   Home — Mortgages dropdown (single-screen cover, no page scroll)
   ========================================================================== */

/* flat priority-ordered dropdown (11 services, read down col 1 then col 2) */
.sub-inner-flat {
  display: grid;
  grid-template-rows: repeat(6, auto);
  grid-auto-flow: column;
  column-gap: 44px;
  row-gap: 2px;
}

/* Mortgages is a menu trigger (hover on desktop, revealed inline in the
   mobile menu below) */
.rail .has-sub > a {
  cursor: pointer;
}

/* mobile: the rail becomes a full-screen menu. Reveal the service list inline
   so every service stays reachable without any page scroll; the menu overlay
   itself scrolls internally if the list runs taller than the screen. */
@media (max-width: 900px) {
  .rail.is-open {
    align-items: flex-start;
    justify-content: center;
    overflow-y: auto;
    padding: 84px 24px 40px;
  }

  .rail.is-open .sub {
    display: block;
    position: static;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: none;
    width: auto;
    max-width: none;
    margin: 16px 0 0;
    padding: 0;
    background: none;
    border: 0;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }

  .rail.is-open .sub-inner-flat {
    display: flex;
    flex-direction: column;
    gap: 14px;
  }

  .rail.is-open .sub a {
    font-size: 18px;
    color: var(--on-dark-muted);
  }
}
