/* btclevels — siehe DESIGN.md */

:root {
  --bg:        oklch(0.17 0.008 70);
  --bg-raised: oklch(0.21 0.009 70);
  --bg-inset:  oklch(0.14 0.007 70);
  --border:    oklch(0.30 0.010 70);
  --text:      oklch(0.93 0.005 80);
  --text-dim:  oklch(0.68 0.010 75);
  --text-faint:oklch(0.50 0.010 75);
  --accent:    oklch(0.75 0.16 65);
  --accent-ink:oklch(0.20 0.03 65);
  --ok:        oklch(0.72 0.13 155);
  --warn:      oklch(0.78 0.14 85);
  --err:       oklch(0.65 0.19 25);
  --radius: 8px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font: 400 1rem/1.5 "Segoe UI", system-ui, -apple-system, "Inter", sans-serif;
  font-variant-numeric: tabular-nums;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

main {
  width: min(1180px, 100% - 3rem);
  margin: 0 auto;
  flex: 1;
}

h1, h2 { margin: 0; font-weight: 600; }
h1 { font-size: 1.25rem; letter-spacing: -0.01em; }
h2 { font-size: 1rem; }
.h1-sub, .h2-sub {
  font-size: 0.8125rem;
  font-weight: 400;
  color: var(--text-faint);
  margin-left: 0.5rem;
}

/* ---------- Topbar ---------- */

.topbar {
  width: min(1180px, 100% - 3rem);
  margin: 0 auto;
  padding: 1.2rem 0 1.6rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.wordmark {
  font-size: 1.125rem;
  letter-spacing: 0.01em;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 0.55rem;
  user-select: none;
}
.wordmark b { color: var(--text); font-weight: 650; }
.wordmark-tick {
  width: 0.65rem; height: 0.65rem;
  border-radius: 2px;
  background: var(--accent);
  display: inline-block;
}

.topbar-status { display: flex; align-items: baseline; gap: 1rem; }

.btc-price {
  font-weight: 650;
  font-size: 1.0625rem;
  color: var(--accent);
  white-space: nowrap;
}

.updated { font-size: 0.8125rem; color: var(--text-faint); white-space: nowrap; }
.updated.is-scraping { color: var(--warn); }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 550;
  border-radius: var(--radius);
  border: 1px solid transparent;
  padding: 0.5rem 0.9rem;
  cursor: pointer;
  transition: background-color 0.18s var(--ease), border-color 0.18s var(--ease),
              color 0.18s var(--ease), transform 0.12s var(--ease);
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:disabled { opacity: 0.45; cursor: default; transform: none; }

.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
}
.btn-primary:hover:not(:disabled) { background: oklch(0.80 0.16 68); }
.btn-primary.copied { background: var(--ok); }

/* ---------- Notice ---------- */

.notice {
  width: min(1180px, 100% - 3rem);
  margin: 0 auto 0.75rem;
  padding: 0.5rem 0.85rem;
  border: 1px solid oklch(0.45 0.10 85 / 0.55);
  background: oklch(0.78 0.14 85 / 0.07);
  color: var(--warn);
  border-radius: var(--radius);
  font-size: 0.8125rem;
}
.notice.error {
  border-color: oklch(0.50 0.14 25 / 0.55);
  background: oklch(0.65 0.19 25 / 0.07);
  color: var(--err);
}

/* ---------- Levels-Strip ---------- */

.levels-head { margin-bottom: 1rem; }

.levels-strip {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-raised);
  overflow: hidden;
}

.level-cell {
  padding: 1.15rem 1.3rem 1.05rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  min-width: 0;
  transition: background-color 0.15s var(--ease);
}
.level-cell + .level-cell { border-left: 1px solid var(--border); }
.level-cell:hover { background: oklch(0.24 0.010 70); }

.level-name {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--text-dim);
  white-space: nowrap;
}
.level-dot {
  width: 0.55rem; height: 0.55rem;
  border-radius: 50%;
  flex: none;
}

.level-value {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 1.625rem;
  font-weight: 650;
  letter-spacing: -0.01em;
  line-height: 1.15;
}
.level-value.flash { animation: flash 0.9s var(--ease); }
@keyframes flash { 0% { color: var(--accent); } 100% { color: inherit; } }

.level-cell.stale .level-value { color: var(--warn); }

.level-meta {
  font-size: 0.75rem;
  color: var(--text-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.level-delta { font-size: 0.75rem; color: var(--text-faint); }
.level-delta .above { color: var(--ok); }
.level-delta .below { color: var(--err); }

.stale-badge {
  font-size: 0.6875rem;
  color: var(--warn);
  border: 1px solid oklch(0.45 0.10 85 / 0.55);
  border-radius: 999px;
  padding: 0.05rem 0.45rem;
  margin-left: auto;
}

.level-cell.skeleton { height: 6.4rem; justify-content: center; }
.level-cell.skeleton span {
  display: block;
  height: 0.9rem;
  width: 70%;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--border) 25%, oklch(0.34 0.01 70) 50%, var(--border) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite linear;
}
.level-cell.skeleton span:first-child { width: 45%; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- PineScript ---------- */

.pine { margin: 2rem 0 2.5rem; }

.pine-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.pine-code {
  margin: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-inset);
  padding: 0.9rem 1.1rem;
  font: 400 0.8125rem/1.55 ui-monospace, "Cascadia Mono", Consolas, monospace;
  color: var(--text-dim);
  overflow: auto;
  max-height: 60vh;
  white-space: pre;
}
.pine-code:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Responsive ---------- */

@media (max-width: 1080px) {
  .levels-strip { grid-template-columns: repeat(3, 1fr); }
  .level-cell:nth-child(3n + 1) { border-left: 0; }
  .level-cell:nth-child(n + 4) { border-top: 1px solid var(--border); }
}

@media (max-width: 640px) {
  .topbar, main, .notice { width: calc(100% - 1.5rem); }
  .levels-strip { grid-template-columns: 1fr; }
  .level-cell + .level-cell { border-left: 0; border-top: 1px solid var(--border); }
  .level-cell:nth-child(n + 4) { border-top: 1px solid var(--border); }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
