/* One plain background for the whole site, with text and lines in the opposite colour.
   The inline script in _Layout sets data-theme before the first paint. */
:root {
    --bg: #fff;
    --fg: #000;
    --dim: rgba(0, 0, 0, 0.3);
    --page-width: 1360px;
    --text-width: 1100px;
    --gutter: clamp(16px, 4vw, 40px);
    --font: "Helvetica Neue", Helvetica, Arial, system-ui, sans-serif;
    color-scheme: light;
}

:root[data-theme="dark"] {
    --bg: #000;
    --fg: #fff;
    --dim: rgba(255, 255, 255, 0.35);
    color-scheme: dark;
}

/* Without JavaScript nothing sets data-theme, so the system's setting decides. */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) {
        --bg: #000;
        --fg: #fff;
        --dim: rgba(255, 255, 255, 0.35);
        color-scheme: dark;
    }
}

* {
    box-sizing: border-box;
}

html {
    background: var(--bg);
}

@media (prefers-reduced-motion: no-preference) {
    html {
        scroll-behavior: smooth;
    }
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--fg);
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    transition: background-color 0.4s ease, color 0.4s ease;
}

/* Links look exactly like the text around them. */
a {
    color: inherit;
    text-decoration: none;
}

:focus-visible {
    outline: 2px solid var(--fg);
    outline-offset: 3px;
}

img,
video {
    display: block;
    width: 100%;
    height: auto;
}

/* <picture> only wraps the srcset variants; it must not add a box of its own around the image. */
picture {
    display: contents;
}

h1,
h2,
h3 {
    font-weight: 400;
}

/* Screen-reader-only text. */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

.page {
    width: min(100% - 2 * var(--gutter), var(--page-width));
    margin-inline: auto;
}

.text-page {
    width: min(100% - 2 * var(--gutter), var(--text-width));
    padding-top: clamp(24px, 5vw, 64px);
}

.page-title {
    margin: 0 0 24px;
    font-size: clamp(28px, 4vw, 44px);
    line-height: 1.1;
}

.plain-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

/* Nav bar: no line or background of its own, and it scrolls away with the page.
   Theme toggle, page buttons and language toggle on one row, the icons centred below. */
.site-header {
    padding: 20px var(--gutter) 0;
}

.site-nav {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    grid-template-areas:
        "theme pages language"
        ".     icons .";
    align-items: center;
    row-gap: 16px;
    max-width: var(--page-width);
    margin-inline: auto;
}

.site-nav.is-pages-only {
    grid-template-areas: ". pages .";
}

.nav-pages,
.nav-icons {
    display: flex;
    justify-content: center;
    margin: 0;
    padding: 0;
    list-style: none;
}

.nav-pages {
    grid-area: pages;
    gap: 10px;
}

