@font-face {
    font-display: swap;
    font-family: "Nunito";
    src: url('../fonts/Nunito-Regular.woff2') format('woff2'),
         url('../fonts/Nunito-Regular.woff') format('woff');
    font-weight: 400;
}

@font-face {
    font-display: swap;
    font-family: "Nunito";
    src: url('../fonts/Nunito-Bold.woff2') format('woff2'),
         url('../fonts/Nunito-Bold.woff') format('woff');
    font-weight: 700;
}

:root {
    --color-background:      #212121;
    --color-surface:         #2c2c2c;
    --color-text:            #f6faff;
    --color-text-muted:      #d5d5d5;
    --color-accent:          #039bf5;  /* logo blue, brand color */
    --color-link:            #4fc3f7;  /* accent variant readable on the page background */
    --color-footer:          #0277bd;  /* dark enough for white text */
    --color-white:           #ffffff;
    --color-white-dim:       rgba(255, 255, 255, 0.82);
    --content-max-width:     960px;

    --icon-size:             96px;
    /* Corner radius of the app icon artwork relative to its size */
    --icon-radius-ratio:     0.2237;
    --tile-padding:          1.25rem;
    --cover-radius:          0.375rem;
    /* Concentric corners: icon radius plus the distance to the tile edge keeps the gap even around the corner */
    --tile-radius:           calc(var(--icon-size) * var(--icon-radius-ratio) + var(--tile-padding));
}

@media (prefers-color-scheme: light) {
    :root {
        --color-background:  #f8f7f1;
        --color-surface:     #ffffff;
        --color-text:        rgba(1, 1, 1, 0.82);
        --color-text-muted:  #52646f;
        --color-link:        #0277bd;
    }
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Jumping to an anchor must not end up below the sticky bar */
html {
    scroll-padding-top: 6rem;
}

body {
    font-family: "Nunito", sans-serif;
    font-size: 16px;
    font-weight: 400;
    line-height: 1.313;
    color: var(--color-text);
    background: var(--color-background);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

main {
    flex: 1;
    width: 100%;
    max-width: var(--content-max-width);
    margin: 0 auto;
    padding: 0 1.25rem 3rem;
}

a {
    text-decoration: none;
    color: inherit;
}

.skip-link {
    position: absolute;
    left: -999px;
}

.skip-link:focus {
    left: 1rem;
    top: 1rem;
    z-index: 200;
    padding: 0.5rem 1rem;
    background: var(--color-surface);
}

/* ── Header ── */

/* Stays at the top while scrolling. Once the page is scrolled (class set by components.js) the content shimmers
   through the blurred bar. The bar keeps enough contrast for white text on light content. */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    padding: 1rem 1.25rem;
    background: var(--color-footer);
    color: var(--color-white);
    transition: background-color 0.2s ease, box-shadow 0.2s ease;
}

.site-header.is-scrolled {
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.12), 0 4px 16px rgba(0, 0, 0, 0.18);
}

@media (prefers-reduced-transparency: no-preference) {
    @supports (backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px)) {
        .site-header.is-scrolled {
            background: rgba(1, 100, 165, 0.88);
            -webkit-backdrop-filter: blur(14px) saturate(1.4);
            backdrop-filter: blur(14px) saturate(1.4);
        }
    }
}

/* One row: brand left, navigation and language menu right.
   Narrow: brand and language menu in the first row, navigation below. */
.header-inner {
    max-width: var(--content-max-width);
    margin: 0 auto;
    display: grid;
    grid-template-columns: 1fr auto auto;
    grid-template-areas: "brand nav lang";
    align-items: center;
    /* Shrinks with the viewport so the single row fits down to the narrow layout */
    --header-gap: clamp(1rem, 3vw, 1.75rem);
    gap: 0 var(--header-gap);
}

.brand {
    grid-area: brand;
    justify-self: start;
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--color-white);
}

.main-nav {
    grid-area: nav;
}

.main-nav ul {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem var(--header-gap);
    list-style: none;
    font-weight: 700;
}

.main-nav a:hover,
.main-nav a[aria-current="page"],
.lang-menu summary:hover,
.lang-menu details[open] summary {
    text-decoration: underline;
    text-decoration-thickness: 2px;
    text-underline-offset: 0.3em;
}

