/* LMGT — let me google that (lmgt.com) */

/*
 * Self-hosted fonts. These are byte-for-byte the files Google Fonts was serving
 * (Fraunces v38 + Inter v20, latin subset), so rendering is unchanged -- what
 * goes away is the round trip: a stylesheet request to fonts.googleapis.com that
 * has to finish before the browser even learns which font files it needs, plus a
 * second connection to fonts.gstatic.com to fetch them. Both are now same-origin
 * and preloaded from the document head.
 *
 * One file per family covers every weight in use, because both are variable
 * fonts. Only the latin subset is kept -- the page is English-only, and the
 * cyrillic/greek/vietnamese/latin-ext subsets were never being downloaded.
 *
 * Regenerate with scripts/fetch-lmgt-fonts.sh if the design ever needs another
 * weight or family; do not hand-edit the ranges.
 */
@font-face {
  font-family: 'Fraunces';
  font-style: normal;
  font-weight: 500 700;
  font-display: swap;
  src: url('../fonts/fraunces-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: 'Inter';
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url('../fonts/inter-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;
}

:root {
  --ground: #f7f1e8;
  --ground-elevated: #fffdf9;
  --ink: #1a1228;
  --ink-muted: #5c5368;
  --ink-faint: #8a8196;
  --accent: #5b2a86;
  --accent-hover: #4a216c;
  --accent-soft: #efe6f8;
  --accent-ring: rgba(91, 42, 134, 0.35);
  --line: #e4d9c8;
  --ok: #1f6b3a;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 12px 40px rgba(26, 18, 40, 0.08);
  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --max: 36rem;
  --space: clamp(1rem, 3vw, 1.75rem);

  /* The page is a fixed light design. Without this, a browser in dark mode
     restyles the native inputs, checkbox and scrollbars to dark and they stop
     matching the cream card they sit on. */
  color-scheme: light;
}

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

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

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.5;
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 50% -10%, #fff8ef 0%, transparent 55%),
    radial-gradient(800px 500px at 100% 20%, #f0e6fb 0%, transparent 50%),
    var(--ground);
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

a {
  color: var(--accent);
  text-underline-offset: 0.15em;
}

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

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

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: 1rem;
  top: -100px;
  z-index: 100;
  padding: 0.6rem 1rem;
  background: var(--ink);
  color: #fff;
  border-radius: 8px;
  text-decoration: none;
}

.skip-link:focus {
  top: 1rem;
}

.shell {
  width: min(100% - 2 * var(--space), var(--max));
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: clamp(1.5rem, 5vw, 3rem) 0 clamp(2rem, 6vw, 3.5rem);
}

.shell-doc {
  --max: 42rem;
}

.brand {
  text-align: center;
  margin-bottom: clamp(1.75rem, 5vw, 2.75rem);
}

.brand-compact {
  text-align: left;
  margin-bottom: 1.5rem;
}

.brand-kicker {
  margin: 0 0 0.75rem;
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.brand-kicker a {
  color: inherit;
  text-decoration: none;
}

.brand-kicker a:hover {
  color: var(--accent);
}

.wordmark {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(2.4rem, 9vw, 3.75rem);
  line-height: 0.95;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.wordmark-line {
  display: block;
}

.wordmark-accent {
  color: var(--accent);
  font-style: italic;
  font-weight: 500;
}

.tagline {
  margin: 1rem auto 0;
  max-width: 22rem;
  color: var(--ink-muted);
  font-size: 1rem;
  /* Evens out the ragged line break on the three-line mobile wrap. */
  text-wrap: balance;
}

.doc-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(2rem, 6vw, 2.75rem);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.stage {
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 1.25rem;
}

.search-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.search-field-wrap {
  position: relative;
}

.search-field {
  width: 100%;
  appearance: none;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  background: var(--ground-elevated);
  box-shadow: var(--shadow);
  padding: 1rem 1.15rem;
  font: inherit;
  font-size: 1.0625rem;
  color: var(--ink);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.search-field::placeholder {
  color: var(--ink-faint);
}

.search-field:hover {
  border-color: #d2c4ae;
}

.search-field:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--shadow), 0 0 0 4px var(--accent-ring);
}

body.is-playing .search-field {
  caret-color: transparent;
}

.actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.65rem;
}

@media (min-width: 420px) {
  .actions {
    grid-template-columns: 1fr 1fr;
  }
}

.btn {
  appearance: none;
  border: 1.5px solid transparent;
  border-radius: var(--radius-sm);
  font: inherit;
  font-weight: 600;
  font-size: 0.9375rem;
  line-height: 1.2;
  padding: 0.85rem 1.1rem;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.1s ease;
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  cursor: default;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--ground-elevated);
  border-color: var(--line);
  color: var(--ink);
}

.btn-secondary:hover {
  border-color: #c9b89e;
  background: #fff;
}

.btn-small {
  padding: 0.55rem 0.85rem;
  font-size: 0.875rem;
  border-radius: 8px;
}

.btn-ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--ink-muted);
}

