/* ==========================================================================
   St Stephens Engineering Ltd.
   ========================================================================== */

:root {
  --brand:        #b03a28;
  --brand-dark:   #8c2d1e;
  --brand-tint:   #f7eeec;

  --ink:          #14171a;
  --ink-2:        #3d454d;
  --ink-3:        #6b757e;
  --rule:         #e2e5e8;
  --paper:        #ffffff;
  --paper-2:      #f5f6f7;

  --wrap:         1240px;
  --gutter:       clamp(1.25rem, 4vw, 3.5rem);
  --header-h:     78px;

  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;

  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

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

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.65;
  color: var(--ink-2);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 {
  color: var(--ink);
  font-weight: 800;
  line-height: 1.08;
  letter-spacing: -0.022em;
  margin: 0 0 0.5em;
}

h1 { font-size: clamp(2.5rem, 6vw, 4.25rem); }
h2 { font-size: clamp(1.9rem, 3.6vw, 2.9rem); }
h3 { font-size: clamp(1.15rem, 1.8vw, 1.4rem); letter-spacing: -0.012em; }

p { margin: 0 0 1.15em; }
p:last-child { margin-bottom: 0; }

/* --- Layout helpers ------------------------------------------------------ */

.wrap {
  max-width: var(--wrap);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.section { padding-block: clamp(4rem, 9vw, 7.5rem); }
.section--tint { background: var(--paper-2); }
.section--brand { background: var(--brand); color: #fff; }
.section--brand h2, .section--brand h3 { color: #fff; }

.eyebrow {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--brand);
  margin-bottom: 1.1rem;
}
.section--brand .eyebrow { color: rgba(255, 255, 255, 0.75); }

.lede {
  font-size: clamp(1.1rem, 1.6vw, 1.3rem);
  line-height: 1.6;
  color: var(--ink-2);
  max-width: 62ch;
}
.section--brand .lede { color: rgba(255, 255, 255, 0.9); }

.measure { max-width: 68ch; }

/* --- Buttons ------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.6em;
  padding: 0.95em 1.9em;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  border: 2px solid var(--brand);
  background: var(--brand);
  color: #fff;
  cursor: pointer;
  transition: background 0.2s var(--ease), border-color 0.2s var(--ease),
              color 0.2s var(--ease), transform 0.2s var(--ease);
}
.btn:hover {
  background: var(--brand-dark);
  border-color: var(--brand-dark);
  text-decoration: none;
  transform: translateY(-2px);
}
.btn svg { width: 1em; height: 1em; }

.btn--ghost { background: transparent; color: #fff; border-color: rgba(255, 255, 255, 0.6); }
.btn--ghost:hover { background: #fff; color: var(--brand); border-color: #fff; }

.btn--outline { background: transparent; color: var(--brand); }
.btn--outline:hover { background: var(--brand); color: #fff; }

/* Text link with arrow */
.arrow-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  font-weight: 700;
  font-size: 0.95rem;
}
.arrow-link::after {
  content: "→";
  transition: transform 0.2s var(--ease);
}
.arrow-link:hover { text-decoration: none; }
.arrow-link:hover::after { transform: translateX(5px); }

/* --- Header -------------------------------------------------------------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  background: #fff;
  border-bottom: 1px solid var(--rule);
}

.site-header__inner {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
}

.logo { display: flex; align-items: center; flex-shrink: 0; }
.logo:hover { text-decoration: none; }
.logo__mark {
  background: var(--brand);
  color: #fff;
  font-weight: 800;
  font-size: 0.82rem;
  line-height: 1.22;
  letter-spacing: 0.01em;
  text-transform: uppercase;
  padding: 0.62rem 0.85rem;
}

.nav { display: flex; align-items: center; gap: clamp(1.1rem, 2.2vw, 2.1rem); }

.nav a {
  color: var(--ink);
  font-size: 0.94rem;
  font-weight: 600;
  padding-block: 0.4rem;
  position: relative;
}
.nav a::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 2px;
  background: var(--brand);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.22s var(--ease);
}
.nav a:hover { text-decoration: none; }
.nav a:hover::after, .nav a[aria-current="page"]::after { transform: scaleX(1); }

.nav-toggle {
  display: none;
  width: 44px; height: 44px;
  border: 0;
  background: none;
  cursor: pointer;
  padding: 10px;
}
.nav-toggle span {
  display: block;
  height: 2px;
  background: var(--ink);
  margin: 5px 0;
  transition: transform 0.25s var(--ease), opacity 0.2s var(--ease);
}
.nav-open .nav-toggle span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-open .nav-toggle span:nth-child(2) { opacity: 0; }
.nav-open .nav-toggle span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

@media (max-width: 980px) {
  .nav-toggle { display: block; }
  .nav {
    position: fixed;
    inset: var(--header-h) 0 auto 0;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    background: #fff;
    border-bottom: 1px solid var(--rule);
    padding: 0.5rem var(--gutter) 1.5rem;
    transform: translateY(-120%);
    transition: transform 0.3s var(--ease);
  }
  .nav-open .nav { transform: translateY(0); }
  .nav a { padding: 0.9rem 0; border-bottom: 1px solid var(--rule); font-size: 1.05rem; }
  .nav a::after { display: none; }
  .nav .btn { margin-top: 1.25rem; justify-content: center; }
}

/* --- Hero ---------------------------------------------------------------- */

.hero {
  position: relative;
  min-height: min(78vh, 720px);
  display: flex;
  align-items: flex-end;
  background: var(--ink) center / cover no-repeat;
  color: #fff;
  overflow: hidden;
}
.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  /* Darkens only the left column, where the white type sits.
     The sky on the right is left clear. */
  background:
    linear-gradient(90deg,
      rgba(10, 12, 14, 0.82) 0%,
      rgba(10, 12, 14, 0.58) 26%,
      rgba(10, 12, 14, 0.26) 54%,
      transparent 74%),
    linear-gradient(180deg,
      transparent 0%,
      transparent 45%,
      rgba(10, 12, 14, 0.45) 100%);
}
.hero > .wrap { position: relative; z-index: 1; width: 100%; padding-block: clamp(3rem, 7vw, 5.5rem); }
.hero h1 { color: #fff; max-width: 17ch; }
.hero .lede { color: rgba(255, 255, 255, 0.88); margin-top: 1.25rem; max-width: 46ch; }
.hero__actions { display: flex; flex-wrap: wrap; gap: 1rem; margin-top: 2.25rem; }

/* The two extruder renders, set diagonally over the hero photograph.
   The current machine sits in front, overlapping the older one. */
.hero__renders {
  position: absolute;
  top: clamp(1rem, 2.5vw, 2rem);
  right: clamp(1rem, 4vw, 3.5rem);
  z-index: 2;
  width: min(38%, 430px);
  aspect-ratio: 1 / 1;
  pointer-events: none;
}

.hero__render {
  position: absolute;
  height: auto;
  filter: drop-shadow(0 18px 38px rgba(0, 0, 0, 0.5));
}
.hero__render--old { top: 0; right: 0; width: 52%; }
.hero__render--new { bottom: 0; left: 0; width: 56%; z-index: 1; }

/* Below this the hero text needs the full width. */
@media (max-width: 1000px) {
  .hero__renders { display: none; }
}

/* Compact hero for interior pages */
.page-hero {
  background: var(--ink);
  color: #fff;
  padding-block: clamp(3.5rem, 8vw, 6rem);
  position: relative;
  overflow: hidden;
}
.page-hero::before {
  content: "";
  position: absolute;
  top: 0; right: 0;
  width: 42%;
  height: 100%;
  background: var(--brand);
  clip-path: polygon(28% 0, 100% 0, 100% 100%, 0 100%);
  opacity: 0.9;
}
.page-hero > .wrap { position: relative; z-index: 1; }
.page-hero h1 { color: #fff; margin-bottom: 0.35em; }
.page-hero .lede { color: rgba(255, 255, 255, 0.85); }

/* --- Breadcrumb ---------------------------------------------------------- */

.crumb {
  font-size: 0.82rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.6);
  margin-bottom: 1.25rem;
}
.crumb a { color: rgba(255, 255, 255, 0.6); }
.crumb a:hover { color: #fff; }

/* --- Grids --------------------------------------------------------------- */

.grid { display: grid; gap: clamp(1.5rem, 3vw, 2.5rem); }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); }
.grid--3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); }
.grid--4 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); }

