/* Shared layout and theme for tomwhitepainting.
   mucss is loaded first and handles everything else; these rules set the
   site's palette, keep body text off the blue, and override the content
   column width and how photos sit inside it. */

/* ONE PALETTE FOR THE WHOLE SITE.

   Taken from the mucss azure theme rather than invented, so the pages that
   bring their own CSS agree with the pages that only use mucss. Before this,
   those pages carried a warm palette of their own (#1b1a18 ink on #faf8f4)
   against mucss's cool blue greys, and some of them used --ink, --muted and
   --serif without anything defining them at all, so their text fell back to
   whatever it inherited. */
:root {
    --accent: var(--mu-primary);                 /* #0172ad, the site's blue */
    --accent-hover: var(--mu-primary-hover);
    --ink: var(--mu-color);                      /* #373c44 */
    --muted: var(--mu-muted-color);              /* #646b79 */
    --rule: var(--mu-muted-border-color);
    --wash: var(--mu-card-sectioning-background-color);
    --tint: color-mix(in srgb, var(--accent) 12%, var(--mu-background-color));

    /* The display face used for headings. Named --serif as well because
       pages already ask for it by that name. */
    --display: Georgia, "Iowan Old Style", "Palatino Linotype", Palatino, serif;
    --serif: var(--display);
}

/* THE BLUE, WITHOUT PUTTING TEXT ON IT.

   mucss paints the whole of an `article.card-primary` with --mu-primary and
   never sets a text colour, so every paragraph in a card on this site was
   #373c44 on #0172ad: a contrast ratio of 2.12:1, where AA asks 4.5 for body
   text. Muted text came out at 1.02:1, which is invisible.

   Swapping which token holds the blue fixes it without touching a single
   page: --card-bg goes white, so text lands on white at 11.1:1, and
   --card-color keeps the blue, so mucss's own `color-mix(--card-color 12%,
   --card-bg)` still tints the card's header band — a pale blue #e1eef5 that
   reads at 9.4:1. The blue stays the site's colour; it just stops being the
   paper. */
.card-primary {
    --card-bg: var(--mu-background-color);
    --card-color: var(--accent);
}

/* And the heading in that band takes the blue, so the colour is still the
   first thing you see on a card. */
.card-primary > header :is(h1, h2, h3, h4, h5, h6) {
    color: var(--accent);
}

:root {
    /* A column that stays readable on a laptop but still fills a large
       monitor: floor 900px, ceiling 1300px, scaling gently between. The
       45vw means it only starts to grow past ~2000px, so a 1920px laptop
       keeps the tighter 900px. */
    --column: clamp(900px, 45vw, 1300px);
}

/* THE HEADER IS ONE BAND, IN THE LOGO'S OWN COLOUR.

   The logo is not a transparent mark — it is a 1600x575 image with a solid
   dark blue baked into it, #02476E, which is 560,330 of its pixels and far
   and away its most common colour. On a white page that makes it a rectangle
   stuck on top, and no amount of sizing or aligning the links beside it will
   stop the two reading as separate things.

   So the header takes that exact colour. The logo's own background merges
   into the band and stops being an edge, and the links sit on the same blue,
   which makes the whole row one object. White on #02476E reads at 9.86:1.

   This is not the blue the page content sits on — body text is still on white
   (see .card-primary above). A navigation band is chrome, and chrome carrying
   the brand colour is the point of it. */
:root {
    --header-blue: #02476E;
}

/* The gap above the header band. This was an inline style on `<body>`, so
   it was the same 2rem on a 390px phone as on a 1600px monitor and nothing
   could reach it; a phone screen is mostly fold, so it gives some back
   below 600px. */
body.container {
    margin-top: 2rem;
}

.site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem 2.5rem;
    margin-bottom: 2.5rem;
    padding: 0.9rem 1.5rem;
    background: var(--header-blue);
    border-radius: var(--mu-border-radius, 0.35rem);
}

