/* lila: "paper, ink and one green", inside the Subtle Path frame (shared.css).
   Colours are lila's own (its design Foundations); the e-paper panel stays light in both themes. */

@font-face {
  font-family: Newsreader;
  src: url("./fonts/newsreader.woff2") format("woff2");
  font-weight: 400 600;
  font-display: swap;
}

:root {
  --paper: #fbfaf6;
  --surface: #fffdf8;
  --ink: #1d1d1b;
  --slate: #6b665c;
  --rule: #e2ddd0;
  --route: #2f5d50;
  --route-hover: #244a3f;
  --on-route: #fff;
  --shoal: #f3f0e7;
  --bezel: #2b2a27;
  --panel: #f1f0eb;
  --mark: #2f5d50;
  --display: Newsreader, Georgia, serif;
  --gutter: 2.5rem;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    --paper: #1e1d1b;
    --surface: #2a2926;
    --ink: #eceae3;
    --slate: #a9a396;
    --rule: #3a3833;
    --route: #6fae98;
    --route-hover: #8ec3b0;
    --on-route: #10221c;
    --shoal: #262522;
    --bezel: #0f0f0e;
  }
}

:root:where([data-theme="dark"]) {
  --paper: #1e1d1b;
  --surface: #2a2926;
  --ink: #eceae3;
  --slate: #a9a396;
  --rule: #3a3833;
  --route: #6fae98;
  --route-hover: #8ec3b0;
  --on-route: #10221c;
  --shoal: #262522;
  --bezel: #0f0f0e;
}

body {
  line-height: 1.6;
}

.mast,
main {
  max-width: 1240px;
  margin-inline: auto;
}

main > section {
  margin-inline: var(--gutter);
  padding-block: clamp(3.5rem, 8vw, 6rem);
  border-top: 1px solid var(--rule);
}

main > .hero {
  border-top: 0;
}

h1,
h2,
h3 {
  font-family: var(--display);
  font-weight: 500;
  letter-spacing: -0.015em;
}

img {
  max-width: 100%;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.5rem;
  margin-top: 2rem;
}

.note {
  margin: 1rem 0 0;
  font-size: 0.9rem;
  color: var(--slate);
}

/* The black mark sits on its own paper, in both themes */
.wordmark img,
.download-card img {
  display: block;
  border-radius: 25%;
  background: #fbfaf6;
  box-shadow: inset 0 0 0 1px #1d1d1b1f;
}

/* Hero: the copy, and the page itself */

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 29rem);
  gap: clamp(2.5rem, 6vw, 5.5rem);
  align-items: center;
  padding-block: clamp(3rem, 6vw, 5rem) clamp(3.5rem, 8vw, 6rem);
}

.wordmark {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0 0 2rem;
  font-size: 1.6rem;
  font-weight: 650;
  letter-spacing: -0.015em;
}

.wordmark img {
  width: 52px;
  height: 52px;
  padding: 4px;
}

.hero h1 {
  max-width: 10.5em;
  margin: 0;
  font-size: clamp(2.75rem, 5.4vw, 4.75rem);
  line-height: 1.02;
  text-wrap: balance;
}

.hero .lede {
  max-width: 33em;
  margin: 1.75rem 0 0;
  font-size: 1.1rem;
  line-height: 1.65;
  color: var(--slate);
  text-wrap: pretty;
}

.namesake {
  font-style: italic;
}

/* The viewer */

.viewer {
  margin: 0;
  min-width: 0;
}

.viewer-stage {
  display: grid;
  justify-items: center;
  gap: 1.5rem;
  padding: 2.25rem 1.25rem 1.5rem;
  border: 1px solid var(--rule);
  border-radius: 16px;
  background: var(--shoal);
}

.reader {
  --w: 264px;
  padding: 12px;
  border-radius: 18px;
  background: var(--bezel);
  box-shadow: inset 0 0 0 1px #ffffff14, 0 22px 40px -24px #1d1d1b99;
}

.viewer[data-device="x4"] .reader {
  --w: 240px;
}

.screen {
  position: relative;
  isolation: isolate;
  width: var(--w);
  max-width: 100%;
  border-radius: 2px;
  background: var(--panel);
}

/* The renderer draws black on white; multiply turns the white into the panel's grey */
.screen img {
  display: block;
  width: 100%;
  height: auto;
  mix-blend-mode: multiply;
}

