/* Quiet gallery white: one neutral palette, one typeface family, hairline
   rules and generous space. It follows the system light or dark setting.
   Layout lives in structure.css, which loads first. */

:root {
  --bg: #fbfbfd;
  --ink: #1d1d1f;
  --ink-secondary: #6e6e73;
  --rule: rgba(0, 0, 0, 0.1);
  --image-edge: rgba(0, 0, 0, 0.08);
  --image-shadow: rgba(0, 0, 0, 0.22);
  --field: rgba(0, 0, 0, 0.05);
  --surface: #ffffff; /* raised elements, like the search bar */
  --field-border: rgba(0, 0, 0, 0.22);
  --focus: #0071e3;
  --search-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none' stroke='%236e6e73' stroke-width='1.5' stroke-linecap='round'%3E%3Ccircle cx='7' cy='7' r='4.75'/%3E%3Cpath d='M10.5 10.5L14 14'/%3E%3C/svg%3E");

  --font:
    -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Helvetica Neue",
    Helvetica, Arial, sans-serif;

  color-scheme: light dark;
}

/* Dark palette. It applies when the system is dark unless light was chosen
   with the toggle, or whenever dark was chosen with the toggle. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111113;
    --ink: #f5f5f7;
    --ink-secondary: #a1a1a6;
    --rule: rgba(255, 255, 255, 0.12);
    --image-edge: rgba(255, 255, 255, 0.1);
    --image-shadow: rgba(0, 0, 0, 0.6);
    --field: rgba(255, 255, 255, 0.08);
    --surface: #161618;
    --field-border: rgba(255, 255, 255, 0.28);
    --focus: #2997ff;
    --search-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none' stroke='%23a1a1a6' stroke-width='1.5' stroke-linecap='round'%3E%3Ccircle cx='7' cy='7' r='4.75'/%3E%3Cpath d='M10.5 10.5L14 14'/%3E%3C/svg%3E");
  }
}

:root[data-theme="dark"] {
  --bg: #111113;
  --ink: #f5f5f7;
  --ink-secondary: #a1a1a6;
  --rule: rgba(255, 255, 255, 0.12);
  --image-edge: rgba(255, 255, 255, 0.1);
  --image-shadow: rgba(0, 0, 0, 0.6);
  --field: rgba(255, 255, 255, 0.08);
  --surface: #161618;
  --field-border: rgba(255, 255, 255, 0.28);
  --focus: #2997ff;
  --search-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none' stroke='%23a1a1a6' stroke-width='1.5' stroke-linecap='round'%3E%3Ccircle cx='7' cy='7' r='4.75'/%3E%3Cpath d='M10.5 10.5L14 14'/%3E%3C/svg%3E");
  color-scheme: dark;
}

:root[data-theme="light"] {
  color-scheme: light;
}

/* ---------- Page ---------- */

