/* ==========================================================================
   mattbegent.co.uk
   ========================================================================== */


/* --------------------------------------------------------------------------
   Variables
   -------------------------------------------------------------------------- */

:root {
    color-scheme: light;
    --bg: #ffffff;
    --panel: #f4f4f5;
    --edge: #d7d8db;
    --fg: #0b0b0c;
    --fg-2: #55565b;
    --red: #b42020;
    --red-lit: #b42020;
    --on-red: #ffffff;
    --grid: rgba(0, 0, 0, 0.05);
    --font-body: Archivo, system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, monospace;
}

/* Dark theme, chosen explicitly via the toggle */
:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0b0c0e;
    --panel: #131519;
    --edge: #262a31;
    --fg: #e7e9ec;
    --fg-2: #9aa1ab;
    --red-lit: #f2604f;
    --grid: rgba(255, 255, 255, 0.045);
}

/* Dark theme, inherited from the OS unless the toggle forces light */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;
        --bg: #0b0c0e;
        --panel: #131519;
        --edge: #262a31;
        --fg: #e7e9ec;
        --fg-2: #9aa1ab;
        --red-lit: #f2604f;
        --grid: rgba(255, 255, 255, 0.045);
    }
}


/* --------------------------------------------------------------------------
   Base
   -------------------------------------------------------------------------- */

html {
    box-sizing: border-box;
    scroll-behavior: smooth;
}

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

body {
    margin: 0;
    background-color: var(--bg);
    background-image:
        linear-gradient(var(--grid) 1px, transparent 1px),
        linear-gradient(90deg, var(--grid) 1px, transparent 1px);
    background-size: 44px 44px;
    color: var(--fg);
    font-family: var(--font-body);
    font-size: 1.03125rem;
    line-height: 1.6;
    text-wrap: pretty;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--red-lit);
    text-underline-offset: 3px;
}

a:hover,
a:focus {
    color: var(--fg);
}

:focus-visible {
    outline: 3px solid var(--red-lit);
    outline-offset: 3px;
}

::selection {
    background-color: var(--red);
    color: var(--on-red);
}

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


/* --------------------------------------------------------------------------
   Layout
   -------------------------------------------------------------------------- */

.l-shell {
    max-width: 1120px;
    margin: 0 auto;
    padding: 0 clamp(16px, 4vw, 36px);
}

.l-split {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(290px, 100%), 1fr));
    gap: clamp(24px, 4vw, 48px);
    align-items: center;
}

.l-split--top {
    align-items: start;
    gap: 24px 48px;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.l-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(258px, 1fr));
    gap: 18px;
}


/* --------------------------------------------------------------------------
   Utilities
   -------------------------------------------------------------------------- */

.u-mono {
    font-family: var(--font-mono);
}

.u-visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    border: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}


/* --------------------------------------------------------------------------
   Skip link
   -------------------------------------------------------------------------- */

.c-skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    z-index: 40;
    padding: 14px 20px;
    background-color: var(--red);
    color: var(--on-red);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    text-decoration: none;
}

.c-skip-link:focus {
    position: fixed;
    left: 12px;
    top: 12px;
    color: var(--on-red);
}


/* --------------------------------------------------------------------------
   Header
   -------------------------------------------------------------------------- */

.c-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px 20px;
    padding: 16px 0 14px;
    border-bottom: 1px solid var(--edge);
}

.c-header__controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 6px;
}

/* Brand */

.c-brand {
    display: flex;
    align-items: center;
    gap: 11px;
}

.c-brand__mark {
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border-radius: 7px;
    background-color: var(--red);
    color: var(--on-red);
    font-weight: 800;
    font-size: 0.8125rem;
    letter-spacing: -0.04em;
    line-height: 1;
}

.c-brand__path {
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    font-weight: 500;
}

.c-brand__punctuation {
    color: var(--fg-2);
}

/* Navigation */

.c-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 2px 4px;
    font-family: var(--font-mono);
    font-size: 0.75rem;
}

.c-nav__link {
    display: flex;
    align-items: center;
    min-height: 44px;
    padding: 0 9px;
    color: var(--fg);
    text-decoration: none;
}

.c-nav__link:hover,
.c-nav__link:focus {
    color: var(--red-lit);
}

/* Theme toggle */

.c-theme-toggle {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 38px;
    min-width: 38px;
    padding: 0 10px;
    border: 1px solid var(--fg-2);
    border-radius: 4px;
    background-color: transparent;
    color: var(--fg-2);
    font-family: var(--font-mono);
    font-size: 0.6875rem;
    cursor: pointer;
}

