/* =========================================================
   Charty — design tokens
   ========================================================= */
:root{
  --bg: #0A0A0F;
  --surface: #131319;
  --surface-2: #1B1B24;
  --surface-3: #232330;
  --border: rgba(255,255,255,0.09);
  --border-strong: rgba(255,255,255,0.16);
  --text: #F4F4EF;
  --muted: #93939F;
  --muted-2: #5F5F6B;
  --accent: #D4FF3F;      /* chart-topping lime */
  --accent-ink: #0A0A0F;  /* text on accent */
  --accent-2: #FF4470;    /* now-playing coral */
  --accent-2-soft: rgba(255,68,112,0.14);
  --accent-soft: rgba(212,255,63,0.12);

  --font-display: 'Space Grotesk', 'Rubik', sans-serif;
  --font-body: 'Inter', 'Rubik', sans-serif;
  --font-heb: 'Rubik', 'Inter', sans-serif;

  --radius: 14px;
  --radius-sm: 8px;
  --header-h: 68px;
}

*{ box-sizing: border-box; }
html, body{ height: 100%; }
body{
  margin:0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  line-height: 1.45;
}
a{ color: inherit; text-decoration: none; }
button{ font-family: inherit; }
ol, ul{ margin:0; padding:0; list-style:none; }
h1,h2,h3{ font-family: var(--font-display); margin:0; letter-spacing: -0.01em; }

:focus-visible{ outline: 2px solid var(--accent); outline-offset: 2px; }

::selection{ background: var(--accent); color: var(--accent-ink); }

/* subtle grain so the near-black doesn't feel flat */
.noise-overlay{
  position: fixed; inset:0; pointer-events:none; z-index: 999;
  opacity: 0.035; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* =========================================================
   Header
   ========================================================= */
.site-header{
  position: sticky; top:0; z-index: 50;
  height: var(--header-h);
  background: rgba(10,10,15,0.82);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.header-inner{
  max-width: 1240px; margin: 0 auto; height:100%;
  display:flex; align-items:center; gap: 28px;
  padding: 0 20px;
}
.logo{ display:flex; align-items:center; gap:10px; margin-inline-end: auto; }
.logo-bars{ display:inline-flex; align-items:flex-end; gap:3px; height:22px; }
.logo-bars .bar{
  width:4px; border-radius: 2px;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  animation: eqPulse 1.1s ease-in-out infinite;
}
.logo-bars .b1{ height:40%; animation-delay: -0.9s; }
.logo-bars .b2{ height:100%; animation-delay: -0.4s; }
.logo-bars .b3{ height:65%; animation-delay: -1.2s; }
.logo-bars .b4{ height:80%; animation-delay: -0.1s; }
@keyframes eqPulse{
  0%, 100%{ transform: scaleY(0.4); }
  50%{ transform: scaleY(1); }
}
@media (prefers-reduced-motion: reduce){
  .logo-bars .bar{ animation: none; }
}
.logo-word{
  font-family: var(--font-display); font-weight:700; font-size: 22px;
  letter-spacing: -0.02em;
}

.main-nav{ display:flex; gap: 26px; }
.nav-link{
  font-size: 14px; font-weight:600; color: var(--muted);
  padding: 6px 2px; position:relative;
  transition: color .15s ease;
}
.nav-link:hover{ color: var(--text); }
.nav-link.active{ color: var(--text); }
.nav-link.active::after{
  content:""; position:absolute; left:0; right:0; bottom:-9px; height:2px;
  background: var(--accent); border-radius: 2px;
}

.header-actions{ display:flex; align-items:center; gap: 10px; }
.icon-btn{
  display:none; width: 36px; height:36px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text); align-items:center; justify-content:center; cursor:pointer;
}
.lang-toggle{
  border: 1px solid var(--border-strong); background: transparent; color: var(--text);
  border-radius: 999px; padding: 7px 13px; font-size:12px; font-weight:700;
  letter-spacing: .04em; cursor:pointer; transition: all .15s ease;
}
.lang-toggle:hover{ border-color: var(--accent); color: var(--accent); }

/* =========================================================
   Ticker
   ========================================================= */
.ticker{
  overflow:hidden; border-bottom: 1px solid var(--border);
  background: var(--surface); white-space: nowrap;
}
.ticker-track{
  display:inline-flex; gap: 48px; padding: 8px 0;
  animation: tickerScroll 28s linear infinite;
  font-family: var(--font-display); font-size: 12px; font-weight: 600;
  color: var(--muted); letter-spacing: .04em; text-transform: uppercase;
}
.ticker-track span{ color: var(--accent); margin-inline-end: 8px; }
@keyframes tickerScroll{
  from{ transform: translateX(0); }
  to{ transform: translateX(-50%); }
}
@media (prefers-reduced-motion: reduce){
  .ticker-track{ animation: none; }
}

/* =========================================================
   Chart tab selector
   ========================================================= */
.chart-select{
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255,255,255,0.02), transparent);
}
.chart-select-inner{ max-width: 1240px; margin:0 auto; padding: 18px 20px; }
.chart-tabs{
  display:flex; gap:10px; overflow-x:auto; scrollbar-width:none;
  padding-bottom: 2px;
}
.chart-tabs::-webkit-scrollbar{ display:none; }
.chart-tab{
  flex: 0 0 auto; cursor:pointer; border:1px solid var(--border);
  background: var(--surface); border-radius: 999px; padding: 10px 18px;
  display:flex; flex-direction:column; gap:2px; min-width: 150px;
  transition: border-color .15s ease, background .15s ease, transform .15s ease;
}
.chart-tab:hover{ border-color: var(--border-strong); transform: translateY(-1px); }
.chart-tab.is-active{
  background: var(--accent); border-color: var(--accent); color: var(--accent-ink);
}
.chart-tab .t-name{ font-weight:700; font-size: 13.5px; }
.chart-tab .t-date{ font-size: 11px; opacity:.65; }

