/* ── Design tokens ── */
:root {
  --bg: #050810;
  --surface: rgba(255,255,255,0.03);
  --border: rgba(255,255,255,0.07);
  --accent: #ff5533;
  --accent2: #ff8844;
  --text: #f0ece4;
  --muted: rgba(240,236,228,0.4);
  --glow: rgba(255,85,51,0.25);
  --green: #22c55e;
  --red: #ef4444;
  --green-glow: rgba(34,197,94,0.2);
  --red-glow: rgba(239,68,68,0.2);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'DM Mono', monospace;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow-x: hidden;
  position: relative;
}

/* ── Starfield ── */
#stars { position: fixed; inset: 0; pointer-events: none; z-index: 0; }

/* ── Noise grain overlay ── */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 1;
  opacity: 0.5;
}

/* ── Radial glow ── */
body::before {
  content: '';
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 900px;
  height: 900px;
  background: radial-gradient(circle, rgba(255,85,51,0.07) 0%, transparent 65%);
  pointer-events: none;
  z-index: 0;
}

/* ── Stock Widget ── */
.stock-widget {
  width: 100%;
  max-width: 560px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px 24px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 0 60px rgba(0,0,0,0.4);
}

.stock-widget::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(255,85,51,0.03) 0%, transparent 60%);
  pointer-events: none;
}

.stock-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
}

.stock-eyebrow {
  font-size: 9px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 4px;
}

.stock-company {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 22px;
  letter-spacing: 0.06em;
  line-height: 1;
  color: var(--text);
}

.stock-ticker-badge {
  font-size: 9px;
  letter-spacing: 0.2em;
  color: var(--muted);
  margin-top: 3px;
}

.stock-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 8px var(--green-glow);
  margin-top: 4px;
  animation: pulse-dot 2s ease-in-out infinite;
  flex-shrink: 0;
}

.stock-status-dot.stale { background: var(--muted); box-shadow: none; animation: none; }

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.5; transform: scale(0.8); }
}

.stock-price-row {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 6px;
}

.stock-price-big {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 48px;
  line-height: 1;
  letter-spacing: 0.02em;
  color: var(--text);
}

.stock-currency {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 8px;
}

.stock-change-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}

.stock-change-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 11px;
  letter-spacing: 0.08em;
  font-weight: 500;
}

.stock-change-badge.up {
  background: rgba(34,197,94,0.1);
  color: var(--green);
  border: 1px solid rgba(34,197,94,0.2);
}

.stock-change-badge.down {
  background: rgba(239,68,68,0.1);
  color: var(--red);
  border: 1px solid rgba(239,68,68,0.2);
}

/* ── Mini sparkline ── */
.sparkline-wrap {
  border-top: 1px solid var(--border);
  padding-top: 14px;
  margin-top: 4px;
}

.sparkline-label {
  font-size: 9px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}

svg.sparkline {
  width: 100%;
  height: 44px;
  display: block;
}

.stock-meta-row {
  display: flex;
  gap: 20px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

.stock-meta-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stock-meta-key {
  font-size: 8px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
}

.stock-meta-val {
  font-size: 12px;
  color: var(--text);
}

.stock-error {
  font-size: 11px;
  color: var(--muted);
  text-align: center;
  padding: 8px 0;
}

.stock-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11px;
  color: var(--muted);
  justify-content: center;
  padding: 16px 0;
}

