/* The page's tokens and the styles every component shares. Adopted by the
   document and by each component's shadow root.

   Each colour is light-dark(light, dark): the page's color-scheme picks one.
   It follows the system, unless Appearance in the settings sets data-theme
   on the root (app/appearance.js). */

:root {
  color-scheme: light dark;
  font-family: system-ui, sans-serif;
  line-height: 1.5;
  --text: light-dark(#1d1d1f, #f5f5f7);
  --muted: light-dark(#6e6e73, #a1a1a6);
  --line: light-dark(#e3e3e8, #3a3a3e);
  --track: light-dark(#f0f0f3, #2a2a2d);
  --surface: light-dark(#ffffff, #1c1c1e);
  --page: light-dark(#fbfbfd, #111113);
  --accent: light-dark(#2f7fd6, #5ea3ec);
  --highlight: light-dark(#fff1a8, #6b5d12);
  --error: light-dark(#c62828, #ef6b6b);
  /* A note's pages are photos of paper: dimmed a little in the dark. */
  --paper: light-dark(#ffffff, #d9d9d6);
  --dim: light-dark(transparent, rgb(0 0 0 / 0.18));
  --serif: "New York", ui-serif, Georgia, "Times New Roman", serif;
  /* The window's bar and the sidebar beside the page. */
  --bar-height: 3.25rem;
  --sidebar-width: 15rem;
}

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

body {
  margin: 0;
  background: var(--page);
  color: var(--text);
}
/* Pages without the app shell, such as the 404 page. */
body > main { max-width: 40rem; margin: 0 auto; padding: 3rem 1rem; }

/* A rating's colour, as the app's: Again red, Hard orange, Good green, Easy blue.
   Set data-rating on the row; the text and rules in it use var(--rating). */
[data-rating="1"] { --rating: light-dark(#d70015, #ff6961); }
[data-rating="2"] { --rating: light-dark(#c75300, #ffa94d); }
[data-rating="3"] { --rating: light-dark(#248a3d, #4cd964); }
[data-rating="4"] { --rating: light-dark(#0062cc, #5ea3ec); }

/* Levels: the "green to violet" palette, neighbouring levels in neighbouring colours. */
[data-level="A1"] { --level: #7cb518; }
[data-level="A2"] { --level: #3fa34d; }
[data-level="B1"] { --level: #119e8a; }
[data-level="B2"] { --level: #2f7fd6; }
[data-level="C1"] { --level: #5a55d6; }
[data-level="C2"] { --level: #9a4fcf; }

:host { display: block; }
[hidden] { display: none !important; }

a { color: inherit; }
h1, h2, h3 { margin: 0; font-weight: 600; }
h1 { font-size: 1.6rem; }
ul { list-style: none; margin: 0; padding: 0; }

button, input {
  font: inherit;
  color: inherit;
  padding: 0.45rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: var(--surface);
}
button { cursor: pointer; }
button.primary { background: var(--text); color: var(--surface); border-color: var(--text); }
button.link { border: none; padding: 0; background: none; text-decoration: underline; }
button:disabled { opacity: 0.5; cursor: progress; }
input { min-width: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

mark { background: var(--highlight); color: inherit; border-radius: 2px; }

.muted { color: var(--muted); }
/* A page's own big title, on a phone, which the window's bar shows small once
   it has scrolled under it; beside the sidebar the bar shows the title. */
.large-title { font-size: 1.9rem; margin: 0.25rem 0 0.75rem; }
@media (min-width: 761px) {
  .large-title { display: none; }
}
/* The tools a page hands the window's bar: hidden until moved there. */
[data-ref="tools"] { display: none; }
.error { color: var(--error); }
.number { color: var(--muted); font-size: 0.85em; font-variant-numeric: tabular-nums; }
.row { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }

/* A level as a small tag in its colour; set data-level on it. */
.badge {
  display: inline-block;
  padding: 0 0.4rem;
  border-radius: 0.4rem;
  font-weight: 600;
  font-size: 0.85em;
  text-decoration: none;
  color: var(--level, var(--muted));
  background: color-mix(in srgb, var(--level, var(--muted)) 15%, transparent);
}

/* A small heading over a group, as list sections head theirs. */
.group-heading {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin: 1.5rem 0 0.25rem;
  padding-bottom: 0.25rem;
  border-bottom: 1px solid var(--line);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
}

/* A box around a component's content. */
.panel {
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  background: var(--surface);
}

/* A level as coloured text, as the card list shows it; set data-level on it. */
.level-text { color: var(--level, var(--muted)); font-weight: 600; }

/* The card's own word in a sentence (term-marks.js). */
.term { text-decoration: underline; text-underline-offset: 0.15em; }

/* Rows in a group, as settings list them: what a row is on the left, its
   value or control on the right; a row that opens a page ends in a chevron. */
.list-group {
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  background: var(--surface);
  overflow: hidden;
}
.list-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.75rem;
  align-items: center;
  min-height: 2.75rem;
  padding: 0.45rem 1rem;
  box-sizing: border-box;
  text-decoration: none;
}
.list-row + .list-row { border-top: 1px solid var(--line); }
.list-row > :first-child { flex: 1; }
.list-row .value { color: var(--muted); font-variant-numeric: tabular-nums; }
a.list-row::after {
  content: "";
  width: 1em;
  height: 1em;
  background: var(--muted);
  mask: url("/icons/chevron-right.svg") center / contain no-repeat;
}
a.list-row:hover { background: color-mix(in srgb, var(--text) 4%, transparent); }
.list-footer { margin: 0.4rem 1rem 0; font-size: 0.85em; color: var(--muted); }

/* An on/off switch. */
.switch {
  appearance: none;
  position: relative;
  width: 2.6rem;
  height: 1.55rem;
  padding: 0;
  border: none;
  border-radius: 1rem;
  background: var(--line);
  cursor: pointer;
  transition: background 0.15s;
}
.switch::before {
  content: "";
  position: absolute;
  top: 0.15rem;
  left: 0.15rem;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.3);
  transition: transform 0.15s;
}
.switch:checked { background: #34c759; }
.switch:checked::before { transform: translateX(1.05rem); }

/* A menu button: an icon and a chevron. */
.menu-toggle {
  display: inline-flex;
  gap: 0.1rem;
  align-items: center;
  height: 2.1rem;
  padding: 0 0.5rem;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
}
.menu-toggle:hover { background: var(--track); color: var(--text); }
.menu-toggle app-icon { font-size: 1.1rem; }
.menu-toggle .chevron { font-size: 0.75rem; }

/* A menu button's popover (card-sort, map-filter): under the button, held
   inside the window; its items checked as chosen. */
.menu-popover {
  position: fixed;
  inset: auto;
  margin: 0;
  min-width: 15rem;
  padding: 0.4rem;
  border: 1px solid var(--line);
  border-radius: 0.8rem;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 12px 40px color-mix(in srgb, var(--text) 18%, transparent);
}
.menu-heading { margin: 0.3rem 0.6rem 0.2rem 1.9rem; font-size: 0.85rem; font-weight: 600; color: var(--muted); }
.menu-popover hr { margin: 0.35rem 0.6rem; border: none; border-top: 1px solid var(--line); }
.menu-item {
  position: relative;
  display: block;
  width: 100%;
  padding: 0.35rem 0.6rem 0.35rem 1.9rem;
  border: none;
  border-radius: 0.45rem;
  background: transparent;
  text-align: left;
}
.menu-item:hover { background: var(--track); }
a.menu-item { color: inherit; text-decoration: none; }
.menu-icon { position: absolute; left: 0.55rem; top: 50%; transform: translateY(-50%); font-size: 0.9rem; }
.menu-check { position: absolute; left: 0.55rem; top: 50%; transform: translateY(-50%); font-size: 0.9rem; visibility: hidden; }
.menu-item[aria-checked="true"] .menu-check { visibility: visible; }

/* A chip: a tag on a card, a card on a map item. Rounded, on the track colour. */
.chip {
  display: inline-flex;
  gap: 0.35rem;
  align-items: center;
  padding: 0.2rem 0.7rem;
  border: none;
  /* Rounded, not a pill: a long card name wraps. */
  border-radius: 0.9rem;
  background: var(--track);
  color: var(--text);
  font-size: 0.9rem;
  text-decoration: none;
}
.chip:hover { background: color-mix(in srgb, var(--text) 12%, transparent); }
.chip app-icon { color: var(--muted); }
