/* adamtibbetts.com -- shared styles.
   Priorities, in order: legibility, contrast, then everything else.
   Colour is only ever used to separate a section or flag a warning. */

:root {
  color-scheme: light dark;

  --page:      #f4f6f4;
  --surface:   #ffffff;
  --ink:       #191d1a;  /* 15.4:1 on --surface */
  --ink-muted: #4c554e;  /*  8.0:1 on --surface */
  --rule:      #d5dbd6;
  --rule-soft: #e6eae7;

  --green:      #1f6b41;  /*  6.4:1 on --surface */
  --green-wash: #eaf3ed;
  --green-edge: #bcd8c6;

  --warn-ink:  #7a4a05;   /*  6.4:1 on --warn-wash */
  --warn-wash: #fcf3e2;
  --warn-edge: #e6cd9a;

  --shadow: 0 1px 2px rgb(0 0 0 / .06), 0 3px 10px rgb(0 0 0 / .05);
  --radius: 12px;
}

@media (prefers-color-scheme: dark) {
  :root {
    /* Deliberately not a low-contrast dark theme. Body text sits above
       13:1 so it stays readable on a phone in a bright room. */
    --page:      #14181a;
    --surface:   #1e2426;
    --ink:       #edf1ee;  /* 14.2:1 on --surface */
    --ink-muted: #b6c0b9;  /*  8.4:1 on --surface */
    --rule:      #39423d;
    --rule-soft: #2b3336;

    --green:      #7fd3a0;  /* 9.6:1 on --surface */
    --green-wash: #1c2f24;
    --green-edge: #315c42;

    --warn-ink:  #f2c86e;   /* 8.9:1 on --warn-wash */
    --warn-wash: #2b2418;
    --warn-edge: #5c4a25;

    --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 3px 10px rgb(0 0 0 / .25);
  }
}

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

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

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  font-size: 1.0625rem;          /* 17px -- a notch up from the usual 16 */
  line-height: 1.65;
  text-rendering: optimizeLegibility;
  /* Long unbroken strings -- hostnames, "Audiobookshelf" -- must wrap
     rather than force the page to scroll sideways on a narrow screen. */
  overflow-wrap: break-word;
}

@media (min-width: 40rem) {
  body { font-size: 1.125rem; }  /* 18px on anything desktop-sized */
}

.wrap {
  max-width: 54rem;
  margin: 0 auto;
  padding: 2.5rem 1.25rem 4rem;
}

@media (max-width: 30rem) {
  .wrap { padding: 1.75rem 1rem 3rem; }
}

/* ---------- type ---------- */

h1, h2, h3 { line-height: 1.25; text-wrap: balance; }

h1 { font-size: clamp(1.5rem, 6vw, 1.9rem); margin: 0 0 .4rem; letter-spacing: -.015em; }
h2 { font-size: 1.35rem; margin: 0 0 .75rem; }
h3 { font-size: 1.1rem;  margin: 1.75rem 0 .5rem; }

p { margin: 0 0 1rem; }
p:last-child { margin-bottom: 0; }

a {
  color: var(--green);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}
a:hover { text-decoration-thickness: 2px; }

:focus-visible {
  outline: 3px solid var(--green);
  outline-offset: 3px;
  border-radius: 4px;
}

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

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

.masthead {
  padding-bottom: 1.5rem;
  margin-bottom: 2.5rem;
  border-bottom: 2px solid var(--rule);
}

/* ---------- section headings ---------- */

/* The one structural use of colour: a green rule marks the start of a
   top-level section so the three parts of the page stay distinct. */
.section { margin-top: 3rem; }
main > .section:first-child { margin-top: 0; }

.section > h2 {
  display: flex;
  align-items: baseline;
  gap: .75rem;
  padding-bottom: .5rem;
  border-bottom: 2px solid var(--green-edge);
}

.section > h2 .count {
  font-size: .8rem;
  font-weight: 400;
  color: var(--ink-muted);
  margin-left: auto;
}

/* ---------- service cards ---------- */

/* Card count will grow over time, so the column count is never hardcoded.
   The min() is what lets this collapse to one column properly: once the
   grid has less room than 20rem, the track floor becomes 100% and a single
   column is the only thing that fits. That reacts to the space actually
   available, not to a viewport guess -- which matters because Android
   display-size and iOS Display Zoom shrink the CSS viewport, and because
   a larger root font size scales the 20rem up and collapses it sooner.
   grid-auto-rows + height:100% keep every card the same size. */
.services {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 20rem), 1fr));
  grid-auto-rows: 1fr;
  gap: 1rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.services li { display: flex; }

