:root {
    --body: #08090B;
    --bodyalt: #f2eff7;
    --dark: #000;
    --light: #fff;
    --primary: #d61818;

    /* Theme switches */
    --bg: var(--body);
    --fg: var(--light);
    --panel: rgb(255 255 255 / .07);
}

:root[data-theme="light"] {
    --bg: var(--bodyalt);
    --fg: var(--dark);
    --panel: rgb(0 0 0 / .06);
}

@font-face {
    font-family: Heading;
    src: url(fonts/morganite/morganite-bold.ttf)
}

@font-face {
    font-family: Header;
    src: url(fonts/mancunian.otf);
}

@font-face {
    font-family: Body;
    src: url(fonts/mancunian-light.otf);
}

img { max-width: 100%; }

body {
    background-color: var(--bg);
    background-image: url(media/bbburst.svg);
    background-size: cover;
    background-repeat: no-repeat;
    background-attachment: fixed;
    color: var(--fg);
    margin: 0;
    overflow-x: hidden;
    transition: background-color .4s ease, color .4s ease;
}


html { 
    scrollbar-width: none; 
    scroll-behavior: smooth;
}
html::-webkit-scrollbar { 
    display: none; 
}

.scroll-thumb {
    position: fixed;
    top: 0;
    right: 4px;
    width: 8px;
    height: 100px;
    border-radius: 10px;
    background: var(--fg);
    opacity: .7;
    z-index: 20;
    cursor: grab;
    touch-action: none;
    transition: opacity .2s ease, background-color .4s ease;
}

.scroll-thumb:hover,
.scroll-thumb.dragging { opacity: 1; }
.scroll-thumb.dragging { cursor: grabbing; }

/* ---------- Header ---------- */
.site-header {
    position: sticky;
    top: 0;
    z-index: 10;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    padding: 20px clamp(16px, 5vw, 72px);
    pointer-events: none;
    max-width: 1250px;
    margin: auto;
    transition: transform .35s ease;
}

.site-header.is-hidden { transform: translateY(-100%); }

.site-header > * { pointer-events: auto; }

.logo {
    position: relative;
    width: 64px;
    height: 64px;
    padding: 0;
    border: 0;
    background: none;
    cursor: pointer;
    justify-self: start;
}
 
.logo-main,
.logo-alt {
    position: absolute;
    inset: 0;
    transition: opacity .25s ease, transform .35s cubic-bezier(.3, 1.4, .5, 1);
}
 
.logo img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
}

.logo::before {
    content: "";
    position: absolute;
    inset: -2px;
    border-radius: 14px;
    clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
    background: #989cd82f;
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
    pointer-events: none;
}

/* Normal logo files: white in dark mode, black in light mode */
.logo .for-light { display: none; }
:root[data-theme="light"] .logo .for-dark  { display: none; }
:root[data-theme="light"] .logo .for-light { display: block; }
 
/* About-section hover files stay hidden until the logo is over About */
.logo .about-dark,
.logo .about-light { display: none; }
 
.logo .logo-alt { opacity: 0; transform: rotate(-12deg) scale(.92); }
 
.logo:hover .logo-main,
.logo:focus-visible .logo-main { opacity: 0; transform: rotate(12deg) scale(.92); }
 
.logo:hover .logo-alt,
.logo:focus-visible .logo-alt { opacity: 1; transform: none; }
 
.logo:focus-visible { outline: 2px solid var(--light); outline-offset: 6px; border-radius: 8px; }
 
/* ---------- Logo while over the About section ---------- */
 
/* Default logo flips colours: black in dark mode, white in light mode */
.site-header.over-about .logo-main .for-dark  { display: none; }
.site-header.over-about .logo-main .for-light { display: block; }
:root[data-theme="light"] .site-header.over-about .logo-main .for-dark  { display: block; }
:root[data-theme="light"] .site-header.over-about .logo-main .for-light { display: none; }
 
/* Hover logo drops the red outline files and uses the line-coloured ones */
.logo .over-about-dark,
.logo .over-about-light { display: none; }
 
.site-header.over-about .logo-alt .over-about-light { display: block; }
:root[data-theme="light"] .site-header.over-about .logo-alt .over-about-light { display: none; }
:root[data-theme="light"] .site-header.over-about .logo-alt .over-about-dark  { display: block; }

