/* Shared design system. Every colour comes from the tokens on :root.
   Tools add only layout of their own, in their page's <style> block. */

/* Fonts ------------------------------------------------------------------ */

@font-face {
  font-family: "Atkinson Hyperlegible";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/assets/fonts/atkinson-hyperlegible-latin-400-normal.woff2") format("woff2");
}

@font-face {
  font-family: "Atkinson Hyperlegible";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/assets/fonts/atkinson-hyperlegible-latin-700-normal.woff2") format("woff2");
}

/* Tokens ----------------------------------------------------------------- */

:root {
  color-scheme: light dark;

  --bg: #EEF2F7;
  --surface: #FFFFFF;
  --surface-2: #E2E8F1;
  --ink: #15233F;
  --muted: #52607A;
  --line: #CBD4E1;
  --edge: #15233F;
  --accent: #2340D8;
  --mark: #FFD84D;
  --mark-ink: #15233F;
  --underline: #FFD84D;
  --danger: #B42318;

  --font: "Atkinson Hyperlegible", "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --step--1: 0.875rem;
  --step-0: 1.0625rem;
  --step-1: 1.3rem;
  --step-2: 1.7rem;
  --step-3: clamp(2.1rem, 1.3rem + 3.4vw, 3.4rem);
  --step-tool: clamp(1.9rem, 1.4rem + 2vw, 2.6rem);

  --r-1: 6px;
  --r-2: 10px;
  --r-3: 16px;

  --content: min(100% - 2.5rem, 68rem);
  --measure: 68ch;
  --offset: 5px;
  --target: 44px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0E1525;
    --surface: #161F33;
    --surface-2: #1F2A42;
    --ink: #E6EBF5;
    --muted: #9BA7BF;
    --line: #2C3853;
    --edge: #5B6C93;
    --accent: #9DB0FF;
    --mark: #FFD84D;
    --mark-ink: #15233F;
    --underline: #7A6519;
    --danger: #FF8A80;
  }
}

/* Base ------------------------------------------------------------------- */

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

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

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: var(--step-0);
  line-height: 1.55;
}

main {
  flex: 1 0 auto;
}

h1,
h2,
h3 {
  line-height: 1.15;
  letter-spacing: -0.025em;
  margin: 0 0 0.5em;
}

h1 {
  font-size: var(--step-2);
}

h2 {
  font-size: var(--step-1);
}

h3 {
  font-size: var(--step-0);
}

p {
  margin: 0 0 1em;
}

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

a:hover {
  text-decoration-thickness: 2px;
}

img,
svg {
  display: block;
  max-width: 100%;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

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

::selection {
  background: var(--mark);
  color: var(--mark-ink);
}

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

kbd {
  font-family: var(--mono);
}

.wrap {
  width: var(--content);
  margin-inline: auto;
}

.sr-only {
  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: 0;
  z-index: 10;
  padding: 0.6rem 1rem;
  background: var(--ink);
  color: var(--bg);
  border-radius: 0 0 var(--r-1) var(--r-1);
  font-weight: 700;
  transform: translateY(-110%);
}

.skip-link:focus {
  transform: none;
}

[hidden] {
  display: none !important;
}

/* Header and footer ------------------------------------------------------ */

.site-header {
  padding-block: 0.75rem;
}

.site-header .wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.25rem 1.5rem;
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  min-height: var(--target);
  color: var(--ink);
  font-weight: 700;
  font-size: var(--step-1);
  letter-spacing: -0.02em;
  text-decoration: none;
}

.wordmark .logo {
  width: 30px;
  height: 30px;
  flex: none;
}

.logo-tile {
  fill: var(--ink);
}

.logo-short {
  fill: var(--bg);
}

.logo-long {
  fill: var(--mark);
}

.site-nav ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0 1.25rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-nav a {
  display: inline-flex;
  align-items: center;
  min-height: var(--target);
  color: var(--ink);
}

.site-footer {
  margin-top: 4rem;
  padding-block: 2rem 2.5rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: var(--step--1);
}

.site-footer .wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem 3rem;
}

.footer-col {
  flex: 1 1 13rem;
}

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

.footer-col li a,
.footer-links a {
  display: inline-flex;
  align-items: center;
  min-height: var(--target);
}

.site-footer .wordmark {
  font-size: var(--step-0);
  min-height: 0;
  margin-bottom: 0.4rem;
}

.site-footer .wordmark .logo {
  width: 24px;
  height: 24px;
}

.site-footer p {
  margin: 0 0 0.4rem;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0 1.25rem;
}

.site-footer a {
  color: var(--muted);
}

