/* Layout and components for public exhibition pages. Colours and type come from themes.css. */
[hidden] { display: none !important; }
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
a { color: inherit; }
h1, h2, h3 {
  font-family: var(--font-head);
  font-weight: var(--head-weight);
  letter-spacing: var(--head-tracking);
  line-height: 1.25;
  margin: 0 0 0.4em;
}
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.wrap { width: 100%; max-width: 1240px; margin: 0 auto; padding: 0 20px; }
.muted { color: var(--muted); }

/* Header */
.site-head { border-bottom: 1px solid var(--line); background: var(--bg); }
.site-head .wrap { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 64px; }
.brand { font-family: var(--font-head); font-weight: var(--head-weight); text-decoration: none; font-size: 1.05rem; }
.nav { display: flex; gap: 6px; flex-wrap: wrap; }
.nav a { text-decoration: none; padding: 10px 12px; min-height: 44px; display: inline-flex; align-items: center; border-radius: var(--radius); color: var(--muted); }
.nav a:hover, .nav a[aria-current="page"] { color: var(--ink); }

/* Ornament band (level chosen per exhibition) */
.ornament { height: 10px; background: var(--ornament); opacity: 0.9; }
[data-ornament="light"] .ornament { height: 6px; opacity: 0.55; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 20px; border-radius: var(--radius);
  border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
  transition: transform 150ms ease, opacity 150ms ease;
}
.btn:hover { opacity: 0.9; }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
[data-theme="pop"] .btn { box-shadow: 3px 3px 0 var(--ink); border-color: var(--ink); }

/* Exhibition hero */
.hero { padding: 56px 0 40px; }
.hero-grid { display: grid; gap: 32px; grid-template-columns: 1fr; align-items: end; }
@media (min-width: 900px) { .hero-grid.has-image { grid-template-columns: 1.1fr 0.9fr; } }
.eyebrow { font-size: 0.85rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin: 0 0 12px; }
.hero h1 { font-size: clamp(2rem, 5vw, 3.6rem); margin-bottom: 12px; }
.hero .subtitle { font-size: 1.15rem; color: var(--muted); max-width: 46ch; margin: 0 0 20px; }
.hero-meta { display: flex; flex-wrap: wrap; gap: 8px 24px; color: var(--muted); font-size: 0.95rem; margin-bottom: 24px; }
.hero-image { border: 1px solid var(--frame); padding: 0; }
.hero-image img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
[data-theme="thai-classic"] .hero-image, [data-theme="heritage"] .hero-image { padding: 8px; border-width: 3px; border-style: double; }

.statement { max-width: 68ch; margin: 0 0 48px; font-size: 1.05rem; }
.statement p { margin: 0 0 1em; }

/* Toolbar above the works */
.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; padding: 16px 0; border-top: 1px solid var(--line); margin-bottom: 24px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.seg button { font: inherit; min-height: 44px; padding: 8px 16px; border: 0; background: transparent; color: var(--muted); cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.search { min-height: 44px; padding: 8px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--ink); font: inherit; min-width: 220px; }

/* Works: grid / masonry / salon */
.works { display: grid; gap: 32px 24px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); padding-bottom: 80px; }
[data-layout="masonry"] .works { display: block; columns: 4 260px; column-gap: 24px; }
[data-layout="masonry"] .work-card { break-inside: avoid; margin-bottom: 28px; }
[data-layout="salon"] .works { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); grid-auto-flow: dense; gap: 16px; }
[data-layout="salon"] .work-card.wide { grid-column: span 2; }
[data-layout="salon"] .work-card.tall { grid-row: span 2; }

.work-card { text-decoration: none; color: inherit; display: block; }
.work-card .frame {
  position: relative; background: var(--surface); border: 1px solid var(--frame);
  border-radius: var(--radius); box-shadow: var(--card-shadow); overflow: hidden;
}
[data-theme="thai-classic"] .work-card .frame, [data-theme="heritage"] .work-card .frame { padding: 6px; }
.work-card img { width: 100%; height: auto; transition: transform 300ms ease; }
[data-layout="grid"] .work-card img { aspect-ratio: 1 / 1; object-fit: contain; background: var(--surface); }
.work-card:hover img { transform: scale(1.02); }
.work-card .cap { padding: 12px 2px 0; }
.work-card .title { font-family: var(--font-head); font-weight: var(--head-weight); font-size: 1.05rem; line-height: 1.35; margin: 0; }
.work-card .artist { color: var(--muted); font-size: 0.95rem; margin: 2px 0 0; }