.site-logo {
    display: block;
    flex: 0 1 auto;
    line-height: 0;
}

/* Bigger than it was floating on white: inside a band it reads as part of
   the furniture rather than as an image, so it can carry its own weight. */
.site-logo img {
    max-height: 125px;
    width: auto;
    max-width: 100%;
}

/* mucss makes the navbar a burger, but only up to 639px: `nav > .navbar-menu`
   is `display: none` and absolutely positioned and `nav > .navbar-burger` is
   `display: block`, both inside `@media (max-width: 639px)`. Above that the
   burger goes and the menu is a plain `nav ul { display: flex }` with mucss's
   own list padding still on it.

   This block used to start at 768px, which left 640–767px in nobody's hands:
   no burger, and none of the styling below either, so six links kept mucss's
   padding, wrapped to two rows and sat under the logo on a line of their own.
   The band came to 258px there — taller than it ever was on a phone. It takes
   over at 640px now, the pixel after mucss lets go. */
@media (min-width: 640px) {
    .site-nav > .navbar-burger {
        display: none;
    }

    .site-nav > .navbar-menu {
        display: flex;
        flex-wrap: wrap;
        align-items: baseline;
        justify-content: flex-end;
        column-gap: 1.75rem;
        row-gap: 0.4rem;
        position: static;
        padding: 0;
        border: 0;
        border-radius: 0;
        background: none;
        box-shadow: none;
        min-width: 0;
        white-space: normal;
    }

    .site-nav > .navbar-menu > li {
        width: auto;
        margin: 0;
        padding: 0;
    }

    .site-nav > .navbar-menu > li > a {
        display: inline;
        margin: 0;
        padding: 0;
        background: none;
    }
}

/* On the band the links are white, whatever width we are at — on a phone
   that means the burger too. */
.site-nav > .navbar-menu > li > a,
.site-nav > .navbar-burger {
    color: #fff;
    text-decoration: none;
}

.site-nav > .navbar-menu > li > a:hover,
.site-nav > .navbar-menu > li > a:focus {
    background: none;
    color: #fff;
    text-decoration: underline;
    text-underline-offset: 4px;
}

/* The page the visitor is on is marked in the nav, and the section it sits
   inside is marked differently — they used to look the same, which read as
   "you are on Paint Colours" while standing on a collection page, a different
   page entirely. The underline is the strong claim and belongs only to the
   page itself; weight alone says "what you want is in here". Screen readers
   get the same distinction from `aria-current` without the styling. */
.site-nav > .navbar-menu > li > a[aria-current="page"] {
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 4px;
}

.site-nav > .navbar-menu > li > a[aria-current="true"] {
    font-weight: 700;
}

/* The nav keeps to the right even when it wraps onto a line of its own, which
   it does on a phone and again between 640 and 767px. `space-between` would
   send a lone item on the second line hard left instead. */
.site-nav {
    margin-left: auto;
}

/* The dropdown keeps mucss's own light panel, so its links go back to being
   dark on white. Only up to 639px: above that there is no dropdown to be
   dark, because mucss has already turned the menu back into a row. */
@media (max-width: 639px) {
    .site-nav > .navbar-toggle:checked ~ .navbar-menu > li > a {
        color: var(--mu-dropdown-color);
    }

    /* The burger's dropdown was opening mostly off the left of the screen.
       mucss hangs it off the nav's own right edge — `position: absolute;
       top: 100%; right: 0` — which is correct, and the nav was in the wrong
       place for it. The logo used to fill the whole first flex line on any
       phone, so the nav wrapped onto a second line, and `space-between` sent
       that lone item hard left. `right: 0` then measured from about 24px in
       and the menu extended leftward off the screen.

       So the nav goes back to the right, where it sits at every other width
       and where mucss expects it (that rule is above, outside this query,
       because the wrap happens between 640 and 767px too), and the dropdown
       positions itself correctly with no override at all. A burger at the
       right is also the convention on a phone.

       Under 600px the logo now leaves room for the burger beside it, so on a
       phone there is no second line left to go wrong at all. */

    /* And a belt for the braces: however long a label gets, the menu cannot
       grow past the screen. 4rem covers the header's own padding either
       side with a little to spare. */
    .site-nav > .navbar-menu {
        max-width: calc(100vw - 4rem);
    }
}

