/*
 * joncook.me: classless stylesheet.
 *
 * The markup has no classes: everything is styled by element, structure and ARIA attributes.
 * Colours and sizes are tokens on :root; dark mode swaps the colour tokens.
 * Mobile first: the base rules are the phone layout, min-width queries add to them.
 */

/* Headings: Manrope (SIL Open Font License, see fonts/OFL.txt), self-hosted, Latin subset, all weights */
@font-face {
    font-family: "Manrope";
    src: url("fonts/manrope-latin.woff2") format("woff2");
    font-weight: 200 800;
    font-style: normal;
    font-display: swap;
}

:root {
    --bg: #fbfbf9;
    --bg-alt: #f1f2ee;
    --text: #1b1e23;
    --muted: #596070;
    --line: #dfe2dc;
    --accent: #0a6e8a;
    --tint: #e5f1f4;         /* icon tiles */
    --tile: #fff;            /* logos always sit on white so client colours stay true */
    --band: #0b5d74;         /* page title band and the contact panel */
    --on-band: #fff;
    --on-band-muted: rgba(255, 255, 255, .82);
    --on-band-line: rgba(255, 255, 255, .6);

    --radius: .75rem;
    --wide: 72rem;           /* page width */
    --measure: 42rem;        /* comfortable line length for reading */
    --gutter: max(1rem, (100vw - var(--wide)) / 2);   /* viewport-based, so full-width bands can cancel it */
    --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --heading: "Manrope", var(--sans);

    color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #111418;
        --bg-alt: #171b21;
        --text: #e6e8eb;
        --muted: #a0a7b2;
        --line: #2b3139;
        --accent: #5cc3e6;
        --tint: #13262d;
        --band: #0d4556;
    }
}

/* ---------------------------------------------------------------- base */

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

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

body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 400 1.0625rem/1.65 var(--sans);
    -webkit-font-smoothing: antialiased;
}

main {
    flex: 1;
    padding: 0 var(--gutter) 4rem;   /* the title band at the top provides the top spacing */
}

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

a {
    color: var(--accent);
    text-decoration-thickness: 1px;
    text-underline-offset: .2em;
}
a:hover { text-decoration-thickness: 2px; }
a[href^="tel:"] { white-space: nowrap; }

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

h1, h2, h3 {
    margin: 0 0 .5em;
    font-family: var(--heading);
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -.02em;
    text-wrap: balance;
}
h1 {
    font-size: clamp(2rem, 1.4rem + 2.6vw, 3rem);
    font-weight: 800;
    letter-spacing: -.03em;
}
h2 { font-size: clamp(1.35rem, 1.15rem + .9vw, 1.7rem); }
h3 { font-size: 1.1rem; }

p, ul, ol, figure, blockquote { margin: 0 0 1.15em; }

/* Skip link: first thing in <body>, visible only when focused */
body > a:first-child {
    position: absolute;
    top: .75rem;
    left: .75rem;
    z-index: 10;
    padding: .5rem 1rem;
    border-radius: var(--radius);
    background: var(--text);
    color: var(--bg);
    transform: translateY(-200%);
}
body > a:first-child:focus { transform: none; }

/* ---------------------------------------------------------------- site header */

body > header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: .75rem 2rem;
    padding: 1.1rem var(--gutter);
    border-bottom: 1px solid var(--line);
}

/* site name, with a small accent square as the mark */
body > header > a {
    display: inline-flex;
    align-items: center;
    gap: .55rem;
    color: var(--text);
    font-family: var(--heading);
    font-size: 1.2rem;
    font-weight: 800;
    letter-spacing: -.02em;
    text-decoration: none;
}
body > header > a::before {
    content: "";
    width: .8rem;
    height: .8rem;
    border-radius: .2rem;
    background: var(--accent);
}

body > header ul {
    display: flex;
    flex-wrap: wrap;
    gap: .25rem 1.4rem;
    margin: 0;
    padding: 0;
    list-style: none;
}
body > header li a {
    display: block;
    padding: .2rem 0;
    border-bottom: 2px solid transparent;
    color: var(--muted);
    font-weight: 500;
    text-decoration: none;
}
body > header li a:hover { color: var(--text); }
body > header li a[aria-current] {
    border-bottom-color: var(--accent);
    color: var(--text);
}

/* ---------------------------------------------------------------- page title band */

/* The heading area of every page (home introduction, category, post, error) is a full-width band */
main > header,
main > article > header {
    margin: 0 calc(-1 * var(--gutter)) clamp(2rem, 5vw, 2.75rem);
    padding: clamp(2rem, 5vw, 3.25rem) var(--gutter) clamp(1.75rem, 4vw, 2.75rem);
    background: var(--band);
    color: var(--on-band);
}
main > header > * { max-width: var(--measure); }
main > header > p {
    color: var(--on-band-muted);
    font-size: 1.1rem;
}
main > header > p:last-child,
main > article > header > h1:last-child { margin-bottom: 0; }
:is(main > header, main > article > header) a { color: var(--on-band); }