.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1.5rem;
  margin-bottom: clamp(2.5rem, 5vw, 3.75rem);
}
.section-head > div { max-width: 60ch; }
.section-head h2 { margin-bottom: 0.35em; }
.section-head p { margin-bottom: 0; }

/* --- Cards --------------------------------------------------------------- */

.card {
  background: #fff;
  border: 1px solid var(--rule);
  padding: clamp(1.75rem, 3vw, 2.5rem);
  display: flex;
  flex-direction: column;
  transition: border-color 0.22s var(--ease), box-shadow 0.22s var(--ease),
              transform 0.22s var(--ease);
}
.card:hover {
  border-color: var(--brand);
  box-shadow: 0 18px 40px -24px rgba(20, 23, 26, 0.4);
  transform: translateY(-4px);
}
.card h3 { margin-bottom: 0.55rem; }
.card p { font-size: 0.97rem; color: var(--ink-3); }
.card .arrow-link { margin-top: auto; padding-top: 1.5rem; }

.card__icon {
  width: 46px; height: 46px;
  display: grid;
  place-items: center;
  background: var(--brand-tint);
  color: var(--brand);
  margin-bottom: 1.5rem;
}
.card__icon svg { width: 24px; height: 24px; }

/* Card with a photograph at the top (parts catalogue) */
.card--photo { padding: 0; overflow: hidden; }
.card__media {
  aspect-ratio: 1 / 1;
  background: var(--paper-2) center / cover no-repeat;
  transition: transform 0.5s var(--ease);
}
.card--photo:hover .card__media { transform: scale(1.04); }
.card__body {
  padding: clamp(1.5rem, 2.6vw, 2rem);
  display: flex;
  flex-direction: column;
  flex: 1;
}
.card__body h3 { margin-bottom: 0.5rem; }
.card__body .ticks { margin-top: auto; padding-top: 1.25rem; }
.card__body .ticks li { font-size: 0.93rem; margin-bottom: 0.55rem; }

