/* =========================================================================
   base.css — reset, self-hosted faces, tokens, typography, focus, utilities.

   No framework, no build step. Loaded first so it establishes the cascade
   layer order for everything that follows.

   The live theme is injected into <head> as an *unlayered* `:root {…}` block
   with the CSP nonce, so it always wins over the defaults declared here.
   ========================================================================= */

@layer reset, tokens, base, layout, components, utilities;

/* -------------------------------------------------------------------------
   Self-hosted faces. Files live in /brand/fonts/ (see public/brand/README.md).
   `font-display: swap` plus a full fallback stack means the page is correct
   and readable before — or entirely without — the woff2 files.
   ------------------------------------------------------------------------- */

@font-face {
  font-family: 'Cinzel';
  src: url('/brand/fonts/cinzel-400.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+2000-206F, U+2074,
    U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215;
}
@font-face {
  font-family: 'Cinzel';
  src: url('/brand/fonts/cinzel-600.woff2') format('woff2');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Cinzel';
  src: url('/brand/fonts/cinzel-700.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Lato';
  src: url('/brand/fonts/lato-400.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Lato';
  src: url('/brand/fonts/lato-400i.woff2') format('woff2');
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: 'Lato';
  src: url('/brand/fonts/lato-700.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* =========================================================================
   Reset
   ========================================================================= */

@layer reset {
  *,
  *::before,
  *::after {
    box-sizing: border-box;
  }

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

  body,
  h1,
  h2,
  h3,
  h4,
  p,
  figure,
  blockquote,
  dl,
  dd,
  ol,
  ul {
    margin: 0;
    padding: 0;
  }

  ul[class],
  ol[class] {
    list-style: none;
  }

  img,
  picture,
  video,
  canvas,
  svg {
    display: block;
    max-width: 100%;
  }

  img {
    height: auto;
    border: 0;
  }

  input,
  button,
  textarea,
  select {
    font: inherit;
    color: inherit;
    margin: 0;
  }

  button {
    background: none;
    border: 0;
    cursor: pointer;
  }

  table {
    border-collapse: collapse;
  }

  a {
    color: inherit;
  }

  hr {
    border: 0;
    margin: 0;
  }

  [hidden] {
    display: none !important;
  }

  ::selection {
    background: color-mix(in srgb, var(--gold) 35%, transparent);
    color: var(--ink);
  }
}

/* =========================================================================
   Tokens — defaults. The injected theme overrides every one of these.
   Sampled from ATHA.png / profile.png; see docs/DESIGN.md.
   ========================================================================= */

@layer tokens {
  :root {
    /* Colour */
    --bg: #0a1016;
    --bg-deep: #05090d;
    --surface: #111a23;
    --surface-raised: #17222d;
    --line: #243341;
    --ink: #f2ece1;
    --ink-muted: #9ba9b6;
    --gold: #c9972b;
    --gold-soft: #e4b46c;
    --accent: #1b8a9b;
    --accent-ink: #04121a;
    --danger: #c41e3a;
    --matte: #0e1721;

    /* Shape */
    --radius: 2px;
    --mat-width: 14px;

    /* Type */
    --font-display: 'Cinzel', 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, serif;
    --font-body: 'Lato', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial,
      sans-serif;

    --fs-xs: 0.8125rem; /* 13 */
    --fs-sm: 0.9375rem; /* 15 */
    --fs-md: 1.0625rem; /* 17 */
    --fs-lg: 1.3125rem; /* 21 */
    --fs-xl: 1.75rem; /*  28 */
    --fs-2xl: 2.5rem; /*   40 */
    --fs-3xl: 4rem; /*     64 */

    --lh-body: 1.55;
    --lh-display: 1.1;
    --tracking-caps: 0.12em;

    /* Structure */
    --frame: 1440px;
    --content: 1220px;
    --wide: 1400px;
    --gutter: 24px;
    --header-h: 84px;
    --measure: 68ch;

    /* Motion */
    --t-hover: 150ms;
    --t-panel: 220ms;
    --ease: cubic-bezier(0.2, 0.7, 0.3, 1);

    color-scheme: dark;
  }
}

/* =========================================================================
   Base elements
   ========================================================================= */

@layer base {
  html {
    background: var(--bg);
  }

  body {
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font-body);
    font-size: var(--fs-md);
    line-height: var(--lh-body);
    font-weight: 400;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
  }

  /* The wall: a very slight vertical fall of light, and an optional canvas
     grain. Both are painted behind everything and never over an image. */
  html[data-vignette='on'] body {
    background-image: radial-gradient(
      120% 80% at 50% -10%,
      color-mix(in srgb, var(--gold) 5%, transparent) 0%,
      transparent 60%
    );
    background-repeat: no-repeat;
    background-attachment: fixed;
  }

  html[data-texture='on'] body::before {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    opacity: 0.5;
    background-image: repeating-linear-gradient(
        0deg,
        rgba(255, 255, 255, 0.012) 0 1px,
        transparent 1px 3px
      ),
      repeating-linear-gradient(90deg, rgba(0, 0, 0, 0.02) 0 1px, transparent 1px 3px);
  }

  h1,
  h2,
  h3,
  h4 {
    font-family: var(--font-display);
    font-weight: 600;
    line-height: var(--lh-display);
    letter-spacing: 0.01em;
    text-wrap: balance;
  }

  h1 {
    font-size: var(--fs-2xl);
  }
  h2 {
    font-size: var(--fs-xl);
  }
  h3 {
    font-size: var(--fs-lg);
  }
  h4 {
    font-size: var(--fs-md);
  }

  p {
    text-wrap: pretty;
  }

  a {
    color: var(--accent);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 0.18em;
    text-decoration-color: color-mix(in srgb, var(--accent) 45%, transparent);
    transition: color var(--t-hover) var(--ease),
      text-decoration-color var(--t-hover) var(--ease);
  }

  a:hover {
    color: var(--gold-soft);
    text-decoration-color: var(--gold-soft);
  }

  strong,
  b {
    font-weight: 700;
    color: var(--ink);
  }

  em,
  i {
    font-style: italic;
  }

  code,
  kbd,
  samp {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.9em;
  }

  small {
    font-size: var(--fs-xs);
  }

  /* ---- Focus: gold, 2px, offset. Everywhere, no exceptions. ---- */
  :focus-visible {
    outline: 2px solid var(--gold);
    outline-offset: 2px;
    border-radius: 1px;
  }

  /* Keep a visible ring for browsers that only support :focus. */
  :focus:not(:focus-visible) {
    outline: none;
  }

  /* ---- The one non-negotiable: never touch a photograph of a work. ---- */
  .art {
    border-radius: 0;
    box-shadow: none;
    filter: none;
    transform: none;
    transition: none;
    /* `contain`, never `cover`: a work is never cropped to fit a box. The mat
       takes up the slack. `--art-h` is set to `100%` by the gallery grid when a
       fixed aspect is configured, and left at `auto` everywhere else. */
    object-fit: contain;
    object-position: center;
    display: block;
    width: 100%;
    height: var(--art-h, auto);
    background: transparent;
  }
}

/* =========================================================================
   Prose — output of the Markdown renderer
   ========================================================================= */

@layer components {
  .prose {
    max-width: var(--measure);
    font-size: var(--fs-md);
    line-height: 1.62;
    color: var(--ink);
  }

  /* The CSP forbids `style=` attributes, so the two measures the site uses are
     classes rather than an inline custom property. */
  .prose--62 {
    --measure: 62ch;
  }

  .prose--68 {
    --measure: 68ch;
  }

  .prose > * + * {
    margin-top: 1.05em;
  }

  .prose h2,
  .prose h3 {
    margin-top: 1.8em;
    color: var(--ink);
  }

  .prose h2 {
    font-size: var(--fs-lg);
  }

  .prose h3 {
    font-size: var(--fs-md);
    letter-spacing: var(--tracking-caps);
    text-transform: uppercase;
    font-family: var(--font-body);
    color: var(--ink-muted);
  }

  .prose ul,
  .prose ol {
    padding-left: 1.3em;
  }

  .prose li + li {
    margin-top: 0.4em;
  }

  .prose blockquote {
    border-left: 1px solid var(--gold);
    padding-left: 1.1em;
    color: var(--ink-muted);
    font-style: italic;
  }

  .prose hr {
    height: 1px;
    background: var(--line);
    margin: 2em 0;
  }

  .prose a {
    color: var(--accent);
  }

  .prose img {
    width: 100%;
    height: auto;
  }

  .prose code {
    background: var(--surface);
    padding: 0.1em 0.35em;
    border: 1px solid var(--line);
  }
}

/* =========================================================================
   Utilities
   ========================================================================= */

@layer utilities {
  .u-vh {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
  }

  /* The auction-catalogue voice: OIL ON CANVAS · 36 × 24 IN · c. 1958 */
  .smallcaps {
    font-family: var(--font-body);
    font-size: var(--fs-xs);
    font-weight: 700;
    letter-spacing: var(--tracking-caps);
    text-transform: uppercase;
    color: var(--ink-muted);
    line-height: 1.4;
  }

  /* Gold is a hairline. That is the whole of its job. */
  .rule {
    height: 1px;
    background: var(--gold);
    opacity: 0.55;
    border: 0;
    width: 100%;
  }

  .rule--short {
    width: 64px;
    opacity: 0.9;
  }

  .u-center {
    margin-inline: auto;
  }
}

/* =========================================================================
   Motion preferences — honoured everywhere, including the lightbox.
   ========================================================================= */

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

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

/* =========================================================================
   Print — an auction catalogue should print like one.
   ========================================================================= */

@media print {
  html[data-texture='on'] body::before {
    display: none;
  }
  body {
    background: #fff;
    color: #000;
  }
  .header,
  .footer,
  .skip,
  .pager,
  .filters,
  .actions,
  .siblings {
    display: none !important;
  }
  a {
    color: #000;
    text-decoration: none;
  }
}
