/* DESIGN.md as CSS (telos/design ticket 01): the reading font, the design's tokens, and the base
   styles every page shares, chest pages (trove.css) and Trove's own (admin.css) alike. Linked
   first on every page. A colour anywhere else is a token from here (src/__tests__/design.test.js
   checks), apart from black and white overlays on photos and the file-type icons' palette. */

/* Gelasio, the reading serif (SIL OFL, fonts/OFL.txt), from fontsource's subsets: Latin, Latin
   Extended and Vietnamese, each fetched only when a page has its characters. Metric-compatible
   with Georgia, which stands in until it loads, or if it never does. */
@font-face {
  font-family: Gelasio;
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/gelasio-vietnamese-400-normal.woff2") format("woff2");
  unicode-range:
    U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1,
    U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329,
    U+1EA0-1EF9, U+20AB;
}
@font-face {
  font-family: Gelasio;
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/gelasio-latin-ext-400-normal.woff2") format("woff2");
  unicode-range:
    U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304,
    U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB,
    U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: Gelasio;
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/gelasio-latin-400-normal.woff2") format("woff2");
  unicode-range:
    U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC,
    U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212,
    U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: Gelasio;
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/gelasio-vietnamese-400-italic.woff2") format("woff2");
  unicode-range:
    U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1,
    U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329,
    U+1EA0-1EF9, U+20AB;
}
@font-face {
  font-family: Gelasio;
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/gelasio-latin-ext-400-italic.woff2") format("woff2");
  unicode-range:
    U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304,
    U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB,
    U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: Gelasio;
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/gelasio-latin-400-italic.woff2") format("woff2");
  unicode-range:
    U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC,
    U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212,
    U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: Gelasio;
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("fonts/gelasio-vietnamese-700-normal.woff2") format("woff2");
  unicode-range:
    U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1,
    U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329,
    U+1EA0-1EF9, U+20AB;
}
@font-face {
  font-family: Gelasio;
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("fonts/gelasio-latin-ext-700-normal.woff2") format("woff2");
  unicode-range:
    U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304,
    U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB,
    U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: Gelasio;
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("fonts/gelasio-latin-700-normal.woff2") format("woff2");
  unicode-range:
    U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC,
    U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212,
    U+2215, U+FEFF, U+FFFD;
}

/* The tokens: DESIGN.md's colours, each light then dark, picked by the element's color-scheme
   (the system's, or dark wherever color-scheme: dark is set, as in the lightbox) */
:root {
  color-scheme: light dark;

  --surface: light-dark(#ffffff, #121212);
  --secondary: light-dark(#f5f5f4, #1e1e1e);
  --text: light-dark(#111827, #ededed);
  --neutral: light-dark(#52525b, #a1a1aa);
  --primary: light-dark(#111111, #ededed);
  --on-primary: light-dark(#ffffff, #111111);
  --border: light-dark(#d4d4d8, #3f3f46);
  --field: light-dark(#71717a, #8a8a93);
  --focus: light-dark(#0a64d8, #7ab4ff);
  --success: light-dark(#15803d, #4ade80);
  --warning: light-dark(#92400e, #fbbf24);
  --danger: light-dark(#b91c1c, #f87171);

  --font-reading: Gelasio, Georgia, "Times New Roman", serif;
  --font-ui:
    system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --font-code: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  /* 14 / 16 / 18 / 24 / 32 / 40px */
  --text-sm: 0.875rem;
  --text-md: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.5rem;
  --text-2xl: 2rem;
  --text-3xl: 2.5rem;

  /* 4 / 8 / 12 / 16 / 24 / 32 / 48px */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;

  --radius-sm: 4px;
  --radius-md: 8px;
}

/* The page: the system sans for the interface, the serif for what's read */
body {
  margin: 0;
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: var(--text-md);
  line-height: 1.4;
}

h1,
h2,
h3 {
  font-family: var(--font-reading);
  font-weight: 700;
  line-height: 1.2;
}

h1 {
  font-size: var(--text-3xl);
}

h2 {
  font-size: var(--text-xl);
}

h3 {
  font-size: var(--text-lg);
}

code,
pre,
kbd {
  font-family: var(--font-code);
  font-size: var(--text-sm);
}

a {
  color: var(--primary);
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

/* One focus ring everywhere, outside what's focused */
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

/* Controls: secondary by default; a main form's action is a primary button (.primary, or the
   first button of a form.fields or an .actions row); what deletes or trashes is .danger */
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  min-height: 24px;
  padding: var(--space-2) var(--space-4);
  border: 1px solid var(--field);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-ui);
  font-weight: 600;
  cursor: pointer;
}

button:hover {
  background: var(--secondary);
}

button:active {
  translate: 0 1px;
}

button:disabled {
  background: var(--secondary);
  color: var(--neutral);
  border-color: var(--border);
  cursor: default;
  translate: none;
}

:is(
  button.primary,
  form.fields > button,
  form.fields p > button:first-child,
  .actions > button:first-child
):not(.danger) {
  background: var(--primary);
  color: var(--on-primary);
  border-color: var(--primary);
}

:is(
    button.primary,
    form.fields > button,
    form.fields p > button:first-child,
    .actions > button:first-child
  ):not(.danger, :disabled):hover {
  background: color-mix(in srgb, var(--primary) 85%, var(--surface));
}

button.danger {
  color: var(--danger);
  border-color: var(--danger);
  background: var(--surface);
}

button.danger:hover:not(:disabled) {
  background: color-mix(in srgb, var(--danger) 10%, var(--surface));
}

input[type="text"],
input[type="password"],
input[type="search"],
input:not([type]),
select,
textarea {
  min-height: 24px;
  padding: var(--space-2);
  border: 1px solid var(--field);
  border-radius: var(--radius-sm);
  background: var(--surface);
  /* 1rem, so phones don't zoom in on focus */
  font-size: var(--text-md);
}

input[type="checkbox"],
input[type="radio"] {
  accent-color: var(--primary);
  width: 1.1em;
  height: 1.1em;
}

progress {
  accent-color: var(--primary);
}

/* What a status says, in its colour, never colour alone (the text says it too) */
.error {
  color: var(--danger);
}

.success {
  color: var(--success);
}

.warning {
  color: var(--warning);
}

/* The upload confirm page in a dialog over any page (uploader.js) */
.upload-confirm {
  width: min(60rem, calc(100vw - 2rem));
  height: min(40rem, calc(100vh - 4rem));
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
}

.upload-confirm iframe {
  width: 100%;
  height: 100%;
  border: none;
}

.upload-confirm .close {
  position: absolute;
  top: var(--space-2);
  right: var(--space-3);
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  font-size: var(--text-xl);
  line-height: 1;
  background: none;
  border: none;
  color: inherit;
}

.upload-confirm::backdrop {
  background: rgb(0 0 0 / 0.5);
}

/* Nothing moves for someone who's asked their system for less motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