.btn-ghost:hover {
  color: var(--ink);
  border-color: #c9b89e;
  background: var(--ground-elevated);
}

.btn.active,
.btn.is-active {
  box-shadow: 0 0 0 4px var(--accent-ring);
  border-color: var(--accent);
}

.btn-primary.active,
.btn-primary.is-active {
  background: var(--accent-hover);
}

.btn-skip {
  align-self: center;
  background: transparent;
  border-color: transparent;
  color: var(--ink-muted);
  font-weight: 500;
  font-size: 0.875rem;
  padding: 0.4rem 0.75rem;
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

.btn-skip:hover {
  color: var(--ink);
}

.instructions {
  margin: 0.25rem 0 0;
  padding: 0.95rem 1.15rem;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.9375rem;
  font-weight: 500;
  text-align: center;
  min-height: 3.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.share {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1rem;
  border-radius: var(--radius);
  background: var(--ground-elevated);
  border: 1.5px solid var(--line);
  box-shadow: var(--shadow);
  animation: share-in 0.2s ease-out;
}

@keyframes share-in {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.share[hidden],
.btn-skip[hidden],
.share-toast[hidden],
.pointer[hidden] {
  display: none !important;
}

.share-url {
  width: 100%;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  padding: 0.75rem 0.9rem;
  font: inherit;
  font-size: 0.875rem;
  color: var(--ink);
  background: #fff;
  text-align: center;
}

.share-url:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.share-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
}

.share-opts {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: center;
  gap: 0.6rem 1.75rem;
}

/*
 * Each option is a block so its note stays attached to its own label. With the
 * options as loose flex children instead, two labels sit on one row and two
 * notes on the next, and the reader has to infer the pairing by position.
 */
.share-opt {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  cursor: pointer;
  color: var(--ink-muted);
  font-size: 0.8125rem;
  font-weight: 500;
}

.switch input {
  width: 1rem;
  height: 1rem;
  margin: 0;
  cursor: pointer;
  accent-color: var(--accent);
}

.switch:hover .switch-label {
  color: var(--ink);
}

/*
 * Always its own line, never beside the label. Inline, the two read as one
 * run-on sentence ("Be nice about it Ends with …") because a flex gap is a weak
 * boundary between two similar-sized pieces of text. A separator character fixes
 * that at wide widths but becomes a stray leading bullet as soon as the note
 * wraps, which it does by ~390px -- and CSS cannot ask whether a flex item
 * wrapped. The column in .share-opt gives the same result at every width
 * instead of one that is only correct on one side of a guessed breakpoint.
 */
.switch-note {
  color: var(--ink-faint);
  font-size: 0.8125rem;
  text-align: center;
}

/* Mid-request. Nothing moves, so the only cue needed is that it is not clickable. */
.switch input:disabled {
  cursor: progress;
}

.switch input:disabled + .switch-label {
  opacity: 0.6;
}

.share-toast {
  margin: 0;
  text-align: center;
  color: var(--ok);
  font-size: 0.875rem;
  font-weight: 600;
}

.site-footer {
  margin-top: clamp(2.5rem, 8vw, 4rem);
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
  text-align: center;
  color: var(--ink-muted);
  font-size: 0.875rem;
}

.footer-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  justify-content: center;
  margin-bottom: 1rem;
}

.footer-nav a,
.linkish {
  color: var(--accent);
  font-weight: 500;
  text-decoration: none;
}

.footer-nav a:hover,
.linkish:hover {
  text-decoration: underline;
}

.linkish {
  appearance: none;
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  cursor: pointer;
}

/* The awards card. Points at the sibling domain: lmgt.org is the awards, not
   this joke.

   This used to be a third paragraph of centred, muted, 0.875rem footer prose,
   sat between the sponsor credit and the copyright line — identical in weight to
   both, so it read as boilerplate and got skipped. A card is the cheapest way to
   say "this is a different kind of sentence" without moving it off the page or
   giving it more words. */
.thanks {
  margin: 0 auto 1.5rem;
  max-width: 30rem;
  padding: 1.15rem 1.25rem 1.2rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--ground-elevated);
  /* Left-aligned inside a centred card: three short centred lines of body copy
     are harder to read than the same copy ragged-right, and the alignment marks
     it as content rather than more footer chrome. */
  text-align: left;
}

/* Mirrors .brand-kicker at the top of the page, which reads "lmgt.com" — but in
   --ink-muted rather than that rule's --ink-faint, which is 3.65:1 on the card
   and short of the 4.5:1 that 12px bold text needs. --ink-muted is 7.15:1 and
   still reads as quiet at this size. */
