/* Desire DB. Shared styles: tokens, type, masthead, code, the ad, the marker, the redaction bar. */

/* ---------- Fonts ---------- */
@font-face {
  font-family: "Big Shoulders Display";
  src: url("/fonts/big-shoulders-display.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: "Schibsted Grotesk";
  src: url("/fonts/schibsted-grotesk.woff2") format("woff2");
  font-weight: 400 900;
  font-display: swap;
}
@font-face {
  font-family: "Martian Mono";
  src: url("/fonts/martian-mono.woff2") format("woff2");
  font-weight: 100 800;
  font-stretch: 75% 112.5%;
  font-display: swap;
}
/* Fallback faces with the metrics of the real ones, so text does not move when a font arrives.
   The numbers come from site/tools/font-metrics.html. Each rule claims every weight, so the
   browser does not make up a bold. */
@font-face {
  font-family: "Big Shoulders Fallback";
  src: local("Impact"), local("Haettenschweiler"), local("Arial Narrow Bold");
  font-weight: 100 900;
  size-adjust: 95.6%;
  ascent-override: 103%;
  descent-override: 22.3%;
  line-gap-override: 0%;
}
@font-face {
  font-family: "Schibsted Fallback";
  src: local("Arial"), local("Helvetica Neue"), local("Helvetica");
  font-weight: 400 599;
  size-adjust: 103.2%;
  ascent-override: 94.6%;
  descent-override: 25%;
  line-gap-override: 0%;
}
@font-face {
  font-family: "Schibsted Fallback";
  src: local("Arial Bold"), local("Helvetica Neue Bold"), local("Helvetica Bold");
  font-weight: 600 900;
  size-adjust: 101.8%;
  ascent-override: 95.9%;
  descent-override: 25.3%;
  line-gap-override: 0%;
}
@font-face {
  font-family: "Martian Fallback";
  src: local("Courier New"), local("Courier");
  font-weight: 100 800;
  size-adjust: 108.3%;
  ascent-override: 92.3%;
  descent-override: 18.5%;
  line-gap-override: 0%;
}

/* ---------- Tokens ---------- */
:root {
  --paper: #f3f0e7;
  --paper-deep: #e9e5d8;
  --ink: #15140f;
  --ink-soft: #4d4a41;
  --rule: rgb(21 20 15 / 0.24);
  --rule-faint: rgb(21 20 15 / 0.12);
  --marker: #ff4a1c;
  --sealed: #0e4b4f;

  --display: "Big Shoulders Display", "Big Shoulders Fallback", Impact, sans-serif;
  --text: "Schibsted Grotesk", "Schibsted Fallback", Arial, sans-serif;
  --mono: "Martian Mono", "Martian Fallback", "Courier New", monospace;

  --gutter: clamp(1rem, 2.4vw, 2.25rem);
  --page: 1720px;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

/* ---------- Base ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: 1.5rem;
}
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--text);
  font-size: 1.0625rem;
  line-height: 1.5;
  font-kerning: normal;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1,
h2,
h3,
h4,
p,
ul,
ol,
dl,
dd,
figure,
pre {
  margin: 0;
}
ul,
ol {
  padding: 0;
  list-style: none;
}
a {
  color: inherit;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}
a:hover {
  text-decoration-thickness: 2px;
}
button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}
:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 3px;
}
::selection {
  background: var(--marker);
  color: var(--ink);
}
[hidden] {
  display: none !important;
}
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.skip {
  position: absolute;
  left: var(--gutter);
  top: -4rem;
  z-index: 10;
  padding: 0.5rem 0.9rem;
  background: var(--ink);
  color: var(--paper);
}
.skip:focus {
  top: 0.5rem;
}

.page {
  max-width: var(--page);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

/* ---------- Display type ---------- */
.display {
  font-family: var(--display);
  font-weight: 900;
  text-transform: uppercase;
  line-height: 0.9;
  letter-spacing: 0.002em;
  text-wrap: balance;
}
code,
kbd,
samp,
.mono {
  font-family: var(--mono);
  font-stretch: 87.5%;
  font-size: 0.8em;
  font-feature-settings: "zero" 0;
}
p code,
li code,
td code,
dd code {
  padding: 0.08em 0.3em;
  background: var(--paper-deep);
  overflow-wrap: anywhere;
}

/* ---------- Masthead ---------- */
.masthead {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem 2rem;
  flex-wrap: wrap;
  padding-block: 1.1rem 0.7rem;
  border-bottom: 4px solid var(--ink);
}
.nameplate {
  font-family: var(--display);
  font-weight: 900;
  font-size: 2.35rem;
  line-height: 0.85;
  text-transform: uppercase;
  text-decoration: none;
  letter-spacing: 0.005em;
}
.masthead nav ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.4rem;
  font-size: 0.95rem;
  font-weight: 500;
}
.masthead nav a {
  text-decoration: none;
  padding-block: 0.2rem;
  display: inline-block;
}
.masthead nav a:hover,
.masthead nav a[aria-current="page"] {
  text-decoration: underline;
  text-decoration-thickness: 2px;
}
.dateline {
  display: flex;
  flex-wrap: wrap;
  gap: 0.1rem 0;
  padding-block: 0.4rem;
  border-bottom: 1px solid var(--ink);
  font-size: 0.82rem;
  color: var(--ink-soft);
}
.dateline > * + * {
  margin-left: 0.8rem;
  padding-left: 0.8rem;
  border-left: 1px solid var(--rule);
}

@media (max-width: 640px) {
  .masthead {
    align-items: center;
    padding-block: 0.8rem 0.55rem;
  }
  .nameplate {
    font-size: 2rem;
  }
  .masthead nav ul {
    gap: 0.25rem 1.1rem;
  }
  /* The links into this page go. The page itself is the way down it. */
  .masthead nav li:has(a[href^="#"]):not(:has(a[href="#start"])) {
    display: none;
  }
  .dateline > :nth-child(n + 3) {
    display: none;
  }
}

/* ---------- Buttons ---------- */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 2.9rem;
  padding: 0.55rem 1.15rem;
  border: 2px solid var(--ink);
  border-radius: 0;
  background: transparent;
  font-weight: 650;
  font-size: 1rem;
  line-height: 1.1;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.12s, color 0.12s;
}
.button:hover {
  background: var(--ink);
  color: var(--paper);
}
.button:active {
  transform: translateY(1px);
}
.button.primary {
  background: var(--marker);
}
.button.primary:hover {
  background: var(--ink);
}
.button[disabled] {
  opacity: 0.55;
  cursor: progress;
}

