/*
 * The whole stylesheet. It ships as one file, it loads no font and it reaches for nothing
 * off this origin.
 *
 * The grid is the page, so the sizes below are chosen to keep a character legible and tappable at
 * a phone width and to fit as many as possible on a desktop. Sections are laid out lazily, which
 * is what lets thousands of cells sit in one document without the browser doing work for the ones
 * nobody has scrolled to.
 */

:root {
  --page: #fbfaf8;
  --ink: #1d1b19;
  --quiet: #6b645c;
  --line: #e2dcd3;
  --cell: #ffffff;
  --accent: #2f6d5c;
  --accent-ink: #ffffff;
  --radius: 10px;
  --gap: 6px;
  --cell-size: 58px;

  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --page: #16151a;
    --ink: #eceae6;
    --quiet: #a09a92;
    --line: #2e2c33;
    --cell: #1f1e25;
    --accent: #7fd1b9;
    --accent-ink: #14211d;
  }
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  padding: 0 16px 64px;
  background: var(--page);
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue",
    sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

.masthead {
  max-width: 1200px;
  margin: 0 auto;
  padding: 28px 0 8px;
}

.masthead__name {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.masthead__tagline {
  margin: 2px 0 0;
  color: var(--quiet);
}

.app,
.colophon {
  max-width: 1200px;
  margin: 0 auto;
}

/* The search field sticks, so the way back to it is always one glance away. */
.search {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 12px 0 8px;
  background: linear-gradient(var(--page) 78%, transparent);
}

.search__field {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--cell);
  color: inherit;
  font: inherit;
  font-size: 1.0625rem;
  -webkit-appearance: none;
  appearance: none;
}

.search__field:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.search__count {
  margin: 6px 2px 0;
  color: var(--quiet);
  font-size: 0.875rem;
}

.status {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  margin: 0 0 8px;
  padding: 4px 2px;
  border-bottom: 1px solid var(--line);
  color: var(--quiet);
  font-size: 0.875rem;
}

.status--empty {
  color: var(--quiet);
}

.status--copied {
  color: var(--accent);
  font-weight: 600;
}

.status__glyph {
  font-size: 1.5rem;
  line-height: 1;
  color: var(--ink);
}

.status__name {
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status__code,
.status__marks {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.8125rem;
}

.status__marks {
  color: var(--accent);
}

.section {
  margin: 20px 0 0;
  /* Offscreen sections are not laid out until they are scrolled to. */
  content-visibility: auto;
  contain-intrinsic-size: auto 320px;
}

.section__title {
  position: sticky;
  top: 74px;
  margin: 0 0 8px;
  padding: 4px 0;
  background: var(--page);
  color: var(--quiet);
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--cell-size), 1fr));
  gap: var(--gap);
}

.cell {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--cell);
  color: inherit;
  font: inherit;
  cursor: pointer;
  /* Each cell paints on its own, so a grid of thousands does not repaint as one. */
  contain: content;
}

.cell:hover {
  border-color: var(--accent);
}

.cell:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}

.cell:active {
  background: var(--accent);
  color: var(--accent-ink);
}

.cell__glyph {
  font-size: 1.5rem;
  line-height: 1;
  /* Emoji and symbols come from whichever font has them; nothing is downloaded for this. */
  font-family: inherit;
}

.notice {
  margin: 16px 2px;
  color: var(--quiet);
}

.notice code {
  padding: 1px 5px;
  border-radius: 5px;
  background: var(--cell);
  border: 1px solid var(--line);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.8125rem;
}

.colophon {
  margin-top: 48px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: var(--quiet);
  font-size: 0.875rem;
}

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

@media (max-width: 560px) {
  :root {
    --cell-size: 52px;
    --gap: 5px;
  }

  body {
    padding: 0 12px 48px;
  }

  .masthead {
    padding-top: 18px;
  }

  .section__title {
    top: 70px;
  }
}

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