/* site.css — Layout, header, footer and shared components */

/* --- 1. PAGE BACKGROUND --- */
.page {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
    background: var(--abyss);
    color: var(--text);
}

/* The home page fits the window and does not scroll. */
.page--home {
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    background: var(--abyss);
}

@media (max-width: 1279px), (orientation: portrait) {
    .page--home {
        height: auto;
        overflow: visible;
    }
}

/* The gallery fits the window: a 5×2 grid with a pager. */
.page--portraits {
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

@media (max-width: 1000px), (orientation: portrait) {
    .page--portraits {
        height: auto;
        overflow: visible;
    }
}

/* The contributions page fits the window: a 3×2 grid with a pager. */
.page--contributions:not(.page--letter) {
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

@media (max-width: 1000px), (orientation: portrait) {
    .page--contributions:not(.page--letter) {
        height: auto;
        overflow: visible;
    }
}

/* The about and personal data pages scroll as a whole. */
.page--contributions,
.page--portraits,
.page--about,
.page--privacy {
    background: radial-gradient(ellipse at 50% 40%,
                                var(--night-raised) 0%,
                                var(--night) 55%,
                                var(--abyss) 100%);
}

/* --- 2. HEADER --- */
.site-header {
    /* Stays visible when the page scrolls. */
    position: sticky;
    top: 0;
    z-index: 20;
    flex-shrink: 0;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1.5rem;
    padding: 1.5rem var(--gutter);
    /* Hairline under the header, matching the one above the footer. */
    border-bottom: 1px solid var(--rule);
}

/* Translucent background over the content scrolling under it. */
.page:not(.page--home) .site-header {
    background: rgba(3, 4, 8, .88);
    -webkit-backdrop-filter: blur(12px);
            backdrop-filter: blur(12px);
}

/* No hairline on the home page on wide screens: the video runs behind the header. */
@media (min-width: 901px) {
    .page--home .site-header {
        border-bottom: 0;
    }
}

.site-header__mark {
    display: inline-flex;
    align-items: center;
    gap: .75rem;
    color: var(--text-bright);
    font-size: .82rem;
    font-weight: 600;
    line-height: 1.15;
    letter-spacing: .18em;
    text-decoration: none;
}

/* Logo: fixed height, width follows. */
.site-header__mark img {
    display: block;
    width: auto;
    height: 38px;
}

.site-header__back {
    color: var(--text-muted);
    font-size: .9rem;
    font-weight: 500;
    letter-spacing: .18em;
    text-transform: uppercase;
    transition: color .2s ease;
}

.site-header__mark:hover .site-header__back,
.site-header__mark:focus-visible .site-header__back {
    color: var(--glow-soft);
}

/* --------------------------------------------------------------------------
   3. NAVIGATION
   -------------------------------------------------------------------------- */
.site-nav {
    display: flex;
    gap: 2rem;
    padding-top: .25rem;
}

/* Language flags before the tabs, dimmed unless current. */
.site-nav__languages {
    display: flex;
    align-items: center;
    gap: .6rem;
    align-self: flex-start;
    margin-top: -.15rem;
}

.site-nav__language {
    display: block;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    opacity: .6;
    transition: opacity .2s ease;
}

.site-nav__language img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.site-nav__language:hover,
.site-nav__language:focus-visible,
.site-nav__language[aria-current] {
    opacity: 1;
}

.site-nav__language[aria-current] {
    outline: 1px solid rgba(var(--glow-rgb), .45);
    outline-offset: 2px;
}

.site-nav__link {
    position: relative;
    padding-bottom: 6px;
    color: var(--text-muted);
    font-size: .82rem;
    font-weight: 500;
    letter-spacing: .14em;
    text-transform: uppercase;
    text-decoration: none;
    transition: color .2s ease;
}

.site-nav__link:hover,
.site-nav__link:focus-visible {
    color: var(--text-bright);
}

/* Underline scaled on hover, so the text does not shift. */
.site-nav__link::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 2px;
    background: currentColor;
    transform: scaleX(0);
    transform-origin: left;
    transition: transform .25s ease;
}

.site-nav__link:hover::after,
.site-nav__link:focus-visible::after {
    transform: scaleX(1);
}

.site-nav__link--current {
    color: var(--glow-soft);
}

.site-nav__link--current::after {
    transform: scaleX(1);
}

/* --------------------------------------------------------------------------
   4. FOOTER
   -------------------------------------------------------------------------- */
.site-footer {
    position: relative;
    z-index: 20;
    flex-shrink: 0;
    margin-top: auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    padding: 1.25rem var(--gutter);
    border-top: 1px solid var(--rule);
    color: var(--text-muted);
    font-size: .72rem;
    letter-spacing: .1em;
}

/* Stays visible when the page scrolls, except on phones where it only comes at the end. */
@media (min-width: 901px) {
    .site-footer {
        position: sticky;
        bottom: 0;
        background: rgba(3, 4, 8, .88);
        -webkit-backdrop-filter: blur(12px);
                backdrop-filter: blur(12px);
    }
}

.site-footer__mark {
    display: inline-flex;
    align-items: center;
    gap: .6rem;
    text-transform: uppercase;
}

/* Footer logo on a white tile (the file has a white background). */
.site-footer__mark img {
    display: block;
    width: auto;
    height: 24px;
    padding: 3px 5px;
    background: #fff;
    border-radius: 3px;
}

.site-footer__links {
    display: flex;
    gap: 1.25rem;
}

.site-footer__link {
    color: var(--text-muted);
    text-transform: uppercase;
    text-decoration: none;
    white-space: nowrap;
    transition: color .2s ease;
}

.site-footer__link:hover,
.site-footer__link:focus-visible,
.site-footer__link--current {
    color: var(--glow-soft);
}

/* --- 5. BACK LINK --- */
/* --- 5b. PAGE TITLES --- */
.contrib__title,
.deposit__title,
.gallery__title,
.about__title,
.identity__name {
    font-family: var(--display);
}

/* --- 6. CLICK OUTSIDE TO GO BACK --- */
.dismiss {
    position: absolute;
    inset: 0;
}

/* --- 6b. CONTRIBUTION CARD --- */
/* 48rem wide with 2rem of padding. */
.letter {
    position: relative;
    width: min(48rem, 100%);
    max-height: 88vh;
    overflow: auto;
    padding: 2rem;
    background: #000622;
    border: 1px solid rgba(var(--glow-rgb), .4);
    border-radius: var(--radius);
    color: var(--text-bright);
}

/* Close button on the right. */
.letter__head {
    display: flex;
    align-items: flex-start;
    justify-content: flex-end;
}

.letter__kind {
    margin: 0;
    font-size: .656rem;   /* 10.5px */
    letter-spacing: .2em;
    text-transform: uppercase;
    color: var(--glow);
}

.letter__close {
    color: #6f7787;
    font-size: 1.125rem;  /* 18px */
    line-height: 1;
    text-decoration: none;
    transition: color .2s ease;
}

.letter__close:hover,
.letter__close:focus-visible {
    color: var(--glow-soft);
}

.letter__name {
    margin: 18px 0 6px;
    font-size: 1.3125rem; /* 21px */
    font-weight: 400;
    letter-spacing: .16em;
    text-transform: uppercase;
    color: #f2ece1;
}

.letter__sub {
    margin: 0;
    font-size: .719rem;   /* 11.5px */
    letter-spacing: .06em;
    color: #6f7787;
}

/* partials/flag, sized to the text beside it. Here because the home page uses the card too. */
.flag {
    display: inline-block;
    width: 1.35em;
    height: auto;
    margin-right: .4em;
    vertical-align: -.12em;
    border-radius: 1px;
}

.letter__text {
    margin: 20px 0 0;
    font-size: 1.1rem;
    font-weight: 300;
    line-height: 1.8;
    color: #e9e4da;

    /* Keep the author's line breaks. */
    white-space: pre-line;
}

/* Quotation marks added by CSS. */
.letter__text::before { content: "\00ab\00a0"; }
.letter__text::after  { content: "\00a0\00bb"; }

.letter__footer {
    margin: 22px 0 0;
    padding-top: 14px;
    border-top: 1px solid rgba(var(--glow-rgb), .16);
    font-size: .656rem;   /* 10.5px */
    letter-spacing: .14em;
    text-transform: uppercase;
    color: #6f7787;
}

/* Dialog: the card centred over a darkened page. */
.letter-dialog {
    position: fixed;
    inset: 0;
    width: 100%;
    max-width: none;
    height: 100%;
    max-height: none;
    margin: 0;
    padding: 32px;
    border: 0;
    align-items: center;
    justify-content: center;
    background: rgba(3, 5, 10, .82);
    color: inherit;
}

.letter-dialog[open] {
    display: flex;
}

.letter-dialog::backdrop {
    background: transparent;
}

/* Fade in and out. */
.letter-dialog {
    opacity: 0;
    transition: opacity .3s ease,
                display .3s allow-discrete,
                overlay .3s allow-discrete;
}

.letter-dialog[open] {
    opacity: 1;
}

@starting-style {
    .letter-dialog[open] {
        opacity: 0;
    }
}

/* On its own page, the card fades in by itself. */
.contrib--one .letter {
    animation: letter-in .4s ease both;
}

@keyframes letter-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

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

    .contrib--one .letter {
        animation: none;
    }
}