html {
  background: var(--bg);
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 0.9375rem;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.site-title {
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: 0.01em;
  color: var(--ink-secondary);
}

/* ---------- Icon buttons ---------- */

.icon-button {
  color: var(--ink-secondary);
}

.icon-button:hover,
.search-toggle[aria-expanded="true"] {
  color: var(--ink);
}

/* While the key hints are hidden, the key hint toggle is muted. While the
   hints are shown, the toggle has the same color as the other icons. */
.hints-toggle[aria-pressed="false"]:not(:hover) {
  color: color-mix(in srgb, var(--ink-secondary) 45%, transparent);
}

/* The same length as the fade of the key hints, so the toggle and the hints
   change together */
@media (prefers-reduced-motion: no-preference) {
  .hints-toggle {
    transition: color 0.3s ease;
  }
}

.icon-button:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---------- Sort options ---------- */

.sort-caption,
.sort-trigger,
.sort-menu label {
  font-size: 0.8125rem;
  line-height: 1.3;
  letter-spacing: 0.01em;
}

/* The chosen option in the trigger is a muted gray, like the artist line */
.sort-trigger {
  color: var(--ink-secondary);
}

.sort-menu label {
  color: var(--ink);
  font-weight: 500;
}

/* "Sorted by" and the order arrow are lighter still, so the widget stays
   quiet next to the artwork */
.sort-caption,
.sort-direction {
  color: color-mix(in srgb, var(--ink-secondary) 60%, transparent);
}

.sort-direction {
  font-size: 0.8125rem;
}

.sort-direction:hover {
  color: var(--ink-secondary);
}

.sort-trigger:focus-visible,
.sort-direction:focus-visible,
.sort-menu label:has(input:focus-visible) {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.sort-highlight {
  background: color-mix(in srgb, var(--ink) 6%, transparent);
}

/* ---------- Search ---------- */

/* The search bar and the sort menu are solid --surface panels, so the page
   scrolling under the panels stays hidden. Three shadows draw each panel
   instead of a border:
   - a 1px ring in a faint ink color, which defines the edge
   - a near-invisible contact shadow directly underneath
   - a large, soft shadow, pulled in at the sides, for elevation
   The shadows are derived from --image-shadow, so they deepen in dark mode. */
input[type="search"],
.sort-menu {
  border-radius: 8px;
  background: var(--surface);
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--ink) 9%, transparent),
    0 1px 1px color-mix(in srgb, var(--image-shadow) 20%, transparent),
    0 12px 32px -12px color-mix(in srgb, var(--image-shadow) 60%, transparent);
}

/* The bar appears already focused, so focus doesn't change the look */
input[type="search"] {
  color: var(--ink);
  font-family: inherit;
  font-size: 0.9375rem;
  line-height: 1.4;
  letter-spacing: -0.01em;
}

/* Below 16px, iOS zooms the page when the field is focused */
@media (max-width: 600px) {
  input[type="search"] {
    font-size: 1rem;
  }
}

input[type="search"]::placeholder {
  color: color-mix(in srgb, var(--ink-secondary) 80%, transparent);
  opacity: 1;
}

input[type="search"]:focus {
  outline: none;
}

/* ---------- Credit ---------- */

/* Because the footer should draw less attention than the artwork, the
   footer uses the smallest text size on the page, the size of the site title
   and the location line */
.credit {
  font-size: 0.8125rem;
  line-height: 1.6;
  letter-spacing: 0.01em;
  color: color-mix(in srgb, var(--ink-secondary) 80%, transparent);
}

/* The title matches the site title at the top of the page */
.credit h2 {
  font-size: inherit;
  font-weight: 600;
  line-height: inherit;
  color: var(--ink-secondary);
}

.credit p {
  text-wrap: pretty;
}

/* Links in the credit use the credit's color, with a faint underline that
   darkens on hover */
.credit a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: var(--field-border);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

.credit a:hover {
  text-decoration-color: currentColor;
}

.credit a:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
  border-radius: 2px;
}

/* ---------- Keys ----------
   All colors are derived from --key-ink. Dark surfaces such as the lightbox
   override it (see lightbox.css). */

.key {
  --key-ink: var(--ink);
  --key-highlight: color-mix(in srgb, var(--bg) 70%, transparent);
  border-color: color-mix(in srgb, var(--key-ink) 28%, transparent);
  background: linear-gradient(
    to bottom,
    color-mix(in srgb, var(--key-ink) 10%, transparent),
    color-mix(in srgb, var(--key-ink) 3%, transparent)
  );
  box-shadow: inset 0 1px 0 var(--key-highlight);
  color: color-mix(in srgb, var(--key-ink) 72%, transparent);
}

.key:hover {
  border-color: color-mix(in srgb, var(--key-ink) 50%, transparent);
  color: color-mix(in srgb, var(--key-ink) 95%, transparent);
}

.key[data-off] {
  border-color: color-mix(in srgb, var(--key-ink) 10%, transparent);
  background: none;
  box-shadow: none;
  color: color-mix(in srgb, var(--key-ink) 20%, transparent);
}

