/* ============================================
   SPEKULACJA.HELP - Modern Fintech Dark Theme
   ============================================ */

:root {
    --bg-primary: #09090b;
    --bg-secondary: #0c0c0f;
    --bg-tertiary: #111114;
    --bg-elevated: #18181b;
    --accent: #3b82f6;
    --accent-glow: rgba(59, 130, 246, 0.25);
    --green: #10b981;
    --green-bright: #34d399;
    --green-glow: rgba(16, 185, 129, 0.3);
    --red: #ef4444;
    --red-glow: rgba(239, 68, 68, 0.3);
    --amber: #f59e0b;
    --text: #fafafa;
    --text-secondary: #a1a1aa;
    --text-dim: #52525b;
    --border: rgba(255, 255, 255, 0.06);
    --border-accent: rgba(59, 130, 246, 0.2);
    --font-sans: 'Space Grotesk', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'IBM Plex Mono', 'SF Mono', 'Cascadia Code', monospace;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
}

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

html, body {
    height: 100%;
    overflow: hidden;
    background: var(--bg-primary);
    color: var(--text);
    font-family: var(--font-sans);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
}

/* ---- Terminal Container ---- */
.terminal {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    max-height: -webkit-fill-available;
    padding-top: var(--safe-top);
    padding-bottom: var(--safe-bottom);
    padding-left: var(--safe-left);
    padding-right: var(--safe-right);
    overflow: hidden;
}

/* ---- Header ---- */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    min-height: 48px;
    gap: 12px;
}

.header-brand {
    font-family: var(--font-sans);
    font-weight: 700;
    font-size: 15px;
    letter-spacing: 0.5px;
    color: var(--text);
    white-space: nowrap;
}

.header-dot {
    color: var(--accent);
}

.header-live-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 100px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 1.5px;
    color: var(--text-dim);
    transition: all 0.3s;
}

.header-live-badge.live {
    color: var(--green);
    border-color: rgba(16, 185, 129, 0.3);
    background: rgba(16, 185, 129, 0.08);
}

.header-live-badge.offline {
    color: var(--red);
    border-color: rgba(239, 68, 68, 0.2);
    background: rgba(239, 68, 68, 0.06);
}

.live-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-dim);
    flex-shrink: 0;
    transition: background 0.3s;
}

.live-dot.live {
    background: var(--green);
    box-shadow: 0 0 8px var(--green-glow);
    animation: pulse-dot 2s ease-in-out infinite;
}

.live-dot.offline {
    background: var(--red);
    animation: none;
}

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

.header-right {
    display: flex;
    align-items: center;
    gap: 14px;
}

.header-listeners {
    display: flex;
    align-items: center;
    gap: 5px;
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-dim);
}

.header-listeners strong {
    color: var(--text-secondary);
    font-weight: 600;
}

.header-listeners svg {
    opacity: 0.5;
}

.header-clock {
    font-family: var(--font-mono);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
}

/* ---- Visualizer ---- */
.visualizer-wrap {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: var(--bg-primary);
    min-height: 80px;
}

#eqCanvas {
    display: block;
    width: 100%;
    height: 100%;
}

.visualizer-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.5s;
}

.visualizer-overlay.visible {
    opacity: 1;
}

.viz-offline-msg {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 2px;
    color: var(--text-dim);
}

.offline-icon {
    opacity: 0.3;
}

