:root {
    color-scheme: light dark;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.6;

    --page-width: 1080px;
    --content-width: 820px;
    --image-width: 640px;

    --background: #f7f7f8;
    --surface: #ffffff;
    --text: #1e2228;
    --muted: #5d6672;
    --border: #d9dde3;
    --accent: #175cd3;
    --accent-hover: #0f47a8;
}


@media (prefers-color-scheme: dark) {
    :root {
        --background: #111318;
        --surface: #191d24;
        --text: #edf0f5;
        --muted: #aeb7c4;
        --border: #343b47;
        --accent: #7db1ff;
        --accent-hover: #a7caff;
    }
}

* {
    box-sizing: border-box;
}

html {
    min-width: 320px;
    background: var(--background);
}

body {
    margin: 0;
    color: var(--text);
    background: var(--background);
}

a {
    color: var(--accent);
    text-underline-offset: 0.18em;
}

a:hover {
    color: var(--accent-hover);
}

img {
    max-width: 100%;
    height: auto;
}

.site-shell {
    width: min(100% - 32px, var(--page-width));
    margin-inline: auto;
}

.site-header {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 24px;
    min-height: 84px;
    border-bottom: 1px solid var(--border);
}

.site-name {
    color: var(--text);
    font-size: 1.18rem;
    font-weight: 750;
    letter-spacing: -0.02em;
    text-decoration: none;
    white-space: nowrap;
}

.main-nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px 18px;
}

.main-nav a {
    color: var(--muted);
    font-size: 0.96rem;
    font-weight: 600;
    text-decoration: none;
}

.main-nav a:hover,
.page-home .nav-home,
.page-about .nav-about,
.page-projects .nav-projects,
.page-site .nav-site,
.page-contact .nav-contact {
    color: var(--text);
}

.page-home .nav-home,
.page-about .nav-about,
.page-projects .nav-projects,
.page-site .nav-site,
.page-contact .nav-contact {
    text-decoration: underline;
    text-decoration-color: var(--accent);
    text-decoration-thickness: 2px;
    text-underline-offset: 0.35em;
}

.language-switch {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 36px;
    padding: 6px 10px;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-weight: 750;
    text-decoration: none;
    box-shadow: 0 1px 2px rgb(16 24 40 / 5%);
}

.language-switch.is-hidden {
    visibility: hidden;
}

.language-switch:hover,
.language-switch:focus-visible {
    color: var(--text);
    border-color: var(--accent);
}

.language-switch--en .language-switch__symbol::before {
    content: "EN";
}

.language-switch--pl .language-switch__symbol::before {
    content: "PL";
}

.language-switch[data-tooltip]::after {
    position: absolute;
    z-index: 10;
    top: calc(100% + 10px);
    right: 0;
    width: max-content;
    max-width: 220px;
    padding: 7px 10px;
    color: var(--surface);
    background: var(--text);
    border-radius: 6px;
    content: attr(data-tooltip);
    font-size: 0.82rem;
    font-weight: 600;
    line-height: 1.3;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-3px);
    transition: opacity 120ms ease, transform 120ms ease;
}

.language-switch[data-tooltip]:hover::after,
.language-switch[data-tooltip]:focus-visible::after {
    opacity: 1;
    transform: translateY(0);
}

/* Simple content area: semantic HTML works without extra classes. */
main {
    max-width: 820px;
    padding: 56px 0 72px;
}

main h1,
main h2,
main h3 {
    line-height: 1.25;
    letter-spacing: -0.02em;
}

main h1 {
    margin: 0 0 1.25rem;
    font-size: clamp(2rem, 5vw, 3rem);
}

main h2 {
    margin: 2.75rem 0 0.8rem;
    font-size: clamp(1.4rem, 3vw, 1.85rem);
}

main h3 {
    margin: 2rem 0 0.65rem;
    font-size: 1.2rem;
}

main p,
main ul,
main ol,
main blockquote,
main pre,
main table {
    margin: 0 0 1rem;
}

main ul,
main ol {
    padding-left: 1.5rem;
}

main li + li {
    margin-top: 0.35rem;
}

main blockquote {
    padding-left: 1rem;
    color: var(--muted);
    border-left: 3px solid var(--border);
}

