@import url('tokens.css');

/* ==========================================================================
   Crest Consultancy Firm — design system
   Light premium corporate. Hexagon/diamond geometry as a structural
   throughline (eyebrow glyphs, hex icons, diamond bullets) echoing the mark.
   ========================================================================== */

/* --- Reset ---------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  /* Defense-in-depth against horizontal overflow (the real fix for the
     mobile off-canvas nav's 320px-off-viewport panel — see the
     .site-header::before comment below — is structural, not this). `clip`
     (unlike `hidden`) doesn't establish a scroll container, so unlike a
     blanket `overflow-x: hidden` here it can't interfere with
     position:sticky descendants (verified against .site-header). */
  overflow-x: clip;
}
body {
  font-family: var(--font-body);
  font-size: 1.05rem;
  line-height: 1.7;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img, svg, picture { display: block; max-width: 100%; }
img { height: auto; }
a { color: var(--blue); text-decoration: none; }
a:hover { color: var(--navy); }
button { font: inherit; color: inherit; cursor: pointer; }
ul { list-style: none; padding: 0; }
:target { scroll-margin-top: 96px; }

/* --- Typography scale ----------------------------------------------------- */
h1, h2, h3 {
  font-family: var(--font-display);
  color: var(--navy);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.015em;
}
h1 { font-size: clamp(2.2rem, 5vw, 3.6rem); line-height: 1.06; }
h2 { font-size: clamp(1.8rem, 3.4vw, 2.65rem); }
h3 { font-size: clamp(1.25rem, 2vw, 1.5rem); font-weight: 600; letter-spacing: -0.01em; }
h4, h5, h6 { font-family: var(--font-body); color: var(--navy); font-weight: 600; line-height: 1.3; }
p { max-width: 68ch; }
strong { font-weight: 600; color: var(--navy); }
.lead { font-size: clamp(1.12rem, 1.6vw, 1.3rem); line-height: 1.6; color: var(--muted); max-width: 60ch; }

/* --- Layout --------------------------------------------------------------- */
.wrap {                 /* centered max-width container with responsive gutters */
  width: 100%;
  max-width: var(--wrap);
  margin-inline: auto;
  padding-inline: clamp(1.25rem, 5vw, 2.5rem);
}
.section {              /* standard vertical rhythm for a page section */
  padding-block: clamp(3.5rem, 8vw, 6.5rem);
  position: relative;
}
.section--alt { background: var(--bg-alt); }   /* subtle warm-gray band */
.section--navy {                                 /* deep navy feature band */
  background: var(--navy);
  color: rgba(255, 255, 255, 0.86);
}
.section--navy h1, .section--navy h2, .section--navy h3 { color: #fff; }
.section--navy .lead { color: rgba(255, 255, 255, 0.86); }
.section--hex::before {                          /* faint honeycomb corner texture */
  content: "";
  position: absolute;
  inset: 0;
  background: url('../assets/img/hex-pattern.svg') top right / 620px auto no-repeat;
  opacity: 0.7;
  pointer-events: none;
  z-index: 0;
}
.section--hex > .wrap { position: relative; z-index: 1; }

/* --- Eyebrow (section label) --------------------------------------------- */
.eyebrow {              /* small-caps blue label prefixed with a diamond glyph */
  display: inline-flex;
  align-items: center;
  gap: 0.6em;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--blue);
  margin-bottom: 1rem;
}
.eyebrow::before {                               /* the recurring brand diamond */
  content: "";
  width: 8px;
  height: 8px;
  background: linear-gradient(135deg, var(--blue), var(--navy));
  transform: rotate(45deg);
  flex: none;
}
.section--navy .eyebrow { color: var(--blue-light); }

/* --- Hero ----------------------------------------------------------------- */
.hero {                 /* full-bleed opening block; pairs with .section--hex */
  padding-block: clamp(4.5rem, 11vw, 8.5rem);
  overflow: hidden;
}
.hero__inner { max-width: 44rem; }
.hero h1 { margin-bottom: 1.25rem; }
.hero .lead { margin-bottom: 2rem; }
.hero__actions { display: flex; flex-wrap: wrap; gap: 0.9rem; }

/* --- Buttons -------------------------------------------------------------- */
.btn {                  /* primary CTA: solid navy, soft lift on hover */
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  padding: 0.85em 1.6em;
  font-family: var(--font-body);
  font-size: 0.98rem;
  font-weight: 600;
  line-height: 1;
  color: #fff;
  background: var(--navy);
  border: 1px solid var(--navy);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: transform 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}
.btn:hover {
  color: #fff;
  background: var(--blue);
  border-color: var(--blue);
  transform: translateY(-2px);
  box-shadow: 0 14px 34px rgb(10 86 148 / 0.24);
}
.btn:active { transform: translateY(0); }
.btn--ghost {           /* secondary CTA: outlined, transparent fill */
  color: var(--navy);
  background: transparent;
  border-color: var(--line);
  box-shadow: none;
}
.btn--ghost:hover {
  color: var(--navy);
  background: var(--bg-alt);
  border-color: var(--navy);
  box-shadow: none;
}
.section--navy .btn--ghost {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.4);
}
.section--navy .btn--ghost:hover { background: rgba(255, 255, 255, 0.1); border-color: #fff; }
.section--navy .btn:not(.btn--ghost) {        /* inverted primary: navy label on white box */
  color: var(--navy);
  background: #fff;
  border-color: #fff;
}
.section--navy .btn:not(.btn--ghost):hover {
  color: var(--navy-deep);
  background: rgba(255, 255, 255, 0.85);
  border-color: rgba(255, 255, 255, 0.85);
  transform: translateY(-2px);
  box-shadow: 0 14px 34px rgb(10 86 148 / 0.24);
}

/* --- Grids ---------------------------------------------------------------- */
.grid-2, .grid-3 {      /* responsive card grids; collapse to 1 col on narrow */
  display: grid;
  gap: clamp(1.25rem, 2.5vw, 2rem);
}
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 860px) { .grid-3 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 620px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

/* --- Card ----------------------------------------------------------------- */
.card {                 /* elevated content surface with a hover-active top edge */
  position: relative;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: clamp(1.5rem, 3vw, 2.1rem);
  box-shadow: 0 1px 2px rgb(20 24 107 / 0.04);
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}
.card::after {                                   /* navy→blue accent that draws in on hover */
  content: "";
  position: absolute;
  left: 0; top: 0;
  height: 3px;
  width: 0;
  background: linear-gradient(90deg, var(--navy), var(--blue));
  border-radius: var(--radius) var(--radius) 0 0;
  transition: width 0.35s ease;
}
.card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow);
  border-color: transparent;
}
.card:hover::after { width: 100%; }
.card h3 { margin-bottom: 0.6rem; }
.card p { color: var(--muted); }
a.card, .card a.card__link { color: inherit; }
.card__more {
  display: inline-block;
  margin-top: 1.15rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--blue);
}
a.card:hover .card__more { color: var(--navy); }