@media (max-width: 640px) {
    .letter-dialog {
        padding: 16px;
    }
}

/* --- 7. PAGE TRANSITIONS --- */
/* No @view-transition: each page has its own entrance animation. */

/* --- 8. NARROW SCREENS --- */
@media (max-width: 900px) {
    .site-header {
        align-items: center;
        padding-top: 1rem;
        padding-bottom: 1rem;
        background: rgba(3, 4, 8, .88);
        -webkit-backdrop-filter: blur(12px);
                backdrop-filter: blur(12px);
        border-bottom: 1px solid var(--rule);
    }

    .site-nav {
        gap: 1.5rem;
        padding-top: 0;
        flex-wrap: nowrap;
    }

    .site-nav__link {
        letter-spacing: .1em;
        white-space: nowrap;
    }

    .site-footer {
        gap: 1rem;
    }
}

/* Phone: logo hidden, tabs spread across the width. */
@media (max-width: 700px) {
    .site-header {
        flex-direction: column;
        align-items: stretch;
        gap: .75rem;
        padding-bottom: .75rem;
    }

    /* No logo on a phone: the first tab already leads home. */
    .site-header__mark {
        display: none;
    }

    /* Tabs grouped in the middle. */
    .site-nav {
        justify-content: center;
        gap: 1.5rem;
    }

    /* Logo only: the name is on the legal notice page. */
    .site-footer__name {
        display: none;
    }

    .site-nav__link {
        font-size: min(.82rem, 2.75vw);
        letter-spacing: .08em;
    }
}

@media (prefers-reduced-motion: reduce) {
    .site-nav__link::after {
        transition: none;
    }
}
