/* Find the relevant xkcd. Paper, ink, pencil, ballpoint, one highlighter. */
:root {
  --paper: #ffffff;
  --ink: #000000;
  --pencil: #595959; /* 7:1 on paper */
  --rule: #d4d4d4;
  --pen: #2348c9; /* links and focus: 7.4:1 on paper */
  --highlighter: #fff04d;

  --hand: "Shantell Sans", "Comic Neue", ui-rounded, system-ui, sans-serif;
  --text: "Atkinson Hyperlegible Next", "Atkinson Hyperlegible", system-ui, sans-serif;

  --measure: 46rem;
}

* {
  box-sizing: border-box;
}

html {
  color: var(--ink);
  background: var(--paper);
  font-family: var(--text);
  font-size: 100%;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
}

a {
  color: var(--pen);
  text-underline-offset: 0.18em;
}

:focus-visible {
  outline: 3px solid var(--pen);
  outline-offset: 3px;
}

.page {
  max-width: var(--measure);
  margin: 0 auto;
  padding: clamp(1.5rem, 5vw, 3.5rem) clamp(1rem, 4vw, 2rem) 3rem;
}

/* ---------------------------------------------------------------- header */

.masthead h1 {
  margin: 0;
  font-family: var(--hand);
  font-weight: 800;
  font-size: clamp(1.125rem, 2.4vw, 1.375rem);
  letter-spacing: 0.01em;
}

.masthead-title {
  margin: 0;
  font-family: var(--hand);
  font-weight: 800;
  font-size: clamp(1.125rem, 2.4vw, 1.375rem);
}

.masthead-title a,
.masthead h1 a {
  color: inherit;
  text-decoration: none;
}

.unofficial {
  margin: 0.2rem 0 0;
  color: var(--pencil);
  font-size: 0.875rem;
}

/* ------------------------------------------------- the fill-in sentence */

.ask {
  margin: clamp(2.5rem, 9vw, 5rem) 0 2.5rem;
}

.ask-label {
  display: block;
  font-family: var(--hand);
  font-weight: 600;
  font-size: clamp(2rem, 6.5vw, 3.25rem);
  line-height: 1.1;
  letter-spacing: -0.01em;
}

.ask-row {
  display: flex;
  align-items: flex-end;
  gap: 1rem;
  margin-top: 0.5rem;
}

.ask input {
  flex: 1;
  min-width: 0;
  padding: 0.35rem 0 0.4rem;
  border: 0;
  border-bottom: 3px solid var(--ink);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font-family: var(--hand);
  font-weight: 400;
  font-size: clamp(1.375rem, 4vw, 2rem);
  line-height: 1.3;
  -webkit-appearance: none;
  appearance: none;
}

.ask input::placeholder {
  color: #767676; /* 4.5:1 on paper */
}

.ask input::-webkit-search-cancel-button {
  -webkit-appearance: none;
}

.ask input:focus {
  outline: none;
  border-bottom-color: var(--pen);
}

.ask input:focus-visible {
  outline: none;
  box-shadow: 0 3px 0 0 var(--pen);
}

.ask button {
  flex: none;
  padding: 0.55rem 1.1rem 0.6rem;
  border: 3px solid var(--ink);
  /* Uneven corners, as if inked by hand. */
  border-radius: 14px 6px 12px 5px / 6px 12px 5px 14px;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--hand);
  font-weight: 800;
  font-size: 1.125rem;
  cursor: pointer;
}

.ask button:hover {
  background: var(--ink);
  color: var(--paper);
}

/* ----------------------------------------------------- status, examples */

.status {
  min-height: 1.5em;
  margin: 0 0 1rem;
  font-family: var(--hand);
  font-size: 1.125rem;
}

.status:empty {
  min-height: 0;
  margin: 0;
}

