/* The look that the staff app and the public site share. Every colour is here, and nowhere else. */

:root {
  color-scheme: light dark;
  --page: #ffffff;
  --surface: #ffffff;
  --panel: #eef2fd;
  --text: #141b38;
  --muted: #545d80;
  --line: #d5dcf0;
  --control-line: #6f7bab;
  --accent: #2c4bd0;
  --accent-hover: #213aa8;
  --on-accent: #ffffff;
  --accent-soft: #eef2fd;
  --accent-text: #213aa8;
  --strong: #17245a;
  --lamp: #f5b324;
  --lamp-hover: #ffc64d;
  --on-lamp: #2a1d00;
  --lamp-soft: #fff3d3;
  --on-lamp-soft: #6b4700;
  --ok: #14694a;
  --ok-soft: #dcf3e7;
  --problem: #b3263d;
  --problem-soft: #fde6ea;
  --focus: #2c4bd0;
  --ink: #121c45;
  --ink-selected: #263573;
  --ink-line: #2c3a78;
  --on-ink: #ffffff;
  --on-ink-muted: #c6d0f5;
  --problem-on-ink: #ffb4be;
  --focus-on-ink: #f5b324;
  --date-back: #ffffff;
  --date-text: #121c45;
  --date-accent: #213aa8;
  --date-muted: #545d80;
  --hero-top: #101a45;
  --hero-end: #22389c;
  --on-hero: #dfe6ff;
  --cell: #f4f6fd;
  --shape: #141b38;
  --backdrop: rgb(13 18 48 / 60%);
  /* Cameras need the light edge, in dark too. */
  --qr: #ffffff;
}

/* On a screen only, so that paper is always light. */
@media screen and (prefers-color-scheme: dark) {
  :root {
    --page: #0b1028;
    --surface: #141b3e;
    --panel: #161e45;
    --text: #e9edfb;
    --muted: #aab5da;
    --line: #2c376b;
    --control-line: #7f8cc0;
    --accent: #a5b6ff;
    --accent-hover: #c1ccff;
    --on-accent: #0b1028;
    --accent-soft: #202b5e;
    --accent-text: #b4c2ff;
    --strong: #e9edfb;
    --lamp: #f5b324;
    --lamp-hover: #ffc64d;
    --on-lamp: #2a1d00;
    --lamp-soft: #3a2d0a;
    --on-lamp-soft: #ffd988;
    --ok: #7fd6ae;
    --ok-soft: #12382b;
    --problem: #ff9aa8;
    --problem-soft: #43182a;
    --focus: #f5b324;
    --ink: #18225a;
    --ink-selected: #2b3a85;
    --ink-line: #3a488f;
    --on-ink: #ffffff;
    --on-ink-muted: #c6d0f5;
    --problem-on-ink: #ffb4be;
    --focus-on-ink: #f5b324;
    --date-back: #e9edfb;
    --date-text: #121c45;
    --date-accent: #213aa8;
    --date-muted: #49527a;
    --hero-top: #0b1028;
    --hero-end: #1d2f86;
    --on-hero: #dfe6ff;
    --cell: #141b40;
    --shape: #e9edfb;
    --backdrop: rgb(0 0 0 / 70%);
    --qr: #ffffff;
  }
}

:root {
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
}

/* Grounds. Each sets its own tokens, so that a link, a quiet button or a focus ring is
   right wherever it stands, with no rule of its own. */

.on-ink,
.side,
.plain-head,
.record-head,
.total-bar,
.hero {
  --text: var(--on-ink);
  --accent-text: var(--on-ink);
  --strong: var(--on-ink);
  --ok: var(--on-ink);
  --on-lamp-soft: var(--on-ink);
  --shape: var(--on-ink);
  --muted: var(--on-ink-muted);
  --control-line: var(--on-ink-muted);
  --accent: var(--lamp);
  --accent-hover: var(--lamp-hover);
  --on-accent: var(--on-lamp);
  --problem: var(--problem-on-ink);
  --focus: var(--focus-on-ink);
  --line: var(--ink-line);
  --surface: var(--ink-selected);
  --panel: var(--ink-selected);
  --accent-soft: var(--ink-selected);
  --lamp-soft: var(--ink-selected);
  --ok-soft: var(--ink-selected);
  --problem-soft: var(--ink-selected);
  background: var(--ink);
  color: var(--text);
}

