/* origami website. Tokens and rules: docs/brand.md ("every line break is a
   fold"), colors from the Tokyo Night themes (Light by day, Night by night):
   valley blue for what origami adds, mountain red for what goes away, dashed
   creases as dividers, Tokyo Night syntax colors in code. */

:root {
  --paper: #d5d6db;
  --sheet: #e6e7ed;
  --ink: #343b58;
  --ink-soft: #565a6e;
  --ink-dim: #6c6e75;
  --valley: #34548a;
  --mountain: #8c4351;
  --crease: #a8aab6;
  --valley-wash: #d1d5e1;
  --mountain-wash: #dbd3da;
  --fold-shadow: rgba(52, 59, 88, 0.14);
  --outline: oklch(0 0 0 / 0.1);
  /* Syntax (Tokyo Night Light); comments lifted to AA contrast. */
  --syn-keyword: #5a4a78;
  --syn-string: #485e30;
  --syn-number: #965027;
  --syn-comment: #5f6272;
  --syn-rule: #0f4b6e;

  --sans: "Schibsted Grotesk", system-ui, sans-serif;
  --mono: "Martian Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  /* Scale 1.25 from 17px. */
  --t-sm: 0.8rem;
  --t-base: 1.0625rem;
  --t-md: 1.328rem;
  --t-lg: 1.66rem;
  --t-xl: 2.075rem;
  --t-2xl: 2.594rem;
  --t-3xl: 3.242rem;

  --measure: 68ch;
  --page: 72rem;
  --gutter: clamp(1rem, 4vw, 2.5rem);
  --ease: cubic-bezier(0.2, 0, 0, 1);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #16161e;
    --sheet: #1a1b26;
    --ink: #c0caf5;
    --ink-soft: #a9b1d6;
    --ink-dim: #737aa2;
    --valley: #7aa2f7;
    --mountain: #f7768e;
    --crease: #3b4261;
    --valley-wash: #20303b;
    --mountain-wash: #37222c;
    --fold-shadow: rgba(0, 0, 0, 0.4);
    --outline: oklch(1 0 0 / 0.08);
    --syn-keyword: #bb9af7;
    --syn-string: #9ece6a;
    --syn-number: #ff9e64;
    --syn-comment: #828bb8;
    --syn-rule: #7dcfff;
    color-scheme: dark;
  }
}

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

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 var(--t-base) / 1.55 var(--sans);
}

a { color: var(--valley); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--valley); outline-offset: 3px; border-radius: 2px; }

code, pre, textarea, .code { font-family: var(--mono); }
code { font-size: 0.82em; }

h1, h2 { font-weight: 800; letter-spacing: -0.02em; line-height: 1.1; text-wrap: balance; margin: 0; }
p, li, dd { text-wrap: pretty; }

.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

.skip { position: absolute; left: -999px; top: 0.5rem; }
.skip:focus { left: var(--gutter); background: var(--sheet); padding: 0.5rem 0.75rem; z-index: 2; }

/* ---- page frame -------------------------------------------------------- */

.top, main > section, .foot {
  width: min(100% - 2 * var(--gutter), var(--page));
  margin-inline: auto;
}

.top {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding-block: 1.25rem;
}

.brand {
  display: inline-flex; align-items: center; gap: 0.6rem;
  color: var(--ink); text-decoration: none;
  font-weight: 800; font-size: var(--t-md); letter-spacing: -0.02em;
}
.brand img { display: block; }

.top { flex-wrap: wrap; }
.top nav { display: flex; gap: 0.25rem; flex-wrap: wrap; margin-right: -0.65rem; }
@media (max-width: 40rem) {
  .top nav { margin-left: -0.65rem; }
  .top nav a { padding-inline: 0.55rem; font-size: var(--t-sm); }
}
.top nav a {
  color: var(--ink-soft); text-decoration: none; font-weight: 500;
  padding: 0.6rem 0.65rem; border-radius: 4px; min-height: 44px;
  display: inline-flex; align-items: center;
  transition-property: color, background-color; transition-duration: 150ms; transition-timing-function: var(--ease);
}
.top nav a:hover { color: var(--ink); background: var(--valley-wash); }