/* ---------- Pill nav ---------- */
.nav {
    position: relative;
    display: flex;
    gap: 2px;
    padding: 2.5px;
    border-radius: 999px;
    background: #989cd82f;
    height: 25px;
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid var(--fg);
    backdrop-filter: blur(14px);
    transition: background-color .4s ease, border-color .4s ease;
}

/* Wrapper around the links: invisible on desktop, becomes the dropdown on phones */
.nav-links {
    display: flex;
    gap: 2px;
}

/* Dropdown button: phones only */
.nav-toggle { display: none; }

.nav a {
    position: relative;
    z-index: 1;
    color: var(--fg);
    text-decoration: none;
    font-family: Header;
    font-size: .8rem;
    letter-spacing: .2rem;
    padding: 7px clamp(10px, 1.6vw, 18px);
    border-radius: 999px;
    outline: none;
    transition: color .25s ease;
}

.nav a.is-active { color: var(--bg); }

/* The sliding fill */
.nav-pill {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 0;
    border-radius: 999px;
    background: var(--fg);
    opacity: 0;
    pointer-events: none;
    transition: transform .35s cubic-bezier(.4, 0, .2, 1),
                width .35s cubic-bezier(.4, 0, .2, 1),
                height .35s cubic-bezier(.4, 0, .2, 1),
                opacity .2s ease,
                background-color .4s ease;
}

/* Pill nav flips colours while over the About section */
.site-header.over-about .nav {
    --fg: var(--dark);
    --bg: var(--light);
}

:root[data-theme="light"] .site-header.over-about .nav {
    --fg: var(--light);
    --bg: var(--dark);
}

/* ---------- Hero ---------- */
:root {
    --header-h: 104px;
    --hero-bleed: max(180px, 12.5vw);
}

.hero {
    position: relative;
    z-index: 0;
    width: 100%;
    height: max(100svh, 700px);
    margin: calc(var(--header-h) * -1) 0 calc(var(--hero-bleed) * -1);
    box-sizing: border-box;
    border-radius: 0;
    overflow: hidden;
    display: grid;
    place-items: center;
}

.hero img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
}

.hero picture {
    display: block;
    width: 100%;
    height: 100%;
}

.hero::after {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 180px;
    background: linear-gradient(to bottom, rgb(0 0 0 / .55), transparent);
    pointer-events: none;
}

/* ---------- Dividers ---------- */
.line-divider {
    width: 100%;
    max-width: 1400px;
    height: 2px;
    border: 0 none;
    margin: auto;
    background-color: var(--fg);
    align-self: center;
    margin-top: 30px;
    margin-bottom: 50px;
    border-radius: .5px;
    transition: background-color .4s ease;
}

.section-heading {
    position: relative;
    z-index: 2;
    width: 100%;
    max-width: 1500px;
    margin: 0 auto clamp(24px, 5vw, 60px);
    padding-top: clamp(30px, 4vw, 60px);
    box-sizing: border-box;
}

.section-heading .line-divider {
    width: calc(100% - 32px);
    max-width: none;
    margin: 0 auto;
}

.section-heading h1 {
    margin: 0 0 0 clamp(8px, 2.5vw, 40px);
    padding-top: .2em;
    font-family: Heading;
    font-size: 6.5rem;
    letter-spacing: .06em;
    line-height: 1;
}

/* ---------- Wave transitions ---------- */
.transition {
    position: relative;
    z-index: 1;
}

.transition img {
    width: 100%;
    display: block;
}

.transition .top {
    margin-top: min(-110px, -7.64vw);   /* scales with the wave image on wide / zoomed-out screens */
}

.transition .bottom {
    margin-top: -5px;
}

/* ---------- About ---------- */
.aboutsection {
    position: relative;
    background-color: var(--primary);
    margin: auto;
    min-height: 0;
    height: auto;
    padding-bottom: 60px;
    margin-top: -40px;
}

.aboutsection > .line-divider {
    width: min(1200px, 100% - 32px);
    margin: auto;  
    margin-top: 0;
}

.contentbox {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: clamp(30px, 8vw, 150px);
    width: min(1200px, 100% - 40px);
    margin: auto;
    margin-top: -20px;
}

