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

:root {
    --page-bg: #ffe4a6;
    --grid-bg: #c7b07b;
    --text: #1a1208;
    --muted: #6b5a38;
    --input-bg: #ffffff;
    --border: rgba(0, 0, 0, 0.22);
    --btn-bg: #1a1208;
    --btn-text: #ffffff;
}

html {
    font-size: 16px;
}

body {
    background: var(--page-bg);
    color: var(--text);
    font-family: Arial, Helvetica, sans-serif;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ── Header ── */
header {
    text-align: center;
    padding: 2.5rem 1rem 2rem;
}

header h1 {
    font-family: "Instrument Serif", Georgia, serif;
    font-size: clamp(3rem, 10vw, 6rem);
    font-weight: 400;
    letter-spacing: -0.01em;
    color: var(--text);
    line-height: 1.05;
}

header h1 a {
    color: inherit;
    text-decoration: none;
}

.tagline {
    margin-top: 0.6rem;
    line-height: 1.5;
}

.tagline .line1 {
    display: block;
    font-family: Arial, Helvetica, sans-serif;
    font-size: clamp(0.85rem, 1.8vw, 1rem);
    color: var(--text);
    font-weight: 400;
}

.tagline .line2 {
    display: block;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 0.78rem;
    color: black;
    font-style: italic;
    margin-top: 0.2rem;
}

/* ── Search ── */
.search-box {
    display: flex;
    gap: 6px;
    max-width: 520px;
    margin: 1.4rem auto 0;
    padding: 0 1rem;
}

.search-box input {
    flex: 1;
    min-width: 0;
    background: #ffffff;
    border: 1px solid var(--border);
    color: #555;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    font-family: Arial, Helvetica, sans-serif;
    font-style: italic;
    outline: none;
    transition: border-color 0.15s;
    border-radius: 2px;
}

.search-box input:focus {
    border-color: #8a6f3a;
    font-style: normal;
    color: var(--text);
}

.search-box input::placeholder {
    color: #aaa;
    font-style: italic;
}

.search-box button {
    background: var(--btn-bg);
    border: 1px solid var(--btn-bg);
    color: #ffffff;
    padding: 0.5rem 0;
    width: 110px;
    flex-shrink: 0;
    font-size: 0.85rem;
    font-family: Arial, Helvetica, sans-serif;
    font-weight: 400;
    cursor: pointer;
    border-radius: 2px;
    transition: opacity 0.15s;
    white-space: nowrap;
    text-align: center;
}

.search-box button:hover {
    opacity: 0.8;
}

.search-box button:disabled {
    opacity: 0.4;
    cursor: default;
}

/* ── Grid section ── */
.grid-section {
    flex: 1;
    background: var(--grid-bg);
    margin: 1.5rem 2rem 0;
    padding: 1.5rem 1.5rem 3.5rem;
    border-radius: 3px;
}

/* ── Status bar ── */
.status {
    text-align: center;
    color: var(--muted);
    font-size: 0.78rem;
    margin-bottom: 1rem;
    min-height: 1rem;
    font-style: italic;
}

.status.error {
    color: #8b2020;
    font-style: normal;
}

/* ── Masonry grid ── */
.photo-grid {
    columns: 240px;
    column-gap: 10px;
}

.photo-card {
    break-inside: avoid;
    margin-bottom: 10px;
    background: #b09060;
    overflow: hidden;
    border-radius: 2px;
}

.photo-card a {
    display: block;
    text-decoration: none;
    color: inherit;
}

.photo-card img {
    width: 100%;
    display: block;
    transition: opacity 0.2s;
}

.photo-card:hover img {
    opacity: 0.88;
}

.photo-meta {
    padding: 0.35rem 0.5rem;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.4rem;
}

.photo-year {
    font-size: 0.72rem;
    color: var(--input-bg);
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
    opacity: 0.85;
}

.photo-title {
    font-size: 0.72rem;
    color: rgba(255, 255, 255, 0.5);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── Empty / loading states ── */
.empty-state {
    text-align: center;
    padding: 4rem 1rem;
    color: var(--input-bg);
}

.empty-state h2 {
    font-size: 1rem;
    font-weight: 400;
    margin-bottom: 0.4rem;
}

.empty-state p {
    font-size: 0.85rem;
    opacity: 0.7;
    line-height: 1.6;
}

/* ── Random modal ── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(20, 14, 4, 0.88);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 1rem;
    cursor: pointer;
}

.modal-box {
    position: relative;
    max-width: min(90vw, 900px);
    cursor: default;
}

.modal-box img {
    display: block;
    max-width: 100%;
    max-height: 80vh;
    object-fit: contain;
}

.modal-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 0 0;
    gap: 1rem;
}

.modal-year {
    color: var(--page-bg);
    font-size: 0.8rem;
}
.modal-title {
    color: rgba(245, 208, 122, 0.6);
    font-size: 0.8rem;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.modal-info a {
    color: rgba(245, 208, 122, 0.7);
    font-size: 0.78rem;
    text-decoration: none;
    white-space: nowrap;
}
.modal-info a:hover {
    color: var(--page-bg);
}

.modal-close {
    position: absolute;
    top: -2.2rem;
    right: 0;
    background: none;
    border: none;
    color: rgba(245, 208, 122, 0.6);
    font-size: 1.8rem;
    line-height: 1;
    cursor: pointer;
    padding: 0;
}
.modal-close:hover {
    color: var(--page-bg);
}

/* ── Footer — fixed overlay at bottom ── */
footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 0.55rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2rem;
    background: rgba(255, 228, 166, 0.92);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    z-index: 50;
}

footer a {
    color: var(--muted);
    text-decoration: none;
    font-size: 0.78rem;
    font-style: italic;
    transition: color 0.15s;
}
footer a:hover {
    color: var(--text);
}

.footer-refresh {
    position: absolute;
    right: 1.2rem;
    font-size: 0.82rem;
    color: #000;
    font-style: italic;
    font-weight: 700;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.4s;
}

.footer-refresh.visible {
    opacity: 1;
}

/* ── Secondary pages ── */
.page-header {
    text-align: center;
    padding: 2.5rem 1rem 1.5rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.12);
}

