/*
Theme Name: Art Catalogue
Theme URI: https://artcatalogue.decipherable.ai/
Author: Decipherable
Description: WordPress port of the custom Art Catalogue app — card-grid browse, single-record view with lightbox and gallery carousel, and a client-side statistics page. Visual design cloned from the original app's style.css.
Version: 1.0.0
Requires PHP: 8.0
License: GNU General Public License v2 or later
Text Domain: artcatalogue
*/

:root {
  --ink: #2b2620;
  --text: #4f4f4f;
  --paper: #ffffff;
  --card: #ffffff;
  --accent: #8c2d19;
  --line: #d9d9d9;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: 'Avenir Next', Avenir, Calibri, Carlito, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  background: var(--paper);
  color: var(--text);
}
main { max-width: 1200px; margin: 0 auto; padding: 1rem 1.5rem 3rem; }
a { color: var(--accent); }
h1 { font-weight: normal; }

/* top bar */
.topbar {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding: 0.7rem 1.5rem;
  background: var(--ink); color: var(--paper);
  position: sticky; top: 0; z-index: 5;
}
.topbar .brand { color: var(--paper); text-decoration: none; font-size: 1.2rem; display: flex; align-items: center; gap: 0.6rem; }
.topbar .brand-logo { height: 2.1rem; width: auto; display: block; background: #fff; padding: 2px 6px; border-radius: 4px; }
.topbar nav { margin-left: auto; display: flex; gap: 1rem; }
.topbar nav a { color: var(--paper); text-decoration: none; }
.topbar nav a:hover { text-decoration: underline; }
.topbar nav .stats-btn {
  background: var(--accent); padding: 0.25rem 0.8rem; border-radius: 4px;
}
.search { display: flex; gap: 0.4rem; flex: 1; max-width: 420px; }
.search input {
  flex: 1; padding: 0.4rem 0.6rem; border: none; border-radius: 4px;
  font: inherit;
}
.search button, .login-box button {
  background: var(--accent); color: #fff; border: none; border-radius: 4px;
  padding: 0.4rem 1rem; font: inherit; cursor: pointer;
}

/* login */
.login-box {
  max-width: 360px; margin: 12vh auto; padding: 2rem;
  background: var(--card); border: 1px solid var(--line); border-radius: 8px;
  text-align: center;
}
.login-box input {
  width: 100%; padding: 0.5rem; margin-bottom: 0.8rem;
  border: 1px solid var(--line); border-radius: 4px; font: inherit;
}
.login-box .error { color: var(--accent); }
.login-box .warn { color: #a8651b; }

/* browse grid */
.grid {
  display: grid; gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 6px;
  overflow: hidden; text-decoration: none; color: var(--ink);
  display: flex; flex-direction: column;
  outline: 2px solid transparent;
  transition: box-shadow 0.15s, transform 0.15s, outline-color 0.15s;
}
.card:hover, .card:focus-visible {
  box-shadow: 0 6px 18px rgba(0,0,0,0.28);
  transform: translateY(-3px);
  outline-color: var(--accent);
}
.card img { width: 100%; height: 180px; object-fit: contain; background: #f4f4f4; }
.noimg {
  width: 100%; height: 180px; display: flex; align-items: center; justify-content: center;
  background: #f4f4f4; color: #999; font-style: italic;
}
.noimg.big { height: 320px; border-radius: 6px; }
.card-body { padding: 0.6rem 0.8rem; display: flex; flex-direction: column; gap: 0.15rem; }
.card-body { flex: 1; }
.card-body .itemno { font-size: 0.78rem; color: #6b6b6b; letter-spacing: 0.05em; margin-top: auto; padding-top: 0.35rem; }
.card-body .title { font-style: italic; font-size: 0.9rem; }
.card-body .medium { font-size: 0.8rem; color: #595959; }

.pager {
  display: flex; justify-content: space-between; align-items: center;
  margin: 1rem 0; color: #595959;
}
.empty { font-style: italic; }

/* record view */
.record-nav {
  display: flex; justify-content: space-between; align-items: center;
  margin: 0.5rem 0 1rem; color: #595959;
}
.record { display: flex; gap: 2rem; flex-wrap: wrap; }
.record-left { flex: 1 1 380px; min-width: 0; }
.record-image { flex: 1 1 380px; }
.record-image img {
  width: 100%; max-height: 75vh; object-fit: contain;
  background: var(--card); border: 1px solid var(--line); border-radius: 6px;
}
.record-details { flex: 1 1 340px; }
.record-details h1 { margin: 0; color: #6b6b6b; font-size: 1rem; letter-spacing: 0.08em; }
.record-details h2 { margin: 0.2rem 0 1rem; font-size: 1.6rem; }
.detail-table { border-collapse: collapse; width: 100%; background: var(--card); }
.detail-table th, .detail-table td {
  text-align: left; padding: 0.5rem 0.7rem; border: 1px solid var(--line);
  vertical-align: top;
}
.detail-table th { width: 38%; background: #f4f4f4; font-weight: normal; color: #595959; }
/* "Dimensions" group: a bold main heading with Framed/Unframed indented beneath
   it, shown as ONE connected block (internal row borders removed). Same label
   shading as the other rows — no highlight. */
.detail-table tr.subsection th { font-weight: bold; }
.detail-table tr.subsection th,
.detail-table tr.subsection td { border-bottom: none; }
.detail-table tr.dim-field th { padding-left: 1.6rem; }
.detail-table tr.dim-field th,
.detail-table tr.dim-field td { border-top: none; border-bottom: none; }

/* statistics */
.lede { font-size: 1.05rem; }
.controls { display: flex; gap: 1.5rem; margin: 1rem 0 0.3rem; flex-wrap: wrap; }
.controls select { font: inherit; padding: 0.3rem; }
.hint { color: #595959; font-size: 0.9rem; margin-top: 0.2rem; }
.stats-table { border-collapse: collapse; width: 100%; background: var(--card); }
.stats-table th, .stats-table td {
  text-align: left; padding: 0.45rem 0.7rem; border: 1px solid var(--line);
}
.stats-table th {
  background: var(--ink); color: var(--paper); cursor: pointer; user-select: none;
  position: sticky; top: 3.4rem;
}
.stats-table th .arrow { font-size: 0.8em; }
.stats-table tr:nth-child(even) td { background: #f7f7f7; }
.stats-table td.num { text-align: right; font-variant-numeric: tabular-nums; }

footer { text-align: center; color: #6b6b6b; padding: 1rem; font-size: 0.85rem; }
footer .footer-credit { display: block; margin-top: 0.35rem; }

/* ---- record image: clickable to enlarge ---- */
.record-image { position: relative; cursor: zoom-in; }
.record-image .zoom-hint {
  position: absolute; bottom: 0.6rem; right: 0.6rem;
  background: rgba(43, 38, 32, 0.72); color: var(--paper);
  padding: 0.15rem 0.55rem; border-radius: 4px; font-size: 0.78rem;
  opacity: 0; transition: opacity 0.15s; pointer-events: none;
}
.record-image:hover .zoom-hint { opacity: 1; }
body.no-scroll { overflow: hidden; }

/* ---- lightbox overlay ---- */
.lightbox {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(20, 17, 14, 0.92);
  display: flex; align-items: center; justify-content: center;
  cursor: zoom-out; padding: 2rem;
}
.lightbox[hidden] { display: none; }
.lightbox figure { margin: 0; text-align: center; max-width: 95vw; max-height: 95vh; }
.lightbox img {
  max-width: 95vw; max-height: 85vh; object-fit: contain;
  box-shadow: 0 6px 40px rgba(0,0,0,0.6); background: #fff; cursor: default;
}
.lightbox figcaption {
  color: var(--paper); margin-top: 0.8rem; font-size: 0.95rem;
  letter-spacing: 0.02em;
}

/* Blank fields are hidden from viewers (the class is only emitted when the
   user cannot see admin fields; admins always see every field). */
.empty-row { display: none; }

.detail-table td .hint { display: block; color: #6b6b6b; font-size: 0.78rem; margin-top: 0.2rem; }

/* ---- below-image fields (image rights, acquisition date / cost) ---- */
.below-image { margin: 0.8rem 0 0; display: grid; gap: 0.5rem; }
.below-image .bi-field { display: grid; grid-template-columns: 40% 1fr; gap: 0.5rem; align-items: baseline; }
.below-image dt { font-weight: bold; color: var(--ink); }
.below-image dt::after { content: ':'; }
.below-image dd { margin: 0; }

/* ---- admin-only field section ---- */
.admin-fields { margin-top: 1.4rem; }
.admin-fields h2 {
  font-size: 1rem; color: var(--accent); border-top: 2px solid var(--line);
  padding-top: 0.8rem; margin-bottom: 0.5rem; letter-spacing: 0.02em;
}

/* present-location value: opens the history popup */
.loc-value { color: var(--accent); cursor: pointer; text-decoration: underline dotted; }

/* ---- viewer-visibility checkboxes (edit mode, first field group) ---- */
.detail-table .vis-cell { display: none; }
body.editing .detail-table .vis-cell {
  display: table-cell; width: 1.6rem; text-align: center; vertical-align: middle;
}
body.editing .detail-table .vis-cell input { cursor: pointer; accent-color: var(--accent); }

/* ---- browse ordering selectors ---- */
.sortbar { display: flex; gap: 1.2rem; align-items: center; flex-wrap: wrap; margin: 0.2rem 0 0.6rem; font-size: 0.9rem; color: #595959; }
.sortbar select { font: inherit; padding: 0.2rem 0.4rem; border: 1px solid var(--line); border-radius: 4px; background: var(--card); color: var(--ink); }

/* ---- original spreadsheet view (superusers) ---- */
.ss-note { max-width: 1100px; margin: 0.8rem auto; padding: 0 1.5rem; color: #6b6b6b; font-size: 0.9rem; }
.ss-wrap { overflow: auto; max-height: 78vh; margin: 0 1rem 2rem; border: 1px solid var(--line); background: var(--card); }
.ss-table { border-collapse: collapse; font-size: 0.85rem; min-width: 1400px; }
.ss-table th, .ss-table td { border: 1px solid var(--line); padding: 0.35rem 0.55rem; vertical-align: top; text-align: left; }
.ss-table thead th { position: sticky; top: 0; background: var(--ink); color: var(--paper); z-index: 2; white-space: nowrap; }
.ss-table td.num, .ss-table th.num { text-align: right; font-variant-numeric: tabular-nums; color: #6b6b6b; }
.ss-table td.img { width: 76px; }
.ss-table td.img img { width: 70px; height: auto; display: block; }
.ss-table tbody tr:nth-child(even) td { background: #f7f7f7; }

/* ---- About box + generic pages ---- */
.about-box { cursor: default; }
.about-card { max-width: 640px; position: relative; max-height: 85vh; overflow-y: auto; }
.about-card .about-close {
  position: absolute; top: 0.5rem; right: 0.7rem;
  background: none; border: none; font-size: 1.5rem; line-height: 1;
  color: #6b6b6b; cursor: pointer;
}
.about-card .about-close:hover { color: var(--ink); }
.about-content p { margin: 0 0 0.8rem; }
.page-content { max-width: 720px; margin: 2rem auto; padding: 0 1.5rem; }
.page-content h1 { margin-bottom: 1rem; }

/* ---- location history popup ---- */
.history-card {
  background: var(--card); color: var(--ink); border-radius: 8px;
  padding: 1.2rem 1.5rem; max-width: 480px; width: 100%; cursor: default;
  box-shadow: 0 6px 30px rgba(0,0,0,0.4);
}
.history-card h3 { margin: 0 0 0.6rem; }
.history-list { list-style: none; margin: 0; padding: 0; }
.history-list li { padding: 0.35rem 0; border-bottom: 1px solid var(--line); }
.history-list li:last-child { border-bottom: none; }
.history-list .hdate { color: #6b6b6b; font-variant-numeric: tabular-nums; }
.history-list .muted { color: #6b6b6b; font-style: italic; }

/* ==================== superuser front-end editing (task #5) ==================== */

body.editing .record-image { cursor: pointer; }
body.editing .record-image .zoom-hint { display: none; }

/* ---- superuser edit controls ---- */
.edit-fab {
  position: fixed; bottom: 1.4rem; right: 1.4rem; z-index: 40;
  background: var(--accent); color: #fff; border: none; border-radius: 24px;
  padding: 0.6rem 1.3rem; font: inherit; font-size: 1rem; cursor: pointer;
  box-shadow: 0 3px 12px rgba(0,0,0,0.3);
}
.edit-fab:hover { filter: brightness(1.1); }
body.editing .edit-fab { background: #46708c; }

.delete-fab {
  position: fixed; bottom: 4.6rem; right: 1.4rem; z-index: 40; display: none;
  background: #b3261e; color: #fff; border: none; border-radius: 24px;
  padding: 0.6rem 1.3rem; font: inherit; font-size: 1rem; cursor: pointer;
  box-shadow: 0 3px 12px rgba(0,0,0,0.3);
}
body.editing .delete-fab { display: block; }
.delete-fab:hover { filter: brightness(1.1); }
.delete-fab:disabled { opacity: 0.6; cursor: default; }

.edit-bar {
  position: fixed; bottom: 1.4rem; left: 50%; transform: translateX(-50%);
  z-index: 41; display: flex; align-items: center; gap: 0.8rem;
  background: var(--ink); color: var(--paper);
  padding: 0.6rem 1.1rem; border-radius: 8px;
  box-shadow: 0 3px 16px rgba(0,0,0,0.4);
}
.edit-bar[hidden] { display: none; }
.edit-bar-label { font-size: 0.9rem; color: #cbb; }
.edit-bar button {
  background: var(--accent); color: #fff; border: none; border-radius: 4px;
  padding: 0.4rem 1rem; font: inherit; cursor: pointer;
}
.edit-bar button.secondary { background: #595959; }
.edit-bar button:disabled { opacity: 0.6; cursor: default; }
#saveStatus { font-size: 0.9rem; }

/* ---- editable field controls (display span + input, toggled by edit mode) ---- */
.fv-input { display: none; }                 /* hidden until editing */
body.editing .fv-input {
  display: block; width: 100%; font: inherit;
  padding: 0.35rem 0.45rem; border: 1px solid #b5b5b5; border-radius: 4px;
  background: #fafafa;
}
body.editing select.fv-input { padding: 0.3rem; }
body.editing textarea.fv-input { resize: vertical; min-height: 3.4em; }
body.editing .fv-input:focus { outline: 2px solid var(--accent); outline-offset: -2px; }
body.editing .fv-display { display: none; }   /* hide the read-only value while editing */

/* in-place editable cells (detail table + location): the value itself becomes
   editable in edit mode — no separate input box duplicating it */
body.editing .fv-edit {
  background: #fafafa; outline: 2px solid #b5b5b5; outline-offset: -2px;
  cursor: text; min-height: 1.2em;
}
body.editing .fv-edit:focus { outline-color: var(--accent); }

/* present-location value edits in place while editing */
body.editing .loc-value { color: inherit; cursor: text; text-decoration: none; }

/* the locked catalogue key — visibly not editable while editing */
body.editing .locked-field { background: #f4f4f4; color: #595959; }
body.editing .locked-field::after { content: ' 🔒'; font-size: 0.8em; opacity: 0.6; }

/* ---- image tools (edit mode) ---- */
.image-tools { display: none; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.6rem; }
body.editing .image-tools { display: flex; }
.image-tools button {
  background: var(--card); color: var(--ink); border: 1px solid var(--line);
  border-radius: 6px; padding: 0.45rem 0.9rem; font: inherit; cursor: pointer;
}
.image-tools button:hover { background: #f4f4f4; }

/* secondary link to the wp-admin meta-box editor */
.wpadmin-link { font-size: 0.85rem; color: #6b6b6b; margin-top: 0.6rem; }

/* ==================== redesign (December 2026) ==================== */
.card { color: var(--text); }
.card-body .date { font-size: 0.85rem; }

/* entry page */
.entry { text-align: center; }
.entry-title { font-size: clamp(1.5rem, 3.5vw, 2.4rem); margin: 1.6rem 0; }
.entry-title a { color: var(--text); text-decoration: none; border-bottom: 2px solid var(--accent); padding-bottom: 0.15rem; }
.entry-title a:hover { color: var(--accent); }
.entry-banner { margin: 0 calc(50% - 50vw); }
.entry-banner img { display: block; width: 100%; height: min(62vh, 640px); object-fit: cover; }
.entry-banner figcaption { padding: 0.7rem 1.5rem; font-size: 0.95rem; }
body.home { overflow-x: clip; }

/* record page: picture left, centred summary right */
.record { gap: 4rem; padding-top: 1rem; }
.record-left { flex-basis: 420px; }
.record-details { align-self: center; }
.record-image img { border: none; border-radius: 0; background: none; object-position: left top; }
.record-itemno { margin: 0.6rem 0 0; font-size: 1.05rem; }
.summary { text-align: center; max-width: 440px; margin: 0 auto 2rem; }
.record-details .summary-artist { font-weight: bold; font-size: 2.1rem; line-height: 1.2; letter-spacing: 0; margin: 0 0 0.5rem; color: var(--text); }
.summary-title { font-style: italic; font-size: 1.9rem; line-height: 1.25; margin: 0 0 1.4rem; }
.summary-line { border-top: 1px solid #777; margin: 0; padding: 1.3rem 0; font-size: 1.35rem; }
.record-details > p:last-child { text-align: center; }
.thumbs { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.5rem; }
.thumbs[hidden] { display: none; }
.thumbs button { padding: 0; border: 2px solid transparent; background: none; cursor: pointer; line-height: 0; }
.thumbs button[aria-current] { border-color: var(--accent); }
.thumbs img { width: 52px; height: 52px; object-fit: cover; }
.detail-table tr.edit-row { display: none; }
body.editing .detail-table tr.edit-row { display: table-row; }