.card__num {
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  color: var(--brand);
  margin-bottom: 1rem;
}

/* Image-led card (projects) */
.tile { position: relative; display: block; overflow: hidden; background: var(--ink); }
.tile:hover { text-decoration: none; }
.tile__img {
  aspect-ratio: 4 / 3;
  background: var(--ink-2) center / cover no-repeat;
  transition: transform 0.5s var(--ease), opacity 0.3s var(--ease);
}
.tile:hover .tile__img { transform: scale(1.05); opacity: 0.75; }
.tile__body {
  position: absolute;
  inset: auto 0 0 0;
  padding: clamp(1.25rem, 2.5vw, 1.9rem);
  background: linear-gradient(180deg,
    rgba(10, 12, 14, 0) 0%,
    rgba(10, 12, 14, 0.55) 45%,
    rgba(10, 12, 14, 0.93) 100%);
  padding-top: clamp(3rem, 6vw, 4.5rem);
  color: #fff;
}
.tile__body h3 { color: #fff; margin-bottom: 0.25rem; font-size: 1.2rem; }
.tile__meta {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.85);
}

/* --- Stats --------------------------------------------------------------- */

.stat { border-top: 3px solid var(--brand); padding-top: 1.35rem; }
.section--brand .stat { border-top-color: rgba(255, 255, 255, 0.55); }
.stat__num {
  display: block;
  font-size: clamp(2.4rem, 5vw, 3.4rem);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.03em;
  color: var(--ink);
}
.section--brand .stat__num { color: #fff; }
.stat__label {
  display: block;
  margin-top: 0.6rem;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--ink-3);
}
.section--brand .stat__label { color: rgba(255, 255, 255, 0.8); }

/* --- World map ----------------------------------------------------------- */

.worldmap-wrap { margin-bottom: clamp(2rem, 4vw, 3rem); }

.worldmap {
  display: block;
  width: 100%;
  height: auto;
}
.worldmap__base path { fill: rgba(255, 255, 255, 0.17); }
.worldmap__on path { fill: #fff; }
.worldmap__marker circle {
  fill: #fff;
  stroke: var(--brand);
  stroke-width: 2;
}

.country-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.55rem 1.75rem;
}
.country-list li {
  position: relative;
  padding-left: 1.1rem;
  font-size: 0.94rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.88);
}
.country-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.6em;
  width: 6px;
  height: 6px;
  background: #fff;
}

