/*
Theme Name: MRings
Theme URI: https://morrisonrings.com
Author: Morrison Sites
Author URI: https://www.morrisonsites.com
Description: Morrison Rings, the sister company of Morrison Sites. Built from the Morrison Sites boilerplate: square corners, no shadows, Gotham headings, system body type, a centred blend-mode header and a full-screen overlay menu. Monochrome; recolour through the tokens in :root and theme.json.
Version: 0.1.0
Requires at least: 6.6
Requires PHP: 8.0
License: GNU General Public License v2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: mrings
*/

:root {
    /* Core palette. Recolour a site here and in theme.json; nothing else carries a raw colour. */
    --mr-bg: #ffffff;
    --mr-panel: #f5f5f5;
    --mr-line: #e6e6e6;
    /* 5.7:1 on white. Small secondary text must stay at or above 4.5:1. */
    --mr-muted: #616161;
    --mr-text: #000000;
    --mr-accent: #000000;
    --mr-accent-hover: #000000;
    /* The header paints in white and differences against the page, so it reads black on white and white on black. */
    --mr-header-ink: #ffffff;
    /* Basemap greys: the Google map's style reads these, and images/campus.svg is built with the same values. */
    --mr-map-land: #f5f5f5;
    --mr-map-green: #ebebeb;
    --mr-map-water: #e0e0e0;
    --mr-map-building: #dcdcdc;
    --mr-map-road: #ffffff;
    /* The map's one hue, kept to data. Heat runs 1 to 5 as more shifts pass a spot; routes use 4 (4.6:1 on land). */
    --mr-heat-1: #ffe9a8;
    --mr-heat-2: #ffb03b;
    --mr-heat-3: #ff7a00;
    --mr-heat-4: #d42a1a;
    --mr-heat-5: #7a0b1c;

    /* Semantic aliases: components reference these, never the raw values above. */
    --mr-bg-color: var(--mr-bg);
    --mr-panel-color: var(--mr-panel);
    --mr-line-color: var(--mr-line);
    --mr-muted-color: var(--mr-muted);
    --mr-text-color: var(--mr-text);
    --mr-accent-color: var(--mr-accent);
    --mr-header-ink-color: var(--mr-header-ink);
    --mr-map-land-color: var(--mr-map-land);
    --mr-map-green-color: var(--mr-map-green);
    --mr-map-water-color: var(--mr-map-water);
    --mr-map-building-color: var(--mr-map-building);
    --mr-map-road-color: var(--mr-map-road);
    --mr-heat-1-color: var(--mr-heat-1);
    --mr-heat-2-color: var(--mr-heat-2);
    --mr-heat-3-color: var(--mr-heat-3);
    --mr-heat-4-color: var(--mr-heat-4);
    --mr-heat-5-color: var(--mr-heat-5);

    /* Body copy: system UI stack, so no webfont is fetched for it. */
    --mr-font-body:
        -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
        sans-serif, "Apple Color Emoji", "Segoe UI Emoji";

    /* Headings, buttons, labels and navigation: Gotham. */
    --mr-font-heading:
        "Gotham", "Montserrat", "Helvetica Neue", Arial, sans-serif;

    /* Layout. Mirrored by contentSize and wideSize in theme.json. */
    --mr-content: 1000px;
    --mr-wide: 1500px;
    --mr-gutter: 1.5rem;
}

/* Fonts. Licensed webfont: confirm the licence covers each new domain before shipping. */
@font-face {
    font-family: "Gotham";
    src: url("./fonts/book.woff2") format("woff2");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Gotham";
    src: url("./fonts/medium.woff2") format("woff2");
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Gotham";
    src: url("./fonts/bold.woff2") format("woff2");
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Gotham";
    src: url("./fonts/black.woff2") format("woff2");
    font-weight: 900;
    font-style: normal;
    font-display: swap;
}

/* Elements. */
h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: var(--mr-font-heading);
    font-weight: 700;
    text-transform: uppercase;
    margin: 0;
}

p {
    margin: 0 0 1.5rem 0;
}

img,
video {
    max-width: 100%;
    height: auto;
}

/* Content links. */
a {
    color: var(--mr-text-color);
    text-decoration-color: rgba(0, 0, 0, 0.35);
    text-underline-offset: 0.15em;
    text-decoration-thickness: 1px;
    transition: text-decoration-color 200ms ease;
}

