/* Luma Playground: the colors and feel of luma's website. */

:root {
  --orange: #ee7a2e;
  --orange-2: #f59e0b;
  --orange-soft: rgba(238, 122, 46, 0.12);
  --bg: #f6f7f9;
  --panel: #ffffff;
  --panel-2: #f8fafc;
  --line: #e5e7eb;
  --text: #0f172a;
  --muted: #5b677d;
  --code-bg: #ffffff;
  --code-text: #1e2433;
  --gutter: #a0a8b8;
  --sel: rgba(238, 122, 46, 0.22);
  --err: #dc2626;
  --err-soft: rgba(220, 38, 38, 0.1);
  --ok: #16a34a;
  /* syntax */
  --k: #c2410c;
  --t: #0369a1;
  --s: #15803d;
  --n: #b45309;
  --f: #7c3aed;
  --c: #8b93a5;
  --shadow: 0 20px 50px -28px rgba(15, 23, 42, 0.35);
  --mono: ui-monospace, "JetBrains Mono", "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0d12;
    --panel: #12151c;
    --panel-2: #0f1218;
    --line: #232834;
    --text: #eef1f6;
    --muted: #97a2b6;
    --code-bg: #0f1420;
    --code-text: #e6e9ef;
    --gutter: #4b5466;
    --sel: rgba(238, 122, 46, 0.3);
    --err: #f87171;
    --err-soft: rgba(248, 113, 113, 0.12);
    --ok: #4ade80;
    --k: #ff9b5c;
    --t: #7dd3fc;
    --s: #a7e08a;
    --n: #f5c26b;
    --f: #c4b5fd;
    --c: #6b7488;
    --shadow: 0 20px 50px -28px rgba(0, 0, 0, 0.8);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b0d12;
  --panel: #12151c;
  --panel-2: #0f1218;
  --line: #232834;
  --text: #eef1f6;
  --muted: #97a2b6;
  --code-bg: #0f1420;
  --code-text: #e6e9ef;
  --gutter: #4b5466;
  --sel: rgba(238, 122, 46, 0.3);
  --err: #f87171;
  --err-soft: rgba(248, 113, 113, 0.12);
  --ok: #4ade80;
  --k: #ff9b5c;
  --t: #7dd3fc;
  --s: #a7e08a;
  --n: #f5c26b;
  --f: #c4b5fd;
  --c: #6b7488;
  --shadow: 0 20px 50px -28px rgba(0, 0, 0, 0.8);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(900px 420px at 85% -120px, rgba(245, 158, 11, 0.14), transparent 70%),
    var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--sans);
}
button { font: inherit; color: inherit; }
code, kbd { font-family: var(--mono); font-size: 0.88em; }
kbd {
  padding: 0.05em 0.4em;
  border-radius: 5px;
  border: 1px solid var(--line);
  background: var(--panel-2);
}
.muted { color: var(--muted); }
svg path { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
svg path.fill { fill: currentColor; stroke: none; }

/* ---------- top bar ---------- */
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.7rem 1.2rem;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel) 80%, transparent);
  backdrop-filter: blur(8px);
}
.brand { display: flex; align-items: center; gap: 0.7rem; color: inherit; text-decoration: none; min-width: 0; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.brand-text b { font-size: 1.1rem; font-weight: 800; letter-spacing: -0.01em; }
.brand-text small { color: var(--muted); font-size: 0.78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.grad {
  background: linear-gradient(100deg, var(--orange), var(--orange-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.top-right { display: flex; align-items: center; gap: 0.6rem; flex: none; }
.pill {
  padding: 0.15rem 0.65rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--orange);
  background: var(--orange-soft);
  white-space: nowrap;
}
.toplink { color: var(--muted); text-decoration: none; font-weight: 600; font-size: 0.9rem; padding: 0.3rem 0.4rem; }
.toplink:hover { color: var(--orange); }
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel);
  cursor: pointer;
  color: var(--muted);
}
.icon-btn:hover { color: var(--orange); border-color: var(--orange); }
#theme .moon { display: none; }
:root[data-theme="dark"] #theme .sun { display: none; }
:root[data-theme="dark"] #theme .moon { display: inline; }

/* ---------- layout ---------- */
.layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 250px minmax(0, 1.25fr) minmax(0, 1fr);
  gap: 1rem;
  padding: 1rem 1.2rem 1.2rem;
}
.panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.7rem;
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
}
.spacer { flex: 1; }

/* ---------- examples ---------- */
.examples {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
  padding-right: 0.2rem;
}
.examples-head { display: flex; align-items: center; justify-content: space-between; padding: 0.3rem 0.4rem 0.6rem; }
.examples h2 { margin: 0; font-size: 0.8rem; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; color: var(--orange); }
.group { margin: 1rem 0 0.35rem; padding: 0 0.6rem; font-size: 0.74rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.group:first-child { margin-top: 0; }
.ex {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.42rem 0.7rem;
  border: 0;
  border-radius: 10px;
  background: none;
  cursor: pointer;
  color: var(--text);
  font-size: 0.92rem;
}
.ex:hover { background: var(--orange-soft); }
.ex.active { background: var(--orange); color: #fff; font-weight: 600; }

/* ---------- editor ---------- */
.file-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.3rem 0.75rem;
  border-radius: 9px;
  background: var(--panel);
  border: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 0.82rem;
  max-width: 50%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.file-tab .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--orange); flex: none; }