.site-footer a:hover {
  color: var(--ink);
}

/* Home ------------------------------------------------------------------- */

.hub-hero {
  padding-block: 2.5rem 1.75rem;
}

.hub-hero h1 {
  font-size: var(--step-3);
  max-width: 18ch;
  margin-bottom: 0.35em;
}

.lede {
  max-width: var(--measure);
  color: var(--muted);
  font-size: var(--step-1);
  line-height: 1.45;
}

.search {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  max-width: 42rem;
  margin-top: 1.5rem;
  padding-inline: 1rem;
  background: var(--surface);
  border: 3px solid var(--edge);
  border-radius: var(--r-2);
  box-shadow: var(--offset) var(--offset) 0 var(--edge);
}

.search:focus-within {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

.search-icon {
  flex: none;
  width: 22px;
  height: 22px;
  color: var(--muted);
}

.search input {
  flex: 1;
  min-width: 0;
  min-height: 3.6rem;
  padding: 0;
  border: 0;
  background: none;
  font-size: var(--step-1);
  outline: none;
}

.search input::placeholder {
  color: var(--muted);
  opacity: 1;
}

.search-key {
  flex: none;
  padding: 0.05em 0.5em;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: var(--r-1);
  color: var(--muted);
  font-size: var(--step--1);
}

.search:focus-within .search-key {
  display: none;
}

@media (hover: none), (pointer: coarse) {
  .search-key {
    display: none;
  }
}

.recent {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 1rem;
  margin-top: 1.25rem;
  color: var(--muted);
  font-size: var(--step--1);
}

.recent-links {
  display: contents;
}

.recent a {
  display: inline-flex;
  align-items: center;
  min-height: var(--target);
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 2rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: var(--target);
  padding: 0.3rem 0.9rem;
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: var(--r-2);
  font-weight: 700;
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease;
}

.chip:hover {
  border-color: var(--edge);
}

.chip .n {
  color: var(--muted);
  font-weight: 400;
  font-variant-numeric: tabular-nums;
}

.chip[aria-pressed="true"] {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--bg);
}

.chip[aria-pressed="true"] .n {
  color: var(--bg);
}

.group {
  margin-bottom: 2.25rem;
  scroll-margin-top: 1rem;
}

.group-title {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--ink);
  font-size: var(--step-1);
}

.group-title .count {
  color: var(--muted);
  font-size: var(--step--1);
  font-weight: 400;
  letter-spacing: 0;
}

.tool-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 24rem), 1fr));
  column-gap: 2rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tool-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border-bottom: 1px solid var(--line);
}

.tool-link {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: flex-start;
  gap: 0.9rem;
  padding-block: 0.9rem;
  color: var(--ink);
  text-decoration: none;
}

.tool-glyph {
  flex: none;
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  font-size: 1.35rem;
  line-height: 1;
}

.tool-text {
  min-width: 0;
}

.tool-name {
  font-weight: 700;
}

.tool-link:hover .tool-name {
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 0.15em;
}

.tool-desc {
  display: block;
  color: var(--muted);
  font-size: var(--step--1);
  line-height: 1.45;
}

.badge {
  display: inline-block;
  margin-left: 0.5rem;
  padding: 0 0.4rem;
  background: var(--mark);
  color: var(--mark-ink);
  border-radius: var(--r-1);
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1.5;
  vertical-align: 0.1em;
}

.pin {
  flex: none;
  display: grid;
  place-items: center;
  width: var(--target);
  height: var(--target);
  padding: 0;
  background: none;
  border: 0;
  border-radius: 50%;
  color: var(--muted);
  cursor: pointer;
  transition: background-color 120ms ease;
}

.pin:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.star {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linejoin: round;
}

[aria-pressed="true"] > .star {
  fill: var(--mark);
  stroke: var(--mark-ink);
}

.pin[aria-pressed="true"] {
  color: var(--ink);
}

.empty {
  max-width: var(--measure);
  padding: 1.5rem 0;
  color: var(--muted);
  font-size: var(--step-1);
}

/* Tool pages ------------------------------------------------------------- */

.crumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 0.5rem;
  padding-top: 1rem;
  color: var(--muted);
  font-size: var(--step--1);
}

.crumbs a {
  display: inline-flex;
  align-items: center;
  min-height: var(--target);
  color: var(--muted);
}

.crumbs a:hover {
  color: var(--ink);
}

.intro {
  padding-block: 0.5rem 1.75rem;
}

.intro h1 {
  font-size: var(--step-tool);
  margin-bottom: 0.3em;
}

.intro .lede {
  margin-bottom: 1rem;
}

