:root {
    --color-ink: #1C1C1A;
    --color-paper: #FDFDFD;
    --color-stone: #6B6B64;
    --color-paperdark: #EFEFEA;
    --color-blue: #2D7DD2;
    --color-platinum: #E8E9ED;
    --color-silver: #C5C5C5;
    --color-navy: #011627;
    --color-dark-navy: #020e18;
    --color-orange: #EB4511;
}

/* Headlines: Tailwind's font-display sets the family (Space Grotesk); this adds its default
   weight and slightly tighter tracking. A weight class on the element (font-semibold etc.)
   still wins, since tailwind.css loads later. */
.font-display {
    font-weight: 500;
    letter-spacing: -0.02em;
}

/* "Skip to content": the first thing in every page, off-screen until it gets keyboard focus */
.skip-link {
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 60;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    background-color: var(--color-navy);
    color: var(--color-paper);
    font-size: 0.875rem;
    transform: translateY(-200%);
}

.skip-link:focus {
    transform: none;
}

/* Index typewriter: with reduced motion the first phrase stays put (script.js), so drop the
   blinking cursor too (`html` so it outranks the cursor's Tailwind inline-block) */
@media (prefers-reduced-motion: reduce) {
    html .typewriter-cursor {
        display: none;
    }
}

/* Site nav: only the logo is visible by default, fixed top-centre. The logo is
   white and blends with `difference`, so it always renders as the inverse of
   whatever is behind it. That only works while nothing between it and <body>
   creates a stacking context (transform, filter, opacity, isolation, z-index),
   which is also why the panel is a sibling of the logo rather than a wrapper. */
.site-logo {
    position: fixed;
    top: 1rem;
    left: 50%;
    z-index: 50;
    transform: translateX(-50%);
    padding: 0.75rem;
    mix-blend-mode: difference;
}

/* Logo -> wordmark: the image is the whole wordmark (icon on the left), and this
   box clips it to the icon's width. Opening the nav widens the box to reveal
   the name. --logo-size is the icon's width; the ratios come from the image
   (614x128, icon 137px wide). overflow: hidden doesn't create a stacking
   context, so the logo's blend mode still works. */
.site-logo-mark {
    --logo-size: 2rem;
    display: block;
    width: var(--logo-size);
    overflow: hidden;
    transition: width 0.25s ease;
}

.site-logo-mark img {
    /* Override Tailwind preflight's max-width: 100%, which would shrink it into the clip */
    max-width: none;
    height: calc(var(--logo-size) * 128 / 137);
    width: auto;
}

@media (min-width: 768px) {
    .site-logo-mark {
        --logo-size: 2.5rem;
    }
}

/* Expanded whenever the panel is open (same triggers as the .site-nav rules
   below). :has() lets the logo react to its later sibling. */
.site-logo:focus-visible .site-logo-mark,
.site-logo:has(~ .site-nav:focus-within) .site-logo-mark,
.site-logo:has(~ .site-nav.is-open) .site-logo-mark {
    width: calc(var(--logo-size) * 614 / 137);
    transition-duration: 0.35s;
}

@media (hover: hover) {
    .site-logo:hover .site-logo-mark,
    .site-logo:has(~ .site-nav:hover) .site-logo-mark {
        width: calc(var(--logo-size) * 614 / 137);
        transition-duration: 0.35s;
    }
}

@media (prefers-reduced-motion: reduce) {
    .site-logo-mark {
        transition: none !important;
    }
}

.site-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 40;
    /* Top padding clears the logo, so the links sit centred just below it */
    padding: 6.5rem 1.5rem 2rem;
    background-color: var(--color-dark-navy);
    transform: translateY(-100%);
    visibility: hidden;
    /* Closing waits briefly, so a slightly slow move off the logo doesn't drop it */
    transition: transform 0.1s ease, visibility 0s linear 0.5s;
}

/* Mobile (below Tailwind's md): logo sits top-right, and the panel is a
   full-height drawer that slides in from the right. It only goes full width on
   very narrow screens. Right padding lines the links up with the logo's right
   edge (1rem offset + 0.75rem padding). */
