/* pagework.dev. Every value here is explained in DESIGN.md. */

:root {
  color-scheme: light dark;

  /* colour roles: the app's tokens */
  --text: #1A1A1A;
  --text-muted: #595959;
  --surface: #FFFFFF;
  --chrome: #F2F2F2;
  --desk: #E6E6E6;
  --page: #FFFFFF;
  --border: #D0D0D0;
  --action: #1F5FA8;         /* links, the primary button, focus ring only */
  --action-hover: #174A84;
  --on-action: #FFFFFF;
  --sheet-shadow: 0 1px 2px rgb(0 0 0 / 0.14), 0 8px 24px rgb(0 0 0 / 0.12);

  /* type */
  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --size-small: 14px;
  --size-body: 17px;
  --size-h2: 20px;
  --size-h1: 24px;
  --line: 1.55;
  --measure: 65ch;

  /* density: reading tier, 4px base */
  --control-h: 44px;
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 24px;
  --s6: 32px;
  --s7: 48px;
  --s8: 64px;
  --gutter: 16px;
  --radius-control: 4px;

  --dur: 150ms;
}

@media (prefers-color-scheme: dark) {
  :root {
    --text: #E8E8E8;
    --text-muted: #ABABAB;
    --surface: #1C1C1C;
    --chrome: #262626;
    --desk: #2E2E2E;
    --page: #FFFFFF;
    --border: #444444;
    --action: #8DB8EC;
    --action-hover: #B3D0F3;
    --on-action: #141414;
    --sheet-shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 8px 24px rgb(0 0 0 / 0.35);
  }
}

@media (min-width: 600px) {
  :root { --gutter: 32px; }
}

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

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

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  color: var(--text);
  font: 400 var(--size-body) / var(--line) var(--font-ui);
}

main { flex: 1; width: 100%; }

h1, h2 { font-weight: 600; line-height: 1.25; margin: 0; }
h1 { font-size: var(--size-h1); }
h2 { font-size: var(--size-h2); }
p, ul { margin: 0; }

a {
  color: var(--action);
  text-underline-offset: 0.15em;
  transition: color var(--dur) ease-out, background-color var(--dur) ease-out;
}
a:hover { color: var(--action-hover); }
a:focus-visible {
  outline: 2px solid var(--action);
  outline-offset: 2px;
  border-radius: 2px;
}

.wrap {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 var(--gutter);
}

/* skip link: off-screen until focused */
.skip {
  position: absolute;
  left: var(--gutter);
  top: var(--s2);
  padding: var(--s2) var(--s3);
  background: var(--surface);
  transform: translateY(-200%);
}
.skip:focus-visible { transform: none; }

/* header and footer: the app's chrome */
.site-header, .site-footer { background: var(--chrome); }
.site-header { border-bottom: 1px solid var(--border); }
.site-footer {
  border-top: 1px solid var(--border);
  margin-top: var(--s8);
  font-size: var(--size-small);
  color: var(--text-muted);
}

.site-header .wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s2) var(--s5);
  min-height: 56px;
}
.site-name {
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
}
.site-name:hover { color: var(--text); }
.site-nav ul {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s1) var(--s5);
  padding: 0;
  list-style: none;
}
.site-nav a {
  display: inline-block;
  padding: var(--s2) 0;
}

.site-footer .wrap { padding-block: var(--s5) var(--s6); }
.site-footer p + p { margin-top: var(--s1); }
.site-footer .owner { color: var(--text); }

/* links that stand on their own line get a 24px+ target; links inside sentences don't need one */
.site-footer a, .standalone {
  display: inline-block;
  padding-block: var(--s1);
}

/* opening: sentence and button beside the page */
.opening {
  display: grid;
  gap: var(--s6);
  padding-top: var(--s7);
}
.opening-text > * + * { margin-top: var(--s4); }
.opening-text h1 { max-width: 22ch; }
.opening-text .terms { color: var(--text-muted); margin-top: var(--s3); }

.button {
  display: inline-flex;
  align-items: center;
  min-height: var(--control-h);
  padding: 0 var(--s5);
  border-radius: var(--radius-control);
  background: var(--action);
  color: var(--on-action);
  font-weight: 600;
  text-decoration: none;
}
.button:hover { background: var(--action-hover); color: var(--on-action); }

/* the desk, and the page lying on it */
.desk {
  margin: 0 calc(var(--gutter) * -1);
  padding: var(--s6) var(--gutter) var(--s5);
  background: var(--desk);
}
.sheet {
  display: block;
  width: 100%;
  max-width: 480px;
  height: auto;
  margin: 0 auto;
  background: var(--page);
  box-shadow: var(--sheet-shadow);
}
.desk figcaption {
  max-width: 480px;
  margin: var(--s4) auto 0;
  font-size: var(--size-small);
  color: var(--text-muted);
}

@media (min-width: 900px) {
  .opening {
    grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
    align-items: start;
    gap: var(--s7);
  }
  .opening-text { padding-top: var(--s7); }
  .desk { margin: 0; padding: var(--s7) var(--s7) var(--s5); }
}

/* reading column */
.section {
  max-width: var(--measure);
  margin-top: var(--s8);
}
.section h2 + * { margin-top: var(--s3); }
.section p + p, .section p + ul, .section ul + p { margin-top: var(--s4); }
.section ul { padding-left: 1.25em; }
.section li + li { margin-top: var(--s2); }

.prose { padding-top: var(--s7); max-width: var(--measure); }
.prose h1 + * { margin-top: var(--s5); }
.prose p + p, .prose h2 + p { margin-top: var(--s4); }
.prose h2 { margin-top: var(--s7); }
.prose .updated { margin-top: var(--s7); font-size: var(--size-small); color: var(--text-muted); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; }
}

@media (forced-colors: active) {
  .sheet { border: 1px solid CanvasText; }
  .button { border: 1px solid ButtonText; }
}
