/* =========================================================
   LAYOUT.CSS — GLOBAL STRUCTURE (DIAMOND-GRADE)
   Purpose:
   - Page shell: header / main / sections / footer
   - Responsive layout rules (grid / spacing)
   - NO component styling (buttons/cards/forms are in components.css)
   ========================================================= */


/* =========================
   0) GLOBAL CONTAINERS
   ========================= */

.wrap{
  width: min(var(--max, 1180px), calc(100% - 40px));
  margin: 0 auto;
}

.content-narrow{
  width: min(860px, calc(100% - 40px));
  margin: 0 auto;
}

body{
  min-height: 100%;
}


/* =========================
   1) HEADER (STRUCTURE ONLY)
   ========================= */

.site-header{
  position: sticky;
  top: 0;
  z-index: 1000;

  background: rgba(4, 12, 24, .72);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);

  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}

.header-inner{
  width: min(var(--max, 1180px), calc(100% - 40px));
  margin: 0 auto;

  display: flex;
  align-items: center;
  gap: 18px;

  padding: 14px 0;
}

.header-brand{
  flex: 0 0 auto;
  position: relative;
  z-index: 3;
  pointer-events: auto;
}

/* navigation row */
.site-nav{
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 1;
  justify-content: center;
  min-width: 0;

  flex-wrap: nowrap;
  overflow: visible;
  position: relative;
  z-index: 1;
}

/* CTA aligned right */
.header-cta{
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-width: 180px;
  position: relative;
  z-index: 2;
}


/* =========================
   2) PAGE HERO (STRUCTURE)
   ========================= */

.page-hero{
  position: relative;
  border-bottom: 1px solid var(--line);
}

.page-hero--simple{
  padding: 56px 0 34px;
}

.page-hero--brand{
  padding: 68px 0 40px;
}

.page-title{ margin: 0; }

.page-lead{
  margin: 12px 0 0;
  max-width: 72ch;
}

.hero__cta{
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 18px;
}


/* =========================
   3) HOME HERO (STRUCTURE)
   ========================= */

.hero{
  position: relative;
  overflow: hidden;
  border-bottom: 1px solid var(--line);

  min-height: min(720px, 100svh);
  min-height: min(720px, 100dvh);
  padding: 64px 0 36px;
}

.hero__inner{
  position: relative;
  z-index: 2;
  display: grid;
  align-items: center;
  min-height: 620px;
}

/* Inner pages use single-column hero layout (no empty right side) */
.hero.hero--page .hero__inner{
  grid-template-columns: 1fr;
  align-items: start;
  min-height: 0;
}

/* Inner pages should not inherit homepage hero height */
.hero.hero--page{
  min-height: 0;
  padding: 56px 0 34px;
}

.hero.hero--page .hero__wave{
  height: 44px;
}

/* Home hero: tighter top spacing under header */
.hero:not(.hero--page){
  min-height: min(680px, 100svh);
  min-height: min(680px, 100dvh);
  padding: 38px 0 34px;
}

.hero:not(.hero--page) .hero__inner{
  align-items: start;
  min-height: 0;
}

.hero__content{
  max-width: 760px;
}