nav[aria-label="Breadcrumb"] ol {
    display: flex;
    flex-wrap: wrap;
    margin: 0 0 .6rem;
    padding: 0;
    list-style: none;
    color: var(--on-band-muted);
    font-size: .9rem;
}
nav[aria-label="Breadcrumb"] li + li::before {
    content: "/";
    margin: 0 .5em;
    opacity: .6;
}
nav[aria-label="Breadcrumb"] a {
    color: inherit;
    text-decoration: none;
}
nav[aria-label="Breadcrumb"] a:hover {
    color: var(--on-band);
    text-decoration: underline;
}

/* Post headers: the client logo on a white tile, or the service icon */
main > article > header figure { margin: 1.25rem 0 0; }
main > article > header img {
    width: auto;
    max-width: min(100%, 17rem);
    max-height: 8.5rem;
    padding: .9rem 1.1rem;
    border-radius: var(--radius);
    background: var(--tile);
    object-fit: contain;
}
main > article > header > nav { grid-column: 1 / -1; }

/* service icon: beside the title, before it */
main > article > header:has(> svg) {
    display: grid;
    grid-template-columns: auto minmax(0, 44rem);
    justify-content: start;
    align-items: center;
    column-gap: clamp(1rem, 3vw, 1.5rem);
}
main > article > header > svg {
    display: block;
    grid-row: 2;
    grid-column: 1;
    width: clamp(3.25rem, 8vw, 4.5rem);
    height: clamp(3.25rem, 8vw, 4.5rem);
    padding: clamp(.75rem, 2vw, 1rem);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, .12);
    color: var(--on-band);
}
main > article > header:has(> svg) h1 {
    grid-row: 2;
    grid-column: 2;
    margin: 0;
}

/* client logo: to the right of the title on wider screens */
@media (min-width: 48rem) {
    main > article > header:has(figure) {
        display: grid;
        grid-template-columns: minmax(0, 44rem) auto;
        justify-content: start;
        align-items: center;
        column-gap: 3rem;
    }
    main > article > header:has(figure) h1,
    main > article > header figure { margin: 0; }
}

/* ---------------------------------------------------------------- call and email buttons */

/* tel: and mailto: links in the home introduction and the contact panel are buttons */
:is(main > header, main > aside) p:has(> a[href^="tel:"]) {
    display: flex;
    flex-wrap: wrap;
    gap: .6rem;
}
main > header p:has(> a[href^="tel:"]) { margin-top: 1.5rem; }
:is(main > header, main > aside) a:is([href^="tel:"], [href^="mailto:"]) {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    padding: .7rem 1.25rem;
    border: 1.5px solid var(--on-band-line);
    border-radius: 999px;
    color: var(--on-band);
    font-weight: 600;
    text-decoration: none;
    transition: background-color .15s, border-color .15s;
}
:is(main > header, main > aside) a[href^="tel:"] {
    border-color: var(--on-band);
    background: var(--on-band);
    color: var(--band);
}
:is(main > header, main > aside) a[href^="mailto:"]:hover {
    border-color: var(--on-band);
    background: rgba(255, 255, 255, .1);
}
:is(main > header, main > aside) a[href^="tel:"]:hover { background: rgba(255, 255, 255, .88); }
:is(main > header, main > aside) a svg {
    flex: none;
    width: 1.1em;
    height: 1.1em;
}

/* ---------------------------------------------------------------- client logo strip (home page) */

main > nav[aria-label="Clients"] h2 {
    margin: 0 0 .8rem;
    color: var(--muted);
    font: 700 .78rem/1.2 var(--sans);
    letter-spacing: .08em;
    text-transform: uppercase;
}
main > nav[aria-label="Clients"] ul {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(7.5rem, 1fr));
    gap: .6rem;
    margin: 0;
    padding: 0;
    list-style: none;
}
main > nav[aria-label="Clients"] a {
    display: grid;
    place-items: center;
    height: 3.75rem;
    padding: .45rem .7rem;
    border: 1px solid var(--line);
    border-radius: .6rem;
    background: var(--tile);
}
main > nav[aria-label="Clients"] img {
    width: auto;
    max-height: 2.6rem;
    object-fit: contain;
    filter: grayscale(1);
    opacity: .75;
    transition: filter .2s, opacity .2s;
}
main > nav[aria-label="Clients"] a:is(:hover, :focus-visible) img {
    filter: none;
    opacity: 1;
}

/* ---------------------------------------------------------------- home page sections */

main > section { margin-top: clamp(2.5rem, 6vw, 4rem); }
main > header + section { margin-top: 0; }
main > section > p {
    max-width: var(--measure);
    color: var(--muted);
}
main > section > p:last-child { margin: 1.5rem 0 0; }       /* "View all ..." */
main > section > p:last-child a {
    font-weight: 600;
    text-decoration: none;
}
main > section > p:last-child a:hover { text-decoration: underline; }

/* ---------------------------------------------------------------- post cards (home sections, category pages) */

main > ul,
main > section > ul {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 15.5rem), 1fr));
    gap: 1rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