.c-theme-toggle:hover,
.c-theme-toggle:focus {
    border-color: var(--red-lit);
    color: var(--fg);
}

.c-theme-toggle__dial {
    width: 11px;
    height: 11px;
    border: 1px solid currentColor;
    border-radius: 50%;
    background: linear-gradient(90deg, currentColor 0 50%, transparent 50% 100%);
}

/* On small screens the label leaves the screen but stays in the accessible name */
@media (max-width: 640px) {
    .c-theme-toggle__label {
        position: absolute;
        width: 1px;
        height: 1px;
        margin: -1px;
        padding: 0;
        border: 0;
        overflow: hidden;
        clip-path: inset(50%);
        white-space: nowrap;
    }
}


/* --------------------------------------------------------------------------
   Sections
   -------------------------------------------------------------------------- */

.c-section {
    padding: clamp(32px, 5vw, 56px) 0;
    border-top: 1px solid var(--edge);
}

.c-section--flush {
    border-top: 0;
}

.c-section__prompt {
    margin: 0 0 24px;
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    color: var(--fg-2);
}

.c-section__prompt--tight {
    margin-bottom: 10px;
}

.c-section__title {
    margin: 0;
    font-weight: 800;
    font-size: clamp(1.75rem, 4vw, 2.75rem);
    line-height: 1.04;
    letter-spacing: -0.032em;
}

.c-section__title--spaced {
    margin-bottom: 26px;
}

.c-section__title--sm {
    margin-bottom: 14px;
    font-weight: 700;
    font-size: clamp(1.5rem, 3.4vw, 2.375rem);
    letter-spacing: -0.03em;
}

.c-section__title--lg {
    font-size: clamp(1.875rem, 5vw, 3.5rem);
    line-height: 1;
    letter-spacing: -0.035em;
}

.c-section__label {
    margin: 0 0 14px;
    font-family: var(--font-mono);
    font-weight: 500;
    font-size: 0.75rem;
    color: var(--fg-2);
}


/* --------------------------------------------------------------------------
   Prose
   -------------------------------------------------------------------------- */

.c-prose {
    max-width: 52ch;
    margin: 0;
    color: var(--fg-2);
}

.c-prose + .c-prose {
    margin-top: 16px;
}

.c-prose--wide {
    max-width: 62ch;
}

.c-prose__note {
    margin: 18px 0 0;
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    line-height: 24px;
}

.c-prose__note-link {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
}


/* --------------------------------------------------------------------------
   Hero
   -------------------------------------------------------------------------- */

.c-hero {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(290px, 100%), 1fr));
    gap: clamp(28px, 4vw, 56px);
    align-items: center;
    padding: clamp(34px, 6vw, 76px) 0 clamp(28px, 4vw, 48px);
}

.c-hero__title {
    margin: 0;
    font-weight: 800;
    font-size: clamp(2.375rem, 6.6vw, 4.75rem);
    line-height: 0.98;
    letter-spacing: -0.038em;
}

.c-hero__intro {
    max-width: 50ch;
    margin: clamp(20px, 3vw, 30px) 0 0;
    font-size: clamp(1.03125rem, 1.6vw, 1.1875rem);
    line-height: 1.55;
    color: var(--fg-2);
}

.c-hero__emphasis {
    color: var(--fg);
    font-weight: 600;
}

.c-hero__caret {
    display: inline-block;
    width: 8px;
    height: 15px;
    margin-left: 8px;
    vertical-align: -2px;
    background-color: var(--red-lit);
    /* Blinks a few times then settles, so it stops well within five seconds */
    animation: caret-blink 1.1s steps(1, end) 4;
}

@keyframes caret-blink {
    0%,
    49% {
        opacity: 1;
    }

    50%,
    100% {
        opacity: 0;
    }
}


/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */

.c-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: clamp(24px, 3.5vw, 34px);
}

.c-btn {
    display: inline-flex;
    align-items: center;
    min-height: 48px;
    padding: 0 22px;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 0.84375rem;
    font-weight: 500;
    text-decoration: none;
}

.c-btn--primary {
    border: 1px solid var(--red-lit);
    background-color: var(--red);
    color: var(--on-red);
}

.c-btn--primary:hover,
.c-btn--primary:focus {
    background-color: transparent;
    color: var(--red-lit);
}

.c-btn--ghost {
    border: 1px solid var(--fg-2);
    background-color: transparent;
    color: var(--fg);
}

.c-btn--ghost:hover,
.c-btn--ghost:focus {
    border-color: var(--red-lit);
    color: var(--red-lit);
}


/* --------------------------------------------------------------------------
   Portrait
   -------------------------------------------------------------------------- */

