/* The Quiet Apartment look, shared by the admin (admin.css) and the mailing list's public pages (public.css).
   It mirrors the web: web/src/styles/global.css, with the values of brand/brand.json and the fonts of web/astro.config.mjs.
   When the web's tokens change, change them here too. Light and dark follow the system setting; there is no toggle. */

/* Fonts ------------------------------------------------------------- */

/* The same two variable files as the web (Literata 400 to 600, Atkinson Hyperlegible Next 400 to 700), `display: block` like the
   web: a page never shows its first frame in a stand-in font. The "fallback" faces are the stand-ins with metrics that match the
   real fonts (made by Astro's Fonts API for the web), so the text does not jump if a font file is slow. Propshaft turns url()
   into the digested path, which the CSP's font-src 'self' allows. The licences (SIL OFL) are in app/assets/fonts. */
@font-face {
  font-family: "Literata";
  src: url("/assets/literata-46200c06.woff2") format("woff2");
  font-display: block;
  font-weight: 400 600;
  font-style: normal;
}

@font-face {
  font-family: "Literata fallback";
  src: local("Times New Roman");
  font-display: swap;
  font-weight: 400 600;
  font-style: normal;
  size-adjust: 118.4%;
  ascent-override: 99.4088%;
  descent-override: 26.0135%;
  line-gap-override: 0%;
}

@font-face {
  font-family: "Atkinson Hyperlegible Next";
  src: url("/assets/atkinson-hyperlegible-next-1f399b12.woff2") format("woff2");
  font-display: block;
  font-weight: 400 700;
  font-style: normal;
}

@font-face {
  font-family: "Atkinson Hyperlegible Next fallback";
  src: local("Arial");
  font-display: swap;
  font-weight: 400 700;
  font-style: normal;
  size-adjust: 99.5961%;
  ascent-override: 98.7991%;
  descent-override: 31.7282%;
  line-gap-override: 0%;
}

/* Tokens ------------------------------------------------------------ */

:root {
  color-scheme: light dark;

  /* light-dark(light, dark) */
  --bg: light-dark(#e8e6e1, #12161a);
  --surface: light-dark(#dad7d0, #1a1f25);
  --text: light-dark(#1a1c1f, #e6e3db);
  --muted: light-dark(#4e5258, #98a0a8);
  --primary: light-dark(#2d6180, #77acce); /* Steel lake: the one accent, links and focus only */
  --on-primary: light-dark(#e8e6e1, #12161a);
  --rule: color-mix(in srgb, var(--text) 16%, transparent);

  /* brand.json: for errors and the one dangerous button. The warning colour is the admin's own (not a brand colour). */
  --error: light-dark(#b3372f, #e0766f);
  --warning: light-dark(#8a5a00, #e0b04f);

  --font-display: "Literata", "Literata fallback", serif;
  --font-text: "Atkinson Hyperlegible Next", "Atkinson Hyperlegible Next fallback", sans-serif;

  /* The web's five type sizes (the larger ones scale with the viewport). */
  --fs-s: 0.9375rem;
  --fs-body: 1.125rem;
  --fs-h3: clamp(1.25rem, 1.12rem + 0.55vw, 1.5rem);
  --fs-h2: clamp(1.875rem, 1.1rem + 2.6vw, 3.25rem);
  --fs-h1: clamp(2.75rem, 1rem + 6.6vw, 6.75rem);

  --space-1: 0.5rem;
  --space-2: 1rem;
  --space-3: 1.5rem;
  --space-4: 2.5rem;
  --space-5: 4.5rem;
  --section-y: clamp(4rem, 2.4rem + 7vw, 9rem);

  --gutter: clamp(1.25rem, 4vw, 3rem);
  --measure: 38rem;

  /* The one corner radius: buttons, form fields, cards and focus rings. */
  --radius: 6px;
}

/* Base -------------------------------------------------------------- */

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

* {
  margin: 0;
}

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  accent-color: var(--primary);
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-text);
  font-size: var(--fs-body);
  line-height: 1.7;
  font-synthesis: none;
  font-optical-sizing: auto;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}

main {
  flex: 1;
}

::selection {
  background: var(--primary);
  color: var(--on-primary);
}

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

h1,
h2,
h3 {
  font-family: var(--font-display);
  text-wrap: balance;
}

p {
  text-wrap: pretty;
}

/* The brand fonts have no italic cut: emphasis is a heavier weight, never a faked slant. */
strong {
  font-weight: 700;
}

em {
  font-style: normal;
  font-weight: 600;
}

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

/* Text link in the accent colour; the underline thickens and drops a little on hover. */
a {
  color: var(--primary);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.22em;
  transition:
    text-decoration-thickness 0.2s ease,
    text-underline-offset 0.2s ease;
}

a:hover {
  text-decoration-thickness: 2px;
  text-underline-offset: 0.3em;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  left: var(--gutter);
  top: var(--space-1);
  z-index: 10;
  padding: var(--space-1) var(--space-2);
  background: var(--text);
  color: var(--bg);
  text-decoration: none;
  transform: translateY(-300%);
}

.skip-link:focus {
  transform: none;
}

.wrap {
  width: min(100% - 2 * var(--gutter), 76rem);
  margin-inline: auto;
}

/* The name and the mark ----------------------------------------------- */

/* The mark is a mask, so it takes the text colour (ink on light, off-white on dark) like the web's inline logo. */
.mark {
  flex: none;
  width: 2.25rem;
  aspect-ratio: 102 / 92.5;
  background: currentColor;
  mask: url("/assets/mark-f903a636.svg") center / contain no-repeat;
  forced-color-adjust: none;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 2.75rem;
  color: inherit;
  font-family: var(--font-display);
  font-weight: 600;
  white-space: nowrap;
  text-decoration: none;
}

.brand:hover {
  text-decoration: none;
}

/* Text -------------------------------------------------------------- */

.hint {
  font-size: var(--fs-s);
  color: var(--muted);
}

/* Forms ------------------------------------------------------------- */

.field {
  display: grid;
  gap: var(--space-1);
}

.field label,
legend {
  font-weight: 600;
}

input[type="email"],
input[type="password"],
input[type="text"],
input[type="number"],
input[type="url"],
input[type="date"],
textarea,
select {
  padding: var(--space-2);
  border: 1px solid var(--muted);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  font: inherit;
  line-height: 1.6;
}

textarea {
  resize: vertical;
}

/* field_aria marks a field that did not pass; the message under it says why, the edge only points at it. */
input[aria-invalid="true"],
textarea[aria-invalid="true"],
select[aria-invalid="true"] {
  border-color: var(--error);
}

input[type="checkbox"],
input[type="radio"] {
  flex: none;
  width: 1.125rem;
  height: 1.125rem;
}

/* The one button: ink on the page colour, and on hover the page colour with an ink edge. Primary stays for links and focus. */
.button,
:where(button, input[type="submit"]) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem;
  padding: 0.6em 1.5em;
  border: 1px solid var(--text);
  border-radius: var(--radius);
  background: var(--text);
  color: var(--bg);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition:
    background-color 0.2s ease,
    color 0.2s ease;
}

.button:hover,
:where(button, input[type="submit"]):hover {
  background: transparent;
  color: var(--text);
  text-decoration: none;
}

.button:disabled,
:where(button, input[type="submit"]):disabled {
  border-color: var(--muted);
  background: transparent;
  color: var(--muted);
  cursor: not-allowed;
}

@media (prefers-reduced-motion: reduce) {
  a,
  .button,
  :where(button, input[type="submit"]) {
    transition: none;
  }
}
