/* Styles for index.html. After changing this file, bump ?v= on its <link> there. */

:root {
  --bg: #f5f5f0;
  --paper: #ffffff;
  --ink: #17191c;
  --muted: #565c65;
  --line: #d9d9cf;
  --grid: rgba(23, 25, 28, 0.05);
  --accent: #1d5bc6;
  --accent-ink: #ffffff;
  --mark: #ff6a13;
  --shadow: 0 1px 2px rgba(20, 24, 30, 0.06), 0 16px 40px -20px rgba(20, 24, 30, 0.3);
  --pad: clamp(16px, 4vw, 40px);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #101214;
    --paper: #171a1e;
    --ink: #e8eaed;
    --muted: #9aa1ab;
    --line: #2b3036;
    --grid: rgba(255, 255, 255, 0.035);
    --accent: #80b0ff;
    --accent-ink: #0b1322;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 16px 40px -20px rgba(0, 0, 0, 0.8);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #101214;
  --paper: #171a1e;
  --ink: #e8eaed;
  --muted: #9aa1ab;
  --line: #2b3036;
  --grid: rgba(255, 255, 255, 0.035);
  --accent: #80b0ff;
  --accent-ink: #0b1322;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 16px 40px -20px rgba(0, 0, 0, 0.8);
  color-scheme: dark;
}

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

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

body {
  margin: 0;
  background-color: var(--bg);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 24px 24px;
  color: var(--ink);
  font: 400 17px/1.6 "Newsreader", Georgia, "Times New Roman", serif;
  /* Newsreader's x-height is small; match Plex Mono's so the two read at the same size. */
  font-size-adjust: 0.516;
}

a {
  color: var(--accent);
  text-underline-offset: 3px;
}

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

h1,
h2,
h3,
p,
figure {
  margin: 0;
}

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

.mono {
  font-family: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
}

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

/* Top bar */
.top {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px 24px;
  padding-top: 18px;
  padding-bottom: 16px;
}

.top .name {
  color: var(--ink);
  font-weight: 500;
  text-decoration: none;
}

.top .name:hover {
  color: var(--accent);
}

.top nav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 20px;
  font-size: 14px;
}

.top nav a {
  color: var(--muted);
  text-decoration: none;
}

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

.rule {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 0;
}

/* Hero: text, the live picture, and its controls */
.hero {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  grid-template-areas:
    "intro fig"
    "controls fig";
  grid-template-rows: auto 1fr;
  column-gap: clamp(28px, 4vw, 56px);
  padding-top: clamp(28px, 5vw, 56px);
  padding-bottom: clamp(40px, 6vw, 72px);
}

.intro {
  grid-area: intro;
}

.specimen {
  grid-area: fig;
}

.controls {
  grid-area: controls;
}

.eyebrow {
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.04em;
  margin-bottom: 10px;
}

.eyebrow::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 8px;
  background: var(--mark);
  border-radius: 50%;
  vertical-align: 1px;
}

h1 {
  font-size: clamp(2.4rem, 5.2vw, 3.8rem);
  font-size-adjust: none;
  font-weight: 500;
  line-height: 1.04;
  letter-spacing: -0.015em;
}

.lede {
  margin-top: 16px;
  color: var(--muted);
  font-size: clamp(1.05rem, 1.6vw, 1.2rem);
  max-width: 30em;
}

.frame {
  padding: 10px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: var(--shadow);
}

.stage {
  position: relative;
  width: fit-content;
  max-width: 100%;
  margin: 0 auto;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
  line-height: 0;
}

/* Any shape of picture: full column width, but never taller than the screen */
.stage img,
.stage canvas {
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: min(78vh, 720px);
}

.stage canvas {
  display: none;
  max-height: none; /* the script sizes the canvas to fit, in whole device pixels */
  cursor: ew-resize;
}

#photo {
  display: none;
}

.js #photo {
  display: block;
}

.js .stage.ready #photo {
  display: none;
}

.stage.ready canvas {
  display: block;
}

