:root {
  --bg: #f1f5f9;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --name: #2563eb;
  --ingredients: #16a34a;
  --recipe: #ea580c;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; height: 100%; }

body {
  color: var(--ink);
  background: var(--bg);
}

/* The page is a column: an explanation header at the very top, then the split
   pane filling whatever's left. */
#app {
  height: 100vh;
  display: flex;
  flex-direction: column;
}

/* The explanation that introduces the concept, shown above the demo. */
.page-head {
  flex: none;
  background: #fff;
  border-bottom: 3px solid var(--ink);
  padding: 14px 22px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
}
.page-explain {
  margin: 0;
  max-width: 900px;
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
}
/* The two controls — "← All concepts" and "▶ Play demo" — stack in a
   right-aligned column in the upper part of the header (no absolute
   positioning; pushed to the right edge with margin-left:auto). */
.page-controls {
  flex: none;
  margin-left: auto;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}
.page-head .play { margin: 0; }
.page-explain em { font-style: normal; font-weight: 600; }
.page-explain strong { color: #04263a; }

/* The two halves split the remaining space evenly. */
.split {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-rows: 1fr 1fr;
}

.pane {
  position: relative;
  padding: 18px 22px;
  overflow: auto;
}

.pane-app {
  /* Gentle pancake: a faint tiled pancake-stack watermark over a soft buttery
     cream gradient warming into pale golden honey. The watermark opacity is
     baked into the SVG (~0.16) so it reads as a delicate pattern, not clutter. */
  background-image:
    url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMjAiIGhlaWdodD0iMTIwIiB2aWV3Qm94PSIwIDAgMTIwIDEyMCI+CiAgPGcgb3BhY2l0eT0iMC4xNiI+CiAgICA8IS0tIHN5cnVwIGRyaXBzIG92ZXIgdGhlIGZyb250IGVkZ2UgLS0+CiAgICA8cGF0aCBkPSJNMzQgNjAgcS0zIDEyIDEgMjAgcTUgLTQgNCAtMTUgeiIgZmlsbD0iI2M1ODIxZiIvPgogICAgPHBhdGggZD0iTTg2IDYyIHE0IDExIDAgMjAgcS01IC01IC0zIC0xNiB6IiBmaWxsPSIjYzU4MjFmIi8+CiAgICA8IS0tIHBhbmNha2Ugc3RhY2ssIGJvdHRvbSB0byB0b3AgLS0+CiAgICA8ZWxsaXBzZSBjeD0iNjAiIGN5PSI3MiIgcng9IjM4IiByeT0iMTAiIGZpbGw9IiNkOWEyNGYiLz4KICAgIDxlbGxpcHNlIGN4PSI2MCIgY3k9IjYxIiByeD0iMzYiIHJ5PSI5LjUiIGZpbGw9IiNlM2IwNjYiLz4KICAgIDxlbGxpcHNlIGN4PSI2MCIgY3k9IjUxIiByeD0iMzQiIHJ5PSI5IiBmaWxsPSIjZWJiYjc4Ii8+CiAgICA8ZWxsaXBzZSBjeD0iNjAiIGN5PSI0MiIgcng9IjMyIiByeT0iOC41IiBmaWxsPSIjZjBjNDg5Ii8+CiAgICA8IS0tIHBhdCBvZiBidXR0ZXIgLS0+CiAgICA8cmVjdCB4PSI1MCIgeT0iMzMiIHdpZHRoPSIyMCIgaGVpZ2h0PSIxMyIgcng9IjMuNSIgZmlsbD0iI2ZkZWNhMyIvPgogIDwvZz4KPC9zdmc+Cg=="),
    radial-gradient(130% 80% at 50% 0%, rgba(255, 240, 204, 0.65), transparent 62%),
    linear-gradient(165deg, #fffdf7 0%, #fdf2db 48%, #f7e6c4 100%);
  background-repeat: repeat, no-repeat, no-repeat;
  background-size: 120px 120px, auto, auto;
  border-bottom: 3px solid var(--ink);
}

.pane-api {
  background: #0f172a;
  color: #e2e8f0;
}

/* --- pane labels --------------------------------------------------------- */
.pane-label {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 14px;
}

.badge {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: 999px;
}
.badge-app { background: var(--ink); color: #fff; }
.badge-api { background: #38bdf8; color: #04263a; }

.pane-sub { color: var(--muted); font-size: 13px; }
.pane-api .pane-sub { color: #94a3b8; }

/* "Play demo" auto-tour button — sits at the top-right of the API pane and
   walks the highlight across each field, 2s apart. */
.play {
  margin-left: auto;
  background: transparent;
  color: #38bdf8;
  border: 1px solid #38bdf8;
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.play:hover:not(:disabled) { background: rgba(56, 189, 248, 0.14); }
.play.active { background: #38bdf8; color: #04263a; }
.play:disabled { opacity: 0.45; cursor: default; }

/* --- the app (top) ------------------------------------------------------- */
.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
  max-width: 760px;
  margin: 0 auto;
}

.placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 40px;
  color: var(--muted);
  min-height: 140px;
}

.recipe-card { overflow: hidden; }

.recipe-head {
  padding: 20px 24px;
  border-bottom: 3px solid var(--name);
  transition: opacity 0.15s, box-shadow 0.15s;
}
.recipe-head h1 { margin: 0; font-size: 26px; }
.recipe-tag { margin: 6px 0 0; color: var(--muted); font-size: 13px; }

.recipe-body {
  display: grid;
  grid-template-columns: 0.9fr 1.4fr;
  gap: 0;
}
@media (max-width: 620px) {
  .recipe-body { grid-template-columns: 1fr; }
}

.recipe-col {
  padding: 16px 24px;
  transition: opacity 0.15s, background 0.15s;
}
.recipe-col h2 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 0 0 10px;
}
.field-ingredients { border-right: 1px solid var(--line); }

.ingredients { list-style: none; margin: 0; padding: 0; }
.ingredients li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 0;
  font-size: 15px;
}
.check {
  width: 16px;
  height: 16px;
  border: 2px solid var(--ingredients);
  border-radius: 5px;
  flex: none;
}

.steps { margin: 0; padding-left: 20px; }
.steps li { padding: 4px 0; line-height: 1.5; }
.steps li::marker { color: var(--recipe); font-weight: 700; }

/* Hover-linking: dim the parts that aren't the focused field, glow the one
   that is — so the connection between data and UI is unmistakable. */
.dim { opacity: 0.28; }
.glow { box-shadow: inset 0 0 0 3px currentColor; }
.field-name.glow { color: var(--name); }
.field-ingredients.glow { color: var(--ingredients); background: #f0fdf4; }
.field-recipe.glow { color: var(--recipe); background: #fff7ed; }
.recipe-col.glow h2, .recipe-head.glow h1 { color: inherit; }

.spinner {
  width: 26px; height: 26px;
  border: 3px solid var(--line);
  border-top-color: var(--muted);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- the API (bottom) ---------------------------------------------------- */
.api-grid {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 18px;
  align-items: start;
}
@media (max-width: 620px) {
  .api-grid { grid-template-columns: 1fr; }
}

.block-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #94a3b8;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.http-line {
  display: block;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 10px 12px;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 14px;
  color: #e2e8f0;
}
.method { color: #38bdf8; font-weight: 700; }

.send {
  margin-top: 12px;
  width: 100%;
  background: #38bdf8;
  color: #04263a;
  border: none;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: filter 0.15s;
}
.send:hover:not(:disabled) { filter: brightness(1.08); }
.send:disabled { opacity: 0.6; cursor: default; }

.status-ok { color: #4ade80; font-weight: 700; }
.status-err { color: #f87171; font-weight: 700; }

.json {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 14px 16px;
  margin: 0;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 14px;
  line-height: 1.6;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}
.json.muted { color: #64748b; }
.json.err { color: #f87171; }

.jrow {
  padding: 1px 6px;
  margin: 0 -6px;
  border-radius: 5px;
  border-left: 3px solid var(--c);
  transition: opacity 0.15s, background 0.15s;
}
.jrow:hover { background: rgba(56, 189, 248, 0.08); }
.jrow.dim { opacity: 0.3; }
.jkey { color: var(--c); font-weight: 700; }
.jstr { color: #fcd34d; }
.jpunc { color: #94a3b8; }

/* --- legend -------------------------------------------------------------- */
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  margin: 18px 0 0;
  font-size: 13px;
  color: #94a3b8;
}
.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  cursor: default;
}
.legend-item code { color: var(--c); font-weight: 700; }
.dot {
  width: 11px; height: 11px;
  border-radius: 50%;
  background: var(--c);
  flex: none;
}

/* --- back link ----------------------------------------------------------- */
.back {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  text-decoration: none;
  background: #fff;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
}
.back:hover { background: var(--bg); }