/* Sections are separated by a crease: a dashed rule. */
.band {
  padding-block: clamp(3rem, 7vw, 5rem);
  border-top: 1px dashed var(--crease);
}

.section-head { max-width: var(--measure); margin-bottom: 2rem; }
.section-head h2 { font-size: clamp(var(--t-lg), 3.2vw, var(--t-2xl)); margin-bottom: 0.75rem; }
.section-head p { margin: 0; color: var(--ink-soft); }

/* ---- sheets ------------------------------------------------------------ */

.sheet {
  background: var(--sheet);
  border: 1px solid var(--crease);
  border-radius: 4px;
}

/* The folded corner: used once per view, on the main sheet. */
.fold { position: relative; }
.fold::after {
  content: ""; position: absolute; top: -1px; right: -1px;
  width: 22px; height: 22px;
  background: linear-gradient(225deg, var(--paper) 50%, var(--crease) 50%);
  border-bottom-left-radius: 2px;
  box-shadow: -1px 1px 2px var(--fold-shadow);
}

/* ---- hero -------------------------------------------------------------- */

.hero {
  display: grid; grid-template-columns: minmax(0, 1fr); gap: clamp(2rem, 5vw, 3.5rem);
  padding-block: clamp(2.5rem, 7vw, 5.5rem) clamp(3rem, 7vw, 5rem);
}

.hero h1 {
  font-size: clamp(var(--t-xl), 6.2vw, 4.4rem);
  line-height: 1.02; letter-spacing: -0.035em;
  max-width: 14ch;
}

.lede { font-size: var(--t-md); line-height: 1.45; max-width: 46ch; color: var(--ink-soft); margin: 1.25rem 0 1.75rem; }

.install-line {
  display: inline-flex; align-items: center; gap: 0.25rem;
  background: var(--sheet); border: 1px solid var(--crease); border-radius: 6px;
  padding: 0.25rem 0.25rem 0.25rem 1rem; max-width: 100%;
}
.install-line code { font-size: 0.85rem; white-space: nowrap; overflow-x: auto; min-width: 0; }
.install-line code::before { content: "$ "; color: var(--valley); }

.copy {
  position: relative; display: inline-grid; place-items: center;
  min-width: 40px; min-height: 40px; padding: 0 0.5rem;
  border: 0; border-radius: 4px; background: transparent; color: var(--ink-soft);
  font: 500 var(--t-sm) var(--sans); cursor: pointer;
  transition-property: color, background-color, scale; transition-duration: 150ms; transition-timing-function: var(--ease);
}
.copy:hover { color: var(--ink); background: var(--valley-wash); }
.copy:active { scale: 0.96; }
.copy .icon {
  grid-area: 1 / 1; width: 18px; height: 18px;
  fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round;
  transition-property: opacity, scale, filter; transition-duration: 200ms; transition-timing-function: var(--ease);
}
.copy .icon-done { opacity: 0; scale: 0.25; filter: blur(4px); color: var(--valley); }
.copy.done .icon-copy { opacity: 0; scale: 0.25; filter: blur(4px); }
.copy.done .icon-done { opacity: 1; scale: 1; filter: blur(0); }
.copy.text.done { color: var(--valley); }

.hero-links { margin: 1rem 0 0; font-weight: 500; }

/* The long line sticks out of the sheet until it is folded into it. */
.hero { overflow-x: clip; }
.hero > * { min-width: 0; }
.hero-sheet { margin: 0; padding: 1.5rem 1.5rem 1.25rem; overflow-x: auto; }
@media (min-width: 64rem) { .hero-sheet { overflow-x: visible; } }

/* Token grid: every token is placed by (line, column) in ch units, so the
   fold moves each token from its place in the long line to its place in the
   formatted lines. */