.contentwrapper {
    flex: 0 1 550px;
    max-width: 100%;
}

.contentwrapper img {
    width: 100%;
    border-radius: 8px;
    object-fit: contain;
    height: auto;
    aspect-ratio: 2 / 3;
    margin: 0;
}

.contenttext {
    flex: 1 1 0;
    min-width: 0;
    max-width: 600px;
    color: var(--fg);
    cursor: default;
    transition: color 0.4s ease;
}

.contenttext h1 {
    margin-bottom: 0;
    font-size: clamp(1.8rem, 4.5vw, 3.5rem);
    font-family: Header;
    letter-spacing: .25rem;
    font-weight: 300;
}

.contenttext p {
    line-height: 1.6;
    margin-top: 30px;
    font-family: Body;
    font-size: clamp(1.05rem, 2vw, 1.75rem);
}

.contenttext1 {
    position: relative;
    z-index: 2;
    max-width: 1100px;
    width: calc(100% - 80px);
    margin: 40px auto 0;
    padding: 20px 0;
    box-sizing: border-box;
    color: var(--fg);
}

.contenttext1 h1 {
    font-size: clamp(1.8rem, 4vw, 2.25rem);
    font-weight: 300;
    font-family: Header;
    text-align: center;
}

.contenttext1 p {
    font-size: clamp(1.05rem, 2vw, 1.5rem);
    line-height: 1.6;
    margin: auto;
    width: 100%;
    max-width: 700px;
    font-family: Body;
    text-align: center;
}

/* ---------- Services ---------- */
.servicessection {
    position: relative;
    margin: auto;
    min-height: 0;
    height: auto;
    padding-bottom: clamp(30px, 5vw, 60px);
    margin-top: 0;
}

.contentbox2 {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: clamp(30px, 8vw, 200px);
    width: min(1100px, 100% - 40px);
    margin: auto;
    padding: 20px 0 clamp(30px, 6vw, 60px);
}

.contenttext2 {
    flex: 1;
    max-width: 450px;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    color: var(--fg);
    cursor: default;
    transition: color 0.4s ease;
}

.contenttext2 h1 {
    margin-bottom: 0;
    font-size: clamp(1.5rem, 3vw, 2rem);
    font-family: Header;
    font-weight: 300;    
}

.contenttext2 p {
    line-height: 1.6;
    margin-top: 30px;
    font-family: Body;
    font-size: clamp(1.05rem, 1.8vw, 1.25rem);
}

.servicessection > .line-divider {
    width: min(1200px, 100% - 32px);
    margin: auto;  
    margin-top: 0;
}

/* ---------- Work ---------- */
.worksection {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 25px;
    width: min(1100px, 100% - 80px);
    margin: 60px auto 120px;
    font-family: Body;
}

.workcard {
    display: block;
    color: var(--fg);
    text-decoration: none;
    text-align: center;
    transition: transform .3s ease, color .4s ease;
}

.workcard img {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    border-radius: 5px;
    background: var(--panel);
    display: block;
}

.workcard p {
    font-size: 1.25rem;
    line-height: 1.6;
    margin-top: 16px;
}

.workcard .line-divider {
    width: 100%;
    max-width: 400px;
    margin: 20px auto;
}

.workcard img:hover,
.workcard:focus-visible { transform: scale(0.98); transition: 0.3s ease; }

/* ---------- Skills ---------- */
.skillssection {
    position: relative;
    background-color: var(--primary);
    margin: auto;
    margin-top: -25px;
    margin-bottom: -10px;
    padding: 0 0 clamp(40px, 6vw, 80px);
    height: auto;
    box-sizing: border-box;
    display: block;
    color: var(--fg);
    transition: 0.3s ease;
}

.skillsgrid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: clamp(40px, 6vw, 80px);
    width: min(1200px, 100% - 40px);
    margin: 0 auto;
}

.skillgroup {
    display: flex;
    flex-direction: column;
}

/* Bottom divider always sits at the bottom, so both groups line up */
.skillgroup > .line-divider:last-child { margin-top: auto; }

.skillgroup h1 {
    margin: 0;
    font-size: 2rem;
    font-family: header;
    font-weight: 300;
}

.skillgroup .line-divider {
    width: 100%;
    max-width: 100%;
    margin: 20px 0;
    height: 1px;
    background-color: var(--fg);
}