.badge-endorsed {
  display: inline-flex; align-items: center; gap: 6px; font-size: 0.8rem; font-weight: 600; line-height: 1.2;
  padding: 5px 10px; border-radius: 999px; background: var(--accent); color: var(--accent-ink);
}
.work-card .badge-endorsed { position: absolute; left: 10px; top: 10px; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); }

.empty { padding: 64px 0; color: var(--muted); text-align: center; }

/* Work detail */
.work-page { display: grid; gap: 40px; padding: 32px 0 80px; grid-template-columns: 1fr; }
@media (min-width: 1000px) { .work-page { grid-template-columns: minmax(0, 1.5fr) minmax(320px, 1fr); } }
.work-figure { background: var(--surface); border: 1px solid var(--frame); padding: 16px; display: flex; justify-content: center; }
.work-figure img { max-height: 82vh; width: auto; cursor: zoom-in; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 8px 20px; margin: 20px 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.artist-box { display: flex; gap: 16px; align-items: center; margin: 28px 0 12px; }
.artist-box img { width: 64px; height: 64px; border-radius: 50%; object-fit: cover; }
.pager { display: flex; justify-content: space-between; gap: 12px; margin-top: 32px; }
.lightbox { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.92); display: none; align-items: center; justify-content: center; z-index: 50; cursor: zoom-out; }
.lightbox.open { display: flex; }
.lightbox img { max-width: 96vw; max-height: 96vh; }

/* Lobby */
.lobby-hero { padding: 72px 0 32px; }
.lobby-hero h1 { font-size: clamp(2.2rem, 6vw, 4rem); max-width: 14ch; }
.section-title { font-size: 1.4rem; margin: 48px 0 20px; display: flex; align-items: baseline; gap: 12px; }
.ex-grid { display: grid; gap: 28px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.ex-card { display: block; text-decoration: none; color: inherit; }
.ex-card .cover { aspect-ratio: 16 / 10; background: var(--line); overflow: hidden; border-radius: var(--radius); }
.ex-card .cover img { width: 100%; height: 100%; object-fit: cover; transition: transform 300ms ease; }
.ex-card:hover .cover img { transform: scale(1.03); }
.ex-card h3 { font-size: 1.25rem; margin: 14px 0 4px; }
.pill { display: inline-block; font-size: 0.78rem; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.pill.live { border-color: var(--accent); color: var(--accent); }

/* Forms (submission) */
.form-page { max-width: 820px; padding: 40px 20px 96px; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin: 0 0 24px; background: var(--surface); }
legend { font-family: var(--font-head); font-weight: var(--head-weight); padding: 0 8px; font-size: 1.1rem; }
.field { display: grid; gap: 6px; margin-bottom: 16px; }
.field label { font-weight: 600; font-size: 0.95rem; }
.field .hint { font-size: 0.85rem; color: var(--muted); }
.req { color: var(--accent); }
input[type="text"], input[type="email"], input[type="tel"], input[type="password"], input[type="number"],
input[type="datetime-local"], input[type="date"], select, textarea {
  font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px 12px; min-height: 44px; width: 100%;
}
textarea { min-height: 120px; resize: vertical; }
.grid-2 { display: grid; gap: 0 16px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .grid-2 { grid-template-columns: 1fr 1fr; } }
.drop {
  border: 2px dashed var(--line); border-radius: var(--radius); padding: 20px; text-align: center; cursor: pointer;
  display: grid; gap: 8px; justify-items: center; color: var(--muted); background: var(--bg);
}
.drop.has-image { border-style: solid; padding: 8px; }
.drop img { max-height: 280px; width: auto; }
.progress { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; width: 100%; }
.progress > span { display: block; height: 100%; width: 0; background: var(--accent); transition: width 150ms; }
.error-text { color: #b42318; font-size: 0.9rem; }
[data-theme="heritage"] .error-text { color: #ff9b8f; }
.notice { padding: 16px 20px; border: 1px solid var(--line); border-left: 4px solid var(--accent); background: var(--surface); border-radius: var(--radius); margin: 0 0 24px; }
.check { display: flex; gap: 10px; align-items: flex-start; }
.check input { width: 20px; height: 20px; margin-top: 3px; }

.site-foot { border-top: 1px solid var(--line); padding: 28px 0; color: var(--muted); font-size: 0.9rem; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 40px); opacity: 0; pointer-events: none;
  background: #1d1d1b; color: #fff; padding: 12px 18px; border-radius: 8px; z-index: 100; max-width: 90vw;
  transition: opacity 200ms ease, transform 200ms ease; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast-error { background: #9b1c1c; }
.toast-ok { background: #1f6b3a; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
