/* Design tokens + shared components for the public site and the admin.
   Thesis: a gallery wall. The UI stays neutral; the artwork carries the colour.
   The only accent is the gallery "red dot", reserved for Sold. */

:root {
  color-scheme: light dark;

  --wall: #F5F5F3;          /* page background */
  --surface: #FFFFFF;       /* cards, sheets, fields */
  --ink: #1D1D1F;           /* primary text, 15.4:1 on wall */
  --ink-2: #5F5F66;         /* secondary text, 5.8:1 on wall */
  --hairline: rgba(0, 0, 0, 0.1);
  --fill: rgba(0, 0, 0, 0.05);   /* subtle control fill */
  --fill-2: rgba(0, 0, 0, 0.09);
  --red-dot: #C4141E;       /* Sold, and destructive actions. 5.55:1 on wall */
  --amber: #8A5A00;         /* Reserved. 5.7:1 on wall */
  --green: #1E7B3A;         /* Available. 5.1:1 on wall */
  --link: #0A66D8;          /* links + focus ring. 5.38:1 on white */
  --on-ink: #FFFFFF;
  --glass: rgba(245, 245, 243, 0.72);
  --shadow-hung: 0 1px 2px rgba(0,0,0,.06), 0 12px 32px -12px rgba(0,0,0,.28);
  --shadow-sheet: 0 24px 80px -16px rgba(0,0,0,.35);

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Segoe UI Variable Text",
          "Segoe UI", system-ui, Roboto, "Helvetica Neue", Arial, sans-serif;

  /* Type scale (px): 13 caption / 15 footnote / 17 body / 22 title3 / 34 title / 56 display */
  --t-caption: 0.8125rem;
  --t-foot: 0.9375rem;
  --t-body: 1.0625rem;
  --t-title3: 1.375rem;
  --t-title: clamp(1.75rem, 1.2rem + 2vw, 2.125rem);
  --t-display: clamp(2.5rem, 1.6rem + 4vw, 3.5rem);

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 20px;
  --gutter: clamp(16px, 4vw, 48px);
  --ease: cubic-bezier(.2, .8, .2, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --wall: #111113;
    --surface: #1C1C1F;
    --ink: #F2F2F0;          /* 16.8:1 */
    --ink-2: #A1A1A8;        /* 7.35:1 */
    --hairline: rgba(255, 255, 255, 0.12);
    --fill: rgba(255, 255, 255, 0.07);
    --fill-2: rgba(255, 255, 255, 0.12);
    --red-dot: #FF4B45;      /* 5.7:1 */
    --amber: #F0B44C;
    --green: #4CC774;
    --link: #4D9CFF;
    --on-ink: #111113;
    --glass: rgba(17, 17, 19, 0.7);
    --shadow-hung: 0 1px 2px rgba(0,0,0,.4), 0 16px 40px -12px rgba(0,0,0,.7);
  }
  /* Soften bright artwork so white grounds don't glow against the dark wall (dark-mode.md). */
  .art-img { filter: brightness(.94); }
}

@media (prefers-contrast: more) {
  :root { --ink-2: var(--ink); --hairline: currentColor; }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--wall);
  color: var(--ink);
  font-family: var(--font);
  font-size: var(--t-body);
  line-height: 1.47;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; display: block; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, p { margin: 0; }

:focus-visible {
  outline: 3px solid var(--link);
  outline-offset: 2px;
  border-radius: 6px;
}

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

.skip-link {
  position: absolute; left: 16px; top: -100px; z-index: 100;
  background: var(--ink); color: var(--on-ink); padding: 10px 16px; border-radius: 999px;
}
.skip-link:focus { top: 12px; }

/* ---------- Buttons ---------- */

.btn {
  --bg: var(--fill-2); --fg: var(--ink);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 20px;
  border: 0; border-radius: 999px;
  background: var(--bg); color: var(--fg);
  font: 600 var(--t-foot)/1 var(--font);
  cursor: pointer; text-decoration: none;
  transition: transform .15s var(--ease), opacity .15s, background-color .15s;
}
.btn:hover { text-decoration: none; filter: brightness(1.06); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .4; cursor: not-allowed; transform: none; }
.btn-primary { --bg: var(--ink); --fg: var(--on-ink); }
.btn-plain { --bg: transparent; --fg: var(--link); padding: 0 12px; }
.btn-plain:hover { --bg: var(--fill); }
.btn-danger { --bg: transparent; --fg: var(--red-dot); }
.btn-danger:hover { --bg: var(--fill); }
.btn-danger-filled { --bg: var(--red-dot); --fg: #fff; }
.btn-block { width: 100%; }
.btn-sm { min-height: 36px; padding: 0 14px; font-size: var(--t-caption); }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 44px; height: 44px; border-radius: 999px; border: 0;
  background: var(--fill); color: var(--ink); cursor: pointer;
}
.icon-btn:hover { background: var(--fill-2); }
.icon-btn svg { width: 20px; height: 20px; }

/* ---------- Segmented control ---------- */

.segmented {
  display: inline-flex; padding: 3px; gap: 2px;
  background: var(--fill); border-radius: 999px;
}
.segmented button {
  min-height: 36px; padding: 0 16px;
  border: 0; border-radius: 999px; background: transparent;
  color: var(--ink); font: 500 var(--t-foot)/1 var(--font); cursor: pointer;
  transition: background-color .2s var(--ease), box-shadow .2s;
}
.segmented button[aria-pressed="true"],
.segmented button[aria-checked="true"] {
  background: var(--surface); font-weight: 600;
  box-shadow: 0 1px 3px rgba(0,0,0,.12), 0 0 0 .5px var(--hairline);
}