@media (max-width: 767px) {
    .site-logo {
        left: auto;
        right: 1rem;
        transform: none;
    }

    .site-nav {
        bottom: 0;
        left: auto;
        width: max(min(75vw, 18rem), min(100vw, 14rem));
        padding: 5.5rem 1.75rem 2rem;
        text-align: right;
        transform: translateX(100%);
    }

    /* Dims the rest of the page while open: a huge shadow spread instead of a
       separate backdrop element (script.js catches taps on the dimmed area) */
    .site-nav.is-open {
        box-shadow: 0 0 0 100vmax rgb(0 0 0 / 0.5);
    }
}

/* The panel covers the logo's area when open, so the pointer moves from logo
   to panel without a gap and :hover carries over. Hover is gated to real
   hover devices so a tap doesn't leave it stuck open; touch uses .is-open. */
@media (hover: hover) {
    .site-logo:hover ~ .site-nav,
    .site-nav:hover {
        transform: none;
        visibility: visible;
        transition: transform 0.35s ease, visibility 0s;
    }
}

.site-logo:focus-visible ~ .site-nav,
.site-nav:focus-within,
.site-nav.is-open {
    transform: none;
    visibility: visible;
    transition: transform 0.35s ease, visibility 0s;
}

@media (prefers-reduced-motion: reduce) {
    .site-nav,
    .site-nav.is-open,
    .site-nav:focus-within,
    .site-logo:focus-visible ~ .site-nav {
        transition: visibility 0s;
    }

    @media (hover: hover) {
        .site-logo:hover ~ .site-nav,
        .site-nav:hover {
            transition: visibility 0s;
        }
    }
}

/* Footer and nav links. The hover fade and the nav's sliding underline are
   desktop-only (md+); on mobile the colour just switches. */
.footer-link {
    color: var(--color-stone);
}

.nav-link {
    position: relative;
    color: var(--color-silver);
}

.nav-link-selected {
    position: relative;
    color: var(--color-platinum);
}

.footer-link:hover,
.nav-link:hover {
    color: var(--color-platinum);
}

.nav-link:after,
.nav-link-selected:after {
    content: "";
    position: absolute;
    left: 0;
    bottom: -8px;
    height: 2px;
    background-color: var(--color-blue);
}

.nav-link:after {
    width: 0;
    transition: width 0.2s;
}

.nav-link-selected:after {
    width: 100%;
    opacity: 0.4;
}

@media (min-width: 768px) {
    .footer-link:hover,
    .nav-link:hover {
        transition: color 0.2s ease;
    }

    .nav-link:hover:after {
        width: 100%;
    }
}

/* Buttons: every CTA uses .btn (plus .btn-sm for the compact header/drawer button).
   Colours come from the --btn-* variables, so a variant only overrides those.
   Base rules use `html body :where(.btn)`: two element selectors (0,0,2) beat
   Tailwind's preflight reset (`* { border-width: 0 }`, `a { color: inherit }`)
   whatever order the stylesheets load in, but any single Tailwind utility on the
   element (width, margins, padding, hidden md:flex...) still wins. */
.btn {
    --btn-color: var(--color-platinum);
    --btn-bg: var(--color-blue);
    --btn-border: transparent;
    --btn-fill: var(--color-platinum);
    --btn-hover-color: var(--color-blue);
}

html body :where(.btn) {
    position: relative;
    isolation: isolate;
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    gap: 3rem;
    padding: 1rem 1.5rem;
    border: 2px solid var(--btn-border);
    border-radius: 3rem;
    /* Crops the ::before fill to the rounded corners (see below) */
    overflow: hidden;
    background-color: var(--btn-bg);
    color: var(--btn-color);
    font-family: "Poppins", sans-serif;
    font-size: 1rem;
    line-height: 1.5rem;
    text-align: left;
    transition: color 0.3s ease;
}

/* Fill slides in from the left on hover, then exits to the right on hover-out. It's a plain
   rectangle cropped by the button's overflow: hidden, so the corners keep their exact curve
   throughout; a rounded fill would get its corners squashed by the scaleX mid-animation. */
html body :where(.btn)::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background-color: var(--btn-fill);
    transform: scaleX(0);
    transform-origin: right;
    transition: transform 0.3s ease;
}

html body :where(.btn:focus-visible) {
    color: var(--btn-hover-color);
}