.chart {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-rows: 320px auto;
    column-gap: 24px;
    margin: 30px 0;
}

.chart-axis {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
}

.chart-axis li {
    flex: 1;
    display: flex;
    align-items: center;
    font-family: Header;
    justify-content: flex-end;
    font-size: 1.1rem;
    font-weight: 300;
}

.chart-bars,
.chart-names {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    justify-items: center;
    font-family: Header;
}

.chart-bars {
    grid-template-rows: 100%;
    align-items: end;
}

.bar {
    width: 28px;
    height: calc((var(--level) - 0.5) * 20%);
    border-radius: 5px;
    background: var(--fg);
    transition: 0.3s ease;
}

.chart-names {
    grid-column: 2;
    margin-top: 14px;
    min-height: 2.6em;          /* room for a two-line label, so both charts end at the same height */
    align-items: start;
    font-size: clamp(.6rem, 1.6vw, .95rem);
    text-align: center;
}

.chart-names span {
    min-width: 0;
    overflow-wrap: anywhere;
}

/* ---------- Contact ---------- */
.section-heading h1 + .line-divider { margin-top: 20px; }

.contactsection {
    position: relative;
    margin-top: -4vw;            /* tucks under the wave so no dark gap shows between them */
    padding-top: 4vw;
    padding-bottom: clamp(30px, 5vw, 60px);
}

/* Solid background hides the body's burst pattern from here down */
.contactsection,
.site-footer {
    background-color: var(--bg);
    transition: background-color .4s ease;
}

.contactform {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 30px clamp(30px, 6vw, 80px);
    width: min(1100px, 100% - 40px);
    margin: 0 auto;
    color: var(--fg);
}

.contactintro {
    grid-column: 1 / -1;
    margin: 0;
    font-family: Body;
    font-size: clamp(1.05rem, 2vw, 1.5rem);
}