a:hover,
a:focus-visible {
    text-decoration-color: currentColor;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
    outline: 2px solid var(--mr-accent-color);
    outline-offset: 2px;
}

/* WordPress core emits this on structural headings, which render as visible text unstyled. */
.screen-reader-text {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

.screen-reader-text:focus {
    position: static;
    width: auto;
    height: auto;
    margin: 0;
    overflow: visible;
    clip-path: none;
    white-space: normal;
}

/* Reachable only by keyboard, first thing in the tab order. */
.skip-link {
    position: absolute;
    top: -100%;
    left: 0.5rem;
    z-index: 100;
    padding: 0.75rem 1.25rem;
    background-color: var(--mr-bg-color);
    color: var(--mr-text-color);
    border: 3px solid var(--mr-accent-color);
    font-family: var(--mr-font-heading);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    text-decoration: none;
}

.skip-link:focus {
    top: 0.5rem;
}

/* Scroll-reveal, scoped to .js so a blocked script can never leave content invisible. */
.js .fade-up {
    opacity: 0;
    transform: translateY(1.25rem);
    transition:
        opacity 600ms cubic-bezier(0.22, 1, 0.36, 1),
        transform 600ms cubic-bezier(0.22, 1, 0.36, 1);
}

.js .fade-up.visible {
    opacity: 1;
    transform: none;
}

@media (prefers-reduced-motion: reduce) {
    .js .fade-up {
        opacity: 1;
        transform: none;
        transition: none;
    }
}

.hidden {
    display: none !important;
}

/* Buttons. Outlined by default; .btn-solid and the core Button block are filled. Every corner is square. */
button,
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background-color: var(--mr-bg-color);
    color: var(--mr-text-color);
    border: 3px solid var(--mr-accent-color);
    border-radius: 0;
    padding: 0.75rem 1.75rem;
    min-height: 44px;
    /* Buttons are border-box by default; the link version must say so, or min-height adds to the padding. */
    box-sizing: border-box;
    font-family: var(--mr-font-heading);
    font-weight: 700;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    text-decoration: none;
    cursor: pointer;
    transition:
        background-color 250ms ease,
        color 250ms ease,
        border-color 250ms ease;
}

button:hover,
button:focus,
button:active,
.btn:hover,
.btn:focus,
.btn:active {
    background-color: var(--mr-accent-color);
    color: var(--mr-bg-color);
}

.btn-solid {
    background-color: var(--mr-accent-color);
    color: var(--mr-bg-color);
}

.btn-solid:hover,
.btn-solid:focus,
.btn-solid:active {
    background-color: var(--mr-bg-color);
    color: var(--mr-text-color);
    border-color: var(--mr-accent-hover);
}

/* Gutenberg core Button block: filled, and its Outline style is the outlined .btn. */
.wp-block-button__link {
    background-color: var(--mr-accent-color);
    color: var(--mr-bg-color);
    border: 3px solid var(--mr-accent-color);
    border-radius: 0;
    padding: 0.75rem 1.75rem;
    min-height: 44px;
    box-sizing: border-box;
    font-family: var(--mr-font-heading);
    font-weight: 700;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    transition:
        background-color 250ms ease,
        color 250ms ease,
        border-color 250ms ease;
}

.wp-block-button__link:hover,
.wp-block-button__link:focus,
.wp-block-button__link:active {
    background-color: var(--mr-bg-color);
    color: var(--mr-text-color);
    border-color: var(--mr-accent-hover);
}

/* Core's Outline style sets a 2px border and em padding at equal specificity, loaded later; the frame must match the filled button. */
.wp-block-button.is-style-outline > .wp-block-button__link {
    background-color: var(--mr-bg-color);
    color: var(--mr-text-color);
    border: 3px solid var(--mr-accent-color);
    padding: 0.75rem 1.75rem;
}

.wp-block-button.is-style-outline > .wp-block-button__link:hover,
.wp-block-button.is-style-outline > .wp-block-button__link:focus,
.wp-block-button.is-style-outline > .wp-block-button__link:active {
    background-color: var(--mr-accent-color);
    color: var(--mr-bg-color);
}