html body :where(.btn:focus-visible)::before {
    transform: scaleX(1);
    transform-origin: left;
}

/* Hover gated to real hover devices, so a tap doesn't leave the fill stuck on */
@media (hover: hover) {
    html body :where(.btn:hover) {
        color: var(--btn-hover-color);
        transition: color 0.1s ease;
    }

    html body :where(.btn:hover)::before {
        transform: scaleX(1);
        transform-origin: left;
    }
}

/* Compact button (the header's "Book a call"): no arrow, smaller type and padding. One class
   more specific than the base rules, so it also beats their md/lg size steps. */
html body .btn-sm {
    gap: 0;
    padding: 0.5rem 1.25rem;
    font-size: 0.875rem;
    line-height: 1.25rem;
}

/* Header booking button: fixed top-right, vertically centred on the logo (logo centre is
   1rem offset + 0.75rem padding + half its 2.34rem height, at md+; minus half the button's 2.5rem). Above the nav panel
   (z-40), so it stays put and readable when the panel drops down behind it. It's a sibling
   of .site-logo, so its z-index can't affect the logo's blend mode. */
.site-cta {
    position: fixed;
    top: calc(2.92rem - 1.25rem);
    right: 2rem;
    z-index: 50;
}

/* The trailing arrow SVG inside a .btn */
:where(.btn-arrow) {
    flex-shrink: 0;
    width: 2rem;
    height: 0.75rem;
}

@media (min-width: 768px) {
    html body :where(.btn) {
        padding: 1rem 2rem;
        font-size: 1.2rem;
        line-height: 2rem;
    }

    :where(.btn-arrow) {
        width: 3rem;
        height: 1rem;
    }
}

@media (min-width: 1024px) {
    html body :where(.btn) {
        font-size: 1.5rem;
    }
}

/* Index hero: fills the first screen on md+. Phones get a hero as tall as its content,
   because anything tied to the viewport height jumps as the browser toolbars show/hide. */
@media (min-width: 768px) {
    .hero-full {
        min-height: 100vh;
        min-height: 100svh;
    }
}

/* Index $36 donut: 36/37 of the ring is the return; the remaining sliver is the $1 invested */
.return-donut {
    background: conic-gradient(var(--color-blue) 350.27deg, var(--color-platinum) 0);
}

/* Bar charts: --target (inline style) is the fill width */
.share-bar-fill {
    width: var(--target);
}

/* Waffle charts (index "2% of sends / 37% of sales"): a 10x10 grid drawn in CSS instead of 100
   spans. The mask cuts the element into rounded squares (each tile is a 0.8 square plus a 0.2 gap,
   and 10 tiles span 9.8 squares' worth so the last gap falls outside). Behind it: platinum, then
   --rows full rows of blue, then --rem blue squares on the next row (inline style, e.g.
   `--rows: 3; --rem: 7` for 37). The element is square, so % works for both axes. */
.waffle {
    --tile: calc(100% / 9.8);
    aspect-ratio: 1;
    background:
        linear-gradient(to bottom, transparent calc(var(--rows) * var(--tile)), var(--color-blue) 0 calc((var(--rows) + 1) * var(--tile)), transparent 0) 0 0 / calc(var(--rem) * var(--tile)) 100% no-repeat,
        linear-gradient(to bottom, var(--color-blue) calc(var(--rows) * var(--tile)), transparent 0),
        var(--color-platinum);
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10'%3E%3Crect width='8' height='8' rx='1.4'/%3E%3C/svg%3E") 0 0 / var(--tile) var(--tile);
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10'%3E%3Crect width='8' height='8' rx='1.4'/%3E%3C/svg%3E") 0 0 / var(--tile) var(--tile);
}

/* Navy CTA card: soft blue glows in two corners. Gradients rather than blurred spans,
   because iOS Safari clips a blurred child to the card before blurring. Only
   background-image, so bg-navy still sets the colour underneath. */
.cta-glow {
    background-image:
        radial-gradient(14rem circle at 3rem 3rem, rgb(45 125 210 / 0.4) 25%, transparent),
        radial-gradient(14rem circle at calc(100% - 3rem) calc(100% - 3rem), rgb(45 125 210 / 0.2) 25%, transparent);
}

