/* Shared styles for Caleb's Photos: base, masonry gallery, lightbox, toast. */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    background: #0a0a0a;
}

body {
    background: #0a0a0a;
    color: #fff;
    font-family: 'area-normal', 'Area', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    min-height: 100vh;
    -webkit-tap-highlight-color: transparent;
}

a {
    color: inherit;
}

/* ---------------- Site header ---------------- */
.site-header {
    padding: 1.25rem 1rem;
    position: sticky;
    top: 0;
    background: rgba(10, 10, 10, 0.92);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 10;
    transition: transform 0.3s ease;
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
}

.site-header.header-hidden {
    transform: translateY(-100%);
}

.site-header h1,
.site-header .brand {
    font-size: 0.9rem;
    font-weight: 700;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    color: #fff;
    text-decoration: none;
}

.site-header .meta {
    font-size: 0.8rem;
    color: #777;
    white-space: nowrap;
}

/* ---------------- Masonry ---------------- */
.masonry {
    display: flex;
    align-items: flex-start;
    max-width: 2000px;
    margin: 0 auto;
}

.masonry-column {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.photo-item {
    position: relative;
    cursor: pointer;
    overflow: hidden;
    background: #161616;
    width: 100%;
    scroll-margin-top: 5rem;
}

.photo-item img {
    width: 100%;
    height: auto;
    display: block;
    opacity: 0;
    transition: opacity 0.35s ease, transform 0.4s ease;
}

.photo-item img.loaded {
    opacity: 1;
}

.photo-item.broken {
    min-height: 120px;
}

@media (hover: hover) {
    .photo-item:hover img {
        transform: scale(1.02);
    }
}

.gallery-empty,
.gallery-loading {
    text-align: center;
    padding: 4rem 1rem;
    color: #666;
    width: 100%;
}

/* ---------------- Lightbox ---------------- */
.lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.96);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.25s ease;
    touch-action: pan-y;
}

.lightbox.active {
    display: flex;
    opacity: 1;
}

.lightbox {
    --viewer-gutter: 20px;
    --viewer-height: 100vh;
    --viewer-height: 100dvh;
    padding: 52px var(--viewer-gutter) calc(16px + env(safe-area-inset-bottom));
}

.lightbox-frame {
    width: fit-content;
    max-width: 100%;
    display: flex;
    flex-direction: column;
}

.lightbox-content {
    width: auto;
    height: auto;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-content img {
    max-width: calc(100vw - var(--viewer-gutter) * 2);
    max-height: calc(var(--viewer-height) - 140px - env(safe-area-inset-bottom));
    width: auto;
    height: auto;
    object-fit: contain;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.lightbox-content img.loaded {
    opacity: 1;
}

.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.08);
    border: none;
    color: #fff;
    width: 48px;
    height: 48px;
    border-radius: 2.5px;
    cursor: pointer;
    font-size: 1.6rem;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
}

.lightbox-nav:hover {
    background: rgba(255, 255, 255, 0.18);
}

.lightbox-prev { left: 1.5rem; }
.lightbox-next { right: 1.5rem; }

.lightbox-close {
    position: absolute;
    top: 1rem;
    right: 1.25rem;
    background: none;
    border: none;
    color: #fff;
    font-size: 2.2rem;
    line-height: 1;
    cursor: pointer;
    opacity: 0.75;
    z-index: 2;
}

.lightbox-close:hover { opacity: 1; }

.lightbox-counter {
    position: absolute;
    top: 1.35rem;
    left: 1.25rem;
    font-size: 0.8rem;
    color: #777;
    letter-spacing: 0.05em;
    z-index: 2;
}

.lightbox-bar {
    width: 100%;
    min-height: 44px;
    padding: 8px 0 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    background: none;
    z-index: 2;
    pointer-events: none;
}

.lightbox-bar > * {
    pointer-events: auto;
}

.lightbox-caption {
    font-size: 0.85rem;
    color: #ccc;
    letter-spacing: 0.02em;
    line-height: 1.4;
    flex: 1;
    min-width: 0;
}

.lightbox-caption:empty {
    display: none;
}

.lightbox-download {
    margin-left: auto;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.1);
    border: 0;
    color: #fff;
    text-decoration: none;
    font-size: 0.85rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 0.7rem 1.4rem;
    border-radius: 2.5px;
    z-index: 2;
}

.lightbox-download:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* On phones, hide arrows; swipe is the primary gesture */
@media (max-width: 768px) {
    .lightbox-nav { display: none; }
}