.hero-code {
  --lh: 1.7em;
  position: relative;
  font: 400 13px / 1 var(--mono);
  height: calc(3 * var(--lh));
  min-width: 72ch;
}
.hero-code .tok {
  position: absolute; left: 0; top: 0; white-space: pre;
  line-height: var(--lh);
  translate: calc(var(--x) * 1ch) calc(var(--y) * var(--lh));
  transition: translate 640ms var(--ease);
  transition-delay: calc(var(--y) * 70ms);
}
.hero-code .kw { color: var(--syn-keyword); }

/* Syntax colors (Tokyo Night) in the hero and the playground output. */
.kw { color: var(--syn-keyword); }
.str { color: var(--syn-string); }
.num-lit { color: var(--syn-number); }
.com { color: var(--syn-comment); font-style: italic; }
.hero-code .crease {
  position: absolute; top: 0; width: 0; height: var(--lh);
  border-left: 1.5px dashed var(--valley);
  translate: calc(var(--x) * 1ch - 0.5ch) 0;
  opacity: 0;
  transition: opacity 180ms var(--ease);
  transition-delay: calc(var(--i) * 90ms);
}
.hero-code.creased .crease { opacity: 1; }
.hero-code.folded .crease { opacity: 0; transition-delay: 0ms; }

.note {
  font: 600 0.78rem / 1.5 var(--mono); color: var(--ink);
  margin: 0;
}
.note-mark { color: var(--valley); }
.hero-note {
  margin-top: 1rem; padding-top: 0.85rem; border-top: 1px dashed var(--crease);
  opacity: 0; translate: 0 4px;
  transition-property: opacity, translate; transition-duration: 300ms; transition-timing-function: var(--ease);
}
.hero-note.show { opacity: 1; translate: 0 0; }

@media (min-width: 64rem) {
  /* Headline left, lede and install right; the sheet spans the page below,
     wide enough for the long line before it folds. */
  .hero { grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr); align-items: end; column-gap: 4rem; }
  .hero-sheet { grid-column: 1 / -1; }
  .lede { margin-top: 0; }
}

/* ---- playground --------------------------------------------------------- */

.pg-controls { display: flex; flex-wrap: wrap; gap: 0.75rem 1.25rem; margin-bottom: 1rem; }
.pg-controls label { display: inline-flex; align-items: center; gap: 0.5rem; font-weight: 500; color: var(--ink-soft); }
select {
  font: 500 var(--t-sm) var(--sans); color: var(--ink);
  background: var(--sheet); border: 1px solid var(--crease); border-radius: 4px;
  min-height: 40px; padding: 0 0.6rem;
}

