:root {
    --ink: #282522;
    --muted: #6f6860;
    --paper: #f7f3ec;
    --paper-deep: #eee6da;
    --card: #fffdf9;
    --line: #d9cdbd;
    --accent: #7d2f3b;
    --accent-dark: #5d1f2a;
    --teal: #315f61;
    --shadow: 0 16px 40px rgba(67, 50, 39, .11);
    --radius: 18px;
    --site-font: "Times New Roman", Times, "Liberation Serif", serif;
}

* { box-sizing: border-box; }

html {
    color-scheme: light;
    scroll-behavior: smooth;
}

body {
    margin: 0;
    background:
        radial-gradient(circle at 10% -10%, rgba(125, 47, 59, .08), transparent 32rem),
        var(--paper);
    color: var(--ink);
    font-family: var(--site-font);
    line-height: 1.55;
}

a { color: inherit; }

button, select { font: inherit; }

button, a, select { -webkit-tap-highlight-color: transparent; }

:focus-visible {
    outline: 3px solid rgba(49, 95, 97, .65);
    outline-offset: 3px;
}

.site-header {
    position: relative;
    max-width: 1040px;
    margin: 0 auto;
    padding: 52px 24px 34px;
    text-align: center;
}

.header-ornament {
    display: flex;
    align-items: center;
    gap: 12px;
    width: min(260px, 70vw);
    margin: 0 auto 18px;
}

.header-ornament::before,
.header-ornament::after {
    content: "";
    height: 1px;
    flex: 1;
    background: var(--accent);
}

.header-ornament span {
    width: 13px;
    height: 13px;
    border: 2px solid var(--accent);
    transform: rotate(45deg);
}

.eyebrow,
.section-kicker {
    margin: 0 0 8px;
    color: var(--accent);
    font-size: .74rem;
    font-weight: 700;
    letter-spacing: .18em;
    text-transform: uppercase;
}

.site-header h1 {
    margin: 0;
    font-family: var(--site-font);
    font-size: clamp(2rem, 5vw, 4.3rem);
    font-weight: 500;
    letter-spacing: -.035em;
    line-height: 1.04;
}

.site-heading-subtitle {
    display: block;
    margin-top: .18em;
    color: var(--accent);
    font-size: .58em;
    letter-spacing: .015em;
    line-height: 1.15;
}

.site-about-button {
    position: absolute;
    top: 24px;
    right: 24px;
}

.header-intro {
    max-width: 740px;
    margin: 22px auto 0;
    color: var(--muted);
    font-family: var(--site-font);
    font-size: clamp(1rem, 2vw, 1.2rem);
}

.catalogue-shell {
    width: min(1380px, calc(100% - 32px));
    margin: 0 auto;
}

.filter-panel {
    display: grid;
    grid-template-columns: minmax(180px, .6fr) minmax(500px, 1.4fr);
    align-items: end;
    gap: 26px;
    padding: 24px 28px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: rgba(255, 253, 249, .88);
    box-shadow: var(--shadow);
}

.filter-panel h2 {
    margin: 0;
    font-family: var(--site-font);
    font-size: 1.65rem;
    font-weight: 500;
}

.filter-form {
    display: grid;
    grid-template-columns: minmax(190px, 1.4fr) minmax(150px, .8fr) auto;
    align-items: end;
    gap: 14px;
}

.filter-form label { display: grid; gap: 7px; }

.filter-form label > span {
    color: var(--muted);
    font-size: .78rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
}

select {
    width: 100%;
    min-height: 47px;
    border: 1px solid #b8aa99;
    border-radius: 10px;
    padding: 0 40px 0 13px;
    background: #fff;
    color: var(--ink);
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 45px;
    border: 1px solid transparent;
    border-radius: 999px;
    padding: 9px 18px;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
}

.button-primary { background: var(--accent); color: #fff; }
.button-primary:hover { background: var(--accent-dark); }
.button-secondary { border-color: var(--line); background: transparent; color: var(--accent-dark); }
.button-secondary:hover { background: var(--paper-deep); }

.result-summary {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    padding: 24px 4px 14px;
    color: var(--muted);
    font-size: .9rem;
}

.result-summary p { margin: 0; }
.result-summary strong { color: var(--ink); }

.object-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 24px;
    padding-bottom: 56px;
}