.thanks-kicker {
  margin: 0 0 0.4rem;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.thanks-title {
  margin: 0 0 0.5rem;
  font-family: var(--font-display);
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.25;
  color: var(--ink);
}

.thanks-body {
  margin: 0 0 0.9rem;
  font-size: 0.875rem;
  line-height: 1.6;
  color: var(--ink-muted);
  /* Keeps the last line off a single orphaned word; the copy ends on "3am." and
     landed there on its own. Ignored by browsers without it, which just wrap. */
  text-wrap: pretty;
}

.thanks-body strong {
  color: var(--ink);
  font-weight: 600;
}

.thanks-cta {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--accent);
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  /* Text this size is a 21px tap target, under the 24px WCAG 2.5.8 floor, and on
     a site sent person-to-person over chat most taps are thumbs. The padding
     buys the height and the negative margin puts the text back where the card's
     spacing wants it. */
  padding: 0.4rem 0;
  margin: -0.4rem 0;
}

.thanks-cta:hover {
  text-decoration: underline;
}

.thanks-arrow {
  transition: transform 0.15s ease;
}

.thanks-cta:hover .thanks-arrow {
  transform: translateX(2px);
}

/* The arrow nudge is decoration; drop it when less motion is asked for. */
@media (prefers-reduced-motion: reduce) {
  .thanks-arrow {
    transition: none;
  }

  .thanks-cta:hover .thanks-arrow {
    transform: none;
  }
}

.sponsor {
  margin: 0 auto 1.25rem;
  max-width: 28rem;
  line-height: 1.55;
}

.legal {
  margin: 0;
  font-size: 0.75rem;
  color: var(--ink-faint);
  line-height: 1.5;
}

/* Playback pointer */
.pointer {
  position: fixed;
  z-index: 50;
  width: 24px;
  height: 24px;
  margin: 0;
  pointer-events: none;
  filter: drop-shadow(0 2px 4px rgba(26, 18, 40, 0.35));
  transition: none;
}

body.is-playing {
  cursor: wait;
}

body.is-playing .actions .btn:not(.is-active) {
  opacity: 0.7;
}

/* Privacy / prose pages */
.prose {
  background: var(--ground-elevated);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(1.25rem, 4vw, 2rem);
}

.prose .lede {
  margin-top: 0;
  color: var(--ink-muted);
}

.prose h2 {
  margin: 1.75rem 0 0.6rem;
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 700;
}

.prose p,
.prose li {
  color: var(--ink-muted);
}

.prose ul {
  padding-left: 1.2rem;
}

.prose li + li {
  margin-top: 0.5rem;
}

.prose code {
  font-size: 0.875em;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}

.prose .back {
  margin: 2rem 0 0;
}

/* Modals (About / Privacy)
   Native <dialog>: Escape and focus trapping come free, ::backdrop gives the
   dim layer, and a click landing on the dialog element itself is a backdrop
   click (the card is a child), which is what closes it in js/lmgt.js. */
.modal {
  width: min(34rem, calc(100vw - 2rem));
  max-width: none;
  margin: auto;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  overflow: visible;
}

.modal::backdrop {
  background: rgba(26, 18, 40, 0.5);
}

.modal-card {
  position: relative;
  max-height: min(80vh, 42rem);
  overflow-y: auto;
  padding: clamp(1.35rem, 4vw, 1.9rem);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--ground-elevated);
  box-shadow: 0 24px 60px rgba(26, 18, 40, 0.28);
  text-align: left;
}

.modal-close {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  display: grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink-faint);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.modal-close:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.modal-title {
  margin: 0 2rem 0.85rem 0;
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.modal-body > :first-child {
  margin-top: 0;
}

.modal-body > :last-child {
  margin-bottom: 0;
}

/* The Privacy modal is filled with privacy.html's .prose children, so its
   typography is restated here without the card chrome .prose carries. */
.modal-body p,
.modal-body li {
  color: var(--ink-muted);
}

.modal-body h2 {
  margin: 1.5rem 0 0.5rem;
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--ink);
}

.modal-body ul {
  padding-left: 1.2rem;
}

.modal-body li + li {
  margin-top: 0.5rem;
}

.modal-body code {
  font-size: 0.875em;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}

.modal-aside {
  margin-top: 1.25rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--line);
  font-size: 0.8125rem;
}

.modal-loading {
  color: var(--ink-faint);
  font-style: italic;
}

.modal[open] {
  animation: modal-in 0.18s ease-out;
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

  .btn,
  .search-field,
  .modal-close {
    transition: none;
  }

  .btn:hover:not(:disabled) {
    transform: none;
  }

  .share,
  .modal[open] {
    animation: none;
  }
}
