/* ynet tube trends — editorial "wire desk" look.
   Frank Ruhl Libre = newspaper headlines, Heebo = UI chrome. */

:root {
  --red: #de0000;
  --red-dark: #b00000;
  --red-deep: #8a0000;
  --ink: #191713;
  --muted: #6f6a62;
  --bg: #f6f4f0;
  --card: #ffffff;
  --line: #e6e2da;
  --gold-bg: #fff6dd;
  --gold-ink: #7a5a00;
  --font-display: "Frank Ruhl Libre", "Times New Roman", serif;
  --font-ui: "Heebo", "Segoe UI", sans-serif;
  --shadow: 0 1px 2px rgba(25, 23, 19, 0.06), 0 6px 18px rgba(25, 23, 19, 0.07);
  --shadow-hover: 0 2px 4px rgba(25, 23, 19, 0.08), 0 14px 34px rgba(25, 23, 19, 0.14);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-ui);
  color: var(--ink);
  background:
    radial-gradient(1200px 400px at 85% -50px, rgba(222, 0, 0, 0.05), transparent 60%),
    var(--bg);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ── masthead ─────────────────────────────────────────── */

.masthead {
  background: linear-gradient(105deg, var(--red) 0%, var(--red-dark) 55%, var(--red-deep) 100%);
  color: #fff;
  border-bottom: 4px solid var(--red-deep);
}

.masthead-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 18px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  background: #fff;
  color: var(--red);
  border-radius: 12px;
  font-size: 20px;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.12);
}

.brand-text h1 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(22px, 3.6vw, 30px);
  letter-spacing: 0.5px;
  line-height: 1;
  direction: ltr;
  text-align: right;
}

.brand-text h1 em { font-style: normal; opacity: 0.75; }

.brand-text p {
  margin: 4px 0 0;
  font-size: 13px;
  opacity: 0.9;
}

.masthead-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.updated-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(0, 0, 0, 0.22);
  border-radius: 99px;
  padding: 6px 14px;
  font-size: 13px;
}

.updated-chip.is-stale { background: var(--gold-bg); color: var(--gold-ink); }

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #7dff9b;
  animation: pulse 2.2s ease-in-out infinite;
}

.updated-chip.is-stale .live-dot { background: #d9a400; }

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(125, 255, 155, 0.6); }
  50% { box-shadow: 0 0 0 5px rgba(125, 255, 155, 0); }
}

.btn-ghost {
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 500;
  color: #fff;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 9px;
  padding: 7px 14px;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}

.btn-ghost:hover { background: rgba(255, 255, 255, 0.14); }
.btn-ghost:active { transform: scale(0.97); }

.refresh-icon { display: inline-block; }

.btn-ghost.is-loading .refresh-icon { animation: spin 0.9s linear infinite; }

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

/* ── controls ─────────────────────────────────────────── */

.controls {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.controls-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.region-toggle {
  display: inline-flex;
  flex-shrink: 0;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 3px;
  gap: 3px;
}

.region-btn {
  font-family: var(--font-ui);
  font-size: 13.5px;
  font-weight: 500;
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 8px;
  padding: 6px 13px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.region-btn.active {
  background: var(--ink);
  color: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

.tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 2px;
}

.tabs::-webkit-scrollbar { display: none; }

.tab {
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 99px;
  padding: 7px 16px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.tab:hover { border-color: var(--red); color: var(--red); }

.tab.active {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
  box-shadow: 0 3px 10px rgba(222, 0, 0, 0.3);
}

/* ── stale banner ─────────────────────────────────────── */

.stale-banner {
  background: var(--gold-bg);
  color: var(--gold-ink);
  border-bottom: 1px solid #ecd9a0;
  text-align: center;
  font-size: 13.5px;
  padding: 8px 16px;
}

/* ── board & cards ────────────────────────────────────── */

.board {
  flex: 1;
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 22px 20px 40px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(255px, 1fr));
  gap: 18px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  opacity: 0;
  transform: translateY(14px);
  animation: reveal 0.45s ease forwards;
  animation-delay: calc(var(--i, 0) * 45ms);
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}

@keyframes reveal { to { opacity: 1; transform: none; } }

.card:hover { box-shadow: var(--shadow-hover); transform: translateY(-3px); }

.thumb {
  position: relative;
  display: block;
  aspect-ratio: 16 / 9;
  background: #dcd8d0;
  overflow: hidden;
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.35s ease;
}

.card:hover .thumb img { transform: scale(1.045); }

.rank {
  position: absolute;
  top: 0;
  inset-inline-start: 0;
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 17px;
  line-height: 1;
  color: #fff;
  background: rgba(15, 13, 10, 0.82);
  padding: 7px 11px 8px;
  border-end-end-radius: 12px;
}

.card:nth-child(-n+3) .rank { background: var(--red); }

.dur {
  position: absolute;
  bottom: 8px;
  inset-inline-end: 8px;
  background: rgba(15, 13, 10, 0.82);
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  border-radius: 6px;
  padding: 2px 7px;
}

.flame {
  position: absolute;
  top: 8px;
  inset-inline-end: 8px;
  font-size: 19px;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.45));
  animation: flicker 1.6s ease-in-out infinite;
}