main li > article {
    position: relative;
    height: 100%;
    padding: 1rem 1.1rem 1.15rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--bg-alt);
    transition: border-color .15s, transform .15s, box-shadow .15s;
}
main li > article:hover {
    border-color: var(--accent);
    transform: translateY(-3px);
    box-shadow: 0 12px 26px -14px rgba(10, 30, 40, .45);
}

/* the card's link covers the whole card */
main li > article > a {
    color: var(--text);
    text-decoration: none;
}
main li > article > a::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
}
@supports selector(:has(a)) {
    main li > article > a:focus-visible { outline: none; }
    main li > article:has(> a:focus-visible) {
        outline: 2px solid var(--accent);
        outline-offset: 2px;
    }
}

/* client logo, or for posts without one (the services), their icon */
main li > article img {
    width: 100%;
    height: 7.5rem;
    margin-bottom: 1rem;
    padding: .9rem;
    border-radius: calc(var(--radius) - .3rem);
    background: var(--tile);
    object-fit: contain;
}
main li > article > a > svg {
    display: block;
    width: 3.1rem;
    height: 3.1rem;
    margin-bottom: .9rem;
    padding: .75rem;
    border-radius: .7rem;
    background: var(--tint);
    color: var(--accent);
}
main li > article :is(h2, h3) {
    margin: 0 0 .35rem;
    font-size: 1.05rem;
    letter-spacing: -.01em;
}
main li > article:hover :is(h2, h3) { color: var(--accent); }
main li > article p {
    display: -webkit-box;
    margin: 0;
    overflow: hidden;
    color: var(--muted);
    font-size: .92rem;
    line-height: 1.55;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
}

/* ---------------------------------------------------------------- posts */

main > article > :not(header) { max-width: var(--measure); }
main > article > h2 {
    margin-top: 2.25rem;
    font-size: 1.45rem;
}
main > article > header + h2 { margin-top: 0; }
main > article ul, main > article ol { padding-left: 1.3rem; }
main > article li {
    margin-bottom: .4em;
    padding-left: .2rem;
}
main > article li::marker { color: var(--accent); }
main > article > figure img {
    border: 1px solid var(--line);
    border-radius: var(--radius);
}
main > article blockquote {
    padding-left: 1rem;
    border-left: 3px solid var(--accent);
    color: var(--muted);
}

/* previous / next post, and the section links on error pages */
main > nav:not([aria-label="Clients"]) {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 1rem 2rem;
    max-width: var(--measure);
    margin-top: 3rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--line);
}
main > header + nav:not([aria-label="Clients"]) {
    margin-top: 0;
    padding-top: 0;
    border-top: 0;
}
main > nav:not([aria-label="Clients"]) > a {
    max-width: 20rem;
    font-weight: 600;
    text-decoration: none;
}
main > nav:not([aria-label="Clients"]) > a:hover { text-decoration: underline; }
main > nav > a[rel="next"] {
    margin-left: auto;
    text-align: right;
}
main > nav > ul {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem 1.5rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

/* ---------------------------------------------------------------- "Have a project in mind?" panel */

main > aside {
    display: grid;
    gap: 1.25rem 2rem;
    margin-top: clamp(3rem, 7vw, 4.5rem);
    padding: clamp(1.5rem, 4vw, 2.25rem);
    border-radius: var(--radius);
    background: var(--band);
    color: var(--on-band);
}
@media (min-width: 48rem) {
    main > aside {
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: center;
    }
}
main > aside h2 { margin: 0 0 .3rem; }
main > aside p {
    margin: 0;
    color: var(--on-band-muted);
}

/* ---------------------------------------------------------------- site footer */

body > footer {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 13rem), 1fr));
    gap: 2rem 2.5rem;
    padding: 3rem var(--gutter) 2rem;
    border-top: 1px solid var(--line);
    background: var(--bg-alt);
    color: var(--muted);
    font-size: .93rem;
}
body > footer h2 {
    margin-bottom: .8rem;
    color: var(--text);
    font-size: .78rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
}
body > footer h2 a {
    color: inherit;
    text-decoration: none;
}
body > footer section p:last-child { margin-bottom: 0; }
body > footer ul {
    margin: 0;
    padding: 0;
    list-style: none;
}
body > footer li {
    margin-bottom: .45rem;
    line-height: 1.4;
}
body > footer li a {
    color: inherit;
    text-decoration: none;
}
body > footer li a:hover {
    color: var(--accent);
    text-decoration: underline;
}
body > footer > p {
    grid-column: 1 / -1;
    margin: 0;
    padding-top: 1.5rem;
    border-top: 1px solid var(--line);
    font-size: .85rem;
}

/* ---------------------------------------------------------------- preferences and print */

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; }
    main li > article:hover { transform: none; }
}

@media print {
    body > header nav, body > footer, main > nav, main > aside { display: none; }
    main > header, main > article > header,
    :is(main > header, main > article > header) * { background: none !important; color: #000 !important; }
    a { color: inherit; }
}