.object-card {
    min-width: 0;
    overflow: hidden;
    border: 1px solid rgba(185, 168, 149, .75);
    border-radius: 16px;
    background: var(--card);
    box-shadow: 0 8px 24px rgba(68, 50, 38, .07);
    transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}

.object-card:hover {
    transform: translateY(-4px);
    border-color: rgba(125, 47, 59, .55);
    box-shadow: 0 16px 34px rgba(68, 50, 38, .14);
}

.object-card a { display: block; height: 100%; text-decoration: none; }

.thumbnail-frame {
    position: relative;
    display: grid;
    place-items: center;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    background:
        linear-gradient(135deg, rgba(255,255,255,.8), rgba(232,224,212,.75)),
        var(--paper-deep);
}

.thumbnail-frame img {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 8px;
    transition: transform .35s ease;
}

.object-card:hover img { transform: scale(1.025); }

.thumbnail-placeholder {
    position: absolute;
    color: var(--muted);
    font-family: var(--site-font);
}

.object-card h2 {
    margin: 0;
    padding: 16px 16px 18px;
    font-family: var(--site-font);
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.35;
    text-align: center;
}

.object-caption span { display: block; }

.object-caption span + span {
    margin-top: .18em;
    color: var(--muted);
    font-size: .92em;
    font-weight: 500;
}

.empty-state,
.message-card {
    max-width: 680px;
    margin: 40px auto 80px;
    padding: 36px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--card);
    box-shadow: var(--shadow);
    text-align: center;
}

.empty-state h2,
.message-card h1 {
    margin-top: 0;
    font-family: var(--site-font);
    font-weight: 500;
}

.site-footer {
    padding: 26px 20px 38px;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-family: var(--site-font);
    text-align: center;
}

.message-page { padding: 24px; }

.audit-shell {
    width: min(1100px, calc(100% - 32px));
    margin: 36px auto 70px;
}

.audit-summary {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    margin: 24px 0;
}

.audit-summary div,
.audit-section {
    padding: 20px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--card);
}

.audit-summary strong {
    display: block;
    font-family: var(--site-font);
    font-size: 2rem;
}

.audit-table-wrap { overflow-x: auto; }

.audit-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--card);
}

.audit-table th,
.audit-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--line);
    text-align: left;
}

.audit-table th { color: var(--muted); font-size: .78rem; text-transform: uppercase; }

.viewer-body { min-height: 100vh; }

.viewer-header {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 20px;
    min-height: 66px;
    padding: 12px 28px;
    border-bottom: 1px solid var(--line);
    background: rgba(255, 253, 249, .94);
}

.viewer-header p {
    margin: 0;
    font-family: var(--site-font);
    font-weight: 600;
    text-align: center;
}

.viewer-brand { grid-column: 2; }

.viewer-brand p + p {
    margin-top: 2px;
    color: var(--accent);
    font-size: .9em;
    font-weight: 500;
}

.viewer-about-button {
    grid-column: 3;
    justify-self: end;
}

.back-link {
    justify-self: start;
    color: var(--accent-dark);
    font-weight: 700;
    text-decoration: none;
}

.back-link:hover { text-decoration: underline; }

.viewer-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.12fr) minmax(360px, .88fr);
    gap: clamp(28px, 4vw, 70px);
    width: min(1520px, calc(100% - 48px));
    margin: 0 auto;
    padding: clamp(24px, 4vw, 60px) 0;
}

.viewer-panel { min-width: 0; }

.viewer-stage {
    position: relative;
    min-height: min(690px, calc(100vh - 180px));
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 22px;
    background: #f1ece3;
    box-shadow: var(--shadow);
    touch-action: none;
}

.viewer-stage canvas {
    display: block;
    width: 100%;
    height: 100%;
}

.viewer-stage:fullscreen {
    width: 100vw;
    height: 100vh;
    border: 0;
    border-radius: 0;
}

.viewer-loading {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 24px;
    background: rgba(241, 236, 227, .92);
    color: var(--muted);
    font-family: var(--site-font);
    text-align: center;
}

.viewer-loading[hidden] { display: none; }

.viewer-loading.is-error { color: var(--accent-dark); font-weight: 700; }

.viewer-controls {
    position: absolute;
    z-index: 3;
    right: 14px;
    bottom: 14px;
    left: 14px;
    display: flex;
    justify-content: center;
    gap: 8px;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity .2s ease, transform .2s ease;
}