/* ── Spinner ── */
.spin {
  width: 14px; height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Main container ── */
.container {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 48px;
  padding: 40px 20px;
  text-align: center;
}

/* ── Footer ── */
.footer-text {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 48px;
  font-size: 18px;
  letter-spacing: 0.08em;
  color: var(--text);
}

.footer-text img {
  height: 72px;
  width: 72px;
  object-fit: contain;
  opacity: 0.8;
  transition: opacity 0.3s ease;
}

.footer-text:hover img { opacity: 1; }

/* ── Header ── */
.header { display: flex; flex-direction: column; align-items: center; gap: 12px; }

.eyebrow {
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.35em;
  text-transform: uppercase;
  color: var(--accent);
  opacity: 0.85;
}

.title {
  font-family: 'Bebas Neue', sans-serif;
  font-size: clamp(48px, 8vw, 96px);
  letter-spacing: 0.04em;
  line-height: 1;
  background: linear-gradient(135deg, var(--text) 30%, var(--accent2) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  font-size: 12px;
  letter-spacing: 0.12em;
  color: var(--muted);
}

/* ── Countdown grid ── */
.countdown {
  display: flex;
  align-items: flex-start;
  gap: 0;
  justify-content: center;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
}

.unit {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 0 24px;
  position: relative;
}

.unit:not(:last-child)::after {
  content: ':';
  font-family: 'Bebas Neue', sans-serif;
  font-size: clamp(36px, 6vw, 72px);
  color: var(--accent);
  opacity: 0.5;
  position: absolute;
  right: -4px;
  top: 0;
  line-height: 1;
}

.unit:first-child { padding-left: 0; }
.unit:last-child  { padding-right: 0; }

.digit-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 18px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 0 40px var(--glow), inset 0 1px 0 rgba(255,255,255,0.06);
  min-width: 70px;
}

.digit-wrap::before {
  content: '';
  position: absolute;
  left: 0; right: 0;
  top: 50%;
  height: 1px;
  background: rgba(0,0,0,0.5);
  z-index: 1;
}

.digit {
  font-family: 'Bebas Neue', sans-serif;
  font-size: clamp(36px, 6vw, 72px);
  line-height: 1;
  letter-spacing: 0.02em;
  color: var(--text);
  transition: opacity 0.12s ease;
  display: block;
  text-shadow: 0 0 30px var(--glow);
}

.label {
  font-size: 10px;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--muted);
}

@keyframes flip-in {
  0%   { transform: rotateX(90deg); opacity: 0; }
  100% { transform: rotateX(0deg);  opacity: 1; }
}
.flip { animation: flip-in 0.25s ease forwards; }

/* ── Progress bar ── */
.progress-wrap {
  width: 100%;
  max-width: 560px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  letter-spacing: 0.12em;
  color: var(--muted);
  text-transform: uppercase;
}

.progress-bar-bg {
  height: 4px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  border-radius: 99px;
  transition: width 1s linear;
  box-shadow: 0 0 12px var(--glow);
}

/* ── Citation section ── */
.citation-section {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

#sickness-image {
  width: 100%;
  max-width: 500px;
  height: auto;
  display: block;
  margin: 0 auto;
  border-radius: 12px;
}

/* ── Sickness / Injury section ── */
.sickness-section {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.sickness-section {
  animation: none !important;
  opacity: 1 !important;
  transform: none !important;
}

/* ── Section divider ── */
.section-divider {
  width: 100%;
  max-width: 560px;
  border-top: 1px solid var(--border);
}

/* ── Staggered reveal animation ── */
.container > * {
  opacity: 0;
  transform: translateY(20px);
  animation: reveal 0.7s ease forwards;
}
.container > *:nth-child(1) { animation-delay: 0.1s; }
.container > *:nth-child(2) { animation-delay: 0.3s; }
.container > *:nth-child(3) { animation-delay: 0.5s; }
.container > *:nth-child(4) { animation-delay: 0.65s; }
.container > *:nth-child(5) { animation-delay: 0.8s; }
.container > *:nth-child(6) { animation-delay: 0.9s; }
.container > *:nth-child(7) { animation-delay: 1.0s; }
.container > *:nth-child(8) { animation-delay: 1.1s; }

@keyframes reveal {
  to { opacity: 1; transform: translateY(0); }
}

/* ── Responsive ── */
@media (max-width: 560px) {
  .unit { padding: 0 10px; }
  .digit-wrap { padding: 14px 16px; min-width: 70px; }
  .unit:not(:last-child)::after { right: -3px; }
}

/* ── Roast button active state ── */
#roast-btn.roast-btn-active {
  padding: 8px 16px;
  width: auto;
  margin-top: -45px;
  margin-bottom: 10px;
  display: inline-block;
  color: var(--text) !important;
}

#roast-text.roast-text-active {
  font-size: 24px !important;
  color: var(--text) !important;
  font-weight: 500;
  text-shadow: 0 0 20px var(--glow);
  line-height: 1.3;
}