main code {
    padding: 0.1em 0.35em;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    font-size: 0.92em;
}

main address {
    font-style: normal;
}

main pre {
    overflow-x: auto;
    padding: 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
}

main pre code {
    padding: 0;
    background: transparent;
    border: 0;
}

main hr {
    margin: 2.5rem 0;
    border: 0;
    border-top: 1px solid var(--border);
}

main table {
    width: 100%;
    border-collapse: collapse;
}

main th,
main td {
    padding: 0.65rem 0.8rem;
    text-align: left;
    border: 1px solid var(--border);
}

main th {
    background: var(--surface);
}

/* Non-clickable content image */
main .content-image {
    display: block;
    width: auto;
    max-width: min(100%, var(--image-width));
    height: auto;
    margin: 1.5rem 0;
}

/* Clickable image without requiring <figure> */
main .image-link {
    display: inline-block;
    width: auto;
    max-width: min(100%, var(--image-width));
    margin: 1.5rem 0;
    line-height: 0;
    vertical-align: top;
}

/* Image inside the clickable link */
main .image-link img {
    display: block;
    width: auto;
    max-width: 100%;
    height: auto;
    margin: 0;
    cursor: zoom-in;
    transition:
        transform 150ms ease,
        box-shadow 150ms ease;
}

main .image-link:hover img,
main .image-link:focus-visible img {
    transform: scale(1.01);
    box-shadow: 0 8px 24px rgb(0 0 0 / 18%);
}

/* Optional wrapper used only when a caption is needed */
main .image-figure {
    display: block;
    width: fit-content;
    max-width: min(100%, var(--image-width));
    margin: 1.5rem 0;
}

/* Remove duplicate margins when the link is inside <figure> */
main .image-figure .image-link {
    display: block;
    max-width: 100%;
    margin: 0;
}

/* Optional caption */
main .image-figure figcaption {
    margin-top: 0.6rem;
    color: var(--muted);
    font-size: 0.9rem;
    line-height: 1.4;
    text-align: center;
}

/* Image gallery */
main .image-gallery {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
    width: 100%;
    margin: 1.5rem 0;
}

/* Reset normal figure styling inside the gallery */
main .image-gallery > .image-figure {
    display: block;
    width: 100%;
    min-width: 0;
    max-width: none;
    margin: 0;
}

/* Link fills the whole gallery tile */
main .image-gallery > .image-figure > .image-link {
    display: block;
    width: 100%;
    max-width: none;
    margin: 0;
    overflow: hidden;
    border-radius: 6px;
    line-height: 0;
}

/* Uniform gallery thumbnails */
main .image-gallery > .image-figure > .image-link > img {
    display: block;
    width: 100%;
    max-width: none;
    height: auto;
    aspect-ratio: 4 / 3;
    margin: 0;
    object-fit: cover;
}

/* Optional captions */
main .image-gallery > .image-figure > figcaption {
    margin-top: 0.5rem;
    padding-inline: 0.25rem;
    color: var(--muted);
    font-size: 0.9rem;
    line-height: 1.4;
    text-align: center;
}

/* Two columns on medium screens */
@media (max-width: 700px) {
    main .image-gallery {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* One column on small screens */
@media (max-width: 460px) {
    main .image-gallery {
        grid-template-columns: 1fr;
    }
}


main > :last-child {
    margin-bottom: 0;
}

.site-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px 24px;
    min-height: 86px;
    color: var(--muted);
    border-top: 1px solid var(--border);
    font-size: 0.92rem;
}

.site-footer p {
    margin: 0;
}

.footer-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
}

.footer-nav a {
    color: inherit;
}

@media (max-width: 860px) {
    .site-header {
        grid-template-columns: 1fr auto;
        gap: 14px;
        padding: 18px 0;
    }

    .main-nav {
        grid-column: 1 / -1;
        grid-row: 2;
        justify-content: flex-start;
        padding-bottom: 4px;
    }
}

@media (max-width: 520px) {
    .site-shell {
        width: min(100% - 24px, var(--page-width));
    }

    .main-nav {
        gap: 10px 14px;
    }

    main {
        padding: 42px 0 56px;
    }

    .site-footer {
        align-items: flex-start;
        flex-direction: column;
        justify-content: center;
        padding: 20px 0;
    }
}