@keyframes flicker {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.18) rotate(-4deg); }
}

.card-body {
  padding: 13px 15px 15px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.card-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 17px;
  line-height: 1.32;
  color: var(--ink);
  text-decoration: none;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  transition: color 0.15s ease;
}

.card-title:hover { color: var(--red); }

.card-src {
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 12px;
  font-size: 12.5px;
  color: var(--muted);
  margin-top: auto;
}

.velocity {
  color: var(--red);
  font-weight: 700;
  font-size: 13.5px;
}

.copy-btn {
  font-family: var(--font-ui);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink);
  background: transparent;
  border: 1px dashed var(--line);
  border-radius: 9px;
  padding: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.copy-btn:hover { border-color: var(--red); color: var(--red); border-style: solid; }

.copy-btn.copied {
  border-style: solid;
  border-color: #1a9a4c;
  color: #1a9a4c;
  background: #f0faf4;
}

/* ── skeletons ────────────────────────────────────────── */

.skeleton {
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--card);
  overflow: hidden;
}

.skeleton .sk-thumb { aspect-ratio: 16 / 9; }

.skeleton .sk-line { height: 13px; border-radius: 6px; margin: 12px 15px; }

.skeleton .sk-line.short { width: 55%; }

.sk-shimmer {
  background: linear-gradient(100deg, #ece9e3 40%, #f8f6f2 50%, #ece9e3 60%);
  background-size: 200% 100%;
  animation: shimmer 1.3s linear infinite;
}

@keyframes shimmer { to { background-position: -200% 0; } }

/* ── states & footer ──────────────────────────────────── */

.state-box {
  text-align: center;
  padding: 70px 20px;
  color: var(--muted);
  font-size: 15px;
}

.state-emoji { font-size: 44px; margin-bottom: 10px; }

.btn-solid {
  font-family: var(--font-ui);
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  background: var(--red);
  border: 0;
  border-radius: 10px;
  padding: 11px 26px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(222, 0, 0, 0.35);
  transition: background 0.15s ease, transform 0.1s ease;
}

.btn-solid:hover { background: var(--red-dark); }
.btn-solid:active { transform: scale(0.97); }

.footer {
  border-top: 1px solid var(--line);
  padding: 16px 20px 22px;
  text-align: center;
  font-size: 12.5px;
  color: var(--muted);
}

.footer a { color: var(--red); text-decoration: none; font-weight: 500; }

/* ── auth modal ───────────────────────────────────────── */

.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(25, 10, 8, 0.55);
  backdrop-filter: blur(6px);
}

.auth-overlay[hidden] { display: none; }

.auth-card {
  width: 100%;
  max-width: 380px;
  background: #fff;
  border-radius: 16px;
  padding: 0 26px 24px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.35);
  text-align: center;
  animation: authIn 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}

@keyframes authIn {
  from { opacity: 0; transform: translateY(22px) scale(0.96); }
}

.auth-band {
  height: 7px;
  background: linear-gradient(90deg, var(--red), var(--red-deep));
  border-radius: 0 0 6px 6px;
  margin: 0 -26px 20px;
}

.auth-card h2 {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 26px;
  margin: 0 0 4px;
}

.auth-sub { margin: 0 0 20px; font-size: 13.5px; color: var(--muted); }

.auth-label {
  display: block;
  text-align: start;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 6px;
}

#auth-input {
  width: 100%;
  font-family: var(--font-ui);
  font-size: 15px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  padding: 11px 13px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

#auth-input:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(222, 0, 0, 0.12);
}

.auth-error { color: var(--red); font-size: 13px; margin: 10px 0 0; }

.auth-submit { width: 100%; margin-top: 16px; }

.auth-hint { margin: 14px 0 0; font-size: 12px; color: var(--muted); line-height: 1.5; }

/* ── responsive ───────────────────────────────────────── */

@media (max-width: 640px) {
  .masthead-inner { padding: 14px 14px; }
  .brand-text p { display: none; }
  .controls-inner { flex-direction: column; align-items: stretch; gap: 8px; padding: 8px 14px; }
  .region-toggle { align-self: center; }
  .tabs { justify-content: flex-start; }
  .board { padding: 16px 14px 30px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
  .card-title { font-size: 15px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .card { opacity: 1; transform: none; }
}
