/* Landing page for legacy-printer-airprint-relay. One stylesheet, no JavaScript, no web fonts.
 *
 * The idea: the dark bar at the top is the printer's output slot, and the hero is one printed sheet
 * feeding out of it. Everything below sits on the desk. Type is Palatino where the device has it
 * (one of the typefaces built into PostScript printers), with the system monospace for commands.
 * Cyan is used only for "signal": links, the wires in the diagram and the focus ring.
 * SPDX-License-Identifier: MIT
 */

:root {
  color-scheme: light dark;

  --serif: "Palatino Linotype", Palatino, Palladio, "URW Palladio L", P052, "Book Antiqua", Georgia, serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  /* The desk (page background) and what sits on it */
  --desk: #e8edf3;
  --raised: #f6f8fb;
  --text: #0f172a;
  --muted: #475569;
  --rule: #c3ccd8;
  --rule-strong: #94a3b8;
  --link: #155e75;
  --signal: #0891b2;
  --focus: #155e75;

  /* The printer's slot (top bar) and the terminal block: dark in both colour schemes */
  --slot: #0f172a;
  --slot-text: #e2e8f0;
  --slot-signal: #22d3ee;
  --terminal: #0f172a;
  --terminal-text: #e2e8f0;

  /* The printed sheet: always ink on paper */
  --paper: #ffffff;
  --ink: #0f172a;
  --ink-muted: #475569;

  --column: 46rem;
  --gutter: clamp(1.25rem, 6vw, 3rem);
}

@media (prefers-color-scheme: dark) {
  :root {
    --desk: #0f172a;
    --raised: #162036;
    --text: #e2e8f0;
    --muted: #94a3b8;
    --rule: #2a3750;
    --rule-strong: #475569;
    --link: #22d3ee;
    --signal: #22d3ee;
    --focus: #22d3ee;
    --slot: #020617;
    --terminal: #020617;
    --paper: #f8fafc;
  }
}

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

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

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

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

body {
  margin: 0;
  background: var(--desk);
  color: var(--text);
  font-family: var(--serif);
  font-size: 1.125rem;
  line-height: 1.6;
  text-rendering: optimizeLegibility;
}

h1,
h2,
p,
dl,
dd,
ol,
ul,
pre {
  margin: 0;
}

h1,
h2 {
  text-wrap: balance;
}

h2 {
  font-size: clamp(1.625rem, 1.25rem + 1.6vw, 2.125rem);
  line-height: 1.15;
  letter-spacing: -0.01em;
}

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

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

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

code,
pre {
  font-family: var(--mono);
}

code {
  font-size: 0.86em;
}

.skip {
  position: absolute;
  top: -4rem;
  left: 0.75rem;
  z-index: 10;
  padding: 0.5rem 0.75rem;
  border-radius: 3px;
  background: var(--paper);
  color: var(--ink);
}

.skip:focus {
  top: 0.5rem;
}

/* ---------- The slot: top bar ---------- */

.slot {
  --focus: #22d3ee;

  position: relative;
  z-index: 2;
  background: var(--slot);
  color: var(--slot-text);
}

/* The mouth of the slot: the sheet below appears to come out of it. */
.slot::after {
  content: "";
  display: block;
  width: min(calc(var(--column) + 2.5rem), 100%);
  height: 0.5rem;
  margin-inline: auto;
  border-radius: 0.25rem 0.25rem 0 0;
  background: rgb(0 0 0 / 60%);
}

.slot-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  width: min(var(--column), 100% - 1.5rem);
  margin-inline: auto;
  padding: 0.75rem var(--gutter) 0.65rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  color: inherit;
  font-size: 1.0625rem;
  font-weight: 700;
  line-height: 1.2;
  text-decoration: none;
}

.mark {
  flex: none;
}

.mark-body {
  stroke: var(--slot-text);
}

.mark-signal {
  stroke: var(--slot-signal);
}

.mark-dot {
  fill: var(--slot-signal);
}

.slot-links {
  display: flex;
  gap: 1.25rem;
  font-size: 1rem;
}

.slot-links a {
  color: inherit;
  text-decoration: none;
}

.slot-links a:hover {
  text-decoration: underline;
}

