/* ==========================================================
   Image Board styles
   Colors live in one place (just below) so they're easy to change.
   ========================================================== */

:root {
    --bg: #161817;          /* page background */
    --surface: #202322;     /* empty photo tile while it loads */
    --line: #2c302e;        /* thin divider lines */
    --text: #eceeec;        /* main text */
    --muted: #8b928e;       /* quieter text (years, counts) */
    --accent: #00FAB3;      /* mint highlight */

    --gutter: clamp(12px, 4vw, 40px);   /* space at the left and right edges */
    --gap: 6px;                         /* space between photos */
    --cols: 2;                          /* photos per row (changes with screen size below) */

    color-scheme: dark;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: "Bricolage Grotesque", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-optical-sizing: auto;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

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

h1, h2, p {
    margin: 0;
}

/* Keeps the page lined up and centered on wide screens */
.site-header,
.board,
.site-footer {
    max-width: 1400px;
    margin-inline: auto;
    padding-left: max(var(--gutter), env(safe-area-inset-left));
    padding-right: max(var(--gutter), env(safe-area-inset-right));
}

/* ---------- Page header ---------- */

.site-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
    padding-top: max(20px, env(safe-area-inset-top));
    padding-bottom: 16px;
}

.site-header h1 {
    font-size: clamp(1.375rem, 1rem + 1.4vw, 2rem);
    font-weight: 700;
    letter-spacing: -0.015em;
    line-height: 1.1;
}

.photo-total {
    color: var(--muted);
    font-size: 0.9375rem;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* ---------- One day of photos ---------- */

.day {
    border-top: 1px solid var(--line);
    padding-bottom: 32px;
}

/* Phone and tablet: the date is a bar that stays at the top while you scroll that day */
.day-label {
    position: sticky;
    top: 0;
    z-index: 2;
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-inline: calc(-1 * var(--gutter));
    padding: 12px var(--gutter) 10px;
    background: rgba(22, 24, 23, 0.92);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
}

.day-label h2 {
    font-weight: 700;
    line-height: 1.1;
}

.day-md {
    font-size: 1.25rem;
    letter-spacing: -0.01em;
}

.day-year {
    margin-left: 4px;
    color: var(--muted);
    font-size: 1rem;
    font-weight: 500;
}

.day-count {
    color: var(--accent);
    font-size: 0.875rem;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* ---------- The photo grid ---------- */

.grid {
    display: grid;
    grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
    gap: var(--gap);
}

.tile {
    position: relative;
    display: block;
    aspect-ratio: 4 / 5;
    overflow: hidden;
    border-radius: 4px;
    background: var(--surface);
    cursor: zoom-in;
    -webkit-tap-highlight-color: transparent;
}

.tile img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: opacity 0.4s ease, transform 0.5s ease;
}

/* Photos fade in once they finish loading (only when the script is running) */
.js .tile img {
    opacity: 0;
}

.js .tile img.is-loaded {
    opacity: 1;
}

@media (hover: hover) {
    .tile:hover img {
        transform: scale(1.03);
    }
}

.tile:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Shown if a photo file is missing */
.tile.is-broken::after {
    content: "Photo not found";
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    color: var(--muted);
    font-size: 0.8125rem;
}

/* ---------- Footer ---------- */

.site-footer {
    padding-top: 8px;
    padding-bottom: max(40px, env(safe-area-inset-bottom));
}

.to-top {
    display: inline-block;
    padding: 10px 0;
    color: var(--muted);
    font-size: 0.9375rem;
    text-decoration: none;
}

.to-top:hover {
    color: var(--text);
}

.to-top:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 4px;
    border-radius: 2px;
}

/* ---------- Screen sizes ---------- */

/* Large phones turned sideways, small tablets */
@media (min-width: 560px) {
    :root {
        --cols: 3;
    }
}

/* Tablets */
@media (min-width: 760px) {
    :root {
        --cols: 4;
        --gap: 8px;
    }
}

/* Desktop: dates move into their own column on the left */
@media (min-width: 900px) {
    :root {
        --cols: 3;
        --gap: 10px;
    }

    .site-header {
        padding-top: 48px;
        padding-bottom: 28px;
    }

    .day {
        display: grid;
        grid-template-columns: 200px minmax(0, 1fr);
        column-gap: 32px;
        align-items: start;
        padding-top: 24px;
        padding-bottom: 64px;
    }

    .day-label {
        top: 24px;
        display: block;
        margin: 0;
        padding: 0;
        background: none;
        -webkit-backdrop-filter: none;
        backdrop-filter: none;
    }

    .day-md {
        display: block;
        font-size: 2.75rem;
        line-height: 1;
        letter-spacing: -0.025em;
    }

    .day-year {
        display: block;
        margin: 8px 0 0;
        font-size: 1.125rem;
    }

    .day-count {
        margin-top: 16px;
    }
}

@media (min-width: 1100px) {
    :root {
        --cols: 4;
    }
}

@media (min-width: 1400px) {
    :root {
        --cols: 5;
    }
}

/* ==========================================================
   Full-screen photo viewer
   ========================================================== */

html.viewer-open {
    overflow: hidden;
}

.viewer {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: grid;
    grid-template-columns: 80px minmax(0, 1fr) 80px;
    grid-template-rows: auto minmax(0, 1fr) auto;
    grid-template-areas:
        ".    .     close"
        "prev stage next"
        "info info  info";
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    background: #0a0b0b;
    animation: viewer-in 0.2s ease-out;
}

.viewer[hidden] {
    display: none;
}

@keyframes viewer-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.viewer-stage {
    grid-area: stage;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0;
    padding: 4px 0;
    touch-action: pan-y pinch-zoom;
}

.viewer-img {
    display: block;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 2px;
    user-select: none;
    -webkit-user-select: none;
    transition: opacity 0.15s ease;
}

.viewer-img.is-switching {
    opacity: 0;
}

.viewer-btn {
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.15s ease;
}

.viewer-btn svg {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.viewer-btn:hover {
    background: rgba(255, 255, 255, 0.16);
}

.viewer-btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.viewer-btn:disabled {
    opacity: 0.25;
    cursor: default;
}

.viewer-btn:disabled:hover {
    background: rgba(255, 255, 255, 0.08);
}

.viewer-close {
    grid-area: close;
    justify-self: center;
    margin: 12px 0;
}

.viewer-prev {
    grid-area: prev;
    place-self: center;
}

.viewer-next {
    grid-area: next;
    place-self: center;
}

.viewer-info {
    grid-area: info;
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 24px 18px;
    font-size: 0.9375rem;
}

.viewer-date {
    color: var(--text);
}

.viewer-pos {
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

/* Phone viewer: arrows move to the bottom, next to the date, so they're easy to reach with a thumb */
@media (max-width: 699px) {
    .viewer {
        grid-template-columns: 72px minmax(0, 1fr) 72px;
        grid-template-areas:
            ".     .     close"
            "stage stage stage"
            "prev  info  next";
    }

    .viewer-close {
        margin: 8px 0;
    }

    .viewer-info {
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        padding: 12px 0 16px;
        text-align: center;
    }
}

/* Turn off movement for people who've asked their device for less motion */
@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        animation: none !important;
        transition: none !important;
    }
}
