:root {
  --fg: #dce8f5;
  --fg-dim: #8fa8bf;
  --accent: #7fc4c9;
  --panel-w: min(88vw, 62rem);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #060a12;
  color: var(--fg);
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  -webkit-font-smoothing: antialiased;
}

/* Slow drifting gradient backdrop */
.bg {
  position: fixed;
  inset: -25%;
  background:
    radial-gradient(38% 42% at 28% 30%, rgba(64, 110, 142, .34), transparent 70%),
    radial-gradient(42% 46% at 72% 62%, rgba(52, 84, 130, .30), transparent 70%),
    radial-gradient(30% 34% at 55% 25%, rgba(76, 104, 96, .22), transparent 70%),
    linear-gradient(160deg, #060a12, #0a1420 55%, #060a12);
  animation: drift 90s ease-in-out infinite alternate;
  filter: blur(2px) saturate(1.05);
}

@keyframes drift {
  0%   { transform: translate3d(-2%, -1%, 0) scale(1.00) rotate(0deg); }
  50%  { transform: translate3d( 1%,  2%, 0) scale(1.06) rotate(3deg); }
  100% { transform: translate3d( 2%, -2%, 0) scale(1.02) rotate(-2deg); }
}

#stage { position: fixed; inset: 0; }

.panel {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 6vh 4vw;
  opacity: 0;
  transform: translateY(1.4rem) scale(.985);
  transition: opacity 2.2s ease, transform 2.2s ease;
  pointer-events: none;
}

.panel.is-active {
  opacity: 1;
  transform: none;
}

.panel-kicker {
  font-size: clamp(.85rem, 1.4vw, 1.1rem);
  letter-spacing: .42em;
  text-transform: uppercase;
  color: var(--fg-dim);
  margin-bottom: 2.2rem;
}

.panel-big {
  font-size: clamp(4rem, 12vw, 9rem);
  font-weight: 300;
  line-height: 1;
}

.panel-sub {
  margin-top: 1.6rem;
  font-size: clamp(1.1rem, 2.4vw, 1.8rem);
  color: var(--fg-dim);
}

.panel-rows {
  margin-top: 2.4rem;
  display: flex;
  gap: 3rem;
  flex-wrap: wrap;
  justify-content: center;
  font-size: clamp(.95rem, 1.8vw, 1.3rem);
  color: var(--fg-dim);
}

.panel-rows b { color: var(--fg); font-weight: 500; }

/* Clock */
.clock-time {
  font-size: clamp(5rem, 17vw, 13rem);
  font-weight: 200;
  line-height: 1;
  letter-spacing: .02em;
  font-variant-numeric: tabular-nums;
}

.clock-date {
  margin-top: 2rem;
  font-size: clamp(1.2rem, 2.6vw, 2rem);
  color: var(--fg-dim);
  letter-spacing: .08em;
}

.clock-breath {
  margin-top: 4rem;
  width: 5.5rem;
  height: 5.5rem;
  border-radius: 50%;
  border: 1px solid rgba(127, 196, 201, .35);
  animation: breath 8s ease-in-out infinite;
}

@keyframes breath {
  0%, 100% { transform: scale(.72); opacity: .35; }
  50%      { transform: scale(1.0); opacity: .9; }
}

/* News */
.news-list {
  width: var(--panel-w);
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: n;
  text-align: left;
  --news-scale: 1;
}

.news-list li {
  counter-increment: n;
  padding: calc(1.1rem * var(--news-scale)) 0 calc(1.1rem * var(--news-scale)) 3.4rem;
  position: relative;
  font-size: calc(clamp(1.05rem, 2.1vw, 1.55rem) * var(--news-scale));
  line-height: 1.45;
  border-bottom: 1px solid rgba(143, 168, 191, .14);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.news-list li::before {
  content: counter(n, decimal-leading-zero);
  position: absolute;
  left: 0;
  top: calc(1.25rem * var(--news-scale));
  font-size: .8em;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.news-list li:last-child { border-bottom: 0; }
.news-list .src { color: var(--fg-dim); font-size: .72em; margin-left: .6em; }

/* Markets */
.market-list {
  display: flex;
  gap: clamp(2rem, 6vw, 5rem);
  flex-wrap: wrap;
  justify-content: center;
}

.market-item { min-width: 9rem; }
.market-item .sym { font-size: clamp(.9rem, 1.5vw, 1.1rem); letter-spacing: .3em; color: var(--fg-dim); }
.market-item .price { font-size: clamp(2rem, 4.5vw, 3.4rem); font-weight: 300; margin-top: .6rem; font-variant-numeric: tabular-nums; }
.market-item .chg { margin-top: .5rem; font-size: clamp(.95rem, 1.7vw, 1.25rem); font-variant-numeric: tabular-nums; }
.market-item .up   { color: #8fd6a4; }
.market-item .down { color: #e08e8e; }

.muted { color: var(--fg-dim); }

/* Update progress bar */
#progress {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: 2px;
  background: rgba(143, 168, 191, .12);
}

#progress-bar {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, rgba(127,196,201,.2), rgba(127,196,201,.75));
  transition: width linear;
}

/* Panel dots */
#dots {
  position: fixed;
  bottom: 1.6rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: .9rem;
}

#dots button {
  width: .55rem;
  height: .55rem;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(143, 168, 191, .3);
  cursor: pointer;
  transition: background .6s, transform .6s;
}

#dots button.on { background: var(--accent); transform: scale(1.25); }

/* Controls */
#controls {
  position: fixed;
  top: 1.4rem;
  right: 1.6rem;
  display: flex;
  gap: .6rem;
  opacity: .45;
  transition: opacity .8s;
}

#controls:hover { opacity: 1; }

#controls button {
  font: 500 .8rem/1 system-ui, sans-serif;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--fg-dim);
  background: rgba(10, 20, 32, .5);
  border: 1px solid rgba(143, 168, 191, .25);
  border-radius: 999px;
  padding: .55rem 1rem;
  cursor: pointer;
  backdrop-filter: blur(4px);
  transition: color .3s, border-color .3s;
}

#controls button[aria-pressed="true"] { color: var(--accent); border-color: rgba(127,196,201,.55); }
#controls button:hover { color: var(--fg); }

/* Sound hint */
#hint {
  position: fixed;
  bottom: 3.4rem;
  left: 50%;
  transform: translateX(-50%);
  font: 400 .85rem/1 system-ui, sans-serif;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--fg-dim);
  opacity: .8;
  transition: opacity 1.4s;
  pointer-events: none;
}

#hint.gone { opacity: 0; }

/* Idle: hide cursor + chrome like a proper screensaver */
body.idle { cursor: none; }
body.idle #controls,
body.idle #dots { opacity: 0; pointer-events: none; }
body.idle #controls, body.idle #dots { transition: opacity 1.2s; }

@media (prefers-reduced-motion: reduce) {
  .bg, .clock-breath { animation: none; }
  .panel { transition: opacity 1.2s ease; }
}