/* --- Hexagon icon --------------------------------------------------------- */
.hex-icon {             /* pointy-top hex tile (clip-path) for service/feature icons */
  --hex-size: 66px;
  width: var(--hex-size);
  height: var(--hex-size);
  display: grid;
  place-items: center;
  color: #fff;
  font-size: calc(var(--hex-size) * 0.42);
  background: linear-gradient(150deg, var(--navy), var(--blue));
  clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
  margin-bottom: 1.25rem;
}
.hex-icon svg, .hex-icon img { width: 46%; height: auto; }

/* --- Stat ----------------------------------------------------------------- */
.stat {                 /* headline metric: big serif number + quiet label */
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.stat__num {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(2.1rem, 4vw, 3rem);
  line-height: 1;
  color: var(--navy);
  letter-spacing: -0.02em;
}
.stat__label {
  font-size: 0.9rem;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.section--navy .stat__num { color: #fff; }
.section--navy .stat__label { color: rgba(255, 255, 255, 0.7); }

/* --- Diamond list --------------------------------------------------------- */
.diamond-list {         /* feature/benefit list with rotated-square brand bullets */
  display: grid;
  gap: 0.85rem;
}
.diamond-list li {
  position: relative;
  padding-left: 1.75rem;
  color: var(--ink);
}
.diamond-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.62em;
  width: 9px;
  height: 9px;
  background: linear-gradient(135deg, var(--blue), var(--navy));
  transform: translateY(-50%) rotate(45deg);
}
.section--navy .diamond-list li { color: rgba(255, 255, 255, 0.86); }

/* --- Service page components ----------------------------------------------- */
.hero--lite { padding-block: clamp(3.25rem, 7vw, 5rem); }
.svc-hero__grid { display: grid; grid-template-columns: 1.02fr 0.98fr; gap: clamp(2rem, 5vw, 4.5rem); align-items: center; }
.svc-hero__copy { max-width: 40rem; }
.svc-hero__media { position: relative; }
.svc-hero__media::before {
  content: ""; position: absolute; top: -24px; right: -24px;
  width: clamp(82px, 11vw, 128px); aspect-ratio: 1;
  background: linear-gradient(150deg, var(--navy), var(--blue));
  clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%); z-index: 0;
}
.svc-frame { position: relative; z-index: 1; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); aspect-ratio: 3 / 2; }
.svc-frame picture { display: block; width: 100%; height: 100%; }
.svc-frame img { width: 100%; height: 100%; object-fit: cover; }
.svc-frame::after { content: ""; position: absolute; inset: 0; background: linear-gradient(120deg, rgba(23, 30, 96, 0.30), rgba(10, 86, 148, 0) 60%); }