.viewer-stage.is-ready .viewer-controls {
    opacity: 1;
    transform: none;
}

.viewer-controls button {
    border: 1px solid rgba(255,255,255,.65);
    border-radius: 999px;
    padding: 8px 13px;
    background: rgba(40, 37, 34, .86);
    color: #fff;
    cursor: pointer;
    backdrop-filter: blur(5px);
}

.viewer-controls button:hover { background: var(--accent-dark); }

.viewer-help {
    margin: 10px 0 0;
    color: var(--muted);
    font-size: .82rem;
    text-align: center;
}

.object-information {
    align-self: start;
    padding: clamp(4px, 2vw, 24px) 0;
}

.object-information h1 {
    margin: 0;
    font-family: var(--site-font);
    font-size: clamp(2rem, 4vw, 3.6rem);
    font-weight: 500;
    letter-spacing: -.025em;
    line-height: 1.08;
}

.object-meta {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin: 28px 0;
}

.object-meta div {
    padding: 15px 16px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: rgba(255,253,249,.7);
}

.object-meta dt {
    color: var(--muted);
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .1em;
    text-transform: uppercase;
}

.object-meta dd {
    margin: 4px 0 0;
    font-family: var(--site-font);
    font-size: 1.08rem;
}

.description {
    padding-top: 26px;
    border-top: 1px solid var(--line);
    color: #443e39;
    font-family: var(--site-font);
    font-size: 1.03rem;
    line-height: 1.72;
    white-space: pre-line;
}

.viewer-error { color: var(--accent-dark); }

.about-dialog {
    width: min(680px, calc(100% - 32px));
    max-height: min(80vh, 760px);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 0;
    background: var(--card);
    color: var(--ink);
    font-family: var(--site-font);
    box-shadow: 0 24px 80px rgba(40, 37, 34, .32);
}

.about-dialog::backdrop {
    background: rgba(40, 37, 34, .55);
    backdrop-filter: blur(3px);
}

.about-dialog-content { padding: clamp(24px, 5vw, 42px); }

.about-dialog h2 {
    margin: 0 0 20px;
    font-size: clamp(1.8rem, 4vw, 2.5rem);
    font-weight: 500;
    text-align: center;
}

.about-copy {
    max-height: 52vh;
    overflow-y: auto;
    line-height: 1.7;
    white-space: pre-line;
}

.about-dialog form {
    display: flex;
    justify-content: center;
    margin-top: 28px;
}

.no-js .no-js-only { display: inline-flex; }
.no-js-only { display: none; }

@media (max-width: 900px) {
    .filter-panel { grid-template-columns: 1fr; align-items: start; }
    .viewer-layout { grid-template-columns: 1fr; }
    .viewer-stage { min-height: min(70vh, 640px); }
    .object-information { max-width: 760px; }
}

@media (max-width: 640px) {
    .site-header { padding: 38px 18px 25px; }
    .site-about-button { position: static; margin-bottom: 18px; }
    .catalogue-shell { width: min(100% - 22px, 1380px); }
    .filter-panel { padding: 20px; }
    .filter-form { grid-template-columns: 1fr; }
    .result-summary { padding-inline: 2px; }
    .object-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px; }
    .object-card h2 { padding: 11px 9px 13px; font-size: .88rem; }
    .thumbnail-frame img { padding: 4px; }
    .viewer-header { grid-template-columns: 1fr auto 1fr; gap: 8px; padding: 10px 12px; }
    .viewer-header p { font-size: .74rem; }
    .back-link { font-size: .78rem; }
    .viewer-about-button { min-height: 38px; padding: 7px 12px; font-size: .78rem; }
    .viewer-layout { width: calc(100% - 22px); padding: 12px 0 34px; gap: 26px; }
    .viewer-stage { min-height: 56vh; border-radius: 14px; }
    .viewer-controls { flex-wrap: wrap; }
    .viewer-controls button { font-size: .78rem; }
    .object-meta { grid-template-columns: 1fr; }
    .audit-summary { grid-template-columns: 1fr; }
}

@media (max-width: 390px) {
    .object-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        scroll-behavior: auto !important;
        transition-duration: .001ms !important;
        animation-duration: .001ms !important;
    }
}