.contactfields {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.contactfields label {
    font-family: Header;
    font-size: 1rem;
    letter-spacing: .1rem;
}

.contactfields input + label { margin-top: 24px; }

.contactfields input,
.contactmessage {
    box-sizing: border-box;
    width: 100%;
    padding: 12px 14px;
    border: 2px solid color-mix(in srgb, var(--fg) 35%, transparent);
    border-radius: 8px;
    background: var(--panel);
    color: var(--fg);
    font-family: Body;
    font-size: 1.1rem;
    transition: border-color .3s ease, background-color .4s ease, color .4s ease;
}

.contactmessage {
    min-height: 220px;
    resize: vertical;
}

.contactfields input:focus,
.contactmessage:focus {
    outline: none;
    border-color: var(--fg);
}

.contactbtn {
    grid-column: 1 / -1;
    justify-self: end;
    padding: 10px 32px;
    border: 0;
    border-radius: 999px;
    background: var(--fg);
    color: var(--bg);
    font-family: Header;
    font-size: .9rem;
    letter-spacing: .15rem;
    cursor: pointer;
    transition: transform .3s ease, background-color .4s ease, color .4s ease;
}

.contactbtn:hover,
.contactbtn:focus-visible { transform: scale(0.96); }

.contactbtn:focus-visible { outline: 2px solid var(--fg); outline-offset: 4px; }

/* ---------- Footer ---------- */
.site-footer {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 6px;
    padding: 40px 16px;
    color: var(--fg);
    font-family: Body;
    transition: color .4s ease;
}

.site-footer p {
    margin: 0 0 6px;
    font-size: .95rem;
}

.footer-logo {
    width: 48px;
    height: 48px;
    display: block;
}

/* White logo in dark mode, black logo in light mode */
.footer-logo.for-light { display: none; }
:root[data-theme="light"] .footer-logo.for-dark  { display: none; }
:root[data-theme="light"] .footer-logo.for-light { display: block; }

/* ---------- Tablets and below (1000px) ---------- */
@media (max-width: 1000px) {

    .transition .top { margin-top: -6.875vw; }

    .contentbox, .contentbox2 {
        flex-direction: column;
        align-items: stretch;
        gap: 30px;
        width: calc(100% - 40px);
        padding: 20px 0 50px;
        text-align: center;
    }

    .contentwrapper {
        order: -1;
        width: 100%;
        max-width: 300px;
        margin: auto;
    }

    .contenttext, .contenttext2 {
        order: 1;
        max-width: 600px;
        width: 100%;
        margin: 0 auto 30px;
    }

    .contenttext2 { flex: none; }

    .contenttext1 { width: calc(100% - 40px); margin-top: 20px; }

    .servicessection { padding-bottom: 30px; }

    .worksection {
        gap: 40px;
        width: calc(100% - 40px);
    }
}

/* ---------- Skills stack (900px) ---------- */
@media (max-width: 900px) {
    .skillsgrid { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- Two-column work grid collapses (700px) ---------- */
@media (max-width: 700px) {
    .worksection {
        grid-template-columns: minmax(0, 1fr);
        gap: 50px;
    }

    .contactform { grid-template-columns: minmax(0, 1fr); }
    .contactmessage { min-height: 160px; }
}

/* ---------- Phones (640px) ---------- */
@media (max-width: 640px) {

    :root {
        --header-h: 64px;
        --hero-bleed: 100px;
    }

    .site-header {
        grid-template-columns: auto minmax(0, 1fr);
        gap: 8px;
        padding: 10px;
    }

    .logo { width: 36px; height: 36px; }

    /* Dropdown nav: a small "Menu" pill that opens a list underneath */
    .nav {
        justify-self: end;
        height: auto;
        padding: 2px;
    }

    .nav-toggle {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 5px 12px;
        border: 0;
        background: none;
        color: var(--fg);
        font-family: Header;
        font-size: .68rem;
        letter-spacing: .12rem;
        cursor: pointer;
        outline: none;
    }

    .nav-toggle:focus-visible { outline: 2px solid var(--light); outline-offset: 2px; border-radius: 999px; }

    /* The down arrow, drawn with two borders */
    .nav-arrow {
        width: 6px;
        height: 6px;
        border-right: 2px solid currentColor;
        border-bottom: 2px solid currentColor;
        transform: rotate(45deg);
        margin-top: -3px;
        transition: transform .25s ease, margin .25s ease;
    }

    .nav.open .nav-arrow {
        transform: rotate(-135deg);
        margin-top: 3px;
    }

    .nav-links {
        position: absolute;
        top: calc(100% + 8px);
        right: 0;
        flex-direction: column;
        min-width: 140px;
        box-sizing: border-box;
        padding: 4px;
        border-radius: 18px;
        border: 1px solid color-mix(in srgb, var(--fg) 20%, transparent);
        background: color-mix(in srgb, var(--bg) 92%, transparent);
        opacity: 0;
        visibility: hidden;
        transform: translateY(-6px);
        transition: opacity .25s ease, transform .25s ease, visibility 0s linear .25s;
    }

    .nav.open .nav-links {
        opacity: 1;
        visibility: visible;
        transform: none;
        transition-delay: 0s;
    }

    .nav-links a {
        display: block;
        font-size: .75rem;
        letter-spacing: .15rem;
        padding: 10px 16px;
        white-space: nowrap;
    }

    .hero { height: 100svh; min-height: 480px; margin-top: -60px; }

    .transition .top {
        margin-top: -100px;
        margin-bottom: -30px;
    }

    .aboutsection { min-height: 0; padding-bottom: 30px; }

    .contentwrapper { padding-top: 0; }

    .contenttext h1,
    .contenttext1 h1, .contenttext2 h1 { font-size: 1.8rem; }

    .contenttext p,
    .contenttext1 p, .contenttext2 p { font-size: 1.05rem; }

    .worksection { margin: 40px auto 80px; }
    .workcard p { font-size: 1.05rem; }

    .skillgroup h1 { font-size: 1.8rem; }
    .chart { grid-template-rows: 240px auto; column-gap: 12px; }
    .chart-axis li { font-size: .8rem; }
    .bar { width: 20px; }

    .scroll-thumb { width: 4px; right: 2px; }
}

/* ---------- Very small phones (400px) ---------- */
@media (max-width: 400px) {
    .logo { width: 32px; height: 32px; }
}

@media (pointer: coarse) {
    .scroll-thumb { display: none !important; }
}

@media (hover: none) {
    .workcard:hover { transform: none; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; }
    html { scroll-behavior: auto; }
}