.ghost, .run {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.42rem 0.85rem;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  white-space: nowrap;
}
.ghost { border: 1px solid var(--line); background: var(--panel); color: var(--text); }
.ghost:hover { border-color: var(--orange); color: var(--orange); }
.run {
  border: 0;
  color: #fff;
  background: linear-gradient(135deg, var(--orange), var(--orange-2));
  box-shadow: 0 8px 20px -10px rgba(238, 122, 46, 0.9);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.run:hover { transform: translateY(-1px); box-shadow: 0 10px 24px -10px rgba(238, 122, 46, 1); }
.run:disabled { opacity: 0.7; cursor: progress; transform: none; }
.run kbd { border: 0; background: rgba(255, 255, 255, 0.22); color: #fff; font-size: 0.7rem; }
.run.busy svg { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.editor {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  background: var(--code-bg);
  overflow: hidden;
}
.gutter {
  flex: none;
  min-width: 3.2rem;
  padding: 1rem 0.7rem 1rem 0.5rem;
  text-align: right;
  font: 14px/1.6 var(--mono);
  color: var(--gutter);
  user-select: none;
  overflow: hidden;
  border-right: 1px solid var(--line);
}
.gutter div { white-space: pre; }
.gutter .err { color: var(--err); font-weight: 700; }
.gutter .err::before { content: "● "; font-size: 0.7em; vertical-align: 0.15em; }
.code-wrap { position: relative; flex: 1; min-width: 0; }
.highlight, #code {
  margin: 0;
  padding: 1rem 1.1rem 3rem;
  font: 14px/1.6 var(--mono);
  tab-size: 4;
  white-space: pre;
  letter-spacing: 0;
  word-spacing: 0;
}
.highlight {
  position: absolute;
  inset: 0;
  overflow: hidden;
  color: var(--code-text);
  pointer-events: none;
}
#code {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  resize: none;
  border: 0;
  outline: none;
  background: transparent;
  color: transparent;
  caret-color: var(--orange);
  overflow: auto;
}
#code::selection { background: var(--sel); color: transparent; }
.highlight .line { display: block; }
.highlight .errline { background: var(--err-soft); box-shadow: inset 3px 0 0 var(--err); }
.hl-k { color: var(--k); font-weight: 600; }
.hl-t { color: var(--t); }
.hl-s { color: var(--s); }
.hl-i { color: var(--orange); }
.hl-n { color: var(--n); }
.hl-f { color: var(--f); }
.hl-c { color: var(--c); font-style: italic; }
.hl-b { color: var(--k); }

/* ---------- output ---------- */
.tabs { gap: 0.2rem; overflow-x: auto; scrollbar-width: none; }
.tab {
  padding: 0.4rem 0.8rem;
  border: 0;
  border-radius: 9px;
  background: none;
  cursor: pointer;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.88rem;
  white-space: nowrap;
}
.tab:hover { color: var(--text); background: var(--orange-soft); }
.tab.active { background: var(--orange); color: #fff; }
.view-note { margin: 0; padding: 0.5rem 1rem 0; font-size: 0.82rem; color: var(--muted); min-height: 0; }
.view-note:empty { display: none; }
.result {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 0.9rem 1rem;
  font: 13.5px/1.6 var(--mono);
  white-space: pre;
  outline: none;
}
.result .out { color: var(--text); }
.result .err-text { color: var(--err); }
.result a.pos { color: var(--err); font-weight: 700; text-decoration: underline dotted; cursor: pointer; }
.result .note { color: var(--muted); font-style: italic; }
.placeholder { white-space: normal; font-family: var(--sans); font-size: 0.95rem; max-width: 28rem; color: var(--text); }
.placeholder p { margin: 0 0 0.7rem; }
.status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 1rem;
  border-top: 1px solid var(--line);
  font-size: 0.82rem;
  color: var(--muted);
  min-height: 2.2rem;
}
.status:empty { display: none; }
.status .ok { color: var(--ok); font-weight: 700; }
.status .bad { color: var(--err); font-weight: 700; }
.input-box { border-top: 1px solid var(--line); background: var(--panel-2); }
.input-box summary { padding: 0.5rem 1rem; cursor: pointer; font-weight: 600; font-size: 0.88rem; }
.input-box summary .muted { font-weight: 400; margin-left: 0.3rem; }
.input-box textarea {
  display: block;
  width: calc(100% - 2rem);
  margin: 0 1rem 0.8rem;
  min-height: 4.5rem;
  resize: vertical;
  padding: 0.5rem 0.7rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  font: 13px/1.5 var(--mono);
}
.input-box textarea:focus { outline: 2px solid var(--orange); outline-offset: -1px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  transform: translate(-50%, 20px);
  padding: 0.6rem 1.1rem;
  border-radius: 12px;
  background: var(--text);
  color: var(--bg);
  font-weight: 600;
  font-size: 0.9rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.only-small { display: none; }

/* ---------- smaller screens ---------- */
@media (max-width: 1100px) {
  .layout { grid-template-columns: 220px minmax(0, 1fr); grid-template-rows: minmax(0, 1.2fr) minmax(0, 1fr); }
  .examples { grid-row: 1 / 3; }
}
@media (max-width: 760px) {
  body { height: auto; min-height: 100%; }
  .layout { display: flex; flex-direction: column; padding: 0.6rem; gap: 0.7rem; }
  .editor-panel { height: 62vh; }
  .output-panel { height: 55vh; }
  .only-small { display: inline-flex; }
  .examples {
    position: fixed;
    z-index: 20;
    inset: 0 auto 0 0;
    width: min(85vw, 300px);
    padding: 1rem;
    background: var(--panel);
    border-right: 1px solid var(--line);
    box-shadow: var(--shadow);
    transform: translateX(-105%);
    transition: transform 0.2s ease;
  }
  .examples.open { transform: none; }
  .brand-text small, .toplink, .pill, .run kbd, #share span { display: none; }
  .top { padding: 0.6rem 0.8rem; }
}