/* =========================================================
   Board layout
   ========================================================= */
.board{
  max-width: 1240px; margin: 0 auto; padding: 32px 20px 80px;
  display:grid; grid-template-columns: 1fr 360px; gap: 32px;
  align-items:start;
}
.song-col-head{
  display:flex; align-items:baseline; justify-content:space-between;
  gap: 12px; margin-bottom: 18px; flex-wrap:wrap;
}
.song-col-head h1{ font-size: clamp(24px, 3vw, 34px); }
.updated-date{ color: var(--muted); font-size: 13px; font-weight:600; }

.loading{ display:flex; flex-direction:column; align-items:center; gap:16px; padding: 60px 0; color: var(--muted); }
.eq-loader{ display:flex; align-items:flex-end; gap:5px; height:32px; }
.eq-loader span{
  width:6px; background: var(--accent); border-radius:3px;
  animation: eqPulse 1s ease-in-out infinite;
}
.eq-loader span:nth-child(1){ height:40%; animation-delay:-0.8s; }
.eq-loader span:nth-child(2){ height:90%; animation-delay:-0.6s; }
.eq-loader span:nth-child(3){ height:60%; animation-delay:-0.4s; }
.eq-loader span:nth-child(4){ height:100%; animation-delay:-0.2s; }
.eq-loader span:nth-child(5){ height:55%; animation-delay:0s; }

