/* Layout: fixed header, page containers, footer, next-page link. */


/* Header */

/* Keep content out of the notch and home-bar areas (safe-area insets are 0 elsewhere). */
.site-header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 72px;
    z-index: 100;
    pointer-events: none;

    /* Comma syntax on purpose, here and in the mask below: Chromium stores such a colour on
       8 bits per channel, and paints these gradients one level off with the modern syntax. */
    /* stylelint-disable-next-line color-function-notation, color-function-alias-notation, alpha-value-notation -- see above */
    background: linear-gradient(180deg, rgba(26, 26, 26, 0.85) 0%, transparent 100%);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
    padding-top: env(safe-area-inset-top);
}

/* The blur takes whatever lies behind the header. The 0.30 black veil keeps the white logo
   readable over light content; the mask fades blur and veil out together so no hard edge shows. */
.site-header::before {
    content: '';
    position: absolute;
    inset: 0 0 -40px;
    z-index: -1;
    pointer-events: none;
    background: rgb(0 0 0 / 30%);
    -webkit-backdrop-filter: blur(16px);
    backdrop-filter: blur(16px);

    /* stylelint-disable color-function-notation, color-function-alias-notation, alpha-value-notation -- comma syntax on purpose, see .site-header */
    -webkit-mask-image: linear-gradient(180deg, #000 0%, #000 58%, rgba(0, 0, 0, 0.55) 78%, transparent 100%);
    mask-image: linear-gradient(180deg, #000 0%, #000 58%, rgba(0, 0, 0, 0.55) 78%, transparent 100%);
    /* stylelint-enable color-function-notation, color-function-alias-notation, alpha-value-notation */
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    padding: 0 42px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 40px;
}

.burger-btn {
    width: 36px;
    height: 22px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    pointer-events: auto;
    z-index: 110;
    position: relative;
}

/* Transparent pseudo-element: enlarges the hit area only, nothing drawn moves. */
.burger-btn::after {
    content: '';
    position: absolute;
    inset: -11px -6px;
}

.burger-line {
    display: block;
    width: 100%;
    height: 2px;
    background: var(--white);
    transform-origin: center;
    transition: transform var(--dur-med) var(--ease-out), opacity var(--dur-med) var(--ease-out), background var(--dur-fast);
}

.burger-btn:hover .burger-line { background: var(--red); }
body.is-menu-open .burger-line:nth-child(1) { transform: translateY(10px) rotate(45deg); }

body.is-menu-open .burger-line:nth-child(2) {
    opacity: 0;
    transform: scaleX(0);
}

body.is-menu-open .burger-line:nth-child(3) { transform: translateY(-10px) rotate(-45deg); }

/* Project pages only: the script sets has-back-button on the body. */
.header-back-btn {
    display: none;
    align-items: center;
    gap: 10px;
    color: var(--white);
    pointer-events: auto;
    transition: transform var(--dur-base) var(--ease-overshoot);
}

.header-back-btn:hover { transform: translateX(-8px) scale(1.05); }
.header-back-btn:active { transform: scale(0.95); }
.header-back-btn .font-sketch { font-size: 2.2rem; }
body.has-back-button .header-back-btn { display: flex; }

.sketch-arrow-back {
    width: 50px;
    height: 25px;
}

.header-logo {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s var(--ease-out);
}

.header-logo.is-visible {
    opacity: 1;
    pointer-events: auto;
}

.header-logo-text {
    font-size: 2.3rem;
    line-height: 1;
    letter-spacing: 0.03em;
    animation: sketch-wobble var(--sketch-timing);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 54px;
    pointer-events: auto;
}

.lang-switcher {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.08em;
}

.lang-btn {
    opacity: 0.35;
    transition: opacity var(--dur-fast);
    position: relative;
}

/* Hit area: stops at the middle of the gap so neighbouring targets touch without overlapping. */
.lang-btn::after {
    content: '';
    position: absolute;
    inset: -14px -6px;
}

.lang-btn.is-active { opacity: 1; }
.lang-btn:hover { opacity: 0.75; }
.lang-sep { opacity: 0.2; }

.social-nav {
    display: flex;
    gap: 16px;
    align-items: center;
}

.social-link {
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.5;
    transition: opacity var(--dur-fast), color var(--dur-fast), transform var(--dur-fast);
    position: relative;
}

/* Hit area: extends far outwards (no neighbour) and only to the middle of the gap inwards. */
.social-link::before {
    content: '';
    position: absolute;
    inset: -14px -4px;
}

.social-link:first-child::before { inset: -14px -4px -14px -11px; }
.social-link:last-child::before { inset: -14px -11px -14px -4px; }

.social-link::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 0;
    width: 0;
    height: 1px;
    background: var(--red);
    transition: width var(--dur-fast);
}

.social-link:hover {
    opacity: 1;
    color: var(--red);
    transform: translateY(-2px);
}

.social-link:hover::after { width: 100%; }

@media (max-width: 768px) {
    .header-inner { padding: 0 18px; }
    .header-right { gap: 14px; }
    .social-nav { gap: 8px; }

    .social-icon {
        width: 15px;
        height: 15px;
    }

    .lang-switcher {
        gap: 4px;
        font-size: 0.75rem;
    }

    /* On phones the back button and the centred logo do not both fit: on a project page the logo
       fades out. */
    body.has-back-button .header-logo {
        opacity: 0;
        pointer-events: none;
    }
}

@media (max-width: 303px) {
    /* Narrowest phones (Galaxy Fold closed): shrink the logo onto one line and nudge it left to
       clear the language switcher. */
    .header-logo {
        left: calc(50% - 28px);
        white-space: nowrap;
    }

    .header-logo-text { font-size: 1.3rem; }
}


/* Pages */

.page-wrapper {
    width: 100%;
    height: 100%;
    position: relative;
}

.page {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    overflow: hidden auto;
    opacity: 0;
    pointer-events: none;
    scrollbar-width: thin;
    scrollbar-color: rgb(255 255 255 / 10%) transparent;
}

.page::-webkit-scrollbar { width: 4px; }
.page::-webkit-scrollbar-thumb { background: rgb(255 255 255 / 10%); }

/* An inactive page never takes pointer events, whatever weight its children use to turn them
   back on. */
/* stylelint-disable-next-line declaration-no-important -- must hold against any descendant rule */
.page:not(.is-active) * { pointer-events: none !important; }

/* Inactive pages are really hidden, not just transparent. visibility:hidden removes them from the
   tab order; content-visibility:hidden skips their rendering so lazy images do not load before the
   page opens. Browsers without content-visibility fall back to visibility alone. contain-intrinsic-
   size keeps the scrollbar from jumping when a page opens. */
.page:not(.is-active) {
    visibility: hidden;
    content-visibility: hidden;
    contain-intrinsic-size: auto 100vh;
}

.page.is-active {
    opacity: 1;
    pointer-events: auto;
    visibility: visible;
    content-visibility: visible;
}

.page-inner {
    max-width: var(--content-max);
    margin: 0 auto;
    padding: 120px 60px 100px;
}

.page-heading {
    display: flex;
    align-items: baseline;
    gap: 16px;
    margin-bottom: 16px;
}

.page-num {
    font-family: var(--font-display);
    font-size: 1.1rem;
    color: var(--red);
    letter-spacing: 0.05em;
}

.page-title {
    font-family: var(--font-display);
    font-size: clamp(3rem, 7vw, 6rem);
    line-height: 0.9;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.page-intro {
    font-size: 1.05rem;
    color: var(--muted);
    font-weight: 300;
    max-width: 550px;
    margin-bottom: 60px;
    line-height: 1.7;
}

/* Project pages: panels span the full width, so the page gives up its side padding and the
   heading gets it back. */
.project-detail-page .page-inner {
    max-width: none;
    margin: 0;
    padding: 120px 0 0;
}

.project-detail-page .page-heading,
.project-detail-page .page-intro {
    padding-left: 60px;
    padding-right: 60px;
    max-width: var(--content-max);
}

@media (max-width: 991px) {
    .page { padding: 100px 30px 40px; }
}

@media (max-width: 768px) {
    .page-inner { padding: 95px 20px 80px; }
    .page-title { font-size: clamp(2.2rem, 8vw, 3.5rem); }

    .page-intro {
        font-size: 0.95rem;
        margin-bottom: 36px;
    }

    /* Project pages: on phones the panels run edge to edge, so their coloured background and torn
       lines (pseudo-elements sized to the panel) reach the screen edge. Their own padding keeps
       content off the edges. */
    .page.project-detail-page {
        padding-left: 0;
        padding-right: 0;
    }
}


/* Footer */

.site-footer {
    background: var(--bg-deep);
    color: rgb(255 255 255 / 40%);
    border-top: 1px solid rgb(255 255 255 / 5%);
    margin-bottom: -100px;
    padding-left: 60px;
    padding-right: 60px;
    position: relative;
    clear: both;

    /* Full-bleed inside a padded page. 100vw includes the scrollbar of .page; --scrollbar-width
       (set by script) subtracts it so the footer does not overflow. */
    width: calc(100vw - var(--scrollbar-width, 0px));
    left: 50%;
    right: 50%;
    margin-left: calc(-50vw + var(--scrollbar-width, 0px) / 2);
    margin-right: calc(-50vw + var(--scrollbar-width, 0px) / 2);
}

.site-footer--spaced { margin-top: 80px; }

/* The bottom padding grows with the home-bar inset. */
.footer-inner {
    max-width: var(--content-max);
    margin: 0 auto;
    padding: 50px 60px max(40px, calc(40px + env(safe-area-inset-bottom)));
}

.footer-top {
    display: flex;
    align-items: baseline;
    gap: 16px;
    margin-bottom: 30px;
}

.footer-logo {
    font-size: 1.6rem;
    color: var(--white);
    animation: sketch-wobble var(--sketch-timing);
}

.footer-year {
    font-size: 0.85rem;
    opacity: 0.5;
}

.footer-legal {
    font-size: 0.8rem;
    line-height: 1.7;
    opacity: 0.5;
    max-width: 800px;
    margin-bottom: 26px;
}

.footer-legal p { margin-bottom: 12px; }

.footer-bottom {
    display: flex;
    gap: 14px;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    opacity: 0.3;
}

.footer-sep { opacity: 0.3; }

@media (max-width: 768px) {
    .footer-inner {
        padding-top: 36px;
        padding-left: 20px;
        padding-right: 20px;
    }

    .footer-year { font-size: 0.875rem; }

    /* Keep the legal text readable on a phone held at arm's length. */
    .footer-legal {
        font-size: 0.875rem;
        line-height: 1.75;
    }

    .footer-bottom {
        flex-wrap: wrap;
        gap: 8px;
    }

    .footer-bottom,
    .footer-bottom a,
    .footer-sep {
        font-size: 0.8125rem;
    }
}


/* Next-page link */

/* Always at the right edge of the screen, whatever the width of the page around it: the margin
   reaches out of the content column to stop --next-edge short of the screen edge (Even,
   21/10/2026). 100% is the width of that column; --scrollbar-width is set by script. */
.page-next {
    --next-edge: 60px;

    display: flex;
    align-items: center;
    gap: 16px;
    margin-top: 80px;
    margin-bottom: 40px;
    margin-right: calc(var(--next-edge) - (100vw - var(--scrollbar-width, 0px) - 100%) / 2);
    float: right;
    clear: both;
    padding: 10px 0;
    transition: transform var(--dur-base) var(--ease-out);
}

.page-next:hover { transform: translateX(10px); }

.page-next-label {
    font-family: var(--font-sketch);
    font-size: 3.5rem;
    text-transform: lowercase;
    letter-spacing: 0.03em;
    color: var(--white);
    transition: color var(--dur-base);
}

.page-next:hover .page-next-label { color: var(--red); }

.page-next-arrow {
    width: 60px;
    height: 30px;
    animation: sketch-wobble var(--sketch-timing);
}

.page-next-arrow path { stroke: var(--red); }

@media (max-width: 768px) {
    /* Phones: the same edge as the page margins. */
    .page-next { --next-edge: 20px; }
}