/* ---------- Form fields ---------- */

.field { display: grid; gap: 6px; }
.field > label, .field-label {
  font-size: var(--t-foot); font-weight: 600; color: var(--ink);
}
.field .hint { font-size: var(--t-caption); color: var(--ink-2); }
.input, .select, .textarea {
  width: 100%; min-height: 44px; padding: 10px 14px;
  font: 400 var(--t-body)/1.4 var(--font); color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--hairline); border-radius: var(--r-md);
  transition: border-color .15s, box-shadow .15s;
}
.textarea { min-height: 120px; resize: vertical; }
/* Native option lists don't inherit the select's translucent fill (white list + light text on
   Windows in dark mode), so give options solid themed colours. */
.select option, .select optgroup { background-color: var(--surface); color: var(--ink); }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--link);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--link) 25%, transparent);
}
.input[aria-invalid="true"], .textarea[aria-invalid="true"] { border-color: var(--red-dot); }
.field-error { font-size: var(--t-caption); color: var(--red-dot); min-height: 0; }
.field-error:empty { display: none; }

.form-error {
  padding: 12px 14px; border-radius: var(--r-md);
  background: color-mix(in srgb, var(--red-dot) 10%, transparent);
  color: var(--red-dot); font-size: var(--t-foot);
}
.form-error:empty { display: none; }

/* Toggle switch: a real checkbox, restyled, keeps its semantics */
.switch { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 44px; cursor: pointer; }
.switch input {
  appearance: none; flex: none; margin: 0;
  width: 51px; height: 31px; border-radius: 999px;
  background: var(--fill-2); position: relative; cursor: pointer;
  transition: background-color .2s var(--ease);
}
.switch input::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 27px; height: 27px; border-radius: 50%; background: #fff;
  box-shadow: 0 2px 4px rgba(0,0,0,.2);
  transition: transform .2s var(--ease);
}
.switch input:checked { background: var(--green); }
.switch input:checked::after { transform: translateX(20px); }
.switch .switch-text { display: grid; gap: 2px; }
.switch .switch-text small { color: var(--ink-2); font-size: var(--t-caption); }

/* ---------- Status: the red dot ---------- */

.status {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: var(--t-caption); font-weight: 600; color: var(--ink-2);
}
.status::before {
  content: ""; width: 9px; height: 9px; border-radius: 50%;
  background: currentColor; flex: none;
}
.status-sold { color: var(--red-dot); }
.status-reserved { color: var(--amber); }
.status-reserved::before { background: transparent; box-shadow: inset 0 0 0 2px currentColor; }
.status-available { color: var(--green); }

/* ---------- Toast ---------- */

.toast-region {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  z-index: 1000; display: grid; gap: 8px; pointer-events: none;
  width: min(420px, calc(100vw - 32px));
}
.toast {
  pointer-events: auto;
  background: var(--ink); color: var(--on-ink);
  padding: 12px 18px; border-radius: 999px; text-align: center;
  font-size: var(--t-foot); font-weight: 500;
  box-shadow: var(--shadow-sheet);
  animation: toast-in .3s var(--ease);
}
.toast.is-error { background: var(--red-dot); color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------- Dialog / sheet ---------- */

dialog {
  border: 0; padding: 0; color: var(--ink);
  background: var(--surface); border-radius: var(--r-lg);
  box-shadow: var(--shadow-sheet);
  max-width: calc(100vw - 32px);
}
dialog::backdrop { background: rgba(0,0,0,.4); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
dialog[open] { animation: sheet-in .35s var(--ease); }
@keyframes sheet-in { from { opacity: 0; transform: translateY(24px) scale(.98); } }

.alert-dialog { width: 340px; padding: 24px; text-align: center; }
.alert-dialog h2 { font-size: var(--t-body); font-weight: 600; margin-bottom: 6px; }
.alert-dialog p { font-size: var(--t-foot); color: var(--ink-2); margin-bottom: 20px; }
.alert-dialog .alert-actions { display: grid; gap: 8px; }

.choice-dialog { width: 380px; text-align: left; }
.choice-dialog h2, .choice-dialog > p { text-align: left; }
.choice-list { display: grid; gap: 8px; margin-bottom: 12px; }
.choice {
  display: grid; gap: 2px; text-align: left; width: 100%; min-height: 56px; padding: 10px 14px;
  border: 1px solid var(--hairline); border-radius: var(--r-md); background: var(--surface);
  color: var(--ink); font: inherit; cursor: pointer;
  transition: border-color .15s, background-color .15s;
}
.choice:hover { background: var(--fill); }
.choice:focus-visible { border-color: var(--link); }
.choice-label { font-weight: 600; font-size: var(--t-foot); display: flex; align-items: center; gap: 8px; }
.choice-detail { font-size: var(--t-caption); color: var(--ink-2); }

.spinner {
  width: 20px; height: 20px; border-radius: 50%;
  border: 2px solid var(--fill-2); border-top-color: var(--ink-2);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.skeleton { background: var(--fill); border-radius: var(--r-sm); animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .5; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important; animation-iteration-count: 1 !important;
    transition-duration: .01ms !important; scroll-behavior: auto !important;
  }
}
@media (prefers-reduced-transparency: reduce) {
  dialog::backdrop { backdrop-filter: none; -webkit-backdrop-filter: none; background: rgba(0,0,0,.6); }
}