.pg { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; }
@media (min-width: 56rem) { .pg { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
.pg-pane { min-width: 0; display: flex; flex-direction: column; }

.pane-label {
  display: flex; align-items: center; justify-content: space-between;
  min-height: 40px; font-weight: 600;
}

.code {
  font-size: 12.5px; line-height: 1.6; color: var(--ink);
  height: clamp(22rem, 60vh, 34rem); width: 100%;
  padding: 0.9rem 1rem; overflow: auto; margin: 0;
}
textarea.code { resize: vertical; tab-size: 2; white-space: pre; }
textarea.code:focus-visible { outline-offset: 0; }

/* The input: a transparent textarea over a highlighted copy of its text.
   Both have the same font, padding, border and scroll position. */
.editor { position: relative; }
.editor pre {
  position: absolute; inset: 0; height: auto;
  overflow: hidden; tab-size: 2; white-space: pre; pointer-events: none;
}
.editor textarea {
  position: relative; display: block;
  background: transparent; color: transparent; caret-color: var(--ink);
  border: 1px solid transparent; border-radius: 4px;
}
.editor textarea::selection { background: color-mix(in oklab, var(--valley) 30%, transparent); color: transparent; }

.output { padding: 0.9rem 0; }
.output .ln {
  display: grid; grid-template-columns: 3.2ch 1fr; column-gap: 1ch;
  padding-inline: 0.5rem 1rem; white-space: pre; min-width: max-content;
}
.output .ln::before {
  content: attr(data-n); color: var(--ink-dim); text-align: right;
  font-variant-numeric: tabular-nums;
}
/* Lines of a construct that origami broke: a valley crease in the margin. */
.output .ln.broken { box-shadow: inset 2px 0 0 var(--valley); background: color-mix(in srgb, var(--valley-wash) 55%, transparent); }
.output .ln-note {
  padding: 0.15rem 1rem 0.45rem calc(0.5rem + 4.2ch);
  white-space: normal; min-width: 0;
}
.output .ln-note a { color: var(--syn-rule); text-decoration-color: currentColor; }
.output .empty { padding: 0 1rem; color: var(--ink-soft); font-family: var(--sans); font-size: var(--t-sm); }

.status { min-height: 1.6em; margin: 0.9rem 0 0; color: var(--ink-soft); font-size: var(--t-sm); }
.status .num { font-variant-numeric: tabular-nums; }
.status.error { color: var(--mountain); }

/* ---- figures, facts, install ------------------------------------------ */

/* Photos: a paper crane folded in the theme's colors (docs/brand.md). The
   left part of the photo is empty, so the caption sits there on wide screens. */
.photo { margin: 0; position: relative; }
.photo img { display: block; width: 100%; height: auto; border-radius: 4px; outline: 1px solid var(--outline); outline-offset: -1px; }
.photo figcaption { margin-top: 1.25rem; }
.photo h2 { font-size: clamp(var(--t-lg), 3.2vw, var(--t-2xl)); margin-bottom: 0.75rem; }
.photo p { margin: 0; color: var(--ink-soft); max-width: 32ch; }
@media (min-width: 48rem) {
  .photo figcaption {
    position: absolute; inset: 0 auto 0 0; width: 34%; margin: 0;
    padding: clamp(1.5rem, 4vw, 3.5rem); display: flex; flex-direction: column; justify-content: center;
  }
}
.split { display: grid; gap: 2rem; align-items: start; margin-bottom: 2rem; }
.split .section-head { margin-bottom: 0; }
.detail { display: block; width: 100%; max-width: 14rem; height: auto; border-radius: 4px; outline: 1px solid var(--outline); outline-offset: -1px; }
@media (min-width: 48rem) { .split { grid-template-columns: minmax(0, 1fr) 14rem; } }

.figure { margin: 0; }
.figure img { display: block; width: 100%; height: auto; border-radius: 4px; outline: 1px solid var(--outline); outline-offset: -1px; }
.figure.terminal img { outline: none; }
.figure figcaption { margin-top: 0.75rem; color: var(--ink-soft); font-size: var(--t-sm); max-width: var(--measure); }

.facts { list-style: none; padding: 0; margin: 2.25rem 0 0; display: grid; gap: 1.25rem 2.5rem; }
@media (min-width: 56rem) { .facts { grid-template-columns: 1.1fr 1fr 0.9fr; } }
.facts li { padding-top: 0.85rem; border-top: 1px solid var(--crease); color: var(--ink-soft); }
.facts strong { color: var(--ink); font-weight: 600; }

.install { display: grid; gap: 0.5rem 2rem; margin: 0; max-width: 60rem; }
@media (min-width: 48rem) { .install { grid-template-columns: 13rem 1fr; } }
.install dt { font-weight: 600; padding-top: 0.9rem; }
.install dd { margin: 0; padding-top: 0.9rem; color: var(--ink-soft); }
@media (min-width: 48rem) {
  .install dt, .install dd { border-top: 1px dashed var(--crease); }
}
.install dd code { color: var(--ink); }

/* ---- comparison page (abap-cleaner.html) -------------------------------- */

.page-head { padding-block: clamp(2.5rem, 6vw, 4.5rem) clamp(2rem, 5vw, 3.5rem); }
.page-head h1 { font-size: clamp(var(--t-xl), 5vw, var(--t-3xl)); letter-spacing: -0.03em; }
.page-head .lede { max-width: var(--measure); margin-bottom: 2rem; }
.setup { display: grid; gap: 0.25rem 2rem; margin: 0; max-width: 60rem; font-size: var(--t-sm); }
@media (min-width: 48rem) { .setup { grid-template-columns: 9rem 1fr; } }
.setup dt { font-weight: 600; padding-top: 0.6rem; }
.setup dd { margin: 0; padding-top: 0.6rem; color: var(--ink-soft); }
@media (min-width: 48rem) { .setup dt, .setup dd { border-top: 1px dashed var(--crease); } }

.cmp { padding-top: 2.5rem; }
.cmp + .cmp { margin-top: 1rem; border-top: 1px solid var(--crease); }
.cmp h3 { font-size: var(--t-md); font-weight: 700; letter-spacing: -0.01em; margin: 0 0 0.5rem; }
.cmp > p { margin: 0 0 1rem; max-width: var(--measure); color: var(--ink-soft); }
.cmp-pane { min-width: 0; display: flex; flex-direction: column; }
.cmp-pair { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; margin-top: 1rem; }
@media (min-width: 64rem) { .cmp-pair { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
.code-block {
  margin: 0; padding: 0.9rem 1rem; overflow-x: auto;
  font: 400 12.5px / 1.6 var(--mono); color: var(--ink); white-space: pre;
}
.code-block:focus-visible { outline-offset: 0; }
.cmp-pane.before .code-block { background: transparent; border-style: dashed; color: var(--ink-soft); }
/* origami's pane gets the valley crease, as broken lines do in the playground. */
.cmp-pane.ours .code-block { box-shadow: inset 2px 0 0 var(--valley); }

.legend { list-style: none; padding: 0; margin: 0 0 1.25rem; display: flex; flex-wrap: wrap; gap: 0.5rem 1.5rem; color: var(--ink-soft); font-size: var(--t-sm); }
.legend strong { color: var(--ink); font-variant-numeric: tabular-nums; }
.badge {
  display: inline-block; padding: 0.1rem 0.5rem; border-radius: 3px; white-space: nowrap;
  font: 600 0.72rem / 1.5 var(--sans); border: 1px solid transparent;
}
.badge.yes { background: var(--valley-wash); color: var(--valley); border-color: var(--valley); }
.badge.own { background: var(--valley-wash); color: var(--ink); border-color: var(--crease); }
.badge.no { background: transparent; color: var(--ink-soft); border-color: var(--crease); border-style: dashed; }
.badge.goal { background: var(--mountain-wash); color: var(--mountain); border-color: transparent; }

.table-wrap { overflow-x: auto; border: 1px solid var(--crease); border-radius: 4px; background: var(--sheet); }
.rules { border-collapse: collapse; width: 100%; min-width: 46rem; font-size: var(--t-sm); }
.rules th, .rules td { text-align: left; vertical-align: top; padding: 0.55rem 0.9rem; }
.rules thead th { font-weight: 600; border-bottom: 1px solid var(--crease); }
.rules tr.group th {
  padding-top: 1.1rem; font-weight: 700; color: var(--ink);
  border-top: 1px dashed var(--crease);
}
.rules tbody:first-of-type tr.group th { border-top: 0; }
.rules td { color: var(--ink-soft); border-top: 1px solid color-mix(in srgb, var(--crease) 45%, transparent); }
.rules .rule-name { display: block; color: var(--ink); font-weight: 500; }
.rules .rule-id { color: var(--ink-dim); font-size: 0.72rem; }
.rules .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rules td a { color: var(--syn-rule); font-family: var(--mono); font-size: 0.72rem; }
.table-note { margin: 0.9rem 0 0; color: var(--ink-soft); font-size: var(--t-sm); max-width: var(--measure); }

.foot {
  border-top: 1px dashed var(--crease);
  padding-block: 2rem 3rem; color: var(--ink-soft); font-size: var(--t-sm);
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.5rem 2rem;
}
.foot p { margin: 0; }
.foot p + p a + a { margin-left: 1rem; }