.card {
  flex: 1;
  height: 100%;
  display: flex;
  align-items: center;
  gap: 1.1rem;
  padding: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: inherit;
  text-decoration: none;
  transition: border-color .12s, transform .12s, box-shadow .12s;
}

.card:hover {
  border-color: var(--green);
  transform: translateY(-2px);
  box-shadow: 0 2px 4px rgb(0 0 0 / .07), 0 8px 20px rgb(0 0 0 / .08);
}

@media (prefers-reduced-motion: reduce) {
  .card, .card:hover { transition: none; transform: none; }
}

.card img {
  width: 64px;
  height: 64px;
  flex: none;
}

/* Flex children default to min-width:auto, which makes them refuse to
   shrink below their longest word -- that is what pushes a card wider
   than the screen when someone has text scaling turned up. */
.card > span { min-width: 0; }

/* Only at genuinely tiny viewports do the logo and text stop fitting side
   by side. A 360px phone still has room, so don't stack it. Set in em so
   this follows the user's browser font size, not just zoom. */
@media (max-width: 20em) {
  .card {
    flex-direction: column;
    align-items: flex-start;
    gap: .7rem;
    padding: 1.1rem;
  }
  .card img { width: 52px; height: 52px; }
}

/* What it does leads; the product name is demoted to a subtitle for the
   handful of people who care what they're actually looking at. */
.card .does {
  display: block;
  font-size: 1.2rem;
  font-weight: 650;
  letter-spacing: -.01em;
  line-height: 1.3;
}

.card .appname {
  display: block;
  font-size: .85rem;
  color: var(--ink-muted);
  margin-bottom: .4rem;
}

.card .what {
  display: block;
  font-size: .95rem;
  line-height: 1.45;
  color: var(--ink-muted);
}

/* ---------- the how-to call-out ---------- */

.helpbox {
  margin-top: 2.5rem;
  padding: 1.35rem 1.5rem;
  background: var(--green-wash);
  border: 1px solid var(--green-edge);
  border-left: 5px solid var(--green);
  border-radius: var(--radius);
}

.helpbox h2 { font-size: 1.15rem; margin: 0 0 .85rem; }

.helplinks {
  display: flex;
  flex-wrap: wrap;
  gap: .6rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.helplinks a {
  display: inline-block;
  max-width: 100%;
  padding: .5rem .9rem;
  background: var(--surface);
  border: 1px solid var(--green-edge);
  border-radius: 999px;
  font-size: .95rem;
  text-decoration: none;
  color: var(--green);
}

.helplinks a:hover {
  border-color: var(--green);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ---------- news ---------- */

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

.news li {
  padding: 1.4rem 0;
  border-bottom: 1px solid var(--rule-soft);
}
.news li:last-child { border-bottom: 0; padding-bottom: 0; }

.news time {
  display: block;
  font-size: .82rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: .02em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin-bottom: .2rem;
}

.news h3 { font-size: 1.1rem; margin: 0 0 .35rem; }
.news p  { font-size: .98rem; }

/* ---------- how-to pages ---------- */

.backlink {
  display: inline-block;
  margin-bottom: 1.5rem;
  font-size: .95rem;
}

.steps { margin: 0 0 1.5rem; padding-left: 1.4rem; }
.steps > li { margin-bottom: .9rem; padding-left: .25rem; }
.steps > li::marker { font-weight: 700; color: var(--green); }

.plain { margin: 0 0 1.5rem; padding-left: 1.4rem; }
.plain > li { margin-bottom: .5rem; }

.note, .warn {
  padding: .9rem 1.1rem;
  border-radius: 10px;
  margin: 1.5rem 0;
  font-size: .98rem;
}

.note {
  background: var(--green-wash);
  border: 1px solid var(--green-edge);
  border-left: 5px solid var(--green);
}

/* Amber, used only where something can actually go wrong. */
.warn {
  background: var(--warn-wash);
  color: var(--warn-ink);
  border: 1px solid var(--warn-edge);
  border-left: 5px solid var(--warn-ink);
}

.note strong, .warn strong { display: block; margin-bottom: .15rem; }
.warn a { color: inherit; }

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

.toc li {
  padding: 1.1rem 0;
  border-bottom: 1px solid var(--rule-soft);
}
.toc li:last-child { border-bottom: 0; }

.toc a { font-size: 1.1rem; font-weight: 600; }
.toc p { margin: .2rem 0 0; font-size: .95rem; color: var(--ink-muted); }

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .9em;
  padding: .1em .35em;
  background: var(--rule-soft);
  border-radius: 5px;
}

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

.foot {
  margin-top: 3.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--rule);
  font-size: .9rem;
  color: var(--ink-muted);
}