/* Image states and keyboard focus */
.photo-link { display: block; width: 100%; height: 100%; color: inherit; }
.photo-item:focus-within { outline: 2px solid #fff; outline-offset: -4px; }
.photo-item:has(.photo-link:focus-visible) { z-index: 1; }
.photo-state {
    position: absolute; inset: 0; display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 12px;
    padding: 16px; color: #bbb; font-size: 0.8rem; text-align: center;
    pointer-events: none;
}
.photo-item.broken { min-height: 180px; }
.photo-state .image-retry { pointer-events: auto; }
.lightbox-state {
    position: absolute; inset: 50% auto auto 50%; transform: translate(-50%, -50%);
    display: grid; justify-items: center; gap: 16px; max-width: min(70vw, 360px);
    color: #ccc; text-align: center; z-index: 1;
}
.image-retry {
    padding: 10px 16px; border: 0; border-radius: 3px;
    background: #202020; color: #fff; font: inherit; font-size: 0.8rem; cursor: pointer;
}
.lightbox-share {
    display: grid; place-items: center; flex-shrink: 0;
    width: 40px; height: 40px; margin-right: -10px; padding: 0;
    border: 0; border-radius: 4px; background: transparent;
    color: #999; cursor: pointer; transition: color 140ms ease;
}
.lightbox-share:hover, .lightbox-share.copied { color: #fff; }
.lightbox-share .copied-icon, .lightbox-share.copied .copy-icon { display: none; }
.lightbox-share.copied .copied-icon { display: block; }
.lightbox-frame:not(:has(img.loaded)) { width: min(80vw, 720px); }
.lightbox-frame:not(:has(img.loaded)) .lightbox-content { min-height: min(55vh, 440px); }
.lightbox-download {
    margin-left: 0; border: 0; background: none; padding: 10px 4px;
    font-size: 0.75rem; letter-spacing: 0; text-transform: none;
}
.lightbox-download:hover { background: none; text-decoration: underline; }
.lightbox button:focus-visible, .lightbox a:focus-visible, .lightbox input:focus-visible {
    outline: 2px solid #fff; outline-offset: 4px;
}
.lightbox-state[hidden], .image-retry[hidden], .photo-state[hidden], .lightbox-link[hidden] { display: none; }
.lightbox-link {
    width: 100%; padding: 8px 0; background: none;
}
.lightbox-link label { display: grid; gap: 8px; font-size: 0.8rem; }
.lightbox-link input { width: 100%; padding: 10px; font: inherit; }
.lightbox-share-status {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}
@media (max-width: 768px) {
    .lightbox { --viewer-gutter: 12px; }
    .lightbox-bar { gap: 12px; }
    .lightbox-caption { font-size: 0.75rem; }
}
@media (prefers-reduced-motion: reduce) {
    .photo-item img, .lightbox, .lightbox-content img { transition: none; }
    .photo-item:hover img { transform: none; }
}

/* ---------------- Toast ---------------- */
.status {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: #1a1a1a;
    border: 0;
    padding: 1rem 1.5rem;
    border-radius: 2.5px;
    font-size: 0.9rem;
    opacity: 0;
    transform: translateY(1rem);
    transition: all 0.3s;
    pointer-events: none;
    z-index: 2000;
}

.status.show {
    opacity: 1;
    transform: translateY(0);
}

.status.success {
    color: #8f8;
}

.status.error {
    color: #f88;
}

@media (max-width: 500px) {
    .status {
        left: 1rem;
        right: 1rem;
        bottom: 1rem;
        text-align: center;
    }
}

/* ---------------- Footer ---------------- */
/* Footer layout; native document scrolling remains unchanged. */
.site-footer {
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 574px));
    justify-content: center;
    justify-items: stretch;
    align-content: start;
    align-items: start;
    gap: 32px;
    padding: 56px 32px 34px;
    background: #050504;
    color: #fffffb;
}
.site-footer[hidden] { display: none; }

.legal-template .site-footer {
    height: auto;
    min-height: 0;
    overflow: visible;
    border: 0;
    padding-top: 70px;
}

.footer-meta {
    align-self: start;
    width: 100%;
    margin: 0;
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
    align-items: start;
}

.footer-mark {
    display: grid;
    gap: 6px;
    font-family: 'area-normal', 'Area', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    color: #fffffb;
    font-size: 10px;
    line-height: 14px;
    text-transform: uppercase;
}
.footer-mark p:first-child {
    font-family: 'area-normal', 'Area', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1.8px;
    line-height: 15px;
    text-transform: uppercase;
}
.footer-mark p:last-child {
    font-family: 'area-normal', 'Area', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-weight: 700;
    letter-spacing: 1.8px;
}

.footer-contact,
.footer-legal {
    font-family: 'area-normal', 'Area', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    text-transform: uppercase;
}

.footer-contact {
    display: grid;
    gap: 6px;
    justify-items: start;
    color: rgba(245, 243, 238, 0.82);
    font-size: 12px;
    font-weight: 400;
    line-height: 16px;
}

.footer-legal {
    width: 100%;
    margin: 0;
    display: grid;
    justify-items: end;
    text-align: right;
    gap: 6px;
    color: rgba(245, 243, 238, 0.82);
    font-size: 11px;
    font-weight: 400;
    line-height: 15px;
}

.footer-contact a,
.footer-legal a {
    color: inherit;
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 0.22em;
    text-decoration-color: transparent;
    transition: color 160ms ease, text-decoration-color 160ms ease;
}

.footer-contact a:hover,
.footer-legal a:hover {
    color: #fffffb;
    text-decoration-color: currentColor;
}

@media (max-width: 920px) {
    .site-footer { align-content: center; gap: 24px; padding: 52px 20px 28px; }
    .legal-template .site-footer { padding: 56px 20px 28px; }
}