.c-portrait {
    max-width: 320px;
    margin: 0;
    justify-self: center;
}

.c-portrait__frame {
    border: 1px solid var(--edge);
    border-radius: 6px;
    background-color: var(--panel);
    box-shadow: 8px 8px 0 var(--red);
    overflow: hidden;
}

.c-portrait__image {
    display: block;
    width: 100%;
}

.c-portrait__caption {
    margin-top: 10px;
    font-family: var(--font-mono);
    font-size: 0.6875rem;
    color: var(--fg-2);
}


/* --------------------------------------------------------------------------
   Credentials (facts strip)
   -------------------------------------------------------------------------- */

.c-facts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(158px, 1fr));
    gap: 1px;
    margin: 0;
    border: 1px solid var(--edge);
    border-radius: 4px;
    background-color: var(--edge);
    font-family: var(--font-mono);
    overflow: hidden;
}

.c-facts__item {
    padding: 14px 16px;
    background-color: var(--bg);
}

.c-facts__term {
    margin: 0;
    font-size: 0.75rem;
    color: var(--fg-2);
}

.c-facts__definition {
    margin: 2px 0 0;
    font-size: 0.875rem;
    color: var(--fg);
}


/* --------------------------------------------------------------------------
   Cards
   -------------------------------------------------------------------------- */

.c-card {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--edge);
    border-radius: 6px;
    background-color: var(--panel);
    overflow: hidden;
    transition:
        transform 0.16s ease,
        box-shadow 0.16s ease,
        border-color 0.16s ease;
}

.c-card:hover,
.c-card:focus-within {
    transform: translate(-3px, -3px);
    border-color: var(--red-lit);
    box-shadow: 5px 5px 0 var(--red-lit);
}

.c-card__shot {
    aspect-ratio: 16 / 10;
    border-bottom: 1px solid var(--edge);
    background-color: var(--bg);
    overflow: hidden;
}

.c-card__shot--empty {
    display: grid;
    place-items: center;
    font-family: var(--font-mono);
    font-size: 0.6875rem;
    color: var(--fg-2);
}

.c-card__image {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.c-card__content {
    display: flex;
    flex-direction: column;
    flex: 1;
    gap: 12px;
    padding: 20px;
}

.c-card__kicker {
    margin: 0;
    font-family: var(--font-mono);
    font-size: 0.6875rem;
    color: var(--fg-2);
}

.c-card__label {
    margin: 0;
    font-family: var(--font-mono);
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--red-lit);
}

.c-card__title {
    margin: 0;
    font-weight: 700;
    font-size: 1.4375rem;
    letter-spacing: -0.028em;
}

.c-card__body {
    margin: 0;
    font-size: 0.96875rem;
    color: var(--fg-2);
}

.c-card__tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0;
    font-family: var(--font-mono);
    font-size: 0.6875rem;
}

.c-card__links {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 16px;
    margin: auto 0 0;
    padding-top: 6px;
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    line-height: 24px;
}


/* --------------------------------------------------------------------------
   Tags
   -------------------------------------------------------------------------- */

.c-tag {
    padding: 4px 8px;
    border-radius: 3px;
    background-color: var(--red);
    color: var(--on-red);
}

.c-tag--quiet {
    padding: 4px 8px;
    border: 1px solid var(--edge);
    border-radius: 3px;
    color: var(--fg-2);
}

.c-tag--outline {
    display: inline-flex;
    padding: 4px 8px;
    border: 1px solid var(--red-lit);
    border-radius: 3px;
    font-family: var(--font-mono);
    font-size: 0.6875rem;
    color: var(--red-lit);
}


/* --------------------------------------------------------------------------
   Chips
   -------------------------------------------------------------------------- */

.c-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 10px;
    margin: 0;
    padding: 0;
    list-style: none;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--fg-2);
}

.c-chips__item {
    padding: 5px 8px;
    border: 1px solid var(--edge);
    border-radius: 3px;
}


/* --------------------------------------------------------------------------
   Empire Boy
   -------------------------------------------------------------------------- */

.c-empire__badge {
    margin: 0 0 12px;
}

.c-empire__strapline {
    margin: 12px 0 0;
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    color: var(--fg-2);
}

.c-empire__body {
    max-width: 48ch;
    margin: 16px 0 0;
    color: var(--fg-2);
}

.c-empire__note {
    margin: 14px 0 0;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--fg-2);
}

/* Game Boy illustration */

.c-gameboy {
    width: 100%;
    max-width: 300px;
    padding: 16px 16px 26px;
    border: 1px solid var(--edge);
    border-radius: 14px 14px 34px 14px;
    background-color: var(--panel);
    box-shadow: 8px 8px 0 var(--red);
    justify-self: center;
}

