/* Coiny Regular: Latin + Latin Extended-A subset (covers Polish) */
@font-face {
    font-family: "Coiny";
    src: url("/fonts/Coiny-Regular.woff2") format("woff2");
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

/* Kanagawa Lotus */
:root {
    --bg: #f2ecbc; /* lotusWhite3 */
    --fg: #545464; /* lotusInk1, 6.2:1 */
    --link: #4d699b; /* lotusBlue4, 4.6:1 */
    --edge: #716e61; /* lotusGray2, control borders, 4.3:1 */
    --line: #d5cea3; /* lotusWhite0, decorative rules */
    --selection: #c9cbd1; /* lotusViolet3 */

    /* project-button glow */
    --red: #c84053;
    --orange: #e98a00;
    --yellow: #de9800;
    --green: #6f894e;
    --teal: #4e8ca2;
    --violet: #624c83;

    color-scheme: light;
}

/* Kanagawa Wave */
.dark {
    --bg: #1f1f28; /* sumiInk3 */
    --fg: #dcd7ba; /* fujiWhite, 11.3:1 */
    --link: #7e9cd8; /* crystalBlue, 5.9:1 */
    --edge: #727169; /* fujiGray, 3.3:1 */
    --line: #363646; /* sumiInk5 */
    --selection: #2d4f67; /* waveBlue2 */

    --red: #e46876;
    --orange: #ffa066;
    --yellow: #e6c384;
    --green: #98bb6c;
    --teal: #7fb4ca;
    --violet: #957fb8;

    color-scheme: dark;
}

/* Without JS nothing sets .dark, so follow the system directly.
   Keep in sync with the Wave block above. */
@media (prefers-color-scheme: dark) {
    html:not(.js) {
        --bg: #1f1f28;
        --fg: #dcd7ba;
        --link: #7e9cd8;
        --edge: #727169;
        --line: #363646;
        --selection: #2d4f67;

        --red: #e46876;
        --orange: #ffa066;
        --yellow: #e6c384;
        --green: #98bb6c;
        --teal: #7fb4ca;
        --violet: #957fb8;

        color-scheme: dark;
    }
}

.coiny-regular {
    font-family: "Coiny", system-ui, sans-serif;
    font-weight: 400;
    font-style: normal;
}

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

::selection {
    background-color: var(--selection);
}

:focus-visible {
    outline: 2px solid var(--link);
    outline-offset: 3px;
    border-radius: 4px;
}

/* Entrance: content is visible by default and only hidden for the fade
   when JS has run (html.js) and the visitor accepts motion. */
@keyframes fadein {
    from {
        opacity: 0;
        transform: translateY(0.75rem);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

@keyframes glowing {
    0% {
        background-position: 0 0;
    }
    50% {
        background-position: 400% 0;
    }
    100% {
        background-position: 0 0;
    }
}

@media (prefers-reduced-motion: no-preference) {
    .js [data-anim] {
        animation: fadein 600ms cubic-bezier(0.16, 1, 0.3, 1) both;
    }

    .js [data-anim-delay="100"] { animation-delay: 100ms; }
    .js [data-anim-delay="200"] { animation-delay: 200ms; }
    .js [data-anim-delay="300"] { animation-delay: 300ms; }
    .js [data-anim-delay="400"] { animation-delay: 400ms; }
    .js [data-anim-delay="500"] { animation-delay: 500ms; }
    .js [data-anim-delay="600"] { animation-delay: 600ms; }
    .js [data-anim-delay="700"] { animation-delay: 700ms; }
    .js [data-anim-delay="800"] { animation-delay: 800ms; }
    .js [data-anim-delay="900"] { animation-delay: 900ms; }
    .js [data-anim-delay="1200"] { animation-delay: 1200ms; }
}

html {
    background-color: var(--bg);
    color: var(--fg);
    font-family: system-ui, sans-serif;
    font-size: 100%;
    line-height: 1.6;
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition:
        background-color 0.15s ease-in-out,
        color 0.15s ease-in-out;
}

a {
    color: var(--link);
    font-weight: 500;
    text-decoration-line: underline;
    text-decoration-thickness: 1px;
    text-decoration-color: color-mix(in srgb, var(--link) 60%, transparent);
    text-underline-offset: 0.2em;
    transition: text-decoration-color 0.15s ease-out;

    &:hover {
        text-decoration-color: currentColor;
        text-decoration-thickness: 2px;
    }
}

/* One fluid reading column; grows with its content. */
.page {
    box-sizing: border-box;
    width: 100%;
    max-width: 46rem;
    margin: 0 auto;
    padding-inline: 1.25rem;
    flex: 1;
    padding-top: clamp(2rem, 7vw, 5rem);
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto auto 1fr;
    grid-template-areas:
        "intro aside"
        "world aside"
        "bio   .";
    column-gap: 2.5rem;
    align-content: start;

    h1,
    h2,
    .role {
        text-wrap: balance;
        line-height: 1.15;
    }

    .intro {
        grid-area: intro;
        align-self: end;
    }

    .header {
        margin: 0;
        font-size: clamp(2.25rem, 1.6rem + 2.8vw, 3rem);
    }

    .tagline {
        margin: 0.5rem 0 0;
        font-style: italic;
        text-wrap: balance;
    }

    .world {
        grid-area: world;
        display: flex;
        flex-wrap: wrap;
        column-gap: 1.5rem;
        margin-top: 0.75rem;

        a {
            display: inline-block;
            padding-block: 0.6rem; /* 44px tall */
        }
    }

    .bio {
        grid-area: bio;
        max-width: 65ch;

        p {
            margin: 0 0 1em;
        }

        .role {
            margin: 2rem 0 0.75rem;
            font-size: clamp(1.25rem, 1rem + 1.2vw, 1.5rem);
        }

        h2 {
            margin: 2.25rem 0 0.75rem;
            font-size: 1.5rem;
        }

        ul {
            margin: 0;
            padding-left: 1.25rem;

            a {
                display: inline-block;
                padding-block: 0.2rem; /* >=24px tall */
            }
        }
    }

    .aside {
        grid-area: aside;
        padding-top: 0.5rem;

        .avatar-wrapper {
            position: relative;
            width: 10rem;
        }

        .avatar {
            display: block;
            width: 10rem;
            height: 10rem;
            border-radius: 50%;
            pointer-events: none;
        }
    }

    .button {
        display: inline-block;
        padding: 0.75em 1.5em;
        color: var(--fg);
        text-decoration: none;
        z-index: 0;
        position: relative;
        border-radius: 10px;

        &:before {
            content: "";
            background: linear-gradient(
                45deg,
                var(--red),
                var(--orange),
                var(--yellow),
                var(--green),
                var(--teal),
                var(--violet),
                var(--red)
            );
            position: absolute;
            top: -1px;
            left: -1px;
            background-size: 200%;
            z-index: -1;
            filter: blur(2px);
            width: calc(100% + 2px);
            height: calc(100% + 2px);
            animation: glowing 30s linear infinite;
            border-radius: 10px;

            @media (prefers-reduced-motion: reduce) {
                animation: none;
            }
        }

        &:after {
            z-index: -1;
            content: "";
            position: absolute;
            inset: 0;
            background: var(--bg);
            border-radius: 10px;
        }
    }

    /* Theme toggle: a chip on the avatar whose label slides out on
       hover/focus. Without hover (touch) it sits under the photo with
       its label always visible. */
    .theme {
        position: absolute;
        right: 0;
        bottom: 0;
        display: inline-flex;
        align-items: center;
        box-sizing: border-box;
        max-width: 2.5rem;
        height: 2.5rem;
        padding: 0 0.6rem;
        overflow: hidden;
        background-color: var(--bg);
        color: var(--fg);
        border: 1px solid var(--edge);
        border-radius: 999px;
        font: inherit;
        cursor: pointer;
        transition: max-width 0.4s cubic-bezier(0.16, 1, 0.3, 1);

        &[hidden] {
            display: none;
        }

        &:hover,
        &:focus-visible {
            max-width: 12rem;
        }

        @media (hover: none) {
            position: static;
            max-width: none;
            margin-top: 0.75rem;
            transition: none;
        }

        .theme-icon {
            flex: none;
            width: 1.25rem;
            text-align: center;
            font-size: 1.1rem;
            line-height: 1;
        }

        .theme-text {
            padding: 0 0.4rem 0 0.6rem;
            white-space: nowrap;
            user-select: none;
        }
    }
}

/* Same text column as .page (46rem minus its 1.25rem side padding) */
.footer {
    box-sizing: border-box;
    width: calc(100% - 2.5rem);
    max-width: 43.5rem;
    margin: 3rem auto 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding-block: 1rem 2rem;
    border-top: 1px solid var(--line);
    font-size: 0.9375rem;

    .gpg-key {
        display: inline-block;
        padding-block: 0.25rem;
        text-decoration: none;

        .gpg-label {
            text-decoration: inherit;
            text-decoration-line: underline;
        }
    }
}

/* Phones: single column; photo after the greeting, then CV and email */
@media (max-width: 40rem) {
    .page {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: none;
        grid-template-areas:
            "intro"
            "aside"
            "world"
            "bio";

        .aside {
            padding-top: 1.25rem;
        }

        .aside .avatar-wrapper {
            width: 8rem;
        }

        .aside .avatar {
            width: 8rem;
            height: 8rem;
        }

        .bio .role {
            margin-top: 1.5rem;
        }
    }
}