.page-header h1 {
    font-family: "Instrument Serif", Georgia, serif;
    font-size: clamp(3rem, 10vw, 6rem);
    font-weight: 400;
    line-height: 1.05;
    color: var(--text);
}

.page-header h1 a {
    color: inherit;
    text-decoration: none;
}

.page-content {
    max-width: 640px;
    margin: 0 auto;
    padding: 3rem 1.5rem;
}

.page-content h2 {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 0.5rem;
    margin-top: 2.2rem;
}
.page-content h2:first-child {
    margin-top: 0;
}

.page-content p,
.page-content a.donate-option {
    font-family: Arial, Helvetica, sans-serif;
    font-weight: 400;
}

.page-content p {
    color: var(--muted);
    font-size: 0.9rem;
    line-height: 1.75;
    margin-bottom: 0.75rem;
}

.page-content a {
    color: #7a5c20;
    text-decoration: none;
}
.page-content a:hover {
    text-decoration: underline;
}

.contact-form {
    margin-top: 1.2rem;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.contact-form input,
.contact-form textarea {
    background: var(--input-bg);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 0.55rem 0.75rem;
    font-size: 0.875rem;
    font-family: inherit;
    outline: none;
    resize: vertical;
    border-radius: 2px;
    transition: border-color 0.15s;
    width: 100%;
}
.contact-form input:focus,
.contact-form textarea:focus {
    border-color: #8a6f3a;
}
.contact-form input::placeholder,
.contact-form textarea::placeholder {
    color: #a08650;
}

.contact-form button {
    align-self: flex-start;
    background: var(--btn-bg);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 0.5rem 1.2rem;
    font-size: 0.85rem;
    font-family: inherit;
    cursor: pointer;
    border-radius: 2px;
    transition: background 0.15s;
}
.contact-form button:hover {
    background: #dfc88a;
}

#share-btn {
    background: var(--input-bg);
    border: 1px solid var(--border);
    padding: 0.2rem 0.4rem;
    font-size: 0.85rem;
    cursor: pointer;
    border-radius: 2px;
    line-height: 1;
    flex-shrink: 0;
    transition: background 0.15s;
}
#share-btn:hover {
    background: #ebd9a8;
}

.donate-option {
    display: inline-block;
    border: 1px solid var(--border);
    background: var(--input-bg);
    padding: 0.55rem 1.1rem;
    margin-top: 0.6rem;
    text-decoration: none;
    color: var(--text);
    font-size: 0.875rem;
    border-radius: 2px;
    transition: background 0.15s;
}
.donate-option:hover {
    background: #ebd9a8;
    text-decoration: none;
}
.donate-option span {
    display: block;
    color: var(--muted);
    font-size: 0.78rem;
    margin-top: 0.2rem;
}

/* ── Scrollbar ── */
::-webkit-scrollbar {
    width: 5px;
}
::-webkit-scrollbar-track {
    background: var(--page-bg);
}
::-webkit-scrollbar-thumb {
    background: var(--grid-bg);
}