/* Narrow screens: the name needs the room, and the first button on the sheet goes to GitHub. */
@media (max-width: 34rem) {
  .slot-links {
    display: none;
  }
}

/* ---------- The sheet: hero ---------- */

.hero {
  position: relative;
  overflow: hidden; /* clips the sheet while it feeds out */
  padding-bottom: 3rem; /* room for the sheet's shadow */
}

/* The shadow the printer casts on the sheet and the desk. */
.hero::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  z-index: 1;
  height: 1.1rem;
  background: linear-gradient(rgb(2 6 23 / 34%), rgb(2 6 23 / 0%));
  pointer-events: none;
}

.sheet {
  --link: #155e75;
  --focus: #155e75;

  width: min(var(--column), 100% - 1.5rem);
  margin-inline: auto;
  padding: clamp(2.5rem, 8vw, 4rem) var(--gutter) clamp(2.25rem, 7vw, 3.5rem);
  border-radius: 0 0 3px 3px;
  background: var(--paper);
  color: var(--ink);
  box-shadow:
    0 1px 0 rgb(15 23 42 / 14%),
    0 28px 36px -28px rgb(2 6 23 / 55%);
  animation: feed 850ms cubic-bezier(0.25, 0.6, 0.3, 1) both;
}

@keyframes feed {
  from {
    transform: translateY(-62%);
  }

  to {
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sheet {
    animation: none;
  }
}

.sheet > * + * {
  margin-top: 1.5rem;
}

.sheet h1 {
  font-size: clamp(2.125rem, 1.3rem + 4.4vw, 3.5rem);
  font-weight: 700;
  line-height: 1.07;
  letter-spacing: -0.015em;
}

.lede {
  font-size: 1.25rem;
  line-height: 1.5;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  padding-top: 0.25rem;
}

.button {
  display: inline-block;
  padding: 0.8rem 1.15rem;
  border: 2px solid var(--ink);
  border-radius: 3px;
  font-size: 1.0625rem;
  font-weight: 700;
  line-height: 1.2;
  text-decoration: none;
}

.button-primary {
  background: var(--ink);
  color: var(--paper);
}

.button-primary:hover {
  border-color: #1e3a5f;
  background: #1e3a5f;
}

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

.button-secondary:hover {
  background: rgb(15 23 42 / 7%);
}

.runs-on {
  color: var(--ink-muted);
  font-size: 1rem;
}

/* ---------- Sections on the desk ---------- */

.band {
  width: min(var(--column), 100% - 1.5rem);
  margin: clamp(3.25rem, 9vw, 5.25rem) auto 0;
  padding-inline: var(--gutter);
}

.hero + .band {
  margin-top: clamp(1.25rem, 4vw, 2.5rem);
}

.band > * + * {
  margin-top: 1.1rem;
}

/* Label and value, like a printer's configuration page. */
.band > .spec {
  margin-top: 1.75rem;
  border-top: 1px solid var(--rule);
}

.spec > div {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.3rem;
  padding: 1.05rem 0 1.15rem;
  border-bottom: 1px solid var(--rule);
}

.spec dt {
  font-weight: 700;
  line-height: 1.35;
}

.spec dd > * + * {
  margin-top: 0.6rem;
}

.spec .means {
  color: var(--muted);
}

.spec ul {
  padding-left: 1.1rem;
}

.spec li + li {
  margin-top: 0.15rem;
}

@media (min-width: 44rem) {
  .spec > div {
    grid-template-columns: 13.5rem 1fr;
    gap: 2rem;
  }
}

/* The path of a print job. Vertical on phones, left to right on wider screens. */
.band > .path {
  display: grid;
  margin: 2rem calc(var(--gutter) * -1);
  padding: 0;
  list-style: none;
}

.node {
  padding: 0.95rem 1.05rem 1rem;
  border: 1px solid var(--rule-strong);
  border-radius: 4px;
  background: var(--raised);
}

.node svg {
  display: block;
  margin-bottom: 0.55rem;
  color: var(--muted);
}

.node strong {
  display: block;
  line-height: 1.25;
}

.node > span {
  display: block;
  margin-top: 0.25rem;
  color: var(--muted);
  font-size: 0.9375rem;
  line-height: 1.35;
}

.node ul {
  margin-top: 0.8rem;
  padding: 0.7rem 0 0;
  border-top: 1px solid var(--rule);
  font-size: 0.9375rem;
  line-height: 1.35;
  list-style: none;
}

.node li + li {
  margin-top: 0.35rem;
}

.hop {
  position: relative;
  margin-left: 1.75rem;
  padding: 0.85rem 0 1.15rem 1rem;
  border-left: 2px solid var(--signal);
  color: var(--muted);
  font-size: 0.9375rem;
  font-style: italic;
  line-height: 1.3;
}

/* Arrowhead */
.hop::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: -6px;
  border: 5px solid transparent;
  border-top: 8px solid var(--signal);
  border-bottom: 0;
}

