/* Tyler Felts · site styles
   The whole site's styling lives in this one file (no Bootstrap or MudBlazor).
   Fonts and sizes match what MudBlazor used before: Roboto/Helvetica/Arial body text,
   a Times New Roman title, and small uppercase menu links. */

/* --- Base --- */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    /* Always reserve the scrollbar's space, so the page width (and the gallery columns)
       doesn't change when a scrollbar appears partway through loading. */
    scrollbar-gutter: stable;
}

html,
body {
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    background-color: #000;
    color: #fff;
}

body {
    font-family: Roboto, Helvetica, Arial, sans-serif;
    font-size: 1rem;
    line-height: 1.5;
    letter-spacing: 0.00938em;
    -webkit-font-smoothing: antialiased;
}

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

a {
    color: inherit;
}

:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 3px;
}

/* --- Header: name + menu --- */
.site-header {
    text-align: center;
    padding: 10px 12px 0;
}

.site-title {
    font-family: "Times New Roman", Times, serif;
    font-size: 40px;
    line-height: 1.5;
    letter-spacing: 0.00938em;
}

.site-nav ul {
    list-style: none;
    margin: 20px auto 12px;
    padding: 0;
    max-width: 930px;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
}

/* "/" between menu items */
.site-nav li + li::before {
    content: "/";
    margin: 0 26px;
    color: #fff;
}

.site-nav a {
    display: inline-block;
    padding: 6px 8px;
    border-radius: 4px;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.75;
    letter-spacing: 0.02857em;
    text-transform: uppercase;
    text-decoration: none;
    /* #bdbdbd on black is ~11:1 contrast; the active page is white and underlined. */
    color: #bdbdbd;
}

.site-nav a:hover {
    background-color: rgba(255, 255, 255, 0.08);
}

.site-nav a[aria-current="page"] {
    color: #fff;
    text-decoration: underline;
    text-decoration-thickness: 2px;
    text-underline-offset: 4px;
}

/* The line break item only matters on phones (see below). */
.site-nav .nav-break {
    display: none;
}

/* Phones: Portrait / Personal / Writing on one row, About / Contact on the next. */
@media (max-width: 579.98px) {
    .site-nav ul {
        margin-top: 10px;
    }

    .site-nav li + li::before {
        margin: 0 4px;
    }

    .site-nav a {
        margin: 10px 6px;
    }

    .site-nav .nav-break {
        display: block;
        flex-basis: 100%;
        height: 0;
    }

    .site-nav .nav-break::before,
    .site-nav .nav-break + li::before {
        content: none;
    }
}

/* --- Text pages (About, Contact, Writing intro) --- */
.text-block {
    text-align: center;
    padding: 32px 12px 0;
}

.text-block p {
    margin: 20px;
}

.about-photo {
    display: block;
    width: calc(33.333% - 24px);
    margin: 44px auto 24px;
    border-radius: 0.375rem;
}

/* --- Buttons (outlined, like before) --- */
.button {
    display: inline-block;
    padding: 5px 15px;
    border: 1px solid currentColor;
    border-radius: 4px;
    color: #bdbdbd;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.75;
    letter-spacing: 0.02857em;
    text-transform: uppercase;
    text-decoration: none;
    transition: background-color 150ms;
}

.button:hover {
    background-color: rgba(255, 255, 255, 0.08);
}

.button-info {
    color: #2196f3;
    font-weight: 700;
}

.button-info:hover {
    background-color: rgba(33, 150, 243, 0.08);
}

.button-wide {
    width: 250px;
    max-width: 100%;
    text-align: center;
}

/* --- 404 / error message --- */
.message {
    text-align: center;
    margin: 60px 20px;
}

.message h1 {
    font-size: 1.5rem;
    font-weight: 400;
    line-height: 1.334;
    margin: 0 0 16px;
}

.message p {
    margin: 0 0 24px;
}

/* --- Single photo page --- */
.photo-view {
    text-align: center;
    padding: 1rem;
}

.back-link {
    display: inline-block;
    padding: 0.375rem 0.75rem;
    margin-bottom: 0.5rem;
}

.photo-view figure {
    margin: 0 0 1rem;
}

.photo-view img {
    width: auto;
    max-width: 100%;
    /* Leave room for the header and Back link so the photo fits on screen. */
    max-height: max(320px, calc(100svh - 260px));
    object-fit: contain;
    border-radius: 6px;
}

/* --- Gallery: responsive masonry using CSS columns --- */
/* Hide the gallery until its end marker has arrived, i.e. until every tile is on the page.
   CSS columns rebalance each time a tile is added, so showing a half-loaded gallery makes tiles
   jump between columns. Browsers without :has() ignore this rule and simply show it as before. */
.gallery-shell:not(:has(> .gallery-end)) > .gallery {
    visibility: hidden;
}

/* Default: 3 columns (landscape) */
.gallery {
    column-count: 3;
    column-gap: 16px;
    padding: 12px 5%;
    width: 100%;
    margin: 0 auto;
}

/* Portrait orientation (or narrow viewports): 2 columns */
@media (orientation: portrait), (max-width: 900px) {
    .gallery {
        column-count: 2;
    }
}

/* Each tile must be inline-block to work inside columns and avoid being split */
.tile {
    display: inline-block;
    width: 100%;
    margin: 0 0 16px;
    break-inside: avoid;
    overflow: hidden;
    border-radius: 8px;
    background: transparent;
}

/* Images scale to tile (columns) width and preserve aspect ratio */
.tile img {
    width: 100%;
    height: auto;
    display: block;
    object-fit: cover;
    border-radius: 6px;
    background: #111;
}

/* Photos with width/height attributes already reserve their exact shape before loading.
   Only photos whose size couldn't be read get a placeholder shape, so the columns don't
   collapse; "auto" lets the real shape take over once the file loads. (Applying this to
   every photo would override the width/height shape and make tiles jump as they load.) */
.tile img:not([width]) {
    aspect-ratio: auto 4 / 5;
}

.tile-link {
    display: block;
    cursor: pointer;
}

.tile-link:focus-visible {
    border-radius: 6px;
}

.tile-caption {
    margin-top: 8px;
    font-size: 0.9rem;
    color: #ddd;
    text-align: center;
}

/* Small screens: tighter gaps */
@media (max-width: 600px) {
    .gallery {
        column-gap: 10px;
        padding-left: 8px;
        padding-right: 8px;
    }

    .tile {
        margin-bottom: 10px;
    }
}