@media (max-width: 34rem) {
    .header-inner {
        grid-template-columns: 1fr auto;
        grid-template-areas:
            "brand lang"
            "nav   nav";
        row-gap: 0.25rem;
    }

    .main-nav ul {
        justify-content: flex-end;
        gap: 0.25rem 1.875rem;
    }
}

/* ── Language menu ── */

.lang-menu {
    grid-area: lang;
    position: relative;
}

/* Looks like a navigation item; the padding only enlarges the tap area */
.lang-menu summary {
    display: inline-block;
    padding: 0.5rem 0;
    font-weight: 700;
    cursor: pointer;
    list-style: none;
    white-space: nowrap;
    user-select: none;
    -webkit-user-select: none;
}

.lang-menu summary::-webkit-details-marker {
    display: none;
}

.lang-menu ul {
    position: absolute;
    right: 0;
    top: calc(100% + 0.25rem);
    z-index: 100;
    min-width: 100%;
    padding: 0.25rem;
    list-style: none;
    border-radius: 0.75rem;
    background: var(--color-surface);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
    color: var(--color-text);
    font-size: 0.9375rem;
}

.lang-menu ul a {
    display: block;
    padding: 0.4rem 0.75rem;
    border-radius: 0.5rem;
    white-space: nowrap;
}

.lang-menu ul a:hover,
.lang-menu ul a[aria-current="true"] {
    background: color-mix(in srgb, var(--color-accent) 20%, transparent);
}

/* ── Hero ── */

.hero {
    padding: 2.5rem 0 2rem;
    text-align: center;
}

.hero-title {
    font-size: 3rem;
    font-weight: 700;
    line-height: 1.188;
}

.hero-subtitle {
    margin-top: 0.25rem;
    font-size: 1.5rem;
    line-height: 1.168;
    color: var(--color-text-muted);
}

/* Second line of the slogan, smaller */
.hero-detail {
    margin-top: 0.5rem;
    font-size: 1.125rem;
    line-height: 1.25;
    color: var(--color-text-muted);
}

/* ── Apps ── */

/* Two tiles per row, one per row on narrow screens */
.apps {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.25rem;
    margin-bottom: 1.25rem;
}

@media (max-width: 44rem) {
    .apps {
        grid-template-columns: 1fr;
    }
}

.app {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    align-items: flex-start;
    padding: var(--tile-padding);
    border-radius: var(--tile-radius);
    background: var(--color-surface);
}

/* Continuous corners like the app icons, where supported; otherwise the circular radius applies */
@supports (corner-shape: squircle) {
    .app,
    .cover,
    .legal-content img[src="/images/photo-me.jpg"] {
        corner-shape: squircle;
    }
}

/* The icon files carry their own transparent corners, so no radius here */
.app-icon-link {
    display: block;
    flex: none;
    width: var(--icon-size);
    height: var(--icon-size);
    line-height: 0;
}

.app-icon {
    display: block;
    width: var(--icon-size);
    height: var(--icon-size);
}

.app-body {
    display: flex;
    flex-direction: column;
    flex: 1;
    gap: 0.5rem;
    min-width: 0;
}

.app-title {
    font-size: 1.5rem;
    line-height: 1.168;
}

.app-text {
    color: var(--color-text-muted);
}

.app-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem 1.25rem;
    /* Pins the buttons to the bottom edge of the tile; the gap above keeps a minimum distance to the text */
    margin-top: auto;
    padding-top: 0.25rem;
}

.app-store-badge {
    display: block;
    height: 40px;
    width: auto;
}

/* Book covers on the projects page, small like the app icons */
.cover-link {
    display: block;
    flex: none;
    width: var(--icon-size);
    line-height: 0;
}

.cover {
    display: block;
    width: 100%;
    height: auto;
    border-radius: var(--cover-radius);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

/* Concentric corners for the cover: its radius plus the distance to the tile edge */
.app.project {
    border-radius: calc(var(--cover-radius) + var(--tile-padding));
}

/* Icon, cover and badge grow slightly under the mouse pointer (and the badge with keyboard focus) */
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
    .app-icon,
    .cover,
    .app-store-badge {
        transition: transform 0.15s ease;
    }

    .app-icon-link:hover .app-icon {
        transform: scale(1.06);
    }

    a.cover-link:hover .cover {
        transform: scale(1.06);
    }

    .app-store-btn:hover .app-store-badge,
    .app-store-btn:focus-visible .app-store-badge {
        transform: scale(1.05);
    }
}