/* Process steps (index): each card shows only its number and title. The header is a disclosure
   <button> whose ::after stretches over the whole card, so a click/tap anywhere toggles .is-open
   (script.js, which also sets aria-expanded); with a mouse, hovering opens it too.
   Animating grid-template-rows 0fr -> 1fr works in every browser, unlike height: auto.
   The closed description is visibility: hidden (after the slide), so screen readers skip it too. */
.process-step-button::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
}

.process-step-button:focus-visible {
    outline: none;
}

.process-step:has(.process-step-button:focus-visible) {
    outline: 2px solid var(--color-blue);
    outline-offset: 2px;
}

.process-step-detail {
    display: grid;
    grid-template-rows: 0fr;
}

.process-step-detail > div {
    overflow: hidden;
    visibility: hidden;
}

/* The open card turns navy with paper text and its number badge flips to silver with navy
   text (these selectors outrank the Tailwind bg-platinum / bg-navy / text-stone / border-silver
   classes on the card and its badge) */
.process-step.is-open .process-step-detail {
    grid-template-rows: 1fr;
}

.process-step.is-open .process-step-detail > div {
    visibility: visible;
}

.process-step.is-open {
    background-color: var(--color-navy);
    color: var(--color-paper);
}

.process-step.is-open .process-step-number {
    background-color: var(--color-silver);
    color: var(--color-navy);
}

.process-step.is-open p {
    color: rgb(253 253 253 / 0.85);
}

.process-step.is-open .process-step-toggle {
    transform: rotate(45deg);
    border-color: rgb(253 253 253 / 0.5);
    color: var(--color-paper);
}

@media (hover: hover) and (pointer: fine) {
    .process-step:hover .process-step-detail {
        grid-template-rows: 1fr;
    }

    .process-step:hover .process-step-detail > div {
        visibility: visible;
    }

    .process-step:hover {
        background-color: var(--color-navy);
        color: var(--color-paper);
    }

    .process-step:hover .process-step-number {
        background-color: var(--color-silver);
        color: var(--color-navy);
    }

    .process-step:hover p {
        color: rgb(253 253 253 / 0.85);
    }

    .process-step:hover .process-step-toggle {
        transform: rotate(45deg);
        border-color: rgb(253 253 253 / 0.5);
        color: var(--color-paper);
    }
}

@media (prefers-reduced-motion: no-preference) {
    .process-step,
    .process-step p,
    .process-step-number {
        transition: background-color 0.2s ease, color 0.2s ease;
    }

    .process-step-detail {
        transition: grid-template-rows 0.3s ease;
    }

    /* Hide only once the slide has finished closing */
    .process-step-detail > div {
        transition: visibility 0s linear 0.3s;
    }

    .process-step.is-open .process-step-detail > div {
        transition: none;
    }

    .process-step-toggle {
        transition: transform 0.2s ease, border-color 0.2s ease, color 0.2s ease;
    }
}

@media (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {
    .process-step:hover .process-step-detail > div {
        transition: none;
    }
}

/* Index FAQ: the open answer tucks up 0.5rem into the summary's bottom padding. It's
   done here rather than with -mt-2 on the answer, which the overflow clip below would cut off. */
#faq details[open]::details-content {
    margin-top: -0.5rem;
}

/* Answers slide open/closed instead of snapping. Animating to height:auto needs
   interpolate-size (Chrome/Edge only for now); other browsers just snap as before. */
@media (prefers-reduced-motion: no-preference) {
    #faq details {
        interpolate-size: allow-keywords;
    }

    #faq details::details-content {
        block-size: 0;
        overflow: hidden;
        transition: block-size 0.3s ease, margin-top 0.3s ease, content-visibility 0.3s allow-discrete;
    }

    #faq details[open]::details-content {
        block-size: auto;
    }
}

/* Work page: cropped email preview with a fade-out, so long emails stay card-sized */
.email-preview {
    position: relative;
    display: block;
    height: 28rem;
    border-radius: 1rem;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s ease;
    padding: 0px;
}

.email-preview:hover {
    transform: scale(1.02);
}

.email-preview img {
    width: 100%;
    border-radius: 1rem;
    display: block;
}