.kicker{
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.hero__title{ margin: 0; }

.hero__lead{
  margin: 14px 0 0;
  max-width: 70ch;
}

.hero__cta{
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 22px;
}

.hero__wave{
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 70px;
  pointer-events: none;
  z-index: 1;
}


/* =========================
   4) SECTIONS (STRUCTURE)
   ========================= */

.section{
  padding: 64px 0;
}

.section--dark{
  background: rgba(255,255,255,.02);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.section__head{
  display: grid;
  gap: 10px;
  margin-bottom: 26px;

  justify-items: center;
  text-align: center;
}

.section__title{ margin: 0; }

.section__subtitle{
  margin: 0;
  max-width: 78ch;
}

.section__cta{
  margin-top: 18px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}


/* =========================
   5) GRIDS (LAYOUT ONLY)
   ========================= */

.grid{
  display: grid;
  gap: 18px;
}

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

.grid--3{
  grid-template-columns: repeat(3, minmax(0, 1fr));
}


/* =========================
   6) FOOTER (STRUCTURE ONLY)
   ========================= */

.site-footer{
  position: relative;
  border-top: 1px solid var(--line);
  padding: 42px 0 18px;
  padding-bottom: calc(18px + env(safe-area-inset-bottom));
}

.footer-inner{
  width: min(var(--max, 1180px), calc(100% - 40px));
  margin: 0 auto;

  display: grid;
  grid-template-columns: 1.25fr 1fr .9fr;
  gap: 24px;
  text-align: center;
  justify-items: center;
}

.footer-bottom{
  width: min(var(--max, 1180px), calc(100% - 40px));
  margin: 18px auto 0;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  text-align: center;
}


/* =========================
   7) RESPONSIVE
   ========================= */

/* ✅ KEY FIX: when space becomes tight, nav drops under brand+CTA (does NOT disappear) */
@media (max-width: 980px){
  .header-inner{
    width: min(var(--max, 1180px), calc(100% - 28px));
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 12px 0 10px;
  }

  .header-brand{
    order: 1;
    justify-content: center;
    min-width: 0;
    margin: 0 auto;
  }

  .header-cta{
    order: 2;
    width: 100%;
    min-width: 0;
    justify-content: center;
  }

  .site-header .header-cta .btn-primary{
    width: min(100%, 420px);
  }

  .site-header .header-inner .site-nav{
    order: 3;
    flex: 0 0 auto;
    width: 100%;
    min-width: 0;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    justify-content: stretch;
    align-items: stretch;
    overflow: visible;
  }

  .site-header .header-inner .site-nav .nav-link{
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 8px 6px;
    text-align: center;
    white-space: normal;
    line-height: 1.25;
    border-radius: 12px;
    background: rgba(255,255,255,.03);
    border: 1px solid rgba(255,255,255,.10);
  }

  .site-header .header-inner .site-nav .nav-link::after{
    display: none;
  }

  .site-header .header-inner .site-nav .nav-link:hover{
    background: rgba(255,255,255,.07);
    border-color: rgba(255,255,255,.16);
  }

  .site-header .header-inner .site-nav .nav-link.active{
    background: rgba(255,255,255,.10);
    border-color: rgba(255,255,255,.24);
  }

  .site-header{
    padding-bottom: 4px;
  }
}

@media (max-width: 820px){
  .hero:not(.hero--page) .hero__inner{
    grid-template-columns: 1fr;
    gap: 18px;
  }

  .hero:not(.hero--page) .hero__content{
    max-width: 100%;
  }

  .hero:not(.hero--page) .hero__title{
    font-size: clamp(28px, 8vw, 42px);
    line-height: 1.06;
    letter-spacing: clamp(.035em, .2vw, .08em);
    max-width: 100%;
    overflow-wrap: anywhere;
    text-wrap: balance;
  }

  .hero{
    min-height: 640px;
    padding: 56px 0 30px;
  }

  .hero__inner{
    min-height: 560px;
  }

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

  .footer-inner{
    grid-template-columns: 1fr 1fr;
  }

  .hero:not(.hero--page){
    min-height: 620px;
    padding: 32px 0 28px;
  }

  .hero:not(.hero--page) .hero__inner{
    min-height: 0;
  }
}

@media (max-width: 720px){
  .wrap{
    width: calc(100% - 28px);
  }

  .content-narrow{
    width: calc(100% - 28px);
  }

  .header-inner{
    padding: 12px 0;
  }

  .site-header .header-inner .site-nav{
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .hero{
    min-height: min(600px, 100svh);
    min-height: min(600px, 100dvh);
  }

  .hero__inner{
    min-height: 520px;
  }

  .section{
    padding: 52px 0;
  }

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

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

  .footer-inner{
    grid-template-columns: 1fr;
    text-align: center;
    justify-items: center;
  }

  .footer-inner > *{
    width: min(520px, 100%);
  }

  .hero:not(.hero--page){
    min-height: 560px;
    padding: 26px 0 24px;
  }

  .hero:not(.hero--page) .hero__inner{
    min-height: 0;
  }
}

@media (max-width: 560px){
  .hero:not(.hero--page) .hero__title{
    font-size: clamp(24px, 8.6vw, 32px);
    line-height: 1.08;
    letter-spacing: .03em;
  }

  .hero:not(.hero--page) .hero__lead{
    font-size: clamp(15px, 4.1vw, 17px);
    line-height: 1.52;
  }

  .hero{
    padding: 22px 0 20px;
  }

  .hero__inner{
    grid-template-columns: 1fr;
    gap: 18px;
  }
}

@media (max-width: 420px){
  /* CTA must never disappear; keep it visible and allow it to fit */
  .header-cta{
    display: flex;
    min-width: 0;
  }

  .site-header .header-cta .btn-primary{
    padding: 10px 14px;
    font-size: 13px;
  }
}

/* ===== Premium sticky header behavior ===== */
.site-header{
  transition: background-color .24s ease, backdrop-filter .24s ease, border-color .24s ease, box-shadow .24s ease;
}

.site-header.is-scrolled{
  background: rgba(4, 12, 24, .86);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  border-bottom-color: rgba(255,255,255,.14);
  box-shadow: 0 12px 36px rgba(0,0,0,.35);
}

/* ===== Inner-page hero spacing normalization ===== */
@media (max-width: 720px){
  .hero.hero--page{
    padding: 42px 0 24px;
  }
}

@media (max-width: 560px){
  .hero.hero--page{
    padding: 34px 0 18px;
  }
}