.turn-zone {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 50%;
  padding: 0;
  background: transparent;
}

.turn-zone--back {
  left: 0;
  cursor: w-resize;
}

.turn-zone--next {
  right: 0;
  cursor: e-resize;
}

.viewer-controls {
  display: grid;
  justify-items: center;
  gap: 1rem;
  width: 100%;
}

.viewer-controls[hidden] {
  display: none;
}

.turn {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.turn button {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--rule);
  border-radius: 50%;
  background: var(--paper);
  color: var(--ink);
}

.turn button:hover:not(:disabled) {
  border-color: var(--slate);
}

.turn svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.where {
  min-width: 11.5em;
  margin: 0;
  font-size: 0.9rem;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.choices {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem;
}

.seg {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--paper);
}

.seg button {
  padding: 0.3rem 0.8rem;
  border-radius: 999px;
  background: transparent;
  color: var(--slate);
  font-size: 0.85rem;
  font-weight: 550;
}

.seg button:hover {
  color: var(--ink);
}

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

.viewer figcaption {
  max-width: 29rem;
  margin-top: 1rem;
  font-size: 0.875rem;
  line-height: 1.55;
  color: var(--slate);
}

.viewer .spec {
  display: block;
  color: var(--ink);
  font-weight: 600;
}

/* Section copy */

.section-copy {
  max-width: 40rem;
}

.section-copy h2 {
  margin: 0;
  font-size: clamp(2rem, 3.6vw, 3rem);
  line-height: 1.08;
  text-wrap: balance;
}

.section-copy p {
  margin: 1rem 0 0;
  font-size: 1.05rem;
  text-wrap: pretty;
}

/* The type, up close: four lines of the first page, magnified until the pixels show.
   Coordinates are the X3's own pixels in /lila/pages/x3/m-1.png (rows 298–447). */

.specimen-figure {
  margin: 2.75rem 0 0;
}

.specimen {
  position: relative;
  width: min(100%, 1056px);
  aspect-ratio: 528 / 150;
  border-radius: 6px;
  background-color: var(--panel);
  background-image: url("/lila/pages/x3/m-1.png");
  background-blend-mode: multiply;
  background-repeat: no-repeat;
  background-size: 100% auto;
  background-position: 0 calc(298 / (792 - 150) * 100%);
  image-rendering: pixelated;
}

.specimen .mark,
.specimen-notes li::before {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--mark);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1;
}

.specimen .mark {
  position: absolute;
  translate: -50% -50%;
}

/* 1: in the indent; 2: between the lines above "first"; 3: in the right margin */
.mark--1 { left: calc(34 / 528 * 100%); top: calc(17 / 150 * 100%); }
.mark--2 { left: calc(370 / 528 * 100%); top: calc(36 / 150 * 100%); }
.mark--3 { left: calc(518 / 528 * 100%); top: calc(132 / 150 * 100%); }

/* the indent, from the margin (x 20) to "However" (x 49), in the gap below the first line */
.measure-indent {
  position: absolute;
  left: calc(20 / 528 * 100%);
  width: calc(29 / 528 * 100%);
  top: calc(33 / 150 * 100%);
  height: calc(4 / 150 * 100%);
  border: 1.5px solid var(--mark);
  border-top: 0;
}

/* where every line ends: the right edge of the measure */
.measure-edge {
  position: absolute;
  left: calc(508 / 528 * 100%);
  top: 4%;
  bottom: 4%;
  border-left: 1px dashed var(--mark);
}

.glyph-box {
  position: absolute;
  top: calc(var(--y) / 150 * 100%);
  left: calc(var(--x) / 528 * 100%);
  width: calc(14 / 528 * 100%);
  height: calc(25 / 150 * 100%);
  border: 1.5px dashed var(--mark);
  border-radius: 3px;
}

.glyph-box--first { --x: 348; --y: 40; } /* ﬁ at x 350–360, rows 341–360 */
.glyph-box--fixed { --x: 393; --y: 78; } /* ﬁ at x 395–405, rows 379–398 */

.specimen-pan {
  overflow-x: auto;
  overscroll-behavior-x: contain;
}

.pan-hint {
  display: none;
  margin: 0.6rem 0 0;
  font-size: 0.85rem;
  color: var(--slate);
}