/* On phones the buttons stack full width, so a pair is always symmetrical whatever its labels. */
@media (max-width: 767px) {
    .wp-block-buttons {
        flex-direction: column;
        align-items: stretch;
    }

    .wp-block-buttons > .wp-block-button,
    .wp-block-buttons > .wp-block-button > .wp-block-button__link {
        width: 100%;
        box-sizing: border-box;
    }
}

/* Core Accordion block: size pinned, so the heading level can change without the FAQ resizing. */
.wp-block-accordion-heading,
.page-content .wp-block-accordion-heading {
    margin: 0 !important;
    font-size: 1.15rem;
}

.wp-block-accordion-heading__toggle:hover,
.wp-block-accordion-heading__toggle:focus,
.wp-block-accordion-heading__toggle:active {
    background: none;
    color: inherit;
}

/* Form fields: the same 3px frame as a button, square. */
input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]),
select,
textarea {
    min-height: 44px;
    padding: 0.6rem 0.9rem;
    box-sizing: border-box;
    font: inherit;
    color: var(--mr-text-color);
    background-color: var(--mr-bg-color);
    border: 3px solid var(--mr-accent-color);
    border-radius: 0;
}

/* clip, not hidden: hidden would make the root a scroll container and break the sticky header. */
html {
    overflow-x: clip;
}

/* The menu's scroll lock, with the width of the scrollbar it removes spent so the page can't jump. */
html.mr-menu-open {
    overflow: hidden;
    padding-right: var(--mr-scrollbar-w, 0px);
}

body {
    font-family: var(--mr-font-body);
    font-weight: 400;
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    margin: 0;
    color: var(--mr-text-color);
    background-color: var(--mr-bg-color);
}

/* Containers. */
.page-l {
    width: 100%;
    max-width: var(--mr-content);
    margin: auto;
    padding-inline: var(--mr-gutter);
    box-sizing: border-box;
}

.page-xl {
    width: 100%;
    max-width: var(--mr-wide);
    margin: auto;
    padding-inline: var(--mr-gutter);
    box-sizing: border-box;
}

/* Default WordPress templates. */
.page-main {
    padding-top: clamp(3rem, 6vw, 5.5rem);
    padding-bottom: clamp(3rem, 6vw, 5.5rem);
}

.page-content {
    width: 100%;
    max-width: var(--mr-content);
    margin: 0 auto;
    padding-inline: var(--mr-gutter);
    box-sizing: border-box;
}

.page-content > h1 {
    text-align: center;
    font-size: clamp(2rem, 4vw, 2.75rem);
    line-height: 1.15;
    margin-bottom: 2.5rem;
}

.page-content p,
.page-content li {
    line-height: 1.7;
}

.page-content h2 {
    font-size: 1.5rem;
    margin: 2.5rem 0 1rem;
}

.page-content h3 {
    font-size: 1.15rem;
    margin: 2rem 0 0.75rem;
}

.page-content ul,
.page-content ol {
    margin: 0 0 1.5rem 0;
    padding-left: 1.5rem;
}

.page-content li {
    margin-bottom: 0.5rem;
}

.page-content blockquote {
    margin: 2rem 0;
    padding-left: 1.25rem;
    border-left: 3px solid var(--mr-line-color);
    font-style: italic;
}

.page-content hr {
    border: none;
    border-top: 1px solid var(--mr-line-color);
    margin: 2.5rem 0;
}

/* Header. Scoped to the site header, so a page or post <header> never picks up its sticky blend. */
body > header {
    /* Drives the lockup: the wordmark's rendered height. */
    --mr-logo-h: 1.1rem;
    position: sticky;
    top: 0;
    z-index: 10;
    /* No backdrop: the ink differences against the page beneath, so keep mid-grey out from behind it. */
    mix-blend-mode: difference;
    color: var(--mr-header-ink-color);
}

/* Only the home page keeps the blend; everywhere else text scrolls under it, so it gets a solid fill. */
body:not(.home) > header {
    mix-blend-mode: normal;
    background-color: var(--mr-bg-color);
    color: var(--mr-text-color);
}

/* With the menu open the scrim is the backdrop, so the fill steps aside rather than band across it. */
html.mr-menu-open body:not(.home) > header {
    background-color: transparent;
}