.status[data-tone="problem"] {
  padding: 0.75rem 1rem;
  border: 2px solid var(--ink);
  border-radius: 14px 6px 12px 5px / 6px 12px 5px 14px;
}

.examples h2 {
  margin: 0 0 0.5rem;
  font-family: var(--hand);
  font-weight: 600;
  font-size: 1.125rem;
  color: var(--pencil);
}

.examples ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.examples li {
  border-top: 1px solid var(--rule);
}

.examples li:last-child {
  border-bottom: 1px solid var(--rule);
}

.examples a {
  display: block;
  padding: 0.7rem 0;
  font-family: var(--hand);
  font-size: 1.125rem;
  text-decoration: none;
}

.examples a:hover {
  text-decoration: underline;
}

[hidden] {
  display: none !important;
}

.results[aria-busy="true"] {
  opacity: 0.45;
}

/* -------------------------------------------------------------- results */

.results ol {
  list-style: none;
  margin: 0;
  padding: 0;
}

.comic {
  border-top: 2px solid var(--ink);
}

.comic:last-child {
  border-bottom: 2px solid var(--ink);
}

.comic-link {
  display: block;
  padding: 1.5rem 0 1.25rem;
  color: inherit;
  text-decoration: none;
}

.comic-title {
  margin: 0;
  font-family: var(--hand);
  font-weight: 600;
  font-size: 1.5rem;
  line-height: 1.25;
}

.comic-num {
  margin-right: 0.15em;
  color: var(--pencil);
  font-weight: 400;
}

.comic-name {
  /* The highlighter: only the best match gets it (see .comic:first-child). */
  padding: 0 0.15em;
  margin: 0 -0.15em;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

.comic:first-child .comic-name {
  background: linear-gradient(transparent 38%, var(--highlighter) 38%, var(--highlighter) 92%, transparent 92%);
}

.comic-link:hover .comic-name,
.comic-link:focus-visible .comic-name {
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 0.18em;
}

.comic-date {
  display: block;
  margin-top: 0.15rem;
  color: var(--pencil);
  font-size: 0.875rem;
}

.comic-img {
  display: block;
  max-width: 100%;
  max-height: 26rem;
  height: auto;
  margin: 1rem 0 0;
}

.comic-alt {
  margin: 0.9rem 0 0;
  max-width: 38rem;
  color: var(--pencil);
  font-style: italic;
}

.comic-explain {
  display: inline-block;
  margin-bottom: 1.25rem;
  font-size: 0.875rem;
}

/* ------------------------------------------------------------- API docs */

.doc {
  margin-top: clamp(2rem, 7vw, 4rem);
}

.doc h1 {
  margin: 0 0 1rem;
  font-family: var(--hand);
  font-weight: 600;
  font-size: clamp(2rem, 6.5vw, 3.25rem);
  line-height: 1.1;
}

.doc h2 {
  margin: 2.5rem 0 0.75rem;
  font-family: var(--hand);
  font-weight: 600;
  font-size: 1.5rem;
}

.doc p,
.doc li,
.doc dd {
  max-width: 38rem;
}

.doc code {
  font-family: "Atkinson Hyperlegible Mono", ui-monospace, monospace;
  font-size: 0.9em;
}

.doc pre {
  overflow-x: auto;
  margin: 1rem 0;
  padding: 1rem;
  border: 2px solid var(--ink);
  border-radius: 14px 6px 12px 5px / 6px 12px 5px 14px;
  line-height: 1.45;
}

.doc dt {
  margin-top: 0.75rem;
  font-weight: 600;
}

.doc dd {
  margin: 0.25rem 0 0;
}

/* --------------------------------------------------------------- footer */

.colophon {
  margin-top: 4rem;
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
  color: var(--pencil);
  font-size: 0.875rem;
}

.colophon p {
  margin: 0 0 0.5rem;
  max-width: 38rem;
}

@media (min-width: 40rem) {
  .comic-link {
    padding-top: 1.75rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
  }
}