.draft-note {
  max-width: var(--measure);
  padding: 0.6rem 0.9rem;
  border: 2px dashed var(--line);
  border-radius: var(--r-1);
  color: var(--muted);
  font-size: var(--step--1);
}

.panel {
  padding: clamp(1rem, 0.6rem + 2vw, 1.75rem);
  background: var(--surface);
  border: 2px solid var(--edge);
  border-radius: var(--r-3);
  box-shadow: var(--offset) var(--offset) 0 var(--edge);
  margin-right: var(--offset);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
  margin-bottom: 1rem;
}

.label {
  font-weight: 700;
}

.hint {
  color: var(--muted);
  font-size: var(--step--1);
  margin: 0;
}

.input {
  width: 100%;
  min-height: 48px;
  padding: 0.55rem 0.8rem;
  background: var(--bg);
  border: 2px solid var(--line);
  border-radius: var(--r-1);
  font-size: var(--step-0);
  line-height: 1.4;
}

.input:focus {
  border-color: var(--accent);
}

.input:focus-visible {
  outline-offset: 1px;
}

textarea.input {
  min-height: 12rem;
  resize: vertical;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  min-height: var(--target);
  cursor: pointer;
}

.check input {
  flex: none;
  width: 1.25rem;
  height: 1.25rem;
  margin: 0;
  accent-color: var(--ink);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: var(--target);
  padding: 0.4rem 1rem;
  background: var(--surface);
  border: 2px solid var(--ink);
  border-radius: var(--r-1);
  color: var(--ink);
  font-weight: 700;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 120ms ease;
}

.btn:hover {
  background: var(--surface-2);
}

.btn-primary {
  background: var(--ink);
  color: var(--bg);
}

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

.btn-quiet {
  background: none;
  border-color: transparent;
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

.btn-quiet:hover {
  background: var(--surface-2);
}

.btn-icon {
  width: var(--target);
  padding: 0;
  flex: none;
}

.btn-icon svg {
  width: 20px;
  height: 20px;
}

.pin-btn {
  font-size: var(--step--1);
}

.pin-btn .star {
  width: 18px;
  height: 18px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 1.25rem;
}

.output {
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 2px dashed var(--line);
}

.empty-state {
  margin: 0;
  color: var(--muted);
}

.result-big {
  margin: 0 0 0.25rem;
  font-size: clamp(2.4rem, 1.7rem + 3vw, 3.6rem);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.result-big span {
  text-decoration: underline;
  text-decoration-color: var(--underline);
  text-decoration-thickness: 0.2em;
  text-underline-offset: 0.06em;
  text-decoration-skip-ink: none;
}

.result-sub {
  margin: 0 0 1.25rem;
  color: var(--muted);
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(8rem, 1fr));
  gap: 1rem;
  margin: 0;
}

.stats > div {
  padding-left: 0.75rem;
  border-left: 3px solid var(--line);
}

.stats dt {
  color: var(--muted);
  font-size: var(--step--1);
}

.stats dd {
  margin: 0;
  font-size: var(--step-1);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.3;
}

.notes,
.sources,
.related {
  margin-top: 3rem;
}

.notes {
  max-width: var(--measure);
}

.notes h2 {
  margin-top: 1.75rem;
}

.notes h2:first-child {
  margin-top: 0;
}

.sources {
  max-width: var(--measure);
  font-size: var(--step--1);
  color: var(--muted);
}

.sources h2 {
  color: var(--ink);
}

.sources ul {
  margin: 0;
  padding-left: 1.2rem;
}

.sources li {
  margin-bottom: 0.5rem;
}

.sources .source {
  color: var(--ink);
}

.related h2 {
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--ink);
}

.prose {
  max-width: var(--measure);
}

.prose h2 {
  margin-top: 2rem;
}

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

.prose li {
  margin-bottom: 0.4rem;
}

.page-head {
  padding-top: 2.5rem;
}

.page-head h1 {
  font-size: var(--step-tool);
}

.affiliate-note {
  color: var(--muted);
  font-size: var(--step--1);
}

.error {
  color: var(--danger);
  font-weight: 700;
}

/* Ads -------------------------------------------------------------------- */

.ad-slot {
  display: grid;
  place-items: center;
  min-height: 250px;
  margin-block: 2.5rem;
  overflow: hidden;
}

.ad-slot ins {
  display: block;
  width: 100%;
}

.ad-slot--placeholder {
  border: 2px dashed var(--line);
  border-radius: var(--r-2);
  color: var(--muted);
  font-size: var(--step--1);
}

/* Motion ----------------------------------------------------------------- */

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