.c-gameboy__screen {
    display: grid;
    place-items: center;
    aspect-ratio: 10 / 9;
    border: 1px solid var(--edge);
    border-radius: 5px;
    background-color: var(--bg);
    font-family: var(--font-mono);
    font-size: 0.6875rem;
    color: var(--fg-2);
    overflow: hidden;
}

.c-gameboy__image {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    image-rendering: pixelated;
}

.c-gameboy__controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-top: 20px;
}

.c-gameboy__dpad {
    display: grid;
    grid-template-columns: repeat(3, 12px);
    grid-template-rows: repeat(3, 12px);
    gap: 1px;
}

.c-gameboy__dpad span {
    border-radius: 2px;
}

/* The four arms of the d-pad */
.c-gameboy__dpad span:nth-child(2),
.c-gameboy__dpad span:nth-child(4),
.c-gameboy__dpad span:nth-child(6),
.c-gameboy__dpad span:nth-child(8) {
    background-color: var(--edge);
}

/* The centre of the d-pad */
.c-gameboy__dpad span:nth-child(5) {
    background-color: var(--fg-2);
}

.c-gameboy__buttons {
    display: flex;
    gap: 10px;
}

.c-gameboy__buttons span {
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background-color: var(--red);
}


/* --------------------------------------------------------------------------
   Television (video embed)
   -------------------------------------------------------------------------- */

.c-tv {
    width: 100%;
    max-width: 420px;
    justify-self: center;
}

.c-tv__shell {
    padding: 14px 14px 0;
    border: 1px solid var(--edge);
    border-radius: 16px 16px 12px 12px;
    background-color: var(--panel);
    box-shadow: 8px 8px 0 var(--red);
}

.c-tv__screen {
    position: relative;
    aspect-ratio: 16 / 9;
    border: 1px solid var(--edge);
    border-radius: 10px;
    background-color: #000;
    overflow: hidden;
}

.c-tv__frame {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

.c-tv__panel {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 4px 14px;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--fg-2);
}

.c-tv__dials {
    display: flex;
    align-items: center;
    gap: 9px;
}

.c-tv__dials span:nth-child(-n + 2) {
    width: 13px;
    height: 13px;
    border: 1px solid var(--edge);
    border-radius: 50%;
}

.c-tv__dials span:last-child {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background-color: var(--red);
}

.c-tv__feet {
    display: flex;
    justify-content: space-between;
    padding: 0 34px;
}

.c-tv__feet span {
    width: 12px;
    height: 14px;
    border: 1px solid var(--edge);
    border-top: 0;
    border-radius: 0 0 4px 4px;
    background-color: var(--panel);
}


/* Click-to-load video facade. The iframe is only created once it is activated. */

.c-video {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    color: var(--on-red);
    text-decoration: none;
}

.c-video:focus-visible {
    outline-offset: -4px;
}

.c-video__poster {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.c-video__play {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    padding: 0 18px;
    border-radius: 4px;
    background-color: var(--red);
    color: var(--on-red);
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.35);
}

.c-video:hover .c-video__play,
.c-video:focus-visible .c-video__play {
    background-color: var(--on-red);
    color: var(--red);
}


/* --------------------------------------------------------------------------
   Contact rows
   -------------------------------------------------------------------------- */

.c-rows {
    max-width: 560px;
    margin: 26px 0 0;
    padding: 0;
    list-style: none;
    border-top: 1px solid var(--edge);
    font-family: var(--font-mono);
}

.c-rows__item {
    border-bottom: 1px solid var(--edge);
}

.c-rows__link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 56px;
    padding: 0 2px;
    color: var(--fg);
    font-size: 0.875rem;
    text-decoration: none;
}

.c-rows__link:hover,
.c-rows__link:focus {
    color: var(--red-lit);
}

.c-rows__arrow {
    color: var(--red-lit);
}


/* --------------------------------------------------------------------------
   Footer
   -------------------------------------------------------------------------- */

.c-footer {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 8px 20px;
    padding: 20px 0 40px;
    border-top: 1px solid var(--edge);
    font-family: var(--font-mono);
    font-size: 0.71875rem;
    color: var(--fg-2);
}

.c-footer__copyright {
    font-size: 0.71875rem;
}


/* --------------------------------------------------------------------------
   Reduced motion
   -------------------------------------------------------------------------- */

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

    .c-hero__caret {
        animation: none;
    }

    .c-card {
        transition: none;
    }

    .c-card:hover,
    .c-card:focus-within {
        transform: none;
        box-shadow: none;
    }
}
