/*
Theme Name: UBC Tracker
Theme URI: https://ubctracker.com
Author: Morrison Sites
Author URI: https://www.morrisonsites.com
Description: A community parody tracker for UBC, donated by Morrison Sites. Morrison Sites house style: square corners, no shadows, Gotham headings, system body type, and a full-screen overlay menu. Night navy with a gold accent.
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: ubctracker
*/

:root {
    /* Core palette. Recolour a site here and in theme.json; nothing else carries a raw colour. */
    --ubct-bg: #07162b;
    --ubct-panel: #0d2240;
    --ubct-line: #2a4a75;
    /* 8.5:1 on bg, 7.5:1 on panel. Small secondary text must stay at or above 4.5:1. */
    --ubct-muted: #a3b3c9;
    --ubct-text: #f3f5f9;
    /* UBC Thunderbird-style gold, standing in for the original tracker's red. 10.8:1 on bg. */
    --ubct-accent: #f2c14e;
    --ubct-accent-hover: #f2c14e;

    /* Semantic aliases: components reference these, never the raw values above. */
    --ubct-bg-color: var(--ubct-bg);
    --ubct-panel-color: var(--ubct-panel);
    --ubct-line-color: var(--ubct-line);
    --ubct-muted-color: var(--ubct-muted);
    --ubct-text-color: var(--ubct-text);
    --ubct-accent-color: var(--ubct-accent);

    /* Translucent layers, kept here so the dark recolour is one edit. */
    --ubct-underline-color: rgba(243, 245, 249, 0.35);
    --ubct-header-wash: rgba(7, 22, 43, 0.45);
    --ubct-overlay-scrim: rgba(7, 22, 43, 0.75);
    --ubct-overlay-scrim-solid: rgba(7, 22, 43, 0.97);
    /* The tracker console: frosted panels over the map, scanlines and tick rules. */
    --ubct-panel-wash: rgba(13, 34, 64, 0.94);
    --ubct-scanline: rgba(7, 22, 43, 0.45);
    --ubct-tick-line: rgba(42, 74, 117, 0.6);

    color-scheme: dark;

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

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

    /* Layout. Mirrored by contentSize and wideSize in theme.json. */
    --ubct-content: 1000px;
    --ubct-wide: 1500px;
    --ubct-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(--ubct-font-heading);
    font-weight: 700;
    margin: 0;
}

p {
    margin: 0 0 1.5rem 0;
}

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

