/* Base layout */
:root {
    --color-text: #1a1a1a;
    --color-muted: #666666;
    --color-bg: #ffffff;
    --color-surface: #ffffff;
    --color-accent: #2a5db0;
    --color-border: #e0e0e0;
}

/* Dark palette: follows system preference by default... */
@media (prefers-color-scheme: dark) {
    :root {
        --color-text: #e8e8e8;
        --color-muted: #a0a0a0;
        --color-bg: #16181c;
        --color-surface: #212327;
        --color-accent: #6ea8ff;
        --color-border: #34373d;
    }
}

/* ...but an explicit choice (via the toggle button) always wins over the system setting */
:root[data-theme="dark"] {
    --color-text: #e8e8e8;
    --color-muted: #a0a0a0;
    --color-bg: #16181c;
    --color-surface: #212327;
    --color-accent: #6ea8ff;
    --color-border: #34373d;
}

:root[data-theme="light"] {
    --color-text: #1a1a1a;
    --color-muted: #666666;
    --color-bg: #ffffff;
    --color-surface: #ffffff;
    --color-accent: #2a5db0;
    --color-border: #e0e0e0;
}

* {
    box-sizing: border-box;
}

html {
    height: 100%;
}

body {
    margin: 0;
    min-height: 100%;
    display: flex;
    flex-direction: column;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    color: var(--color-text);
    background: var(--color-bg);
    line-height: 1.5;
    transition: background-color 0.15s ease, color 0.15s ease;
}

/* Dark-mode toggle */
.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    border: 1px solid var(--color-border);
    border-radius: 999px;
    background: transparent;
    color: var(--color-text);
    cursor: pointer;
    flex-shrink: 0;
}

.theme-toggle svg {
    width: 1.1rem;
    height: 1.1rem;
}

.theme-toggle .theme-toggle__icon--dark {
    display: none;
}

/* Default: system prefers dark and no explicit choice has been made -> show the "currently dark" icon */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .theme-toggle .theme-toggle__icon--light {
        display: none;
    }
    :root:not([data-theme="light"]) .theme-toggle .theme-toggle__icon--dark {
        display: block;
    }
}

/* Explicit choice always wins over the system setting */
:root[data-theme="dark"] .theme-toggle .theme-toggle__icon--light {
    display: none;
}

:root[data-theme="dark"] .theme-toggle .theme-toggle__icon--dark {
    display: block;
}

.site-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* Header */
.site-header {
    border-bottom: 1px solid var(--color-border);
}

.site-header__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    padding: 1rem 1.5rem;
}

.site-header__logo {
    font-size: 1.25rem;
    font-weight: 700;
    text-decoration: none;
    color: var(--color-text);
}

.site-header__right {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.site-nav__list {
    list-style: none;
    display: flex;
    gap: 1.5rem;
    margin: 0;
    padding: 0;
}

.site-nav__link {
    text-decoration: none;
    color: var(--color-text);
}

.site-nav__link:hover,
.site-nav__link.is-active {
    color: var(--color-accent);
}

/* Main content */
.site-main {
    padding: 2rem 0;
    flex: 1;
}

/* Footer */
.site-footer {
    border-top: 1px solid var(--color-border);
    margin-top: 2rem;
}

.site-footer__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    padding: 1.5rem;
    font-size: 0.9rem;
    color: var(--color-muted);
}

.site-footer__list {
    list-style: none;
    display: flex;
    gap: 1rem;
    margin: 0;
    padding: 0;
}

.site-footer__list a {
    color: var(--color-muted);
}

/* Gallery */
.gallery__filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.gallery__filter {
    border: 1px solid var(--color-border);
    background: transparent;
    color: var(--color-text);
    border-radius: 999px;
    padding: 0.35rem 1rem;
    cursor: pointer;
    font-size: 0.9rem;
}

.gallery__filter.is-active {
    background: var(--color-accent);
    border-color: var(--color-accent);
    color: #fff;
}

.gallery__grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
}

.gallery__item {
    margin: 0;
}

.gallery__item[hidden] {
    display: none;
}

.gallery__link {
    display: block;
    cursor: zoom-in;
}

.gallery__thumb {
    width: 100%;
    height: 165px;
    object-fit: cover;
    border-radius: 4px;
    display: block;
}

.gallery__caption {
    font-size: 0.85rem;
    color: var(--color-muted);
    margin-top: 0.35rem;
}

/* Lightbox */
.lightbox {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox[hidden] {
    display: none;
}

.lightbox__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
}

.lightbox__dialog {
    position: relative;
    z-index: 1;
    max-width: 90vw;
    max-height: 90vh;
    background: var(--color-surface);
    color: var(--color-text);
    border-radius: 6px;
    padding: 1.5rem;
    overflow: auto;
    text-align: center;
}

.lightbox__image {
    max-width: 100%;
    max-height: 65vh;
    display: block;
    margin: 0 auto 1rem;
    border-radius: 4px;
}

.lightbox__title {
    margin: 0 0 0.5rem;
}

.lightbox__description {
    margin: 0;
    color: var(--color-muted);
}

.lightbox__close {
    position: absolute;
    top: 0.5rem;
    right: 0.75rem;
    border: none;
    background: transparent;
    font-size: 1.75rem;
    line-height: 1;
    cursor: pointer;
    color: var(--color-text);
}