@media (max-width: 600px) {
    /* The logo used to lose its height cap here and take the whole line,
       which pushed the burger onto a row of its own underneath: 44px of
       band on every page for a 38px button. A width cap instead, 4rem being
       the gap plus the burger plus a little, and the two sit on one row.

       The height cap can stay as it is now — on a phone the width is what
       binds first anyway, and leaving it alone means the logo stops growing
       at 125px on the way up rather than at 147px.

       The logo is not shrunk any further than that on purpose. It is
       1600x575, and the words that matter most to somebody arriving from a
       search — Painting & Decorating — are the smallest thing in it; at the
       width this leaves they are about 9px tall, and much below that they
       stop being readable at all. */
    .site-logo {
        max-width: calc(100% - 4rem);
    }

    .site-header {
        gap: 0.75rem 1rem;
        padding: 0.75rem 1rem;
        margin-bottom: 1.5rem;
    }

    /* A phone screen is mostly fold, so the band starts nearer the top of
       it. */
    body.container {
        margin-top: 1rem;
    }
}

@media (min-width: 1024px) {
    /* Below 1024px mucss's own ladder (510 / 700 / 950px) applies
       unchanged, on every page. */
    body.container {
        max-width: var(--column);
    }

    /* Every photo fills the column, so their edges line up with each other
       and with the paragraphs. Heights vary with each photo's shape, which
       is the trade for never cropping one. */
    article picture {
        display: block;
    }

    article img {
        width: 100%;
        height: auto;
    }
}

/* Keyboard and screen-reader users get a first stop that skips the nav. Off
   screen until focused; nobody else ever sees it. */
.skip-link {
    position: absolute;
    left: -9999px;
}
.skip-link:focus {
    position: fixed;
    top: 0.5rem;
    left: 0.5rem;
    z-index: 10;
    padding: 0.5rem 0.9rem;
    background: #fff;
    color: var(--ink, #1a1a1a);
    border: 2px solid currentColor;
    border-radius: 4px;
}

/* An in-page target lands with a little air above it rather than flush
   against the top of the viewport. */
#interiors,
#exteriors {
    scroll-margin-top: 1rem;
}

/* The footer: a name and two links, on every page. It carries the privacy
   notice, which has to be reachable from wherever somebody has landed —
   adverts drop people on pages that never pass the home page. */
.site-footer {
  margin: 3.5rem 0 1.5rem;
  padding-top: 1.2rem;
  border-top: 1px solid rgba(0, 0, 0, 0.1);
  font-size: 0.85rem;
  color: #6c665e;
}
.site-footer p { margin: 0; }
.site-footer a { color: inherit; }

/* A PAGE'S ONE REAL HEADING.

   Home, About, Testimonials and Contact had no `h1` at all — their headings
   started at `h3`, so the four pages meant to win work were the only ones on
   the site with no heading saying what they were about. The colour pages had
   one all along.

   The 404, the thank-you page and the two trade directory pages were the
   last four to be left behind, and the trade one is the one that mattered:
   it is written to be found, and `hidden_from_search` is meant to be the
   only thing standing between it and search. A page whose first heading is
   an `h3` is also a page a screen reader reads as a fragment of something
   else, whichever way the search engines feel about it.

   Promoting them is a one-tag change, and mucss would answer it by doubling
   the type: `h1` is 2rem against `h3`'s 1.5rem, and 3.5rem once the viewport
   is wide. That is a redesign nobody asked for, so the size stays where it
   was and only the meaning changes. One number here if it should grow. */
.card-primary > header h1,
.card > header h1 {
  font-size: 1.5rem;
  line-height: 1.25;
}