/* Content links. */
a {
    color: var(--ubct-text-color);
    text-decoration-color: var(--ubct-underline-color);
    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(--ubct-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(--ubct-bg-color);
    color: var(--ubct-text-color);
    border: 3px solid var(--ubct-accent-color);
    font-family: var(--ubct-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(--ubct-bg-color);
    color: var(--ubct-text-color);
    border: 3px solid var(--ubct-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(--ubct-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(--ubct-accent-color);
    color: var(--ubct-bg-color);
}

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

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

/* Gutenberg core Button block: filled, and its Outline style is the outlined .btn. */
.wp-block-button__link {
    background-color: var(--ubct-accent-color);
    color: var(--ubct-bg-color);
    border: 3px solid var(--ubct-accent-color);
    border-radius: 0;
    padding: 0.75rem 1.75rem;
    min-height: 44px;
    box-sizing: border-box;
    font-family: var(--ubct-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(--ubct-bg-color);
    color: var(--ubct-text-color);
    border-color: var(--ubct-accent-hover);
}

.is-style-outline > .wp-block-button__link {
    background-color: var(--ubct-bg-color);
    color: var(--ubct-text-color);
}

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

/* Buttons wrap below a 407px viewport, so they go full width once stacked. */
@media (max-width: 26rem) {
    .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(--ubct-text-color);
    background-color: var(--ubct-bg-color);
    border: 3px solid var(--ubct-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;
    /* Stops Safari's double-tap page zoom on quick repeat taps; pinch-to-zoom still works. */
    touch-action: manipulation;
}

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

body {
    font-family: var(--ubct-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(--ubct-text-color);
    background-color: var(--ubct-bg-color);
}

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

.page-xl {
    width: 100%;
    max-width: var(--ubct-wide);
    margin: auto;
    padding-inline: var(--ubct-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(--ubct-content);
    margin: 0 auto;
    padding-inline: var(--ubct-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(--ubct-line-color);
    font-style: italic;
}

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

/* Header. */
header {
    /* The logo's height in the header bar. */
    --ubct-logo-h: 2rem;
    position: sticky;
    top: 0;
    z-index: 10;
}

header .nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem;
    -webkit-user-select: none;
    user-select: none;
}

.header-logo {
    display: flex;
    align-items: center;
    min-height: 44px;
    margin-left: 0.25rem;
}

.header-logo .site-logo-img {
    display: block;
    height: var(--ubct-logo-h);
    width: auto;
}

/* Pixel art stays crisp when the browser scales it. */
.ubct-pixel {
    image-rendering: pixelated;
}

.header-nav-right {
    display: flex;
    align-items: center;
}

#header-nav {
    display: none;
    margin: 0 1rem;
    padding: 0;
}

#header-nav li {
    margin: 0 0.6rem;
}

/* System face, as on morrisonsites.com; 600 exists there, unlike in Gotham. */
#header-nav a {
    font-weight: 600;
}

/* The overlay carries the same links, so the inline nav steps aside rather than sitting under the blur. */
body.ubct-menu-open #header-nav {
    display: none;
}

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

/* 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: var(--ubct-text-color);
    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;
    }
}

/* Frosted strip behind the header; the mask fades the blur out so it has no hard bottom edge. */
header .backdrop {
    position: absolute;
    inset: 0;
    height: 200%;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    background-color: var(--ubct-header-wash);
    mask-image: linear-gradient(to bottom, black 0% 50%, transparent 50% 100%);
    -webkit-mask-image: linear-gradient(to bottom, black 0% 50%, transparent 50% 100%);
}

/* The overlay's own blur runs continuously behind the header, so the header drops its own. */
body.ubct-menu-open header .backdrop {
    display: none;
}

header a {
    position: relative;
    text-decoration: none;
    color: var(--ubct-text-color);
}

header ul {
    list-style: none;
}

header ul li {
    color: var(--ubct-text-color);
}

/* 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: var(--ubct-overlay-scrim);
    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;
    /* visibility waits out the fade on close, so the menu fades both ways instead of snapping shut. */
    transition: opacity 180ms ease-out, visibility 0s linear 180ms;
}

.site-menu-overlay.is-open {
    opacity: 1;
    visibility: visible;
    transition-delay: 0s;
}

/* 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: var(--ubct-overlay-scrim-solid);
    }
}

.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(--ubct-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(--ubct-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(--ubct-accent-color);
    outline-offset: 6px;
}

/* Hidden below 768px, where the menu links already fill the panel on their own. */
.site-menu-overlay-contact {
    display: none;
}

@media (min-width: 768px) {
    .site-menu-overlay-contact {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        justify-content: center;
        gap: 0.6rem 1.75rem;
        font-family: var(--ubct-font-heading);
        font-weight: 700;
        font-size: 0.8rem;
        font-style: normal;
        text-transform: uppercase;
        letter-spacing: 0.08em;
    }

    .site-menu-overlay-contact a {
        color: var(--ubct-text-color);
        text-decoration: none;
    }
}

/* 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(--ubct-panel-color);
    width: 100%;
    padding: 3rem var(--ubct-gutter);
    box-sizing: border-box;
}

.footer-inner {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    max-width: var(--ubct-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-link .site-logo-img {
    display: block;
    height: 2.25rem;
    width: auto;
}

.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;
    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(--ubct-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;
}

/* The parody and non-affiliation line: always visible, never smaller than the copyright. */
.footer-disclaimer {
    margin: 0;
    color: var(--ubct-muted-color);
}

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

/* The logo steps down on the narrowest phones, so the menu button keeps its room. */
@media (max-width: 23.375rem) {
    header {
        --ubct-logo-h: 1.6rem;
    }
}

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

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

    #header-nav {
        display: flex;
    }
}

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

.search-form-label {
    display: block;
    font-family: var(--ubct-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(--ubct-font-heading);
    font-weight: 900;
    font-size: clamp(4rem, 16vw, 9rem);
    line-height: 0.9;
    letter-spacing: -0.03em;
    color: var(--ubct-line-color);
    margin: 0 0 0.5rem;
}

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

.error-404-links {
    border-top: 1px solid var(--ubct-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(--ubct-font-heading);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-size: 0.8rem;
}