.nav-button {
    display: block;
    padding: 6px 18px 7px;
    border: 1.5px solid currentColor;
    border-radius: 999px;
    font-size: 15px;
    line-height: 1.2;
    white-space: nowrap;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.nav-button[aria-current="page"],
.nav-button:hover {
    background: var(--fg);
    color: var(--bg);
}

.nav-icons {
    grid-area: icons;
    gap: 14px;
}

.nav-icons a,
.copy-email {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    color: inherit;
}

.nav-icons svg {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.copy-email {
    padding: 0;
    border: 0;
    background: none;
    cursor: pointer;
}

/* The check mark stands in for the envelope for a moment after the address is copied. */
.copy-email .icon-check,
.copy-email.copied .icon-envelope {
    display: none;
}

.copy-email.copied .icon-check {
    display: block;
}

/* Sun to moon: the disc grows, a shadow slides across it and the rays fold away. */
.theme-toggle {
    grid-area: theme;
    justify-self: start;
    display: grid;
    padding: 3px;
    border: 0;
    background: none;
    color: inherit;
    cursor: pointer;
}

.theme-toggle svg {
    display: block;
}

.theme-toggle-disc {
    transform-origin: 14px 14px;
    transform: scale(0.6);
    transition: transform 0.55s ease;
}

.theme-toggle-carve {
    transform: translate(6px, -6px);
    transition: transform 0.55s ease;
}

.theme-toggle-rays {
    transform-origin: 14px 14px;
    transition: transform 0.55s ease, opacity 0.4s ease;
}

[data-theme="dark"] .theme-toggle-disc {
    transform: scale(1);
}

[data-theme="dark"] .theme-toggle-carve {
    transform: translate(-8px, 0);
}

[data-theme="dark"] .theme-toggle-rays {
    transform: scale(0.4) rotate(45deg);
    opacity: 0;
}

/* Both language codes show, the current one in full colour. Hovering swaps them, previewing
   the switch the link makes. */
.language-toggle {
    grid-area: language;
    justify-self: end;
    display: flex;
    gap: 0.75em;
    padding: 6px 0;
    font-size: 13px;
    letter-spacing: 0.1em;
}

.language-toggle span {
    color: var(--dim);
    transition: color 0.3s ease;
}

.language-toggle span.is-current,
.language-toggle:hover span {
    color: var(--fg);
}

.language-toggle:hover span.is-current {
    color: var(--dim);
}

@media (max-width: 640px) {
    .site-nav {
        grid-template-columns: 1fr 1fr;
        grid-template-areas:
            "theme language"
            "pages pages"
            "icons icons";
        row-gap: 14px;
    }

    .site-nav.is-pages-only {
        grid-template-areas: "pages pages";
    }

    .nav-button {
        padding-inline: 14px;
    }
}

/* Design page */
.site-title {
    margin: clamp(36px, 7vw, 88px) var(--gutter) clamp(36px, 7vw, 96px);
    font-size: clamp(24px, 7.5vw, 96px);
    line-height: 1;
    letter-spacing: 0.04em;
    text-align: center;
    text-transform: uppercase;
}

/* Each banner has its own width and drop, set inline as percentages of the page width.
   site.js packs them (.is-packed); until then, or without JavaScript, they wrap like words
   in a line of text with the leftover space spread around them. */
.tiles {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-around;
    align-items: flex-start;
    gap: clamp(28px, 4.5vw, 72px) 2%;
    width: min(100% - 2 * var(--gutter), var(--page-width));
    margin: 0 auto;
    padding: 0;
    list-style: none;
}

.tile {
    width: calc(var(--size) * 1%);
    margin-top: calc(var(--drop) * 1%);
}

.tiles.is-packed {
    display: block;
    position: relative;
}

.tiles.is-packed .tile {
    position: absolute;
    margin: 0;
}

.tile a {
    display: block;
}

.tile-caption {
    display: block;
    margin-top: 8px;
    font-size: 13px;
    line-height: 1.35;
}

/* Keep these in step with ImageSizes.PhoneTilePercent. */
@media (max-width: 640px) {
    .tile {
        width: min(calc(var(--size) * 2.5%), 86%);
        margin-top: calc(var(--drop) * 1.5%);
    }
}

/* Artwork page */
.artwork {
    padding-top: clamp(24px, 5vw, 64px);
}

.artwork-title {
    margin: 0 0 20px;
    font-size: clamp(28px, 4vw, 44px);
    line-height: 1.1;
}

.artwork-description {
    max-width: 62ch;
}

.artwork-description p {
    margin: 0 0 1em;
}

.artwork-links {
    margin: 0;
    padding: 0;
    list-style: none;
    overflow-wrap: anywhere;
}

/* Equal columns, filled in order; landscape items span two of them (--span). */
.media-grid {
    display: grid;
    grid-template-columns: repeat(var(--columns), minmax(0, 1fr));
    align-items: start;
    gap: clamp(8px, 1.4vw, 20px);
    margin-top: clamp(28px, 4vw, 52px);
}

.media-item {
    grid-column: span var(--span);
}

.media-embed iframe {
    display: block;
    width: 100%;
    aspect-ratio: 16 / 9;
    border: 0;
}

.media-embed.is-portrait iframe {
    aspect-ratio: 9 / 16;
}

@media (max-width: 640px) {
    .media-grid {
        grid-template-columns: 1fr;
    }

    .media-item {
        grid-column: auto;
    }
}

/* REEV page */
.reev-description {
    max-width: 60ch;
    margin: 0 auto;
    text-align: center;
}

.reev-description p {
    margin: 0 0 1em;
}

/* Two images side by side at different sizes, the smaller right one sitting lower. */
.reev-images {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin: clamp(32px, 6vw, 80px) 0 clamp(16px, 3vw, 40px);
}

.reev-image.is-left {
    width: 60%;
}

.reev-image.is-right {
    width: 36%;
    margin-top: 14%;
}

/* Coming up lists, on the REEV and About pages */
.coming-up h2 {
    margin: 2em 0 0.4em;
    font-size: 22px;
    line-height: 1.2;
}

.coming-up .year {
    margin: 1em 0 0.1em;
    font-size: 16px;
    font-weight: 700;
}

/* About page: the text column and the portrait, not equally wide. */
.about {
    display: grid;
    grid-template-columns: 1.2fr 0.8fr;
    align-items: start;
    gap: clamp(24px, 6vw, 88px);
}

.about-text p {
    margin: 0 0 1em;
}

@media (max-width: 640px) {
    .about {
        grid-template-columns: 1fr;
    }

    .about-portrait {
        order: -1;
    }
}

/* Footer: one big arrow back up to the top of the page. */
.site-footer {
    display: flex;
    justify-content: center;
    padding: clamp(72px, 10vw, 140px) 0 40px;
}

.to-top {
    display: block;
    padding: 8px;
}

.to-top svg {
    display: block;
    width: 40px;
    height: 80px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}
