/* =========================================================
   Malachi Chadwick – malachi.digital
   Static rebuild. Brand-faithful palette + Newsreader/Inter.
   ========================================================= */

/* ---------- Fonts (self-hosted) ----------
   Variable woff2 files, latin + latin-ext subsets, from Google Fonts.
   Self-hosted so visitors' browsers don't contact Google (GDPR) and the page
   needs no third-party connection. Licences: assets/fonts/*-OFL.txt.
   The browser only downloads a subset file if the page uses a character in
   its unicode-range, so latin-ext normally never loads. */
@font-face {
  font-family: "Newsreader"; font-style: normal; font-weight: 200 800; font-display: swap;
  src: url("/assets/fonts/newsreader-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Newsreader"; font-style: normal; font-weight: 200 800; font-display: swap;
  src: url("/assets/fonts/newsreader-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Inter"; font-style: normal; font-weight: 400 600; font-display: swap;
  src: url("/assets/fonts/inter-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Inter"; font-style: normal; font-weight: 400 600; font-display: swap;
  src: url("/assets/fonts/inter-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* Metric-matched fallback: while Newsreader downloads, Georgia is shown
   scaled to Newsreader's width (measured on the hero copy), so text doesn't
   re-wrap and shift the layout when the real font swaps in (CLS). */
@font-face {
  font-family: "Newsreader Fallback"; font-weight: 100 550;
  src: local("Georgia"); size-adjust: 97.2%;
}
@font-face {
  font-family: "Newsreader Fallback"; font-weight: 551 900;
  src: local("Georgia Bold"), local("Georgia-Bold"); size-adjust: 96.7%;
}

:root {
  /* Palette (sampled from the original site) */
  --amber:      #FCC013;
  --amber-deep: #E8A800;   /* decorative only – fails text contrast on paper */
  --gold-ink:   #8A6300;   /* WCAG-AA gold for text on paper (4.85:1) */
  --ink:        #211F1C;   /* warm near-black for text */
  --char:       #34322F;   /* dark services section */
  --char-soft:  #45423D;   /* card surface on dark */
  --paper:      #F4F2EC;   /* warm off-white */
  --cream:      #FBFAF5;
  --line:       rgba(33, 31, 28, .14);

  /* Type */
  --display: "Newsreader", "Newsreader Fallback", Georgia, "Times New Roman", serif;
  --body:    "Inter", "Helvetica Neue", Arial, sans-serif;
  /* Measured width (in em) of the hero's longest lines in the display font,
     plus ~3% breathing room. Used to cap the hero sizes so the lines never
     wrap. Re-measure if the display font or the hero copy changes. */
  --name-ems:  8.87;   /* "Malachi Chadwick" */
  --intro-ems: 17.08;  /* "Digital experiences that power progress." (desktop, one line) */
  --intro-ems-mobile: 8.71; /* "that power progress." (longer than "Digital experiences") */

  /* Spacing / layout */
  /* Wide layout so the hero type can fill the screen like the original.
     Text line length is capped separately (in ch), not by this. */
  --wrap: 1600px;
  --gutter: clamp(1.25rem, 3vw, 4rem);
  --section-y: clamp(4.5rem, 10vw, 9rem);

  --ease: cubic-bezier(.22, 1, .36, 1);
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 92px; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  font-family: var(--body);
  color: var(--ink);
  background: var(--paper);
  line-height: 1.6;
  letter-spacing: .01em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img { display: block; max-width: 100%; height: auto; }
a { color: inherit; }

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

/* Display type defaults */
h1, h2, h3 {
  font-family: var(--display);
  font-weight: 460;
  line-height: 1.04;
  letter-spacing: -.015em;
  font-variation-settings: "opsz" 72;
}

.skip-link {
  position: absolute; left: -9999px; top: 0;
  background: var(--ink); color: var(--paper);
  padding: .7rem 1.1rem; border-radius: 0 0 8px 0; z-index: 200;
}
.skip-link:focus { left: 0; }

/* ---------- Buttons ---------- */
.btn {
  --btn-bg: var(--ink); --btn-fg: var(--paper);
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--body); font-weight: 500; font-size: 1rem;
  letter-spacing: .01em; text-decoration: none;
  background: var(--btn-bg); color: var(--btn-fg);
  padding: .85rem 1.6rem; border-radius: 100px; border: 2px solid var(--btn-bg);
  transition: transform .25s var(--ease), background .25s var(--ease), color .25s var(--ease), box-shadow .25s var(--ease);
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 10px 24px -10px rgba(0,0,0,.4); }
.btn:active { transform: translateY(0); }
.btn--dark { --btn-bg: var(--ink); --btn-fg: var(--amber); }
.btn--small { padding: .55rem 1.1rem; font-size: .95rem; }

:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; border-radius: 4px; }

/* ---------- Hand-drawn underline ---------- */
.ul-wrap { position: relative; white-space: nowrap; }
.ul {
  position: absolute; left: 0; bottom: -.28em; width: 100%; height: .42em;
  overflow: visible; color: var(--paper);
}
.ul--accent { color: var(--amber); bottom: -.12em; }
.ul path {
  stroke-dasharray: 460; stroke-dashoffset: 460;
  animation: draw 1s var(--ease) .55s forwards;
}
@keyframes draw { to { stroke-dashoffset: 0; } }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 100;
  background: var(--amber);
  transition: background .3s var(--ease), box-shadow .3s var(--ease);
}
.site-header[data-scrolled] { box-shadow: 0 1px 0 rgba(33,31,28,.12); }
.site-header__inner { display: flex; align-items: center; justify-content: space-between; min-height: 78px; }

.brand { text-decoration: none; }
.brand__mark { font-family: var(--display); font-weight: 800; font-size: 1.9rem; line-height: 1; letter-spacing: -.03em; }
.brand__dot { color: var(--ink); }

.nav { display: flex; align-items: center; }
.nav__menu {
  list-style: none; padding: 0; display: flex; align-items: center; gap: 2rem;
}
.nav__menu a { text-decoration: none; font-weight: 500; font-size: 1.02rem; position: relative; }
.nav__menu a::after {
  content: ""; position: absolute; left: 0; bottom: -4px; width: 100%; height: 2px;
  background: var(--ink); transform: scaleX(0); transform-origin: left; transition: transform .3s var(--ease);
}
.nav__menu a:hover::after { transform: scaleX(1); }
.nav__cta { margin-left: 2rem; }

.nav__toggle {
  display: none; flex-direction: column; gap: 6px; justify-content: center; align-items: center;
  width: 46px; height: 46px; padding: 0; background: none; border: 0; cursor: pointer;
  position: relative; z-index: 120; /* must stack above the fixed drawer */
}
.nav__bar { display: block; width: 26px; height: 2.5px; background: var(--ink); border-radius: 2px; transition: transform .3s var(--ease), background .3s var(--ease), opacity .2s; }

/* Backdrop behind the mobile drawer */
.nav__scrim {
  position: fixed; inset: 0; border: 0; padding: 0; cursor: pointer;
  background: rgba(20, 18, 16, .55);
  opacity: 0; visibility: hidden; z-index: 105;
  transition: opacity .35s var(--ease), visibility .35s var(--ease);
}

/* ---------- Hero ---------- */
.hero { background: var(--amber); color: var(--ink); padding-block: clamp(3rem, 7vw, 6rem) clamp(2rem, 4.5vw, 4rem); }
/* Container query units (cqi = 1% of .hero__inner's content width) let the
   hero type be capped to the space it actually has, not the viewport. */
.hero__inner { container-type: inline-size; }
/* Headline: one line on desktop, two on mobile/tablet. Each size is
   capped so the line(s) always fit. */
.hero__headline {
  font-weight: 320;
  /* Mobile/tablet: "Digital experiences / that power progress." */
  font-size: min(clamp(2.6rem, 7.2vw, 6.4rem), 100cqi / var(--intro-ems-mobile));
}
@media (min-width: 1001px) {
  /* Desktop: the whole headline on one line, spanning ~80% of the column
     so the full-width name below has more impact */
  .hero__headline { font-size: min(7.2vw, 80cqi / var(--intro-ems)); text-align: center; }
  /* Centre the name too: it stops ~3% short of full width (the fit buffer),
     so left-aligned it would leave the centred intro looking off-centre */
  .hero__name { text-align: center; }
  .hero__break { display: none; } /* mobile-only line break */
}
.hero__name {
  font-family: var(--display);
  font-weight: 700; /* always well above the headline's 320 – needs a font with a real heavy weight */
  font-variation-settings: "opsz" 72;
  /* Always one line: the design size, capped to whatever fits */
  font-size: min(10.5vw, 100cqi / var(--name-ems));
  white-space: nowrap;
  line-height: .9; letter-spacing: -.035em;
  word-spacing: .08em; /* tight tracking otherwise closes up the word gap */
  margin-top: clamp(3.5rem, 9vw, 8rem); /* clear the headline underline */
}

/* ---------- About ---------- */
.about { background: var(--paper); padding-block: var(--section-y); }
.about__inner { display: grid; grid-template-columns: 1.1fr .9fr; gap: clamp(2rem, 6vw, 5rem); align-items: center; }
.eyebrow {
  text-transform: uppercase; letter-spacing: .22em; font-size: .8rem; font-weight: 600;
  color: var(--gold-ink); margin-bottom: 1.4rem;
}
.about__heading { font-size: clamp(2.2rem, 5vw, 3.6rem); margin-bottom: 1.6rem; }
.about__heading .ul-wrap { font-weight: 700; } /* "Malachi" – same weight as the hero name */
/* Footnote-style asterisk: tucked against the name, up near cap height */
.about__heading .star { color: var(--gold-ink); margin-left: .06em; }
.about__body p { max-width: 46ch; margin-bottom: 1.1rem; color: #322f2b; }
.pronounce { font-family: var(--body); font-weight: 600; font-size: .9rem; letter-spacing: .04em; color: #6b665e; margin-top: .4rem; }
.about__media img {
  width: 100%; border-radius: 14px; aspect-ratio: 4 / 5; object-fit: cover;
  box-shadow: 0 30px 60px -30px rgba(33,31,28,.45);
}
@media (min-width: 881px) {
  /* Side by side: pull the section up so the headline and the photo's eyes
     land above the fold on common laptop screens (like the original) */
  .about { padding-top: clamp(3rem, 6vw, 5.5rem); }
  .about__inner { align-items: start; }
  /* Square crop, framed with the face high so the eyes appear early */
  .about__media img { aspect-ratio: 1 / 1; object-position: 50% 62%; }
}

/* ---------- Services ---------- */
.services { background: var(--char); color: var(--paper); padding-block: var(--section-y); }
.services__heading { font-size: clamp(2.6rem, 8vw, 6rem); margin-bottom: .6rem; }
.services__hint {
  color: rgba(244, 242, 236, .6); font-size: .9rem; letter-spacing: .04em;
  margin-bottom: clamp(2rem, 4vw, 3.2rem);
}
html:not(.js) .services__hint { display: none; } /* nothing to tap without JS */
.services__grid {
  list-style: none; padding: 0;
  display: grid; grid-template-columns: repeat(3, 1fr); /* 8 services + booking card = 3×3 */
  gap: 1px; background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.12); border-radius: 16px; overflow: hidden;
}
.card { background: var(--char); transition: background .35s var(--ease); }
.card:hover { background: var(--char-soft); }
.card.is-open { background: var(--char-soft); }
html.js .card { cursor: pointer; } /* whole card toggles (see main.js) */
.card__title { margin: 0; font-weight: inherit; }
/* Card title row – shared by the service toggles and the booking card */
.card__toggle, .card__cta-title {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem;
  font-family: var(--display); font-size: 1.5rem; font-weight: 500;
  line-height: 1.12; letter-spacing: -.01em;
  font-variation-settings: "opsz" 40;
  padding: clamp(1.6rem, 2.4vw, 2.4rem) clamp(1.8rem, 2.6vw, 2.6rem) 0;
}
.card__toggle {
  width: 100%; background: none; border: 0; cursor: pointer; text-align: left; color: var(--amber);
}
/* One title line tall (matches .card__toggle line-height), so the centred
   cross sits level with the first line of the title in any font */
.card__icon { position: relative; flex: none; width: 22px; height: 1.12em; }
.card__icon::before, .card__icon::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: 15px; height: 2px;
  background: currentColor; transform: translate(-50%, -50%);
  transition: transform .3s var(--ease), opacity .3s var(--ease);
}
.card__icon::after { transform: translate(-50%, -50%) rotate(90deg); }
.card.is-open .card__icon::after { opacity: 0; transform: translate(-50%, -50%) rotate(0); }
.card__summary {
  margin: 0; color: rgba(244, 242, 236, .8); font-size: .98rem; line-height: 1.45;
  padding: .65rem clamp(1.8rem, 2.6vw, 2.6rem) clamp(1.6rem, 2.4vw, 2.4rem);
}
.card__detail-wrap { display: grid; grid-template-rows: 1fr; }
.card__detail { overflow: hidden; }
.card__detail-inner { padding: 0 clamp(1.8rem, 2.6vw, 2.6rem) clamp(1.7rem, 2.4vw, 2.5rem); }
.card__detail p { color: rgba(244, 242, 236, .82); font-size: .96rem; margin-bottom: .8rem; }
.card__detail p:last-child { margin-bottom: 0; }

/* Booking card in the grid's last cell: mirrors a service card's layout
   (title + icon, summary) but the whole card is one link, in amber */
.card--cta, .card--cta:hover { background: var(--amber); }
.card__cta-link { display: block; height: 100%; text-decoration: none; color: var(--ink); }
.card__cta-arrow { flex: none; transition: transform .3s var(--ease); }
.card__cta-link:hover .card__cta-arrow,
.card__cta-link:focus-visible .card__cta-arrow { transform: translateX(4px); }
.card--cta .card__summary { display: block; color: rgba(33, 31, 28, .82); }
/* Progressive enhancement: only collapse when JS is active (no-JS shows everything) */
html.js .card__detail-wrap { grid-template-rows: 0fr; transition: grid-template-rows .38s var(--ease); }
html.js .card.is-open .card__detail-wrap { grid-template-rows: 1fr; }
/* visibility removes collapsed text from the accessibility tree (matching
   aria-expanded="false"); the delay keeps it visible while it animates shut */
html.js .card__detail { visibility: hidden; transition: visibility 0s .38s; }
html.js .card.is-open .card__detail { visibility: visible; transition-delay: 0s; }

/* ---------- Clients ---------- */
.clients { background: var(--paper); padding-block: var(--section-y); }
.clients__label {
  font-family: var(--display); font-size: clamp(1.5rem, 3vw, 2.2rem);
  margin-bottom: clamp(1.6rem, 3vw, 2.6rem); color: var(--ink);
  font-variation-settings: "opsz" 40;
}
.clients__grid {
  list-style: none; padding: 0; margin: 0;
  display: flex; flex-wrap: wrap; gap: 1.4rem; justify-content: center;
}
.client { flex: 1 1 160px; max-width: 220px; display: flex; flex-direction: column; gap: .8rem; }
.client img {
  width: 100%; aspect-ratio: 1 / 1; object-fit: cover; border-radius: 12px;
  filter: saturate(.96); transition: transform .4s var(--ease);
}
.client:hover img { transform: scale(1.03); }
.client__name { font-family: var(--display); font-weight: 500; font-size: 1.05rem; }

/* ---------- Contact ---------- */
.contact { background: var(--amber); color: var(--ink); padding-block: clamp(4rem, 8vw, 6.5rem); }
.contact__inner { text-align: center; display: flex; flex-direction: column; align-items: center; }
.contact__heading { font-size: clamp(3rem, 9vw, 7rem); }
.contact__lead { max-width: 36ch; margin: 1.4rem auto 2.4rem; font-size: 1.15rem; }
.contact__actions { display: flex; flex-wrap: wrap; gap: 1.2rem 2rem; align-items: center; justify-content: center; }
.contact__email { font-weight: 500; text-decoration: none; border-bottom: 2px solid rgba(33,31,28,.4); padding-bottom: 2px; transition: border-color .25s; }
.contact__email:hover { border-color: var(--ink); }

/* ---------- Footer ---------- */
.site-footer { background: var(--ink); color: var(--paper); padding-block: 2.5rem; }
.site-footer__inner { display: flex; align-items: center; justify-content: space-between; gap: 1.2rem; flex-wrap: wrap; }
.site-footer .brand__mark { color: var(--paper); }
.site-footer .brand__dot { color: var(--amber); }
.site-footer__copy { font-size: .9rem; color: rgba(244,242,236,.7); margin-left: auto; } /* right-aligned, even if it wraps */

/* ---------- Reveal-on-load / scroll ---------- */
/* Only hide when JS is running (html.js is set by an inline script in <head>),
   so the page is never left invisible if main.js fails or JS is off */
html.js .reveal { opacity: 0; transform: translateY(22px); }
html.js .reveal.is-in {
  opacity: 1; transform: none;
  transition: opacity .7s var(--ease), transform .7s var(--ease);
  transition-delay: var(--d, 0s);
}
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1 !important; transform: none !important; }
  .ul path { animation: none; stroke-dashoffset: 0; }
  html.js .card__detail-wrap { transition: none; }
}

/* ---------- Responsive ---------- */
@media (max-width: 1000px) {
  .services__grid { grid-template-columns: repeat(2, 1fr); }
  .card--cta { grid-column: 1 / -1; } /* 9th item: full width, no empty cell */
}

@media (max-width: 880px) {
  .about__inner { grid-template-columns: 1fr; }
  /* Stacked: shrink the portrait to a round profile pic above the intro */
  .about__media {
    order: -1; width: clamp(120px, 28vw, 168px);
    border-radius: 50%; overflow: hidden; /* circle mask, so the img can zoom inside it */
    box-shadow: 0 14px 30px -16px rgba(33,31,28,.45);
  }
  .about__media img {
    aspect-ratio: 1 / 1; border-radius: 0; box-shadow: none;
    object-position: 50% 22%;
    /* Zoom in on the face, then nudge it to the centre of the circle
       (translate is applied after the scale, in circle-relative %) */
    transform: translate(-4%, 7%) scale(1.9); transform-origin: 51% 40%;
  }
}

@media (max-width: 720px) {
  /* Mobile nav */
  .nav__toggle { display: flex; }
  .nav__cta { order: -1; margin: 0 .6rem 0 0; } /* sits left of the hamburger */
  .nav__menu {
    position: fixed; inset: 0 0 0 auto; width: min(82vw, 340px);
    flex-direction: column; align-items: flex-start; gap: 1.6rem;
    background: var(--char); color: var(--paper);
    padding: 6rem var(--gutter) 2rem; z-index: 110;
    transform: translateX(100%);
    /* hidden when closed so its links aren't tabbable or read out off-screen;
       visibility flips after the slide-out finishes */
    visibility: hidden; transition: transform .4s var(--ease), visibility 0s .4s;
  }
  .nav__menu a { font-size: 1.5rem; font-family: var(--display); color: var(--paper); }
  .nav__menu a::after { background: var(--amber); }
  /* Shadow only when open – otherwise it spills onto the page from off-screen */
  [data-nav-open] .nav__menu {
    transform: translateX(0); visibility: visible; transition-delay: 0s;
    box-shadow: -20px 0 60px -30px rgba(0,0,0,.6);
  }
  [data-nav-open] .nav__scrim { opacity: 1; visibility: visible; }
  /* Hamburger → X, recoloured for the charcoal drawer */
  [data-nav-open] .nav__bar { background: var(--paper); }
  [data-nav-open] .nav__bar:first-child { transform: translateY(4.25px) rotate(45deg); }
  [data-nav-open] .nav__bar:last-child { transform: translateY(-4.25px) rotate(-45deg); }
  body[data-nav-open] { overflow: hidden; }
}

@media (max-width: 560px) {
  .services__grid { grid-template-columns: 1fr; }
}