.email-preview:after {
    content: "";
    position: absolute;
    inset: auto 0 0 0;
    height: 40%;
    background: linear-gradient(to bottom, transparent, var(--color-platinum));
    pointer-events: none;
}

.email-preview-cta {
    position: absolute;
    left: 50%;
    bottom: 1.25rem;
    z-index: 1;
    transform: translateX(-50%);
    padding: 0.6rem 1.25rem;
    border-radius: 0.5rem;
    background: var(--color-navy);
    color: var(--color-platinum);
    font-size: 0.875rem;
    white-space: nowrap;
    transition: background-color 0.2s ease;
}

.email-preview-cta:hover {
    background: var(--color-blue);
}

/* Below sm the work grid is 2 narrow columns: shorter previews and a smaller button.
   The featured card keeps its own height (Tailwind h-[...] wins) and full-size button. */
@media (max-width: 639px) {
    .email-preview {
        height: 18rem;
        padding: 4px;
        border-radius: 0.75rem;
    }

    .email-preview img {
        border-radius: 0.55rem;
    }

    [data-work-item]:not(#featured) .email-preview-cta {
        bottom: 0.75rem;
        padding: 0.4rem 0.75rem;
        font-size: 0.7rem;
    }
}

/* Placeholder email until real screenshots exist: header bar, hero block, text lines.
   The -orange/-stone/-dark modifiers only swap the colour variables, for variety. */
.email-skeleton {
    --sk-head: #B9D3EF;
    --sk-hero: var(--color-blue);
    --sk-line: var(--color-platinum);
    --sk-bg: var(--color-paper);
    height: 100%;
    min-height: 28rem;
    border-radius: 0.7rem;
    background:
        linear-gradient(var(--sk-head), var(--sk-head)) 10% 4% / 30% 1.5rem no-repeat,
        linear-gradient(var(--sk-hero), var(--sk-hero)) 10% 16% / 80% 10rem no-repeat,
        repeating-linear-gradient(var(--sk-line) 0 0.6rem, transparent 0.6rem 1.4rem) 10% 60% / 80% 12rem no-repeat,
        var(--sk-bg);
}

.email-skeleton-orange {
    --sk-head: var(--color-navy);
    --sk-hero: var(--color-orange);
}

.email-skeleton-stone {
    --sk-head: var(--color-stone);
    --sk-hero: #B9D3EF;
}

.email-skeleton-dark {
    --sk-head: var(--color-platinum);
    --sk-hero: var(--color-blue);
    --sk-line: #1E3346;
    --sk-bg: var(--color-navy);
}

.email-skeleton-full {
    min-height: 90rem;
}

/* Work page archive: a row of email thumbnails that scrolls sideways (by hand: no
   auto-scroll). Each card also scrolls vertically to read the whole email. */
.archive-strip {
    display: flex;
    background-color: var(--color-dark-navy);
    align-items: flex-start;
    gap: 0.8rem;
    overflow-x: auto;
    padding: 1rem 1.5rem;
    /* No visible scrollbar: it still scrolls by touch, trackpad, shift+wheel or drag */
    scrollbar-width: none;
}

.archive-strip::-webkit-scrollbar {
    display: none;
}

/* Mouse users can also click and drag the strip (work.js). No scroll-snap: mandatory
   snapping made scrollbar/trackpad scrolling jump one card at a time and fought the drag. */
@media (hover: hover) and (pointer: fine) {
    .archive-strip {
        cursor: grab;
    }
}

.archive-strip.is-dragging {
    cursor: grabbing;
    user-select: none;
}

.archive-card {
    position: relative;
    flex: 0 0 auto;
    width: 9rem;
    height: 16rem;
    border-radius: 0.75rem;
    overflow-y: auto;
    overflow-x: hidden;
    background: transparent;
    scrollbar-width: thin;
    scrollbar-color: var(--color-blue) transparent;
}

.archive-card::-webkit-scrollbar {
    width: 3px;
}

.archive-card::-webkit-scrollbar-thumb {
    background: var(--color-blue);
}

@media (min-width: 768px) {
    .archive-strip {
        padding-inline: 2.5rem;
    }

    .archive-card {
        width: 16rem;
        height: 30rem;
    }
}