/* Equal outer columns keep the wordmark on the true centre; the left one stays empty. */
body > header .nav {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    padding: 0.5rem;
    -webkit-user-select: none;
    user-select: none;
}

.header-logo {
    grid-column: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0 0.5rem;
}

/* A brand-name heading set as the wordmark: sized to the heading's capitals, coloured by it. */
.heading-wordmark {
    display: block;
    height: 0.72em;
    width: auto;
    aspect-ratio: 1910 / 148;
}

.header-wordmark {
    display: block;
    height: var(--mr-logo-h);
    width: auto;
    aspect-ratio: 1910 / 148;
}

/* Fallback when the wordmark file is missing: the site name set in the heading face. */
.site-logo-text {
    font-family: var(--mr-font-heading);
    font-weight: 700;
    font-size: calc(var(--mr-logo-h) * 0.8);
    line-height: 1;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.header-nav-right {
    grid-column: 3;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    min-width: 0;
}

body > header .navbar-toggler {
    width: 44px;
    height: 44px;
    min-height: 0;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    background: transparent;
    border: none;
    cursor: pointer;
}

/* The global button colours would flip it black on hover and focus, and black differences to nothing. */
body > header .navbar-toggler,
body > header .navbar-toggler:hover,
body > header .navbar-toggler:focus,
body > header .navbar-toggler:active {
    color: inherit;
    background: transparent;
}

/* Menu icon: two bars converge on centre and rotate to +/-45 degrees. */
.menu-icon {
    --icon: 20px;
    position: relative;
    display: block;
    width: var(--icon);
    height: var(--icon);
    overflow: hidden; /* The bars run past the box once rotated. */
}

.menu-bar {
    position: absolute;
    left: 0;
    width: 100%;
    height: calc(var(--icon) * 0.221);
    background-color: currentColor;
    transition: transform 133ms cubic-bezier(0.167, 0.167, 0.833, 0.833);
}

.menu-bar:nth-child(1) {
    top: calc(var(--icon) * 0.1903);
}

.menu-bar:nth-child(2) {
    top: calc(var(--icon) * 0.5887);
}

.navbar-toggler[aria-expanded="true"] .menu-bar:nth-child(1) {
    transform: translateY(calc(var(--icon) * 0.1992)) rotate(45deg);
}

.navbar-toggler[aria-expanded="true"] .menu-bar:nth-child(2) {
    transform: translateY(calc(var(--icon) * -0.1992)) rotate(-45deg);
}

@media (prefers-reduced-motion: reduce) {
    .menu-bar {
        transition: none;
    }
}

body > header a {
    position: relative;
    text-decoration: none;
    color: inherit;
}

/* A black ring differences to nothing, so focus inside the header is drawn in the ink instead. */
body > header a:focus-visible,
body > header button:focus-visible {
    outline-color: var(--mr-header-ink-color);
}

body:not(.home) > header a:focus-visible,
body:not(.home) > header button:focus-visible {
    outline-color: var(--mr-text-color);
}

body > header ul {
    list-style: none;
}

/* Expanded menu. A fixed scrim below the header, so the toggle stays put and doubles as close. */
.site-menu-overlay {
    position: fixed;
    inset: 0;
    z-index: 5;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2.5rem;
    padding: 2rem;
    box-sizing: border-box;
    background-color: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(32px);
    -webkit-backdrop-filter: blur(32px);
    /* Never display:none, which drops the links from the tab order but cannot transition. */
    opacity: 0;
    visibility: hidden;
    transition: opacity 180ms ease-out;
}

.site-menu-overlay.is-open {
    opacity: 1;
    visibility: visible;
}

/* Without the blur the page behind stays legible, so the scrim has to carry it alone. */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    .site-menu-overlay {
        background-color: rgba(255, 255, 255, 0.97);
    }
}

.site-menu-overlay-menu {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    margin: 0;
    padding: 0;
    list-style: none;
    text-align: center;
}

/* The clamp is the whole "large and occupies the screen" effect: ~32px on a phone, 72px wide. */
.site-menu-overlay-menu a {
    /* inline-block, or transform has nothing to scale. */
    display: inline-block;
    font-family: var(--mr-font-heading);
    font-weight: 900;
    font-size: clamp(2rem, 6vw, 4.5rem);
    line-height: 1.1;
    text-transform: uppercase;
    letter-spacing: 0.01em;
    text-decoration: none;
    color: var(--mr-text-color);
    transition: transform 200ms ease;
}