.app-more {
    font-weight: 700;
    color: var(--color-link);
}

.app-more:hover {
    text-decoration: underline;
}

/* ── Content pages ── */

.legal-content {
    padding-top: 2rem;
    max-width: 42rem;
    margin: 0 auto;
}

.legal-content h1 {
    margin-bottom: 1rem;
    font-size: 2rem;
}

.legal-content p {
    margin-bottom: 1rem;
}

.legal-content a {
    color: var(--color-link);
    text-decoration: underline;
}

/* ── Footer ── */

footer {
    padding: 2.5rem 1.25rem 1.75rem;
    background: var(--color-footer);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    text-align: center;
}

.footer-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.footer-logo {
    display: block;
    height: 72px;
    width: auto;
}

.footer-tagline {
    font-size: 1.5rem;
    line-height: 1.168;
    color: var(--color-white-dim);
    margin-top: 0.25rem;
}

.footer-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem 2rem;
    font-size: 0.75rem;
    font-weight: 700;
    line-height: 1.251;
    margin-top: 0.5rem;
}

.footer-links a {
    color: var(--color-white);
}

.footer-links a:hover {
    text-decoration: underline;
}

.legal-content h2 {
    margin: 2rem 0 0.75rem;
    font-size: 1.5rem;
    line-height: 1.168;
}

.legal-content img {
    display: block;
    max-width: 100%;
    height: auto;
    margin-bottom: 1rem;
    border-radius: 0.75rem;
}

/* The portrait on the contact page has the same corners as the book covers */
.legal-content img[src="/images/photo-me.jpg"] {
    border-radius: var(--cover-radius);
}

/* Linked images are store badges: unaltered, without the rounded corners of photos */
.legal-content a > img {
    display: inline-block;
    margin-bottom: 0;
    border-radius: 0;
}

/* Click-to-reveal contact details look like links */
.reveal-btn {
    padding: 0;
    border: 0;
    background: none;
    font: inherit;
    color: var(--color-link);
    text-decoration: underline;
    cursor: pointer;
}

/* ── 404 page ── */

.not-found {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem 0 2rem;
    text-align: center;
}

.not-found h1 {
    margin-bottom: 0.5rem;
    font-size: 2rem;
    line-height: 1.168;
}

.not-found p {
    max-width: 32rem;
    margin-bottom: 1.25rem;
    color: var(--color-text-muted);
}

.signpost {
    width: min(100%, 360px);
    margin-bottom: 1.5rem;
}

.signpost svg {
    display: block;
    width: 100%;
    height: auto;
    overflow: visible;
}

/* Hiking signposts are yellow in every color scheme */
.sign {
    cursor: pointer;
    filter: drop-shadow(0 3px 3px rgba(0, 0, 0, 0.25));
}

.sign-board {
    fill: #ffd400;
    stroke: #b39600;
    stroke-width: 1.5;
}

.sign-text {
    font-family: "Nunito", sans-serif;
    font-size: 20px;
    font-weight: 700;
    fill: #1d1d1d;
}

.sign:hover .sign-board,
.sign:focus-visible .sign-board {
    fill: #ffe34d;
}

.sign:focus-visible {
    outline: none;
}

.sign:focus-visible .sign-board {
    stroke: var(--color-text);
    stroke-width: 3;
}

/* The sign for the missing page */
.sign-fallen polygon {
    fill: #d9c24a;
    stroke: #a38f2e;
    stroke-width: 1.5;
}

.sign-fallen text {
    font-family: "Nunito", sans-serif;
    font-size: 17px;
    font-weight: 700;
    fill: #4a4220;
}

@media (prefers-reduced-motion: no-preference) {
    .sign {
        transition: transform 0.2s ease;
    }

    .sign:hover,
    .sign:focus-visible {
        transform: rotate(-2.5deg);
    }
}

.button {
    display: inline-block;
    padding: 0.7rem 1.5rem;
    border-radius: 999px;
    background: var(--color-footer);
    color: var(--color-white);
    font-size: 1.0625rem;
    font-weight: 700;
}

.button:hover,
.button:focus-visible {
    filter: brightness(1.15);
}

/* Text for screen readers and search engines that stays out of sight (completes link texts such as "Learn more") */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    border: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}