/* ---------- Code blocks ---------- */
/* The button has a column of its own, so a long line scrolls beside it and never under it. */
.code {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  background: var(--paper-deep);
  border-left: 4px solid var(--ink);
}
.code pre {
  margin: 0;
  padding: 0.95rem 0.6rem 0.95rem 1rem;
  overflow-x: auto;
  font-family: var(--mono);
  font-stretch: 87.5%;
  font-size: 0.78rem;
  line-height: 1.65;
  tab-size: 2;
}
.code pre code {
  font-size: inherit;
}
.code.wrap pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.copy {
  margin: 0.5rem 0.5rem 0.5rem 0;
  min-width: 3.9rem;
  padding: 0.3rem 0.55rem;
  border: 1px solid var(--ink);
  border-radius: 0;
  background: var(--paper);
  font-family: var(--text);
  font-size: 0.76rem;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
}
.copy:hover,
.copy[data-state="copied"] {
  background: var(--ink);
  color: var(--paper);
}
.prompt {
  color: var(--ink-soft);
  user-select: none;
}
/* On a phone the button goes above the text, and the text gets the whole width. */
@media (max-width: 640px) {
  .code {
    grid-template-columns: minmax(0, 1fr);
  }
  .code pre {
    padding: 0.2rem 0.9rem 0.9rem;
  }
  .copy {
    order: -1;
    justify-self: end;
    margin: 0.5rem 0.5rem 0.3rem;
  }
}

/* ---------- Notes ---------- */
.example-note {
  display: inline-block;
  padding: 0.05rem 0.45rem;
  border: 1px dashed var(--ink);
  font-size: 0.76rem;
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
}
.live-note {
  font-size: 0.8rem;
  color: var(--ink-soft);
}
.live-note::before {
  content: "";
  display: inline-block;
  width: 0.5em;
  height: 0.5em;
  margin-right: 0.45em;
  border-radius: 50%;
  background: var(--marker);
  vertical-align: 0.08em;
}