.wipe {
  display: none;
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 44px;
  margin-left: -22px;
  cursor: ew-resize;
}

.stage.ready .wipe {
  display: block;
}

.stage.ready.plain .wipe,
.stage.ready.plain .tag {
  display: none;
}

.wipe::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 21px;
  width: 2px;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25);
}

.knob {
  position: absolute;
  top: 50%;
  left: 50%;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: #fff;
  color: #17191c;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
  font: 500 15px/1 "IBM Plex Mono", monospace;
}

.wipe:focus-visible {
  outline: none;
}

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

.tag {
  display: none;
  position: absolute;
  top: 10px;
  padding: 6px 8px;
  border-radius: 4px;
  background: rgba(10, 12, 14, 0.68);
  color: #fff;
  font: 500 11px/1 "IBM Plex Mono", monospace;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  transition: opacity 0.15s;
}

.stage.ready .tag {
  display: block;
}

.tag.left {
  left: 10px;
}

.tag.right {
  right: 10px;
}

.tag.hidden {
  opacity: 0;
}

.specimen figcaption {
  margin-top: 12px;
  color: var(--muted);
  font-size: 14px;
}

.specimen figcaption .mono {
  color: var(--ink);
  margin-right: 6px;
}

.controls {
  margin-top: 32px;
  align-self: start;
}

.controls[hidden] {
  display: none;
}

.label {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.04em;
}

.ops {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.ops button {
  padding: 9px 4px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--paper);
  color: var(--ink);
  font: 500 13px/1.2 "IBM Plex Mono", monospace;
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s;
}

.ops button:hover {
  border-color: var(--accent);
}

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

.param {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) 5.5ch;
  gap: 12px;
  align-items: center;
  margin-top: 18px;
  font-size: 13px;
}

.param[hidden] {
  display: none;
}

.param label {
  color: var(--muted);
}

.param input {
  width: 100%;
  margin: 0;
  accent-color: var(--accent);
}

.param output {
  text-align: right;
}

.caption {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px dashed var(--line);
  font-size: 15px;
  min-height: 4.8em;
}

.caption a {
  white-space: nowrap;
}

/* Sections below the hero */
.section {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  column-gap: clamp(28px, 4vw, 56px);
  padding-top: 28px;
  padding-bottom: 48px;
}

.section h2 {
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--muted);
  padding-top: 6px;
}

.about p {
  font-size: clamp(1.1rem, 1.8vw, 1.3rem);
  line-height: 1.55;
}

.card {
  padding: clamp(20px, 3vw, 32px);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: var(--shadow);
}

.card h3 {
  font-size: clamp(1.5rem, 2.6vw, 2rem);
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: -0.015em;
  margin-bottom: 12px;
}

.card h3 a {
  color: inherit;
  text-decoration: none;
}

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

.card .tie {
  margin-top: 12px;
  color: var(--muted);
  font-size: 14px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 22px;
}

.btn {
  display: inline-block;
  padding: 9px 16px;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--ink);
  font: 500 14px/1.3 "IBM Plex Mono", monospace;
  text-decoration: none;
}

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

/* The three links under the intro fit on one row beside the picture */
.intro .actions {
  gap: 8px;
}

.intro .btn {
  padding: 9px 12px;
}

.btn-sm {
  padding: 4px 10px;
  font-size: 13px;
  letter-spacing: 0;
}

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

.btn.primary:hover {
  color: var(--accent-ink);
  filter: brightness(1.08);
}

footer {
  padding-top: 18px;
  padding-bottom: 48px;
  color: var(--muted);
  font-size: 14px;
}

footer p+p {
  margin-top: 4px;
}

@media (max-width: 860px) {
  .hero {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "intro" "fig" "controls";
    grid-template-rows: auto;
  }

  .specimen {
    margin-top: 28px;
  }

  .controls {
    margin-top: 24px;
  }

  .section {
    grid-template-columns: minmax(0, 1fr);
  }

  .section h2 {
    margin-bottom: 12px;
  }

}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}