/* ---- Player Controls ---- */
.player-controls {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 16px 20px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.play-btn {
    position: relative;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: 1.5px solid var(--border);
    background: var(--bg-elevated);
    color: var(--text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.play-btn:hover {
    background: rgba(59, 130, 246, 0.1);
    border-color: var(--accent);
    box-shadow: 0 0 20px var(--accent-glow);
}

.play-btn:active {
    transform: scale(0.95);
}

.play-btn svg {
    width: 28px;
    height: 28px;
    transition: opacity 0.15s;
}

.play-icon { display: block; }
.pause-icon { display: none; }
.play-spinner { display: none; }

.play-btn.playing .play-icon { display: none; }
.play-btn.playing .pause-icon { display: block; }
.play-btn.playing {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(59, 130, 246, 0.08);
    box-shadow: 0 0 16px var(--accent-glow);
}

.play-btn.loading .play-icon { display: none; }
.play-btn.loading .pause-icon { display: none; }
.play-btn.loading .play-spinner { display: block; }

.play-spinner {
    width: 24px;
    height: 24px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Volume */
.volume-section {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.volume-btn {
    width: 36px;
    height: 36px;
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    padding: 4px;
    border-radius: 8px;
    transition: color 0.2s, background 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.volume-btn:hover {
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.04);
}

.volume-btn svg {
    width: 20px;
    height: 20px;
}

.volume-btn.muted {
    color: var(--red);
}

.volume-slider {
    flex: 1;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 2px;
    cursor: pointer;
    outline: none;
    min-width: 60px;
}

.volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--text);
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(0,0,0,0.4);
    transition: transform 0.15s;
}

.volume-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.volume-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--text);
    border: none;
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(0,0,0,0.4);
}

.volume-slider::-moz-range-track {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 2px;
    height: 4px;
}

.volume-val {
    width: 40px;
    text-align: right;
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 500;
    color: var(--text-dim);
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
}

/* ---- Footer Ticker ---- */
.footer-ticker {
    overflow: hidden;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
    height: 38px;
    display: flex;
    align-items: center;
}

.ticker-track {
    display: flex;
    white-space: nowrap;
    animation: ticker-scroll 90s linear infinite;
    will-change: transform;
}

.ticker-track:hover {
    animation-play-state: paused;
}

.ticker-content {
    font-family: var(--font-mono);
    font-size: 13px;
    font-weight: 400;
    letter-spacing: 0.5px;
    color: var(--text-dim);
    padding-right: 0;
    flex-shrink: 0;
    line-height: 1;
}

.ticker-content .tk-up {
    color: var(--green-bright);
}

.ticker-content .tk-down {
    color: var(--red);
}

.ticker-content .tk-name {
    color: var(--text-secondary);
    font-weight: 500;
}

.ticker-content .tk-price {
    color: var(--text-secondary);
}

.ticker-content .tk-sep {
    color: var(--text-dim);
    opacity: 0.2;
    margin: 0 14px;
}

@keyframes ticker-scroll {
    0% { transform: translate3d(0, 0, 0); }
    100% { transform: translate3d(-50%, 0, 0); }
}

/* ---- Autoplay Overlay ---- */
.autoplay-overlay {
    position: fixed;
    inset: 0;
    background: rgba(9, 9, 11, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    cursor: pointer;
    transition: opacity 0.4s;
}

.autoplay-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.autoplay-prompt {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: 12px;
    letter-spacing: 2px;
    animation: autoplay-pulse 2s ease-in-out infinite;
}

@keyframes autoplay-pulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

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

@media (max-width: 380px) {
    .header { padding: 10px 12px; }
    .header-brand { font-size: 13px; }
    .header-clock { font-size: 11px; }
    .header-listeners { display: none; }
    .player-controls { padding: 12px 14px; gap: 14px; }
    .play-btn { width: 56px; height: 56px; }
    .play-btn svg { width: 24px; height: 24px; }
    .ticker-content { font-size: 12px; }
    .ticker-content .tk-sep { margin: 0 10px; }
    .footer-ticker { height: 34px; }
}

@media (min-width: 600px) {
    .header { padding: 14px 24px; }
    .header-brand { font-size: 17px; }
    .player-controls { padding: 20px 24px; gap: 24px; }
    .play-btn { width: 72px; height: 72px; }
    .play-btn svg { width: 32px; height: 32px; }
    .ticker-content { font-size: 17px; }
    .ticker-content .tk-sep { margin: 0 20px; }
    .footer-ticker { height: 48px; }
}

@media (min-width: 900px) {
    .terminal {
        max-width: 1200px;
        margin: 0 auto;
        border-left: 1px solid var(--border);
        border-right: 1px solid var(--border);
    }
    .header { padding: 14px 32px; }
    .header-brand { font-size: 18px; }
    .player-controls { padding: 24px 32px; }
    .play-btn { width: 80px; height: 80px; }
    .play-btn svg { width: 36px; height: 36px; }
    .play-spinner { width: 30px; height: 30px; }
    .ticker-content { font-size: 21px; }
    .ticker-content .tk-sep { margin: 0 28px; }
    .footer-ticker { height: 56px; }
}

@media (max-height: 500px) and (orientation: landscape) {
    .header { padding: 6px 16px; min-height: 36px; }
    .player-controls { padding: 8px 16px; gap: 16px; }
    .play-btn { width: 48px; height: 48px; }
    .play-btn svg { width: 22px; height: 22px; }
    .footer-ticker { height: 32px; }
    .ticker-content { font-size: 12px; }
}

/* ---- Info Popover (PWA install) ---- */

.header-info-wrap { position: relative; }

.header-btn {
  background: none; border: none; cursor: pointer; padding: 6px 8px;
  color: var(--text); border-radius: 6px; line-height: 0;
  opacity: 0.75;
  transition: opacity 0.2s, background 0.2s;
}
.header-btn:hover { opacity: 1; background: var(--bg-elevated); }

.info-popover {
  position: absolute; top: calc(100% + 10px); right: 0; z-index: 200;
  width: 360px; background: var(--bg-elevated);
  border: 1px solid var(--border); border-radius: 12px;
  padding: 0; overflow: hidden;
  opacity: 0; pointer-events: none; transform: translateY(-6px);
  transition: opacity 0.18s ease, transform 0.18s ease;
  box-shadow: 0 8px 24px rgba(0,0,0,0.35);
}
.info-popover.visible { opacity: 1; pointer-events: all; transform: translateY(0); }

.info-popover-title {
  font-size: 13px; font-weight: 700; letter-spacing: 0.06em;
  color: var(--text); padding: 16px 18px 6px;
  text-transform: uppercase;
}
.info-popover-desc {
  padding: 4px 18px 16px;
  font-size: 14px; color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  line-height: 1.55;
}
.info-platform {
  display: flex; flex-direction: column; gap: 4px;
  padding: 11px 18px; border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}
.info-platform strong { font-size: 15px; color: var(--text); }
.info-platform span   { font-size: 13px; color: var(--text-secondary); }
.info-platform.current { background: rgba(59,130,246,0.10); }

.info-eq-note {
  padding: 12px 18px; font-size: 13px; color: var(--text-secondary);
  background: rgba(239,68,68,0.08); line-height: 1.5;
}

@media (max-width: 599px) {
  .info-popover {
    position: fixed;
    top: 58px;
    left: 12px;
    right: 12px;
    width: auto;
  }
}
