/* luna.kvds.media: the house style of the kvds.media app sites (the story on the left in
   plain, large type, the app itself on the right, working), in Luna's own look: the
   page grey, the line and its rings, and Git orange. Follows the visitor's light or
   dark setting. */

:root {
  color-scheme: light dark;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  --display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;

  /* the page */
  --paper: #ecebe7;
  --paper-2: #e4e3de;
  --text: #1d1d1f;
  --dim: #505056;          /* 6.9:1 on paper */
  --hair: rgb(30 30 40 / 0.12);
  --link: #b13216;         /* 5.6:1 on paper */
  --glow-a: rgb(240 81 51 / 0.16);
  --glow-b: rgb(244 106 78 / 0.10);

  /* the app (Luna's colours) */
  --w-page: #f7f7f5;
  --w-text: #1d1d1f;
  --w-dim: #6b6b70;
  --w-tertiary: #b4b4ba;
  --accent: #c93a1c;
  --rail: #bebec5;
  --rule: #e2e2e7;
  --picked-row: #fbe4dd;
  --picked-ink: #a8321a;
  --lit: #ececef;
  --on-accent: #ffffff;
  --glass: rgb(201 58 28 / 0.92);
  --w-shadow: 0 30px 80px rgb(60 30 20 / 0.20), 0 2px 8px rgb(0 0 0 / 0.08);
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #161618;
    --paper-2: #1c1c1f;
    --text: #f2f2f4;
    --dim: #b8b8be;
    --hair: rgb(255 255 255 / 0.12);
    --link: #ff7a5e;
    --glow-a: rgb(240 81 51 / 0.16);
    --glow-b: rgb(240 81 51 / 0.06);
    --w-page: #0a0a0a;
    --w-text: #f2f2f4;
    --w-dim: #a0a0a6;
    --w-tertiary: #5c5c63;
    --accent: #f05133;
    --rail: #4a4a52;
    --rule: #1c1c1f;
    --picked-row: #2a120b;
    --picked-ink: #ff8a70;
    --lit: #18181c;
    --on-accent: #0a0a0a;
    --glass: rgb(240 81 51 / 0.86);
    --w-shadow: 0 30px 90px rgb(0 0 0 / 0.6), 0 0 0 1px rgb(255 255 255 / 0.09);
  }
}
@media (prefers-contrast: more) {
  :root { --dim: var(--text); --w-dim: var(--w-text); --hair: rgb(128 128 128 / 0.6); }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
body {
  margin: 0; overflow-x: clip;
  background: var(--paper); color: var(--text);
  font: 400 1.1875rem/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; height: auto; display: block; }
a { color: var(--link); text-underline-offset: 3px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip { position: absolute; left: 16px; top: -80px; z-index: 50; background: var(--text); color: var(--paper); padding: 10px 16px; border-radius: 8px; font-weight: 600; text-decoration: none; }
.skip:focus { top: 16px; }
button, textarea, input { font: inherit; color: inherit; }

/* ── The chapter: story left, the working app right ───────────────────── */

.chapter {
  display: grid;
  grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr);
  grid-template-rows: auto 1fr;
  column-gap: clamp(32px, 4vw, 72px);
  max-width: 1480px; margin: 0 auto;
  padding: 0 clamp(20px, 4vw, 64px);
  overflow-x: clip;
}
.story { grid-column: 1; max-width: 33rem; }
.story-head { padding-top: clamp(32px, 5vw, 56px); }
.story-body { padding-bottom: clamp(40px, 6vw, 96px); }
.stage { grid-column: 2; grid-row: 1 / span 2; }

.brand { display: flex; align-items: center; gap: 12px; margin: 0 0 clamp(48px, 9vw, 104px); font: 700 1.5rem/1 var(--display); letter-spacing: -0.02em; }
.brand img { width: 44px; height: 44px; }

h1, h2, h3 { font-family: var(--display); color: var(--text); margin: 0; }
h1 { font-weight: 700; font-size: clamp(3rem, 6vw, 5.2rem); line-height: 1.02; letter-spacing: -0.035em; margin-bottom: 28px; }
h2 { font-weight: 700; font-size: clamp(1.7rem, 2.4vw, 2.1rem); line-height: 1.15; letter-spacing: -0.02em; margin-bottom: 14px; }
p { margin: 0 0 16px; }
.lede { font-size: clamp(1.3rem, 1.8vw, 1.55rem); line-height: 1.42; font-weight: 500; margin-bottom: 30px; max-width: 26em; }
.story section { margin-top: clamp(48px, 6vw, 72px); }
.story section p { color: var(--dim); }
.story section b { color: var(--text); }

.get { display: flex; align-items: center; flex-wrap: wrap; gap: 14px 20px; margin-bottom: 30px; }
.store { display: inline-block; line-height: 0; border-radius: 10px; }
.store img { width: 150px; height: auto; }
.get span { font-size: 1rem; line-height: 1.45; color: var(--dim); }

.try { display: flex; align-items: center; gap: 14px; font-weight: 600; font-size: 1.0625rem; color: var(--link); }
.try-arrow { width: 30px; height: 2.5px; background: currentColor; border-radius: 2px; position: relative; flex: none; }
.try-arrow::after { content: ""; position: absolute; right: -2px; top: -5px; border: 6.25px solid transparent; border-left-color: currentColor; border-right: 0; }

/* ── The stage: sticky, with an orange glow behind the window ─────────── */

.stage {
  position: sticky; top: 0; align-self: start; container-type: inline-size;
  /* the window keeps its place when the copied prompt appears under it */
  min-height: 100vh; padding: max(24px, calc((100vh - min(640px, 100vh - 150px) - 52px) / 2)) 0 clamp(24px, 4vh, 56px);
  display: flex; flex-direction: column; justify-content: flex-start;
}
.stage::before {
  content: ""; position: absolute; inset: 6% -10% 6% -6%; z-index: -1; pointer-events: none;
  background:
    radial-gradient(55% 50% at 70% 40%, var(--glow-a), transparent 70%),
    radial-gradient(50% 45% at 25% 75%, var(--glow-b), transparent 70%);
}
.stage-note { margin: 16px 4px 0; font-size: 0.9375rem; color: var(--dim); }

.paste { margin: 18px 0 0; }
.paste figcaption { font-size: 0.9375rem; color: var(--dim); margin: 0 4px 8px; }
.paste pre {
  margin: 0; padding: 16px 18px; border-radius: 12px; overflow-x: auto;
  background: var(--w-page); color: var(--w-text); border: 1px solid var(--hair);
  font: 400 13px/1.55 var(--mono); white-space: pre-wrap; word-break: normal; overflow-wrap: anywhere;
}

/* ── The window: Luna's list beside Luna, or beside an open repository ─── */

.win {
  /* Luna's Mac grid (design H) */
  --margin: 20px; --rail-x: 28px; --text-x: 50px; --row: 40px; --corner: 14px;
  --list-w: clamp(260px, 42cqw, 340px);
  position: relative;
  display: grid; grid-template-columns: var(--list-w) 1px minmax(0, 1fr);
  height: min(640px, calc(100vh - 150px)); min-height: 480px;
  background: var(--w-page); color: var(--w-text);
  border-radius: 14px; overflow: hidden; box-shadow: var(--w-shadow);
  font: 400 13px/1.3 var(--sans);
}
.win::before { content: ""; grid-column: 2; grid-row: 1; background: var(--rule); }
.pane { position: relative; min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.pane-list { grid-column: 1; grid-row: 1; }
.pane-detail { grid-column: 3; grid-row: 1; }
.lights { position: absolute; top: 9px; left: 12px; z-index: 3; display: flex; gap: 8px; }
.lights i { width: 12px; height: 12px; border-radius: 50%; background: #ff5f57; }
.lights i:nth-child(2) { background: #febc2e; } .lights i:nth-child(3) { background: #28c840; }

.scroll { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; }
.pane-list .scroll { padding-top: 28px; }   /* clear of the window's buttons, as in the app */
.graph { position: relative; padding-bottom: 88px; }
.lines { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; z-index: 1; }
.lines .rail { stroke: var(--rail); }
.lines .trace { stroke: var(--accent); }
.lines path, .lines circle { fill: none; stroke-width: 2; }
.lines .ring { fill: var(--w-page); stroke: var(--rail); transition: r .16s; }
.lines .ring.waiting { fill: var(--accent); }
.lines .ring.closed { fill: var(--rail); }
.lines .ring.picked { fill: var(--accent); stroke: var(--accent); }
.lines .ring.add { stroke-dasharray: 2.2 2.2; }
.lines .lit-ring { stroke: var(--accent); opacity: 0; }
.lines .lit-ring.on { opacity: 1; }

/* the note box: the line itself, risen round the field */
.box { position: relative; margin-bottom: 14px; }
.box textarea {
  display: block; width: 100%; min-height: 104px; resize: none; overflow: hidden;
  border: 0; background: none; outline: none;
  padding: 12px calc(var(--margin) + 16px) 18px calc(var(--text-x) - 1px);
  font: 400 15px/1.33 var(--sans); color: var(--w-text);
}
.box textarea::placeholder { color: var(--w-dim); opacity: 1; }
.box textarea:focus-visible { outline: none; }
.box:has(textarea:focus-visible) { --focus: 1; }

.rows { list-style: none; margin: 0; padding: 0; }
.row {
  position: relative; display: flex; align-items: baseline; gap: 12px; width: 100%;
  min-height: var(--row); padding: 10.5px var(--margin) 10.5px var(--text-x);
  border: 0; background: none; text-align: left; cursor: pointer;
  font: 700 15px/19px var(--sans); letter-spacing: -0.4px; color: var(--w-text);
}
.row::after { content: ""; position: absolute; left: var(--text-x); right: var(--margin); bottom: 0; height: 1px; background: var(--rule); }
.rows li:last-child .row::after, .row.no-rule::after { display: none; }
.row .name { flex: 1; min-width: 0; overflow-wrap: anywhere; margin-left: -1.67px; }
.row .n { color: var(--accent); font-variant-numeric: tabular-nums; letter-spacing: 0; }
.row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 6px; }
.choosing .row .name { color: var(--w-text); }
.choosing.has-pick .row .name { color: var(--w-dim); }
.row.picked { background: var(--picked-row); }
.choosing.has-pick .row.picked .name { color: var(--picked-ink); }
.row.open { background: var(--lit); }
.row.open::before { content: ""; position: absolute; right: 0; top: 8px; bottom: 8px; width: 3px; background: var(--accent); }

/* the page's one action: orange glass with the note box's corner */
.float { position: absolute; left: 0; right: 0; bottom: 0; z-index: 4; padding: 8px var(--margin); }
.big {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 48px; padding: 0 20px;
  border: 0; border-radius: var(--corner); cursor: pointer; text-align: left;
  background: var(--glass); color: var(--on-accent);
  -webkit-backdrop-filter: blur(14px) saturate(1.4); backdrop-filter: blur(14px) saturate(1.4);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.25), 0 6px 20px rgb(120 30 10 / 0.18);
  font: 700 15px/1.2 var(--sans); letter-spacing: -0.3px;
}
.big .grow { flex: 1; }
.big .key { font-weight: 500; font-size: 13px; opacity: 0.65; letter-spacing: 0; }
.big:active { filter: brightness(0.94); }
.big:focus-visible { outline: 3px solid var(--w-text); outline-offset: 2px; }

/* Luna on her graph */
.luna { position: relative; flex: 1; min-height: 0; overflow: hidden; }
.luna canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.cat { position: absolute; z-index: 2; border: 0; background: none; padding: 0; cursor: pointer; border-radius: 40%; }
.cat:focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; }

/* a repository's page */
.page { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.head { display: flex; align-items: center; padding: 20px var(--margin) 8px 0; min-height: 52px; }
.head h3 { flex: 1; min-width: 0; margin: 0 0 0 calc(var(--text-x) - 1.33px); font: 700 26px/1.15 var(--display); letter-spacing: -0.8px; color: var(--w-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.head .count { font: 700 26px/1.15 var(--display); color: var(--accent); font-variant-numeric: tabular-nums; padding-left: 12px; }
.back { flex: none; width: 44px; height: 44px; margin: 0 calc(var(--text-x) - var(--rail-x) - 22px) 0 calc(var(--rail-x) - 22px); display: grid; place-items: center; border: 0; background: none; color: var(--accent); cursor: pointer; border-radius: 10px; }
.back svg { width: 13px; height: 20px; transform: translateX(1.67px); }
.head:has(.back) h3 { margin-left: -1.33px; }

.note { display: flex; align-items: baseline; gap: 12px; min-height: var(--row); padding: 10px var(--margin) 10px var(--text-x); position: relative; font: 400 15px/20px var(--sans); }
.note::after { content: ""; position: absolute; left: var(--text-x); right: var(--margin); bottom: 0; height: 1px; background: var(--rule); }
.note.last::after { display: none; }
.note .t { flex: 1; min-width: 0; margin-left: -1px; overflow-wrap: anywhere; }
.note .issue { font: 400 11px/1 var(--mono); color: var(--w-dim); }
.note input { flex: 1; min-width: 0; border: 0; background: none; outline: none; padding: 0; margin-left: -1px; font: 400 15px/20px var(--sans); color: var(--w-text); }
.note input::placeholder { color: var(--w-dim); opacity: 1; }
.archive-link { display: flex; align-items: center; gap: 8px; width: 100%; min-height: var(--row); margin-top: 24px; padding: 0 var(--margin) 0 var(--text-x); border: 0; background: none; cursor: pointer; text-align: left; font: 400 15px/1.3 var(--sans); color: var(--w-dim); }
.archive-link .grow { flex: 1; }
.archive-link .n { font-variant-numeric: tabular-nums; }
.archive-link svg { width: 8px; height: 13px; color: var(--w-tertiary); }
.archive-link:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 6px; }
.version { margin: 22px 0 4px; padding-left: calc(var(--text-x) - 1.67px); font: 700 15px/1.3 var(--sans); letter-spacing: -0.4px; color: var(--w-text); }
.closed .t { color: var(--w-dim); }

/* narrow windows: one column, as on iPhone, with Luna under the list */
@container (max-width: 640px) {
  .win { --margin: 22px; --rail-x: 30px; --text-x: 52px; --row: 44px; --corner: 16px;
         grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto; height: auto; min-height: 0; }
  .win::before { display: none; }
  .pane-list, .pane-detail { grid-column: 1; }
  .pane-detail { grid-row: 2; border-top: 1px solid var(--rule); }
  .luna { height: 400px; flex: none; }
  .win[data-view="page"] .pane-list, .win[data-view="archive"] .pane-list { display: none; }
  .win[data-view="page"] .pane-detail, .win[data-view="archive"] .pane-detail { grid-row: 1; border-top: 0; }
  .win[data-view="page"] .luna, .win[data-view="archive"] .luna { display: none; }
  .scroll { overflow: visible; flex: none; }
  .page { flex: none; }
  .lights { display: none; }
  .pane-list .scroll { padding-top: 22px; }
  .graph { padding-bottom: 16px; }
  .graph.choosing, .graph.has-bar { padding-bottom: 80px; }
  .head { padding-top: 22px; }
}

/* ── After the chapter ────────────────────────────────────────────────── */

.after { border-top: 1px solid var(--hair); }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 clamp(20px, 4vw, 64px); }
.intro { color: var(--dim); max-width: 36em; font-size: 1.25rem; }
.access { padding-top: clamp(64px, 9vw, 112px); }
.access h2 { margin-bottom: 28px; }
.access ul { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 18px 48px; max-width: 980px; }
.access li { color: var(--dim); border-top: 1px solid var(--hair); padding-top: 14px; }
.access b { color: var(--text); }

.prose { padding-top: clamp(64px, 8vw, 104px); }
.prose ul { max-width: 40em; padding-left: 1.1em; margin: 20px 0 0; color: var(--dim); }
.prose li { margin-top: 12px; }
.prose li::marker { color: var(--accent); }
.prose b { color: var(--text); font-weight: 600; }
.updated { color: var(--dim); margin-top: 24px; font-size: 1rem; }

.footer {
  max-width: 1180px; margin: clamp(72px, 9vw, 120px) auto 0; padding: 28px clamp(20px, 4vw, 64px) 48px;
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px 24px;
  border-top: 1px solid var(--hair); font-size: 1rem; color: var(--dim);
}
.footer p { margin: 0; display: flex; gap: 22px; }
.footer a { color: inherit; }
.footer a:hover { color: var(--link); }

/* ── Small screens: the story, then the app, then the rest of the story ── */

@media (max-width: 960px) {
  .chapter { grid-template-columns: minmax(0, 1fr); }
  .story, .stage { grid-column: 1; grid-row: auto; max-width: 40rem; }
  .stage { position: relative; min-height: 0; padding: 8px 0 0; }
  .brand { margin-bottom: 40px; }
  .access ul { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  body { font-size: 1.125rem; }
  .win { border-radius: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .lines .ring { transition: none; }
}
@media (forced-colors: active) {
  .stage::before { display: none; }
  .big { forced-color-adjust: none; }
}