.track-list{ display:flex; flex-direction:column; }
.track-row{
  display:grid; grid-template-columns: 52px 1fr auto; align-items:center;
  gap: 14px; padding: 13px 10px; border-bottom: 1px solid var(--border);
  border-radius: var(--radius-sm); transition: background .12s ease;
}
.track-row:hover{ background: var(--surface); }
.track-row.is-playing{ background: var(--accent-2-soft); }
.rank{
  font-family: var(--font-display); font-weight:700; font-size: 20px;
  color: var(--muted-2); text-align:center; font-variant-numeric: tabular-nums;
}
.track-row.is-playing .rank{ color: var(--accent-2); }
.track-row:nth-child(1) .rank, .track-row:nth-child(2) .rank, .track-row:nth-child(3) .rank{
  color: var(--accent);
}
.track-title{
  font-weight:600; font-size:15px; background:none; border:none; color: var(--text);
  text-align: start; cursor:pointer; padding: 4px 0; line-height:1.35;
}
.track-title:hover{ color: var(--accent); }
.track-actions{ display:flex; gap: 6px; }
.mini-btn{
  width:34px; height:34px; border-radius:999px; border:1px solid var(--border);
  background: var(--surface); color: var(--muted); cursor:pointer;
  display:flex; align-items:center; justify-content:center;
  transition: all .15s ease;
}
.mini-btn:hover{ border-color: var(--accent); color: var(--accent); }
.mini-btn.play-btn.is-active{ background: var(--accent-2); border-color: var(--accent-2); color: #fff; }
.mini-btn svg{ width:15px; height:15px; }
.no-video{ opacity:.35; cursor:not-allowed; }
.no-video:hover{ border-color: var(--border); color: var(--muted); }

/* =========================================================
   Side column: player + search
   ========================================================= */
.side-col{ display:flex; flex-direction:column; gap: 18px; position: sticky; top: calc(var(--header-h) + 16px); }
.panel{
  background: var(--surface); border:1px solid var(--border);
  border-radius: var(--radius); padding: 18px;
}
.panel-label{
  font-family: var(--font-display); font-weight:700; font-size:12px;
  letter-spacing: .08em; text-transform:uppercase; color: var(--accent);
  margin-bottom: 12px;
}
.panel-sub{ color: var(--muted); font-size: 13px; margin: 0 0 14px; }

.player-shell{
  position:relative; width:100%; aspect-ratio: 16/9;
  background: var(--surface-2); border-radius: var(--radius-sm); overflow:hidden;
}
.player-empty{
  position:absolute; inset:0; display:flex; flex-direction:column; align-items:center;
  justify-content:center; gap:14px; color: var(--muted-2); text-align:center; padding: 20px;
  font-size: 13px;
}
.player-mount{ position:absolute; inset:0; }
.player-mount iframe{ width:100%; height:100%; border:0; }
.player-meta{ margin-top: 14px; }
.player-track-title{ font-weight:700; font-size: 14px; margin-bottom: 12px; }
.player-controls{ display:flex; gap:8px; }
.btn{
  border-radius: 999px; padding: 9px 14px; font-size:12.5px; font-weight:700;
  cursor:pointer; border:1px solid var(--border-strong); background:transparent; color: var(--text);
  transition: all .15s ease;
}
.btn-ghost:hover{ border-color: var(--accent); color: var(--accent); }
.btn-primary{ background: var(--accent); color: var(--accent-ink); border-color: var(--accent); display:inline-block; }
.btn-primary:hover{ filter: brightness(1.08); }

.mini-link{ color: var(--muted); text-decoration: underline; text-underline-offset: 2px; }
.mini-link:hover{ color: var(--accent); }

.gcse-wrap{ min-height: 44px; }
.gcse-config-note{
  margin-top: 12px; font-size: 11.5px; color: var(--muted-2);
  border-top: 1px dashed var(--border); padding-top: 10px; display:none;
}
.gcse-config-note code{ background: var(--surface-3); padding:1px 5px; border-radius:4px; }
body.gcse-unconfigured .gcse-config-note{ display:block; }

/* Google's injected CSE box: retint minimally to fit the dark theme */
.gsc-control-cse{ background: transparent !important; border:0 !important; padding:0 !important; font-family: var(--font-body) !important; }
.gsc-input-box{ background: var(--surface-2) !important; border: 1px solid var(--border-strong) !important; border-radius: 999px !important; }
input.gsc-input{ color: var(--text) !important; background: transparent !important; }
.gsc-search-button-v2{ border-radius: 999px !important; background: var(--accent) !important; border-color: var(--accent) !important; }
.gsc-search-button-v2 svg{ fill: var(--accent-ink) !important; }

/* =========================================================
   About view
   ========================================================= */
.about-view{ max-width: 720px; margin: 0 auto; padding: 72px 20px 100px; }
.about-view h1{ font-size: clamp(28px, 4vw, 42px); margin-bottom: 22px; }
.about-view p{ color: var(--muted); font-size: 16px; margin-bottom: 18px; }
.about-view .btn-primary{ margin-top: 12px; }

/* =========================================================
   Footer
   ========================================================= */
.site-footer{
  text-align:center; padding: 28px 20px 40px; color: var(--muted-2); font-size: 12.5px;
  border-top: 1px solid var(--border);
}
.footer-link{ color: var(--muted-2); text-decoration: underline; text-underline-offset: 2px; }
.footer-link:hover{ color: var(--accent); }

.ad-panel{ min-height: 90px; }
.ad-panel .adsbygoogle{ display: block; width: 100%; }
.ad-panel-infeed{ margin-top: 18px; padding: 12px; }

/* Install button (shown only once the browser fires beforeinstallprompt) */
.btn-install{
  background: var(--accent); color: var(--accent-ink); border: none;
  border-radius: 999px; padding: 8px 16px; font-weight:700; font-size: 13px;
  cursor: pointer;
}
.btn-install:hover{ filter: brightness(1.08); }

/* Respect device notches / home-indicator area when installed as an app */
.site-header{ padding-top: env(safe-area-inset-top); height: calc(var(--header-h) + env(safe-area-inset-top)); }
.site-footer{ padding-bottom: calc(16px + env(safe-area-inset-bottom)); }

/* =========================================================
   RTL / Hebrew
   ========================================================= */
html[dir="rtl"] body{ font-family: var(--font-heb); }
html[dir="rtl"] .track-title, html[dir="rtl"] h1, html[dir="rtl"] h2{ font-family: var(--font-heb); }

/* =========================================================
   Responsive
   ========================================================= */
@media (max-width: 900px){
  .board{ grid-template-columns: 1fr; }
  /* Track list first on mobile — the ad/player/search stack follows,
     instead of pushing the actual chart below the fold. */
  .side-col{ position: static; }
  .icon-btn{ display:inline-flex; }
}
@media (max-width: 560px){
  .main-nav{ display:none; }
  .header-inner{ gap: 12px; }
  .chart-tab{ min-width: 130px; padding: 9px 14px; }
  .track-row{ grid-template-columns: 38px 1fr auto; gap:10px; }
  .rank{ font-size:16px; }
}
