/* Artemis II Photo Archive — embeddable browser */
*, *::before, *::after { box-sizing: border-box; }

:root {
    --pw-orange: #f47c20;
    --pw-orange-dark: #d96812;
    --bg: #0b0d10;
    --card: #161a20;
    --card-hover: #1c2027;
    --text: #f3f4f6;
    --text-dim: #9ca3af;
    --text-mute: #6b7280;
    --border: #1f2937;
}

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--pw-orange); text-decoration: none; }
a:hover { color: var(--pw-orange-dark); text-decoration: underline; }

/* ============================================
   Header
   ============================================ */
.apb-header {
    padding: 1.75rem 1.25rem 1rem;
    text-align: center;
    border-bottom: 1px solid var(--border);
}
.apb-header h1 {
    margin: 0 0 0.4rem;
    font-size: clamp(1.4rem, 2.5vw, 1.75rem);
    font-weight: 700;
    letter-spacing: -0.01em;
}
.apb-header h1::before {
    content: "📡 ";
    margin-right: 0.25rem;
}
.apb-sub {
    margin: 0 auto 1rem;
    max-width: 56ch;
    font-size: 0.875rem;
    color: var(--text-dim);
    line-height: 1.5;
}
.apb-search {
    display: flex;
    gap: 0.5rem;
    max-width: 520px;
    margin: 0 auto;
}
.apb-search input[type="search"] {
    flex: 1;
    padding: 0.55rem 0.875rem;
    background: var(--card);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.apb-search input[type="search"]:focus {
    border-color: var(--pw-orange);
    box-shadow: 0 0 0 3px rgba(244, 124, 32, 0.18);
}
.apb-search button {
    padding: 0.55rem 1.1rem;
    background: var(--pw-orange);
    color: #000;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.15s ease;
}
.apb-search button:hover { background: #ffa040; }
.apb-search button:active { transform: scale(0.97); }

/* ============================================
   Status / loading
   ============================================ */
.apb-status {
    padding: 0.75rem 1.25rem;
    text-align: center;
    color: var(--text-dim);
    font-size: 0.8125rem;
    min-height: 2.5rem;
}
.apb-status.is-error { color: #f87171; }

/* ============================================
   Grid
   ============================================ */
.apb-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr));
    gap: 0.75rem;
    padding: 0 1rem 1rem;
    max-width: 1400px;
    margin: 0 auto;
}
.apb-cell {
    position: relative;
    cursor: zoom-in;
    overflow: hidden;
    border-radius: 6px;
    background: var(--card);
    aspect-ratio: 4 / 3;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.apb-cell:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.6);
}
.apb-cell img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: opacity 0.3s ease;
    background: var(--card);
}
.apb-cell img:not([src]) { opacity: 0; }
.apb-cell-title {
    position: absolute;
    inset: auto 0 0 0;
    padding: 1.25rem 0.625rem 0.5rem;
    background: linear-gradient(0deg, rgba(0, 0, 0, 0.85) 0%, rgba(0, 0, 0, 0) 100%);
    color: #fff;
    font-size: 0.7rem;
    line-height: 1.3;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
}
.apb-cell:hover .apb-cell-title { opacity: 1; }

/* ============================================
   Pager
   ============================================ */
.apb-pager {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 0.75rem 1rem 1.5rem;
}
.apb-pager button {
    padding: 0.5rem 1rem;
    background: var(--card);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
}
.apb-pager button:not(:disabled):hover {
    background: var(--card-hover);
    border-color: var(--pw-orange);
}
.apb-pager button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.apb-page-info {
    color: var(--text-dim);
    font-size: 0.8125rem;
    font-variant-numeric: tabular-nums;
}

/* ============================================
   Footer
   ============================================ */
.apb-footer {
    padding: 1rem 1.25rem 1.75rem;
    text-align: center;
    border-top: 1px solid var(--border);
    color: var(--text-mute);
    font-size: 0.7rem;
}
.apb-footer p { margin: 0; max-width: 64ch; margin-left: auto; margin-right: auto; }

/* ============================================
   Lightbox
   ============================================ */
.apb-lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.94);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
    overflow-y: auto;
}
.apb-lightbox[hidden] { display: none; }

.apb-lightbox__close,
.apb-lightbox__nav {
    position: fixed;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.15s ease;
    z-index: 10000;
}
.apb-lightbox__close:hover,
.apb-lightbox__nav:hover { background: rgba(255, 255, 255, 0.22); }
.apb-lightbox__close:active,
.apb-lightbox__nav:active { transform: scale(0.95); }

.apb-lightbox__close {
    top: 1rem;
    right: 1rem;
    width: 38px;
    height: 38px;
    font-size: 1.25rem;
    line-height: 1;
}
.apb-lightbox__nav {
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    font-size: 1.6rem;
    line-height: 1;
    padding: 0;
}
.apb-lightbox__nav:hover { transform: translateY(-50%) scale(1.05); }
.apb-lightbox__prev { left: 1rem; }
.apb-lightbox__next { right: 1rem; }

.apb-lightbox__inner {
    margin: 0;
    max-width: 1100px;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}
.apb-lightbox__inner img {
    max-width: 100%;
    max-height: 75vh;
    object-fit: contain;
    border-radius: 6px;
    background: #111;
}
.apb-lightbox__cap {
    width: 100%;
    color: var(--text);
}
.apb-lightbox__cap h2 {
    margin: 0 0 0.5rem;
    font-size: 1.05rem;
    font-weight: 600;
    line-height: 1.4;
}
.apb-lightbox__meta {
    margin: 0 0 0.5rem;
    color: var(--text-dim);
    font-size: 0.8125rem;
}
.apb-dot { margin: 0 0.4rem; opacity: 0.5; }
.apb-lightbox__desc {
    margin: 0 0 0.75rem;
    color: var(--text-dim);
    font-size: 0.875rem;
    line-height: 1.55;
    max-height: 8em;
    overflow-y: auto;
}
.apb-lightbox__links {
    margin: 0;
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    font-size: 0.8125rem;
}

/* ============================================
   Mobile
   ============================================ */
@media (max-width: 600px) {
    .apb-header { padding: 1rem 0.875rem 0.75rem; }
    .apb-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
        padding: 0 0.5rem 0.75rem;
    }
    .apb-lightbox { padding: 0.75rem; }
    .apb-lightbox__close { top: 0.5rem; right: 0.5rem; }
    .apb-lightbox__prev { left: 0.5rem; }
    .apb-lightbox__next { right: 0.5rem; }
    .apb-lightbox__inner img { max-height: 60vh; }
}