.hero {
  background: linear-gradient(var(--hero-top), var(--hero-end));
}

.hero p {
  color: var(--on-hero);
}

/* Ice: a panel, the facts at the head of a record, a section or a form by itself, and a thing that is worked on in place.
   A thing may be all that its item holds, and is then the panel itself.
   A browser that has no :has() drops what is in :is() or :where() alone. Anywhere else, the whole rule would go. */
.panel,
.summary,
.card:where(:not(li)),
.cards > li:is(.thing, :has(form, button, dl):not(:has(> [role="group"]))) {
  --accent-soft: var(--surface);
  padding: min(1.25rem, 5vw);
  border: 0;
  border-radius: 1.125rem;
  background: var(--panel);
  color: var(--text);
}

/* A day of the public calendar. */
.has-events {
  --text: var(--on-accent);
  --muted: var(--on-accent);
  --accent-text: var(--on-accent);
  --focus: var(--on-accent);
  background: var(--accent);
  color: var(--text);
}

/* Readex Pro 5.3.0, SIL Open Font License 1.1: OFL.txt. */

@font-face {
  font-family: "Readex Pro";
  font-style: normal;
  font-weight: 160 700;
  font-display: swap;
  src: url("./readex-pro-5.3.0-latin.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: "Readex Pro";
  font-style: normal;
  font-weight: 160 700;
  font-display: swap;
  src: url("./readex-pro-5.3.0-latin-ext.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: "Readex Pro";
  font-style: normal;
  font-weight: 160 700;
  font-display: swap;
  src: url("./readex-pro-5.3.0-arabic.woff2") format("woff2");
  unicode-range:
    U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F,
    U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC, U+102E0-102FB, U+10E60-10E7E, U+10EC2-10EC4, U+10EFC-10EFF,
    U+1EE00-1EE03, U+1EE05-1EE1F, U+1EE21-1EE22, U+1EE24, U+1EE27, U+1EE29-1EE32, U+1EE34-1EE37, U+1EE39, U+1EE3B,
    U+1EE42, U+1EE47, U+1EE49, U+1EE4B, U+1EE4D-1EE4F, U+1EE51-1EE52, U+1EE54, U+1EE57, U+1EE59, U+1EE5B, U+1EE5D,
    U+1EE5F, U+1EE61-1EE62, U+1EE64, U+1EE67-1EE6A, U+1EE6C-1EE72, U+1EE74-1EE77, U+1EE79-1EE7C, U+1EE7E,
    U+1EE80-1EE89, U+1EE8B-1EE9B, U+1EEA1-1EEA3, U+1EEA5-1EEA9, U+1EEAB-1EEBB, U+1EEF0-1EEF1;
}

/* Base */

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

body {
  margin: 0;
  background: var(--page);
  color: var(--text);
  font: 1rem/1.5 "Readex Pro", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow-wrap: anywhere;
}

h1,
h2,
h3,
h4 {
  margin: 0 0 0.75rem;
  font-weight: 600;
  line-height: 1.25;
  text-wrap: balance;
}

h1 {
  font-size: 2.125rem;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

h2 {
  margin-top: 1.75rem;
  font-size: 1.125rem;
}

h3 {
  margin-block: 1.25rem 0.5rem;
  font-size: 1.0625rem;
  font-weight: 500;
  line-height: 1.35;
}

h4 {
  margin-bottom: 0.5rem;
  font-size: 1rem;
}

p {
  margin: 0 0 1rem;
  max-width: 65ch;
}

/* Kept in the page while empty, so that screen readers notice what is put in them. */
p:empty {
  margin: 0;
}

a {
  color: var(--accent-text);
}

:focus-visible,
/* A date's parts and its calendar button take the focus in turn, and Chrome draws nothing round the button. A box to
   type in shows the focus from a press too. */
input:is([type="date"], [type="time"], [type="datetime-local"], [type="month"], [type="week"]):focus-within {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

/* Focused only to be read out, and not something to press. */
main:focus,
h1:focus,
h2:focus,
h3:focus,
[role="group"]:focus {
  outline: none;
}

/* In the page when it has focus, so that it covers nothing. */
.skip-link {
  display: flex;
  align-items: center;
  width: fit-content;
  min-height: 2.75rem;
  margin: max(0.5rem, var(--safe-top)) 0 0.5rem max(0.5rem, var(--safe-left));
  padding: 0.5rem 1rem;
}

.skip-link:not(:focus),
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  min-height: 0;
  margin: 0;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Pieces */

button,
.button {
  min-height: 2.75rem;
  padding: 0.5rem 1.125rem;
  border: 0.09375rem solid var(--accent);
  border-radius: 0.625rem;
  background: var(--accent);
  color: var(--on-accent);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 120ms ease-out;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  text-decoration: none;
}

button:hover,
.button:hover {
  border-color: var(--accent-hover);
  background: var(--accent-hover);
}

button.quiet,
.button.quiet {
  border-color: var(--control-line);
  background: transparent;
  color: var(--accent-text);
}

button.quiet:hover,
.button.quiet:hover {
  background: var(--accent-soft);
  text-decoration: underline;
}

.button.lamp {
  border-color: var(--shape);
  background: var(--lamp);
  color: var(--on-lamp);
}

.button.lamp:hover {
  background: var(--lamp-hover);
}

/* It shows on ink without an outline. */
:is(.on-ink, .side, .plain-head, .record-head, .total-bar, .hero) .button.lamp {
  border-color: var(--lamp);
}

.tag {
  padding: 0.1875rem 0.625rem;
  border-radius: 0.4375rem;
  background: var(--accent-soft);
  color: var(--accent-text);
  font-size: 0.875rem;
  font-weight: 500;
}

.key {
  display: inline-block;
  max-width: 100%;
  padding: 0.25rem 0.5rem;
  border-radius: 0.4375rem;
  background: var(--accent-soft);
  font-size: 1rem;
  overflow-wrap: anywhere;
}

/* What the page says. Each has words, and an edge of its own. */
.notice,
.warning {
  margin: 0 0 1rem;
  padding: 0.75rem 1rem;
  border-radius: 0 0.625rem 0.625rem 0;
  background: var(--accent-soft);
}

/* So that nested lines stay apart. After those, as it is no stronger. A row of a list has no box there either. */
:where(.panel, .summary, .card:where(:not(li)), .cards > li:is(.thing, :has(form, button, dl):not(:has(> [role="group"])))) :is(.card:where(:not(li)), .notice, .tag, .key),
:where(.panel, .summary, .card:where(:not(li)), .cards > li:is(.thing, :has(form, button, dl):not(:has(> [role="group"])))) .cards > li:is(.thing, :has(form, button, dl):not(:has(> [role="group"]))) {
  border: 1px solid var(--line);
  background: var(--surface);
}

.notice {
  border-left: 0.25rem solid var(--accent);
}

p.notice[role="status"] {
  border-left-color: var(--ok);
  background: var(--ok-soft);
}

.warning {
  border: 1px solid var(--control-line);
  border-left: 0.25rem solid var(--lamp);
  background: var(--lamp-soft);
}

.problem {
  color: var(--problem);
  font-weight: 600;
}

:is(.panel, .card, .thing, .notice, .warning) > :is(h2, h3, h4):first-child {
  margin-top: 0;
}

:is(.panel, .card, .thing, .notice, .warning) > :last-child {
  margin-bottom: 0;
}

/* A day: its number, over its month and weekday. */
.date {
  line-height: 1;
}

.date > * {
  display: block;
  margin-top: 0.3125rem;
  color: var(--muted);
  font-size: 0.8125rem;
}

.date > b {
  margin-top: 0;
  color: var(--strong);
  font-size: 1.6875rem;
  font-weight: 600;
  letter-spacing: -0.04em;
}

/* At the head of an event: its month, its number, its year. */
.date.head {
  width: fit-content;
  min-width: 6.5rem;
  padding: 0.875rem 1.125rem 0.8125rem;
  border-radius: 1rem;
  background: var(--date-back);
  text-align: center;
}

.date.head > * {
  margin: 0;
  color: var(--date-accent);
  font-size: 0.875rem;
  font-weight: 500;
}

.date.head > b {
  margin-block: 0.25rem 0.5rem;
  color: var(--date-text);
  font-size: 3.125rem;
  font-weight: 600;
}

.date.head > b + * {
  padding-top: 0.5rem;
  border-top: 1px solid color-mix(in srgb, var(--date-muted) 25%, var(--date-back));
  color: var(--date-muted);
  font-size: 0.8125rem;
  font-weight: 400;
}

/* A point in time, and nothing else. Always one, as the pair is the calligraphy's own. */
.diamond {
  display: inline-block;
  flex: none;
  width: 0.625rem;
  height: 0.625rem;
  border: 0.09375rem solid var(--shape);
  border-radius: 0.125rem;
  background: var(--lamp);
  transform: rotate(45deg);
}

.diamond:is(.done, .to-come) {
  width: 0.8125rem;
  height: 0.8125rem;
}

/* All edge, so that it is still filled in forced colours, and on paper without backgrounds. */
.diamond.done {
  border-width: 0.40625rem;
  border-color: var(--accent);
  background: var(--accent);
}

.diamond.to-come {
  border-width: 0.15625rem;
  background: transparent;
}

.diamond.now {
  width: 1.0625rem;
  height: 1.0625rem;
  border-width: 0.125rem;
}

.has-events .diamond {
  border-color: var(--on-accent);
}

/* The calligraphy, white on ink or the hero alone: whole, and at its own shape. */
.mark-box {
  display: inline-block;
  color: var(--on-ink);
}

.mark,
.logo {
  display: block;
  max-width: 100%;
  height: auto;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
  }
}

@media (forced-colors: active) {
  .panel,
  .summary,
  .card:where(:not(li)),
  .cards > li:is(.thing, :has(form, button, dl):not(:has(> [role="group"]))),
  .notice,
  .warning,
  .date.head {
    border: 1px solid;
  }

  .notice,
  .warning {
    border-left-width: 0.25rem;
  }

  /* A gradient stays, under text that is no longer white. */
  .hero {
    background: var(--ink);
  }

  /* A filled one, from a quiet one. */
  button:not(.quiet),
  .button:not(.quiet) {
    border-width: 0.1875rem;
  }

  .diamond.done {
    border-color: CanvasText;
    background: CanvasText;
    forced-color-adjust: none;
  }

  .diamond.now {
    border-width: 0.3125rem;
    border-style: double;
  }

  /* White, so it keeps the ink it stands on. */
  .mark-box {
    background: var(--ink);
    forced-color-adjust: none;
  }
}

@media print {
  :root,
  .on-ink,
  .side,
  .plain-head,
  .record-head,
  .total-bar,
  .hero,
  .panel,
  .summary,
  .card:where(:not(li)),
  .cards > li:is(.thing, :has(form, button, dl):not(:has(> [role="group"]))),
  .has-events {
    color-scheme: light;
    --page: #ffffff;
    --surface: #ffffff;
    --panel: #ffffff;
    --accent-soft: #ffffff;
    --lamp-soft: #ffffff;
    --ok-soft: #ffffff;
    --problem-soft: #ffffff;
    --cell: #ffffff;
    --accent: #ffffff;
    --accent-hover: #ffffff;
    --lamp: #ffffff;
    --lamp-hover: #ffffff;
    --ink: #ffffff;
    --ink-selected: #ffffff;
    --hero-top: #ffffff;
    --hero-end: #ffffff;
    --date-back: #ffffff;
    --text: #141b38;
    --muted: #141b38;
    --accent-text: #141b38;
    --strong: #141b38;
    --problem: #141b38;
    --ok: #141b38;
    --on-accent: #141b38;
    --on-lamp: #141b38;
    --on-lamp-soft: #141b38;
    --on-ink: #141b38;
    --on-ink-muted: #141b38;
    --problem-on-ink: #141b38;
    --on-hero: #141b38;
    --date-text: #141b38;
    --date-accent: #141b38;
    --date-muted: #141b38;
    --control-line: #141b38;
    --shape: #141b38;
    --line: #d5dcf0;
    --ink-line: #d5dcf0;
  }

  /* An accent is white there. */
  .diamond,
  .diamond.done,
  .has-events .diamond {
    border-color: var(--shape);
  }

  .diamond.done {
    background: var(--shape);
  }

  nav,
  button,
  .button,
  .skip-link,
  .mark-box,
  .mark,
  .logo {
    display: none !important;
  }
}