.svc-deliver { grid-template-columns: repeat(2, 1fr); gap: 1.35rem 2.2rem; margin-top: clamp(2rem, 4vw, 3rem); }
.svc-deliver strong { display: block; margin-bottom: 0.2rem; }

.svc-steps { list-style: none; display: grid; grid-template-columns: repeat(4, 1fr); gap: clamp(1.25rem, 2.5vw, 2rem); margin-top: clamp(2rem, 4vw, 3rem); }
.svc-step { padding-top: 1.1rem; border-top: 2px solid var(--line); }
.svc-step__num { font-family: var(--font-display); font-weight: 700; font-size: 1.5rem; color: var(--blue); letter-spacing: -0.02em; }
.svc-step h3 { margin: 0.45rem 0; font-size: 1.05rem; }
.svc-step p { color: var(--muted); font-size: 0.95rem; }

.svc-why { text-align: center; }
.svc-why .lead { margin-inline: auto; color: rgba(255, 255, 255, 0.9); }
.svc-why__stat { margin-top: 2.25rem; display: flex; justify-content: center; }
.svc-why__stat .stat { align-items: center; }
.svc-why__stat .stat__num { font-size: clamp(2.6rem, 6vw, 3.6rem); }

.svc-cta { text-align: center; }
.svc-cta .lead { margin-inline: auto; }
.svc-cta__actions { display: flex; justify-content: center; margin-top: 1.75rem; }

@media (max-width: 860px) {
  .svc-hero__grid { grid-template-columns: 1fr; }
  .svc-hero__media { order: -1; }
  .svc-steps { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 620px) {
  .svc-deliver { grid-template-columns: 1fr; }
  .svc-steps { grid-template-columns: 1fr; }
}

/* --- Scroll reveal (JS-gated so no-JS users always see content) ----------- */
.js .reveal {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.7s ease, transform 0.7s ease;
  will-change: opacity, transform;
}
.js .reveal--in { opacity: 1; transform: none; }

/* ==========================================================================
   Header
   ========================================================================== */
.site-header {          /* sticky translucent bar over any page content */
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid var(--line);
}
.site-header::before {
  /* The translucent blur lives on a ::before layer, not on .site-header
     itself. `backdrop-filter` on an element establishes a containing block
     for its position:fixed descendants (same reason the .nav-overlay is
     kept as a sibling of <header> rather than a child — see the comment
     in header.html). #primary-nav *is* a child of .site-header (it has to
     be, for the desktop flex row), and under the 860px breakpoint it
     becomes position:fixed for the off-canvas panel. If .site-header kept
     the backdrop-filter, that would silently re-anchor the fixed nav to
     the header's own box instead of the viewport, making the header's
     (and therefore body's) scrollable-overflow genuinely 320px wider than
     the viewport — real layout overflow, not just a cosmetic scrollbar,
     which is exactly what let real devices swipe/scroll horizontally into
     blank space with the panel closed. Putting the effect on a ::before
     keeps the identical visual result without .site-header ever
     qualifying as a containing block for fixed descendants. */
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: rgba(255, 255, 255, 0.82);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  backdrop-filter: saturate(180%) blur(14px);
}
.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  min-height: 76px;
}
.brand { display: inline-flex; align-items: center; flex: none; }
.brand img { height: 48px; width: auto; }

.nav {                  /* desktop: inline links + CTA, right aligned */
  display: flex;
  align-items: center;
  gap: clamp(1rem, 2.4vw, 2rem);
}
.nav a:not(.nav__cta) {
  position: relative;
  font-size: 0.96rem;
  font-weight: 500;
  color: var(--ink);
  padding: 0.35rem 0;
}
.nav a:not(.nav__cta)::after {                              /* blue underline that grows from center */
  content: "";
  position: absolute;
  left: 0; bottom: -2px;
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, var(--navy), var(--blue));
  transform: scaleX(0);
  transform-origin: center;
  transition: transform 0.25s ease;
}
.nav a:not(.nav__cta):hover { color: var(--navy); }
.nav a:not(.nav__cta):hover::after,
.nav a:not(.nav__cta).active::after { transform: scaleX(1); }
.nav a:not(.nav__cta).active { color: var(--navy); font-weight: 600; }
.nav__cta { margin-left: 0.5rem; }