.site-menu-overlay-menu a:hover,
.site-menu-overlay-menu a:focus-visible {
    transform: translateY(-2px) scale(1.04);
}

.site-menu-overlay-menu a:focus-visible {
    outline: 3px solid var(--mr-accent-color);
    outline-offset: 6px;
}

/* After the rules above, or the plain declarations win on source order. */
@media (prefers-reduced-motion: reduce) {
    .site-menu-overlay,
    .site-menu-overlay-menu a {
        transition: none;
    }

    .site-menu-overlay-menu a:hover,
    .site-menu-overlay-menu a:focus-visible {
        transform: none;
    }
}

/* Footer. */
footer {
    text-align: center;
    font-size: 0.8rem;
    background-color: var(--mr-panel-color);
    width: 100%;
    padding: 3rem var(--mr-gutter);
    box-sizing: border-box;
}

.footer-inner {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    max-width: var(--mr-wide);
    margin: 0 auto;
}

/* Capped, or the copyright line runs long enough to wrap the third footer column onto its own row. */
.footer-brand {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    max-width: 26rem;
    margin-bottom: 1.5rem;
}

.footer-logo-link {
    display: inline-flex;
    padding: 0.25rem 0.25rem 0.25rem 0;
    margin-bottom: 0.5rem;
    text-decoration: none;
}

.footer-logo {
    height: 15px;
    width: auto;
    padding: 0;
    margin: 0;
}

.footer-links {
    display: flex;
    flex-wrap: wrap;
    gap: 2rem;
    padding-bottom: 1.5rem;
}

footer .section {
    min-width: 9rem;
}

footer p {
    text-align: left;
}

footer h2 {
    text-align: left;
    /* Sentence case, as on Morrison Sites: the footer stays a 1:1. */
    text-transform: none;
    font-weight: bold;
    font-size: 0.8rem;
    margin: 0 0 0.5rem;
}

footer ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
}

footer li {
    text-align: left;
}

footer a {
    text-decoration: none;
    color: var(--mr-text-color);
}

/* Links inside footer copy need to look like links; the nav lists don't. */
.footer-brand p a {
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 0.15em;
}

/* Browsers italicise <address>; the rest of the footer lists are upright. */
.footer-contact {
    display: flex;
    flex-direction: column;
    font-style: normal;
    text-align: left;
}

.footer-hours {
    margin: 0.75rem 0 0;
    color: var(--mr-muted-color);
}

/* On phones the wordmark sits left, aligned to the page gutter, with the toggle opposite. */
@media (max-width: 767px) {
    body > header .nav {
        grid-template-columns: 1fr auto;
    }

    .header-logo {
        grid-column: 1;
        justify-content: flex-start;
    }

    .header-nav-right {
        grid-column: 2;
    }
}

@media (min-width: 768px) {
    .footer-inner {
        flex-direction: row;
    }

    .footer-brand {
        margin-bottom: 0;
    }
}

/* Search form: used by search.php and the core Search block fallback. */
.search-form {
    width: 100%;
}

.search-form-label {
    display: block;
    font-family: var(--mr-font-heading);
    font-weight: 700;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 0.5rem;
}

.search-form-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    max-width: 34rem;
}

.search-form-input {
    flex: 1 1 12rem;
    min-width: 0;
}

.search-form-submit {
    flex: 0 0 auto;
}

/* 404. */
.error-404 {
    text-align: center;
}

.error-404-code {
    font-family: var(--mr-font-heading);
    font-weight: 900;
    font-size: clamp(4rem, 16vw, 9rem);
    line-height: 0.9;
    letter-spacing: -0.03em;
    color: var(--mr-line-color);
    margin: 0 0 0.5rem;
}

.error-404-lede {
    max-width: 42ch;
    margin: 0 auto 2.5rem;
    color: var(--mr-muted-color);
}

.error-404-links {
    border-top: 1px solid var(--mr-line-color);
    padding-top: 2rem;
}

.error-404-links ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem 1.5rem;
}

.error-404-links a {
    font-family: var(--mr-font-heading);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-size: 0.8rem;
}