/* Wide screens: the diagram runs left to right and is wider than the text column, centred on it. */
@media (min-width: 60rem) {
  .band > .path {
    grid-template-columns: 11.5rem minmax(0, 1fr) 16.5rem minmax(0, 1fr) 11.5rem;
    align-items: center;
    width: min(60rem, 100vw - 4rem);
    margin-inline: calc(50% - min(30rem, 50vw - 2rem));
  }

  .hop {
    height: 2px;
    margin: 0 0.3rem;
    padding: 0;
    border-left: 0;
    background: var(--signal);
  }

  .hop span {
    position: absolute;
    right: 0.5rem;
    bottom: 0.55rem;
    left: 0;
    text-align: center;
  }

  .hop::after {
    right: -1px;
    bottom: -4px;
    left: auto;
    border: 5px solid transparent;
    border-right: 0;
    border-left: 8px solid var(--signal);
  }
}

/* Commands */
.band > .terminal {
  margin: 1.5rem calc(var(--gutter) * -1);
  padding: 1.2rem var(--gutter);
  overflow-x: auto;
  border-radius: 4px;
  background: var(--terminal);
  color: var(--terminal-text);
  font-size: 0.875rem;
  line-height: 1.75;
}

.band > .terminal:focus-visible {
  outline-offset: 2px;
}

.terminal code {
  font-size: inherit;
}

/* Questions */
.band > .faq {
  margin-top: 1.75rem;
  border-top: 1px solid var(--rule);
}

.faq details {
  border-bottom: 1px solid var(--rule);
}

.faq summary {
  position: relative;
  padding: 0.95rem 2.25rem 0.95rem 0;
  font-weight: 700;
  line-height: 1.35;
  list-style: none;
  cursor: pointer;
}

.faq summary::-webkit-details-marker {
  display: none;
}

.faq summary::after {
  content: "+";
  position: absolute;
  top: 0.8rem;
  right: 0.35rem;
  color: var(--muted);
  font-family: var(--mono);
  font-weight: 400;
}

.faq details[open] summary::after {
  content: "\2212";
}

.faq details p {
  padding-bottom: 1.15rem;
}

/* ---------- Foot ---------- */

.foot {
  width: min(var(--column), 100% - 1.5rem);
  margin: clamp(4rem, 10vw, 6rem) auto 0;
  padding: 2rem var(--gutter) 3.5rem;
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-size: 1rem;
}

.foot > * + * {
  margin-top: 1.25rem;
}

.foot ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.5rem;
  padding: 0;
  list-style: none;
}

.fine-print {
  font-size: 0.9375rem;
  line-height: 1.55;
}

/* ---------- Paper ---------- */

@media print {
  :root {
    --desk: #fff;
    --raised: #fff;
    --text: #000;
    --muted: #333;
    --rule: #999;
    --rule-strong: #666;
    --link: #000;
    --signal: #000;
    --paper: #fff;
    --ink: #000;
    --ink-muted: #333;
    --slot: #fff;
    --slot-text: #000;
    --slot-signal: #000;
    --terminal: #fff;
    --terminal-text: #000;
  }

  .skip,
  .slot::after,
  .hero::before,
  .slot-links,
  .actions {
    display: none;
  }

  .hero {
    overflow: visible;
    padding-bottom: 0;
  }

  .sheet {
    box-shadow: none;
    animation: none;
  }

  .band > .terminal {
    overflow: visible;
    border: 1px solid #999;
  }

  .terminal pre {
    white-space: pre-wrap;
  }
}