/* --- Split (text + image) ------------------------------------------------ */

.split {
  display: grid;
  gap: clamp(2rem, 5vw, 4.5rem);
  align-items: center;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr));
}
.split__media {
  aspect-ratio: 4 / 3;
  background: var(--paper-2) center / cover no-repeat;
  border-bottom: 5px solid var(--brand);
}
.split--top { align-items: start; }
.split--flip .split__media { order: -1; }
@media (max-width: 820px) {
  .split--flip .split__media { order: 0; }
}

/* --- Simple list --------------------------------------------------------- */

.ticks { list-style: none; margin: 1.5rem 0 0; padding: 0; }
.ticks li {
  position: relative;
  padding-left: 1.9rem;
  margin-bottom: 0.85rem;
  color: var(--ink-2);
}
.ticks li::before {
  content: "";
  position: absolute;
  left: 0; top: 0.62em;
  width: 10px; height: 10px;
  background: var(--brand);
}

/* --- CTA band ------------------------------------------------------------ */

.cta {
  background: var(--brand);
  color: #fff;
  padding-block: clamp(3.5rem, 7vw, 5.5rem);
}
.cta__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
}
.cta h2 { color: #fff; margin-bottom: 0.3em; max-width: 20ch; }
.cta p { color: rgba(255, 255, 255, 0.88); margin: 0; max-width: 48ch; }

/* --- Contact / forms ----------------------------------------------------- */

.field { display: flex; flex-direction: column; margin-bottom: 1.4rem; }
.field label {
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink);
  margin-bottom: 0.5rem;
}
.field input,
.field select,
.field textarea {
  font: inherit;
  font-size: 1rem;
  color: var(--ink);
  padding: 0.85rem 1rem;
  border: 1px solid var(--rule);
  background: #fff;
  border-radius: 0;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(176, 58, 40, 0.15);
}
.field textarea { min-height: 160px; resize: vertical; }
.field--row { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); gap: 0 1.4rem; }

.contact-detail { margin-bottom: 2rem; }
.contact-detail h3 { font-size: 0.85rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--brand); margin-bottom: 0.4rem; }
.contact-detail p { margin: 0; color: var(--ink); font-size: 1.05rem; }

/* --- Footer -------------------------------------------------------------- */

.site-footer {
  background: var(--ink);
  color: rgba(255, 255, 255, 0.65);
  padding-block: clamp(3rem, 6vw, 4.5rem) 2rem;
  font-size: 0.94rem;
}
.site-footer h4 {
  color: #fff;
  font-size: 0.8rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-bottom: 1.1rem;
}
.site-footer a { color: rgba(255, 255, 255, 0.65); }
.site-footer a:hover { color: #fff; text-decoration: none; }
.site-footer ul { list-style: none; margin: 0; padding: 0; }
.site-footer li { margin-bottom: 0.6rem; }

.footer-grid {
  display: grid;
  gap: 2.5rem;
  grid-template-columns: 1fr;
}
@media (min-width: 640px) {
  .footer-grid { grid-template-columns: repeat(3, 1fr); }
  .footer-grid > :first-child { grid-column: 1 / -1; }
}
@media (min-width: 960px) {
  .footer-grid { grid-template-columns: 1.6fr repeat(3, 1fr); }
  .footer-grid > :first-child { grid-column: auto; }
}

.footer-bottom {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: space-between;
  margin-top: clamp(2.5rem, 5vw, 4rem);
  padding-top: 1.75rem;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.45);
}

/* --- Reveal on scroll ---------------------------------------------------- */

.reveal {
  opacity: 0;
  transform: translateY(22px);
  transition: opacity 0.6s var(--ease), transform 0.6s var(--ease);
}
.reveal.is-visible { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
  .reveal { opacity: 1; transform: none; }
}

/* --- Utilities ----------------------------------------------------------- */

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--brand);
  color: #fff;
  padding: 0.75rem 1.25rem;
  z-index: 200;
}
.skip-link:focus { left: 0; }

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