.nav-toggle {           /* hamburger, hidden until mobile breakpoint */
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 44px;
  height: 44px;
  padding: 0 10px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.nav-toggle span {
  display: block;
  height: 2px;
  width: 100%;
  background: var(--navy);
  border-radius: 2px;
  transition: transform 0.3s ease, opacity 0.2s ease;
}
.nav-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.nav-overlay {          /* dim scrim behind the mobile panel */
  display: none;
  position: fixed;
  inset: 0;
  background: rgb(23 30 96 / 0.35);
  opacity: 0;
  pointer-events: none;   /* inert while closed, even if still painted */
  transition: opacity 0.3s ease;
  z-index: 90;
}

/* --- Mobile: nav becomes an off-canvas slide-in panel --------------------- */
@media (max-width: 860px) {
  .nav-toggle { display: flex; }
  .nav-overlay { display: block; }
  .nav-overlay.is-open { opacity: 1; pointer-events: auto; }
  .nav {
    position: fixed;
    top: 0; right: 0;
    height: 100dvh;
    width: min(320px, 82vw);
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 0.25rem;
    padding: 6rem 1.75rem 2rem;
    background: var(--bg);
    box-shadow: -20px 0 50px rgb(20 24 107 / 0.14);
    transform: translateX(100%);
    transition: transform 0.34s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 95;
    overflow-y: auto;
  }
  .nav.is-open { transform: translateX(0); }
  .nav a:not(.nav__cta) {
    font-size: 1.08rem;
    padding: 0.85rem 0;
    border-bottom: 1px solid var(--line);
  }
  .nav a:not(.nav__cta)::after { display: none; }
  .nav__cta { margin: 1.25rem 0 0; justify-content: center; }
}

/* --- No-JS fallback: force nav reachable, hide inert toggle --------------- */
.no-js .nav-toggle,
.no-js .nav-overlay { display: none; }
@media (max-width: 860px) {
  .no-js .nav {
    position: static;
    height: auto;
    width: 100%;
    transform: none;
    box-shadow: none;
    padding: 1rem 0 0;
  }
}

/* ==========================================================================
   Footer
   ========================================================================== */
.site-footer {
  background: var(--navy);
  color: rgba(255, 255, 255, 0.72);
  padding-top: clamp(3rem, 6vw, 4.5rem);
}
.site-footer a { color: rgba(255, 255, 255, 0.72); }
.site-footer a:hover { color: #fff; }
.footer-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: clamp(2rem, 5vw, 4rem);
  padding-bottom: 3rem;
}
@media (max-width: 780px) { .footer-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 520px) { .footer-grid { grid-template-columns: 1fr; gap: 2.25rem; } }
.footer-brand img { height: 46px; width: auto; margin-bottom: 1.25rem; }
.footer-blurb { color: rgba(255, 255, 255, 0.66); max-width: 34ch; }
.footer-col h4 {
  color: #fff;
  font-size: 0.82rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  margin-bottom: 1.1rem;
}
.footer-col ul { display: grid; gap: 0.7rem; }
.footer-contact { display: grid; gap: 0.7rem; margin-top: 1.25rem; font-size: 0.96rem; }
.footer-contact div { display: flex; gap: 0.6rem; align-items: baseline; }
.footer-contact .label {
  color: var(--blue-light);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  flex: none;
  width: 3.5rem;
}
.footer-bottom {
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  padding-block: 1.5rem;
  font-size: 0.86rem;
  color: rgba(255, 255, 255, 0.55);
}
.footer-bottom .wrap {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
}

/* ==========================================================================
   Focus & motion
   ========================================================================== */
:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 3px;
  border-radius: 3px;
}
.btn:focus-visible, .nav-toggle:focus-visible { outline-offset: 4px; }

.skip-link {            /* keyboard skip-to-content, visible only on focus */
  position: absolute;
  left: 1rem; top: -3rem;
  z-index: 200;
  padding: 0.6rem 1rem;
  background: var(--navy);
  color: #fff;
  border-radius: 0 0 var(--radius) var(--radius);
  transition: top 0.2s ease;
}
.skip-link:focus { top: 0; color: #fff; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  .js .reveal { opacity: 1; transform: none; }   /* never leave content hidden */
}