/* ---------- The ad: one desire, set as a classified ---------- */
.ads {
  columns: var(--ad-columns, 3);
  column-gap: 0;
  column-rule: 1px solid var(--rule);
}
.ad-group {
  break-inside: avoid-column;
}
.kind-bar {
  break-after: avoid;
  margin: 0;
  padding: 0.22rem 0.55rem 0.16rem;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.02rem;
  line-height: 1.1;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
}
.kind-bar span {
  font-weight: 600;
  opacity: 0.8;
}
.ad {
  position: relative;
  break-inside: avoid;
  padding: 0.5rem 0.6rem 0.55rem;
  border-bottom: 1px solid var(--rule);
  font-size: 0.855rem;
  line-height: 1.34;
  hyphens: auto;
}
.ad a.ad-text {
  text-decoration: none;
  display: block;
}
.ad a.ad-text:hover .ad-lead,
.ad a.ad-text:focus-visible .ad-lead {
  text-decoration: underline;
  text-decoration-thickness: 2px;
}
.ad-side {
  font-family: var(--display);
  font-weight: 800;
  font-size: 0.95em;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-right: 0.4em;
  padding: 0 0.28em;
  background: var(--ink);
  color: var(--paper);
}
.ad-lead {
  font-weight: 750;
}
.ad-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0 0.7em;
  margin-top: 0.3rem;
  font-family: var(--mono);
  font-stretch: 75%;
  font-size: 0.66rem;
  line-height: 1.5;
  color: var(--ink-soft);
  hyphens: none;
}
.ad-meta .sealed-flag {
  color: var(--sealed);
  font-weight: 600;
}
.ad-meta .sealed-flag::before {
  content: "";
  display: inline-block;
  width: 1.5em;
  height: 0.62em;
  margin-right: 0.4em;
  background: var(--sealed);
  vertical-align: -0.02em;
}
.ad-meta .example-flag {
  font-style: italic;
}
.ad-why {
  margin-top: 0.25rem;
  font-size: 0.74rem;
  color: var(--ink-soft);
  hyphens: none;
}
.ad.is-new {
  animation: ad-arrive 1.6s var(--ease-out);
}
@keyframes ad-arrive {
  from {
    background: rgb(255 74 28 / 0.28);
  }
  to {
    background: transparent;
  }
}

/* ---------- A record as rows of field and value ---------- */
.fields {
  margin: 0;
}
.field-row {
  display: grid;
  grid-template-columns: 8.2rem minmax(0, 1fr);
  gap: 0 1rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--rule);
  transition: opacity 0.35s, transform 0.35s var(--ease-out);
}
.field-row.is-waiting {
  opacity: 0;
  transform: translateY(6px);
}
.field-row dt {
  font-family: var(--mono);
  font-stretch: 87.5%;
  font-size: 0.72rem;
  line-height: 1.9;
  color: var(--ink-soft);
}
.field-row dd {
  font-size: 0.98rem;
  min-width: 0;
}
.field-row[data-filled] dt {
  color: var(--ink);
  font-weight: 600;
}
@media (max-width: 640px) {
  .field-row {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ---------- The marker ---------- */
.marked {
  position: relative;
}
.marker-stroke {
  position: absolute;
  overflow: visible;
  pointer-events: none;
  z-index: 2;
  mix-blend-mode: multiply;
}
.marker-stroke path {
  fill: none;
  stroke: var(--marker);
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- The redaction bar ---------- */
.redact {
  position: relative;
  display: inline-block;
  padding: 0 0.3em;
  font-weight: 600;
}
.redact::after {
  content: "";
  position: absolute;
  inset: -0.05em 0;
  background: var(--sealed);
  transform-origin: right center;
  transition: transform 0.7s var(--ease-out);
}
.redact.is-open::after {
  transform: scaleX(0);
}
.redact.is-open {
  box-shadow: inset 0 -2px 0 var(--sealed);
}
.redact > span {
  visibility: hidden;
}
.redact.is-open > span {
  visibility: visible;
  transition: visibility 0s 0.15s;
}

/* ---------- Footer ---------- */
.footer {
  margin-top: 4.5rem;
  padding-block: 1.6rem 3rem;
  border-top: 4px solid var(--ink);
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 1.5rem var(--gutter);
  font-size: 0.92rem;
}
.footer > div:first-child {
  grid-column: span 5;
}
.footer > div {
  grid-column: span 3;
}
.footer > div:last-child {
  grid-column: span 4;
}
.footer h2 {
  font-family: var(--text);
  font-size: 0.92rem;
  font-weight: 700;
  margin-bottom: 0.45rem;
}
.footer li {
  padding-block: 0.12rem;
}
.footer .nameplate {
  font-size: 1.9rem;
  display: inline-block;
  margin-bottom: 0.6rem;
}
.footer p {
  max-width: 34rem;
  color: var(--ink-soft);
}
@media (max-width: 760px) {
  .footer > div,
  .footer > div:first-child,
  .footer > div:last-child {
    grid-column: 1 / -1;
  }
}

/* ---------- Motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
