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

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    background: var(--background);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 1.0625rem;
    line-height: 1.65;
}

/* Leaves room for phone notches in landscape. */
.wrap {
    --gutter: max(1.25rem, env(safe-area-inset-left), env(safe-area-inset-right));
    width: min(100% - 2 * var(--gutter), 68rem);
    margin-inline: auto;
}

h1, h2, h3 {
    margin: 0;
    color: var(--navy);
    font-family: var(--font-heading);
    font-weight: 500;
    line-height: 1.2;
    overflow-wrap: break-word;
}

h1 {
    max-width: 22em;
    font-size: clamp(1.75rem, 5.5vw, 3rem);
}

h2 {
    margin-bottom: 1.5rem;
    font-size: clamp(1.6rem, 4.5vw, 2.25rem);
}

h3 {
    font-size: 1.25rem;
}

/* Navigation: a full bar at the top of the page, then a button once scrolled. */
.site-nav {
    position: sticky;
    top: 0;
    z-index: 20;
    background: var(--background);
    border-bottom: 1px solid var(--border);
    /* Becomes visible at once on opening, so the links can take keyboard focus. */
    transition: transform 0.25s ease, visibility 0s;
}

.site-nav[data-collapsed="true"] {
    transform: translateY(-100%);
    visibility: hidden;
    transition: transform 0.25s ease, visibility 0s 0.25s;
}

.nav-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    column-gap: 2rem;
    padding-block: 0.5rem;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    min-height: 2.75rem;
    color: var(--navy);
    font-family: var(--font-heading);
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.2;
    text-decoration: none;
}

.logo {
    flex: none;
    width: auto;
    height: var(--logo-height);
}