.specimen-notes {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem 2rem;
  margin: 1.75rem 0 0;
  padding: 0;
  list-style: none;
  counter-reset: note;
  font-size: 0.95rem;
  color: var(--slate);
}

.specimen-notes li {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 0.75rem;
  align-items: start;
  counter-increment: note;
}

.specimen-notes li::before {
  content: counter(note);
  margin-top: 0.1rem;
}

/* Around the page */

.screens {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 2.5rem 1.5rem;
  margin: 2.75rem 0 0;
  padding: 0;
  list-style: none;
}

.screens li {
  display: grid;
  justify-items: center;
  align-content: start;
  gap: 1rem;
  text-align: center;
}

.reader--small {
  width: min(100%, 228px);
  padding: 9px;
  border-radius: 14px;
}

.reader--small .screen {
  width: 100%;
}

.screens p {
  max-width: 15em;
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--slate);
}

/* Home and the page: the copy beside two larger screens */

.shelf {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 38rem);
  gap: 2.75rem clamp(2.5rem, 6vw, 5.5rem);
  align-items: center;
}

.screens--pair {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 0;
}

.screens--pair .reader--small {
  width: min(100%, 282px);
  padding: 11px;
  border-radius: 16px;
}

.screens--pair p {
  text-wrap: balance;
}

/* How it works: a sequence, so numbered, joined by one line */

.steps {
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 2rem;
  margin: 2.75rem 0 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
}

.steps::before {
  content: "";
  position: absolute;
  top: 15px;
  left: 15px;
  right: 0;
  border-top: 1.5px solid var(--rule);
}

.steps li {
  position: relative;
  padding-top: 3rem;
  counter-increment: step;
}

.steps li::before {
  content: counter(step);
  position: absolute;
  top: 0;
  left: 0;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1.5px solid var(--route);
  border-radius: 50%;
  background: var(--paper);
  color: var(--route);
  font-size: 0.85rem;
  font-weight: 650;
}

.steps h3 {
  margin: 0 0 0.5rem;
  font-size: 1.45rem;
  line-height: 1.2;
}

.steps p {
  margin: 0;
  font-size: 0.975rem;
  color: var(--slate);
}

/* The readers */

.table-wrap {
  margin-top: 2.25rem;
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 38rem;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

th,
td {
  padding: 0.85rem 1.25rem 0.85rem 0;
  border-bottom: 1px solid var(--rule);
  text-align: left;
  vertical-align: top;
}

thead th {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--slate);
}

tbody th {
  font-weight: 600;
}

/* Download */

.download {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2.5rem 4rem;
  align-items: center;
}

.download .section-copy p + p {
  color: var(--slate);
}

.download-card {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 1.5rem 1.75rem;
  border: 1px solid var(--rule);
  border-radius: 16px;
  background: var(--surface);
}

.download-card img {
  width: 64px;
  height: 64px;
  padding: 6px;
}

.download-card .note {
  margin-top: 0.6rem;
}

.foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem 2rem;
  width: min(calc(100% - 2 * var(--gutter)), calc(1240px - 2 * var(--gutter)));
  margin-inline: auto;
  padding-block: 2rem 3rem;
  border-top: 1px solid var(--rule);
  font-size: 0.875rem;
  color: var(--slate);
}

@media (max-width: 56rem) {
  .hero,
  .shelf {
    grid-template-columns: minmax(0, 1fr);
  }

  .viewer {
    width: min(100%, 29rem);
  }
}

@media (max-width: 64rem) {
  .steps {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    row-gap: 2.5rem;
  }

  .steps::before {
    display: none;
  }

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

@media (max-width: 52rem) {
  .screens {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

@media (max-width: 850px) {
  :root {
    --gutter: 1.5rem;
  }
}

@media (max-width: 36rem) {
  .steps {
    grid-template-columns: minmax(0, 1fr);
  }

  /* keep the pixels visible: pan the lines rather than shrink them */
  .specimen {
    width: 740px;
    max-width: none;
  }

  .pan-hint {
    display: block;
  }

  /* the home's small type needs the width: one screen at a time */
  .screens--pair {
    grid-template-columns: minmax(0, 1fr);
  }

  .nav-wide {
    display: none;
  }

  .download-card {
    flex-direction: column;
    align-items: flex-start;
  }
}
