/* ETH Brew — cozy coffeehouse, not kitsch */
:root {
  color-scheme: dark;
  --bg: #2b1d16;
  --bg-deep: #22160f;
  --ink: #f3e9dc;
  --muted: #cbb8a4;
  --faint: #9e8b78;
  --card: #3a281f;
  --card-edge: #4a352a;
  --line: rgba(243, 233, 220, 0.1);
  --accent: #c8893b;
  --accent-dim: rgba(200, 137, 59, 0.16);
  --sage: #9bb394;
  --sage-bg: rgba(155, 179, 148, 0.12);
  --brick: #c96b5c;
  --brick-bg: rgba(201, 107, 92, 0.14);
  --serif: "Fraunces", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --mono: "IBM Plex Mono", "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  --radius: 16px;
  --max: 34rem;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--bg);
  background-image:
    radial-gradient(ellipse 90% 50% at 50% -8%, rgba(200, 137, 59, 0.13), transparent 58%),
    radial-gradient(ellipse 50% 40% at 100% 100%, rgba(43, 29, 22, 1), transparent 50%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-deep) 100%);
  color: var(--ink);
  font-family: var(--serif);
  font-optical-sizing: auto;
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

.grain,
.coffee-ring {
  pointer-events: none;
  position: fixed;
  z-index: 0;
}

.grain {
  inset: 0;
  opacity: 0.09;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)' opacity='.9'/%3E%3C/svg%3E");
  background-size: 180px 180px;
}

.coffee-ring {
  width: 220px;
  height: 220px;
  right: -36px;
  bottom: 8%;
  color: var(--accent);
  opacity: 0.09;
  transform: rotate(-12deg);
}

.page {
  position: relative;
  z-index: 1;
  width: min(var(--max), calc(100% - 36px));
  margin: 0 auto;
  padding: max(28px, calc(env(safe-area-inset-top, 0px) + 16px)) 0 max(40px, calc(env(safe-area-inset-bottom, 0px) + 28px));
}

header { margin-bottom: 28px; }

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.cup {
  width: 34px;
  height: 34px;
  color: var(--accent);
  flex: none;
}

h1 {
  margin: 0;
  font-weight: 600;
  font-size: 1.35rem;
  letter-spacing: -0.02em;
  line-height: 1.1;
  font-variation-settings: "SOFT" 40, "opsz" 36;
}

h1 em {
  font-style: italic;
  font-weight: 500;
  color: var(--accent);
}

.tag {
  margin: 3px 0 0;
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--faint);
}

.hero { margin-bottom: 22px; }

.eyebrow {
  margin: 0 0 8px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--faint);
}

.price-block {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 10px 16px;
}

.price {
  margin: 0;
  font-size: clamp(3.15rem, 13vw, 4.5rem);
  font-weight: 600;
  letter-spacing: -0.04em;
  line-height: 0.95;
  font-variation-settings: "SOFT" 30, "opsz" 144;
  font-feature-settings: "tnum" 1;
}

.chg {
  margin: 0;
  font-family: var(--mono);
  font-size: 1.05rem;
  font-weight: 500;
  letter-spacing: -0.02em;
}

.chg.up { color: var(--sage); }
.chg.down { color: var(--brick); }
.chg.flat { color: var(--muted); }

.updated {
  margin: 10px 0 0;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--faint);
  letter-spacing: 0.01em;
}

.updated.err { color: var(--brick); }

.spark-wrap { margin-top: 22px; }

.spark {
  display: block;
  width: 100%;
  height: 108px;
  overflow: visible;
}

.spark .price-line {
  fill: none;
  stroke: var(--ink);
  stroke-width: 1.8;
  stroke-linejoin: round;
  stroke-linecap: round;
  opacity: 0.92;
}

.spark .ma-line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.6;
  stroke-dasharray: 5 4;
  stroke-linejoin: round;
  opacity: 0.9;
}

.spark .area {
  fill: url(#sparkFade);
  opacity: 0.7;
}

.spark-legend {
  display: flex;
  gap: 16px;
  margin-top: 8px;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--faint);
}

.leg { display: inline-flex; align-items: center; gap: 6px; }
.leg::before {
  content: "";
  width: 14px;
  height: 0;
  border-top: 1.5px solid currentColor;
}
.price-leg::before { border-color: var(--ink); }
.ma-leg::before {
  border-color: var(--accent);
  border-top-style: dashed;
}

.mas {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 10px;
}

.card {
  background:
    linear-gradient(180deg, rgba(243, 233, 220, 0.035), transparent 40%),
    var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow:
    inset 0 1px 0 rgba(243, 233, 220, 0.05),
    0 10px 24px rgba(0, 0, 0, 0.18);
}

.ma { padding: 14px 14px 13px; }

.ma-k {
  margin: 0;
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--faint);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

.ma-k span {
  letter-spacing: 0.04em;
  color: var(--accent);
  opacity: 0.85;
  font-size: 9.5px;
}

.ma-v {
  margin: 8px 0 4px;
  font-family: var(--mono);
  font-size: 1.12rem;
  font-weight: 500;
  letter-spacing: -0.03em;
  color: var(--ink);
  font-feature-settings: "tnum" 1;
}

.ma-d {
  margin: 0;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.ma-d.up, .rsi-state.oversold { color: var(--sage); }
.ma-d.down, .rsi-state.overbought { color: var(--brick); }
.ma-d.flat, .rsi-state.neutral { color: var(--muted); }

.rsi { padding: 16px 16px 18px; }

.rsi-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}

.rsi-state {
  margin: 0;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.rsi-v {
  margin: 6px 0 16px;
  font-family: var(--mono);
  font-size: 2rem;
  font-weight: 500;
  letter-spacing: -0.04em;
  line-height: 1;
  font-feature-settings: "tnum" 1;
}

.gauge .track {
  position: relative;
  height: 10px;
  border-radius: 999px;
  background: var(--bg-deep);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.35);
  overflow: visible;
}

.gauge .fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: var(--accent);
  transition: width 0.6s ease, background-color 0.4s ease;
}

.gauge .fill.oversold { background: var(--sage); }
.gauge .fill.overbought { background: var(--brick); }
.gauge .fill.neutral { background: var(--accent); }

.gauge .mark {
  position: absolute;
  top: -3px;
  bottom: -3px;
  width: 1px;
  background: var(--ink);
  opacity: 0.35;
  transform: translateX(-0.5px);
}

.gauge .thumb {
  position: absolute;
  top: 50%;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--ink);
  border: 2px solid var(--bg);
  box-shadow: 0 0 0 1px rgba(200, 137, 59, 0.45);
  transform: translate(-50%, -50%);
  left: 0;
  transition: left 0.6s ease;
}

.gauge .scale {
  position: relative;
  height: 16px;
  margin-top: 6px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--faint);
}

.gauge .scale span {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
}
.gauge .scale span:first-child { transform: translateX(0); }
.gauge .scale span:last-child { transform: translateX(-100%); }

footer {
  margin-top: 28px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

footer p {
  margin: 0;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--faint);
  letter-spacing: 0.02em;
}

@media (min-width: 540px) {
  .page { width: min(36rem, calc(100% - 48px)); padding-top: 48px; }
  .spark { height: 128px; }
  .ma { padding: 16px 18px 15px; }
  .ma-v { font-size: 1.2rem; }
}

/* Six averages: 3x2 on desktop, still 2x3 on phones */
@media (min-width: 760px) {
  .page { width: min(48rem, calc(100% - 56px)); }
  .mas { grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .gauge .fill, .gauge .thumb { transition: none; }
}