.nav-links {
    display: flex;
    gap: 1.5rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.nav-links a {
    display: inline-flex;
    align-items: center;
    min-height: 2.75rem;
    color: var(--navy);
    text-decoration: none;
    border-bottom: 2px solid transparent;
}

.nav-links a:hover,
.nav-links a[aria-current="location"] {
    border-bottom-color: var(--navy);
}

.nav-links a.nav-phone {
    gap: 0.35rem;
    font-weight: 600;
}

.nav-phone svg {
    flex: none;
}

/* The bar has room for the word "Call" on narrow phones, and the number on wider screens. */
.phone-full {
    display: none;
    white-space: nowrap;
}

.nav-toggle {
    position: fixed;
    top: max(0.75rem, env(safe-area-inset-top));
    right: max(0.75rem, env(safe-area-inset-right));
    z-index: 30;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 3rem;
    height: 3rem;
    padding: 0;
    background: var(--navy);
    color: var(--on-accent);
    border: 0;
    border-radius: var(--radius);
    box-shadow: 0 2px 10px rgb(0 33 71 / 0.3);
    cursor: pointer;
}

.nav-toggle[hidden] {
    display: none;
}

/* Page sections */
.site-notice {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    font-size: 0.95rem;
    line-height: 1.5;
}

.site-notice p {
    margin-block: 0;
    margin-inline: auto;
    padding-block: 0.7rem;
}

.site-notice strong {
    color: var(--navy);
}

.site-notice a {
    color: var(--navy);
}

.hero {
    padding-block: clamp(3rem, 12vw, 7rem);
}

.wordmark {
    margin: 0 0 1.25rem;
    color: var(--navy);
    font-family: var(--font-heading);
    font-size: clamp(3rem, 14vw, 5.5rem);
    font-weight: 500;
    letter-spacing: 0.12em;
    line-height: 1.05;
}

.wordmark span {
    display: block;
    margin-top: 0.6rem;
    font-size: clamp(0.9rem, 3.4vw, 1.25rem);
    letter-spacing: 0.22em;
}

.colour-bars {
    display: flex;
    gap: 0.5rem;
    max-width: 22rem;
    margin-bottom: 2.5rem;
}

.colour-bars span {
    flex: 1;
    height: 0.4rem;
    background: var(--bar-blue);
}

.colour-bars span:nth-child(2) { background: var(--bar-yellow); }
.colour-bars span:nth-child(3) { background: var(--bar-magenta); }
.colour-bars span:nth-child(4) { background: var(--bar-orange); }
.colour-bars span:nth-child(5) { background: var(--bar-green); }

.hero-phone {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    min-height: 3.25rem;
    margin-bottom: 2rem;
    padding: 0.6rem 1.25rem;
    background: var(--navy);
    color: var(--on-accent);
    border-radius: var(--radius);
    font-size: clamp(1.25rem, 5vw, 1.6rem);
    font-weight: 700;
    letter-spacing: 0.01em;
    text-decoration: none;
    white-space: nowrap;
}

/* Floating call button: phones and tablets only. */
.call-button {
    position: fixed;
    right: max(1rem, env(safe-area-inset-right));
    bottom: max(1rem, env(safe-area-inset-bottom));
    z-index: 15;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 3.5rem;
    height: 3.5rem;
    background: var(--navy);
    color: var(--on-accent);
    border-radius: 50%;
    box-shadow: 0 3px 12px rgb(0 33 71 / 0.4);
    transition: opacity 0.2s ease, visibility 0s;
}

/* Hidden while the form's Send button is on screen, or while someone is typing. */
.call-button[data-hidden="true"] {
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0s 0.2s;
}

.lede {
    max-width: 38rem;
    margin: 1.25rem 0 2rem;
    color: var(--muted);
    font-size: 1.15rem;
}

.services,
.about,
.contact {
    padding-block: clamp(3rem, 9vw, 5.5rem);
    /* Keeps headings clear of the menu button after tapping a link. */
    scroll-margin-top: 1rem;
}

.services {
    background: var(--surface);
}

.service-grid {
    display: grid;
    gap: 1rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.service {
    padding: 1.5rem;
    background: var(--background);
    border: 1px solid var(--border);
    border-top: 3px solid var(--navy);
    border-radius: var(--radius);
}

.service p {
    margin: 0.5rem 0 0;
    color: var(--muted);
}

.about {
    background: var(--navy);
    color: var(--on-accent);
}

.about h2 {
    color: var(--on-accent);
}

.about p {
    max-width: 42rem;
    margin: 0;
    font-size: 1.15rem;
}

/* Narrow enough to fill in comfortably, and left-aligned with the other sections. */
.contact-inner > * {
    max-width: 40rem;
}

.contact-inner h2 {
    margin-bottom: 0.5rem;
}

.contact-inner > p {
    margin: 0 0 2rem;
    color: var(--muted);
}

label {
    display: block;
    margin-bottom: 0.35rem;
    font-weight: 600;
}

/* 16px or larger stops iPhones zooming in on a focused field. */
input,
textarea {
    display: block;
    width: 100%;
    min-height: 2.75rem;
    margin-bottom: 1.25rem;
    padding: 0.7rem 0.8rem;
    background: var(--background);
    color: var(--text);
    border: 1px solid #8a8f98;
    border-radius: var(--radius);
    font: inherit;
}

textarea {
    resize: vertical;
}

.cf-turnstile {
    min-height: 65px;
    margin-bottom: 1.25rem;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 3rem;
    padding: 0.75rem 1.75rem;
    background: var(--accent);
    color: var(--on-accent);
    border: 0;
    border-radius: var(--radius);
    font: inherit;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}

/* Only on devices with a real pointer, or the colour sticks after a tap on phones. */
@media (hover: hover) {
    .button:hover {
        background: var(--bar-blue);
    }
}

.button:disabled {
    opacity: 0.6;
    cursor: wait;
}

form .button {
    width: 100%;
}

a:focus-visible,
input:focus-visible,
textarea:focus-visible,
button:focus-visible {
    outline: 3px solid var(--bar-blue);
    outline-offset: 2px;
}

.form-status {
    min-height: 1.6em;
    margin: 1rem 0 0;
    font-weight: 600;
}

.form-status[data-state="success"] {
    color: var(--success);
}

.form-status[data-state="error"] {
    color: var(--error);
}

.contact-inner > p a {
    color: var(--navy);
    font-weight: 700;
    white-space: nowrap;
}

.site-footer {
    /* Keeps the footer text clear of the floating call button. */
    padding-bottom: 5.5rem;
    color: var(--muted);
    font-size: 0.9rem;
}

.site-footer .colour-bars {
    max-width: none;
    gap: 0;
    margin-bottom: 2rem;
}

.site-footer p {
    margin: 0 0 0.25rem;
}

.no-wrap {
    white-space: nowrap;
}

/* Turnstile needs 300px, so the smallest phones get narrower margins. */
@media (max-width: 340px) {
    .wrap {
        --gutter: 0.625rem;
    }
}

/* Two rows on narrow phones: the name, then the links. */
@media (max-width: 599px) {
    .nav-links {
        justify-content: space-between;
        gap: 1rem;
    }

    .site-nav nav {
        flex-basis: 100%;
    }
}

@media (min-width: 600px) {
    .phone-short {
        display: none;
    }

    .phone-full {
        display: inline;
    }

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

    .service:last-child {
        grid-column: 1 / -1;
    }

    form .button {
        width: auto;
    }
}

@media (min-width: 960px) {
    /* Desktop screens have the number in the top bar, and can't tap to call. */
    .call-button {
        display: none;
    }

    .site-footer {
        padding-bottom: 2.5rem;
    }

    .service-grid {
        grid-template-columns: repeat(6, 1fr);
    }

    .service {
        grid-column: span 2;
    }

    /* The two specialisms get more room. */
    .service:nth-child(-n + 2) {
        grid-column: span 3;
    }

    .service:last-child {
        grid-column: span 2;
    }
}

/* Phones in landscape have very little height to spare. */
@media (max-height: 500px) {
    .hero {
        padding-block: 2rem;
    }

    .wordmark {
        margin-bottom: 0.75rem;
        font-size: 2rem;
    }

    .wordmark span {
        margin-top: 0.3rem;
        font-size: 0.8rem;
    }

    .colour-bars {
        margin-bottom: 1rem;
    }

    .hero-phone {
        min-height: 2.75rem;
        margin-bottom: 1rem;
        font-size: 1.15rem;
    }

    h1 {
        font-size: 1.5rem;
    }

    .lede {
        margin: 0.75rem 0 1rem;
        font-size: 1rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    .site-nav,
    .site-nav[data-collapsed="true"],
    .call-button,
    .call-button[data-hidden="true"] {
        transition: none;
    }
}