.key.pressed {
  border-color: color-mix(in srgb, var(--key-ink) 55%, transparent);
  background: color-mix(in srgb, var(--key-ink) 16%, transparent);
  box-shadow: none;
  color: var(--key-ink);
}

.hint-label {
  color: var(--ink-secondary);
}

/* The row hints stay in view while reading, so the row hints are dimmed
   until the pointer is over them */
.row-hints {
  opacity: 0.55;
}

.row-hints:hover {
  opacity: 1;
}

@media (prefers-reduced-motion: no-preference) {
  .row-hints {
    transition: opacity 0.2s ease;
  }
}

/* ---------- Row navigator ---------- */

.rail button {
  color: var(--ink-secondary);
}

.rail button::before {
  opacity: 0.45;
}

.rail button:hover,
.rail button:focus-visible,
.rail button[aria-current="true"] {
  color: var(--ink);
}

.rail button:hover::before,
.rail button:focus-visible::before,
.rail button[aria-current="true"]::before {
  opacity: 1;
}

.rail button:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: 2px;
}

/* The rail labels and the icon buttons' tooltips */
.rail button::after,
.icon-button[data-tooltip]::after {
  border: 1px solid var(--field-border);
  border-radius: 4px;
  background: var(--bg);
  color: var(--ink);
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  line-height: 1.3;
}

/* ---------- Table ---------- */

/* Hairline rules between rows */
.museum-table tbody tr {
  border-bottom: 1px solid var(--rule);
}

.museum-table td[data-label]::before {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--ink-secondary);
}

.museum-table .ac_name {
  font-size: 1.25rem;
  font-weight: 500;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

.museum-table .auth {
  font-size: 1rem;
  line-height: 1.7;
  color: var(--ink-secondary);
  text-wrap: pretty;
}

.museum-table .artist {
  font-size: 0.9375rem;
  font-weight: 400;
  line-height: 1.3;
  color: var(--ink-secondary);
}

.museum-table .real_name {
  font-size: clamp(1.75rem, 2.8vw, 2.25rem);
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

.museum-table .year {
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
  color: var(--ink-secondary);
}

.museum-table .medium {
  font-size: 1rem;
  line-height: 1.3;
  color: var(--ink-secondary);
  text-wrap: balance;
  margin-top: 1rem;
}

.museum-table .location {
  margin-top: 0.85rem;
  font-size: 0.8125rem;
  line-height: 1.4;
  letter-spacing: 0.01em;
  color: var(--ink-secondary);
}

.museum-table .extra-desc:empty,
.museum-table .medium:empty,
.museum-table .location:empty {
  display: none;
}

.museum-table .desc {
  font-size: 1rem;
  line-height: 1.7;
  text-wrap: pretty;
}

.museum-table .extra-desc {
  font-size: 0.8125rem;
  line-height: 1.7;
  text-wrap: pretty;
  color: var(--ink-secondary);
  margin-top: 1rem;
}

.museum-table img {
  border-radius: 2px;
  box-shadow:
    0 0 0 1px var(--image-edge),
    0 10px 28px -10px var(--image-shadow);
}

/* Image captions */
.museum-table .real_img::after,
.museum-table .fake_img::after,
.museum-table .diff_img::after,
.museum-table .orig_img::after {
  font-size: 0.8125rem;
  color: var(--ink-secondary);
}

/* ---------- Links ---------- */

/* The underline starts as the text color at zero opacity, rather than
   transparent (transparent black), so the hover fade changes only the
   opacity: fading from transparent black can pass through a darker gray,
   which shows in dark mode. Browsers without relative colors use the
   transparent fallback. */
.museum-table a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  border-bottom-color: rgb(from currentColor r g b / 0);
}

.museum-table a:hover {
  border-bottom-color: currentColor;
}

.museum-table a:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
  border-radius: 2px;
}

@media (prefers-reduced-motion: no-preference) {
  .museum-table a {
    transition: border-color 0.2s ease;
  }
}

@media print {
  .museum-table img {
    box-shadow: none;
  }
}
