/* ==========================================================================
   VotingSite · discovery layer: rails, cards, favourites, share bar, ads.
   Loaded after style.css and reusing its tokens (--bg, --panel, --border,
   --text, --muted, --accent, --gold, --cyan, --r, --gap). Mobile-first.
   Nothing here loads a font or an image, and every box that can be filled
   asynchronously (ads, banners) has its size reserved up front.
   ========================================================================== */

/* ------------------------------------------------------------------ rails */
.rail { margin: 0 0 var(--gap); }

.rail-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.rail-head .card-title { margin: 0; border: 0; padding: 0; flex: 1 1 auto; }

.rail-tools { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.rail-cta { font-size: .85rem; font-weight: 600; white-space: nowrap; }

.rail-arrow {
  width: 30px; height: 30px;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  line-height: 1;
  color: var(--muted);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 50%;
  cursor: pointer;
}
.rail-arrow:hover:not(:disabled) { color: var(--text); border-color: var(--muted); }
.rail-arrow:disabled { opacity: .35; cursor: default; }
.rail.has-overflow .rail-arrow { display: inline-flex; }

/* The track itself: snap-scrolling strip with fades at both edges. */
.rail-track {
  display: flex;
  gap: var(--gap);
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  padding: 2px 2px 10px;
  margin: -2px -2px 0;
  /* Edge fades · masked, so they work on any background/theme. */
  -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 14px, #000 calc(100% - 14px), transparent 100%);
  mask-image: linear-gradient(90deg, transparent 0, #000 14px, #000 calc(100% - 14px), transparent 100%);
}
.rail:not(.has-overflow) .rail-track { -webkit-mask-image: none; mask-image: none; }
.rail-track::-webkit-scrollbar { height: 8px; }
.rail-track::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }
.rail-item { scroll-snap-align: start; flex: 0 0 min(84vw, 300px); }

@media (prefers-reduced-motion: reduce) {
  .rail-track { scroll-behavior: auto; }
}

/* ------------------------------------------------------------------ cards */
.dcard {
  display: flex;
  flex-direction: column;
  gap: 10px;
  height: 100%;
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--shadow-sm);
}
.dcard.tier-1 { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
.dcard.tier-2 { border-color: color-mix(in srgb, var(--gold) 45%, var(--border)); }
.dcard.tier-3 { border-color: color-mix(in srgb, var(--cyan) 45%, var(--border)); }

.dcard-banner {
  height: 46px;
  margin: -14px -14px 0;
  border-radius: var(--r) var(--r) 0 0;
  overflow: hidden;
  background: var(--panel-2);
}
.dcard-banner img { width: 100%; height: 100%; object-fit: cover; }

.dcard-head { display: flex; align-items: flex-start; gap: 10px; min-width: 0; }
.dcard-head .srv-icon { width: 44px; height: 44px; flex: 0 0 44px; }
.dcard-id { min-width: 0; flex: 1 1 auto; }
.dcard-id .srv-name { font-size: .98rem; margin-bottom: 2px; }

.dcard-sub {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: .75rem;
  line-height: 1.4;
}
.dcard-rank {
  font-family: var(--font-display);
  font-size: .78rem;
  color: var(--muted);
}

.dcard-reason {
  margin: 0;
  font-size: .78rem;
  font-weight: 600;
  color: var(--accent);
  overflow-wrap: anywhere;
}
.dcard-desc {
  margin: 0;
  font-size: .82rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.dcard-stats {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: .82rem;
}
.dcard-votes { white-space: nowrap; color: var(--muted); }
.dcard-votes b { color: var(--accent); font-family: var(--font-display); font-size: 1rem; }

.dcard-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: auto;
}
.dcard-actions .srv-ip { margin: 0; flex: 1 1 auto; text-align: left; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dcard-actions .srv-ip.copied { color: var(--accent); border-color: var(--accent); }

.btn-sm { padding: 8px 14px; font-size: .8rem; letter-spacing: .3px; }
.dcard .btn-vote.btn-sm { box-shadow: 0 2px 0 color-mix(in srgb, var(--accent) 45%, #000); }

/* ------------------------------------------------------------ status chip */
.status-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  font-variant-numeric: tabular-nums;
  min-width: 0;
}
.status-chip b { font-weight: 700; }
.chip-lat {
  font-size: .72rem;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
}
.chip-age { font-size: .7rem; white-space: nowrap; }
.dcard .chip-age { display: none; }          /* too noisy inside a card */

/* ---------------------------------------------------------------- ratings */
.rating-stars { display: inline-flex; align-items: center; gap: 6px; font-size: .85rem; }
.rating-stars .stars { color: var(--gold); letter-spacing: 1px; }
.rating-num { font-weight: 700; }

/* -------------------------------------------------------------- favourite */
.fav-form { margin: 0; flex: 0 0 auto; }
.fav-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: 600 .78rem/1 var(--font);
  color: var(--muted);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 7px 10px;
  cursor: pointer;
  transition: color .15s ease, border-color .15s ease, background .15s ease;
}
.fav-btn:hover { color: var(--text); border-color: var(--muted); }
.fav-btn .fav-icon { font-size: .95rem; line-height: 1; }
.fav-btn.is-fav {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 55%, transparent);
  background: color-mix(in srgb, var(--danger) 12%, transparent);
}
.fav-btn.is-busy { opacity: .6; }
.fav-btn.is-failed { border-color: var(--danger); }
.dcard .fav-btn .fav-label { display: none; }         /* icon only in a card */

@media (prefers-reduced-motion: no-preference) {
  .fav-btn.is-fav .fav-icon { animation: fav-pop .25s ease; }
}
@keyframes fav-pop { 0% { transform: scale(.6); } 60% { transform: scale(1.25); } 100% { transform: scale(1); } }

/* -------------------------------------------------------------- share bar */
.share-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  /* Had no bottom padding, so the stat row sat flush against the share buttons. */
  padding: 10px 0 16px;
}
.share-label { font-size: .78rem; text-transform: uppercase; letter-spacing: .6px; margin-right: 2px; }
.share-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font: 600 .78rem/1 var(--font);
  color: var(--muted);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 8px 10px;
  cursor: pointer;
  white-space: nowrap;
}
.share-btn:hover { color: var(--text); border-color: var(--muted); text-decoration: none; }
.share-btn.copied { color: var(--accent); border-color: var(--accent); }
.share-bedrock { color: var(--cyan); border-color: color-mix(in srgb, var(--cyan) 45%, var(--border)); }

/* ------------------------------------------------------------- ad slots --
   The box is sized from --ad-w/--ad-h before anything loads, so an ad tag
   dropping in later cannot shift the page. */
.ad-slot {
  display: block;
  margin: 0 auto var(--gap);
  max-width: 100%;
  width: var(--ad-w, 300px);
}
.ad-tag {
  display: block;
  font-size: .62rem;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--muted);
  margin-bottom: 3px;
}
.ad-box {
  position: relative;
  height: var(--ad-h, 250px);
  max-width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: var(--panel);
  border: 1px dashed var(--border);
  border-radius: var(--r);
}
.ad-empty { font-size: .75rem; letter-spacing: .5px; }
.ad-house { display: block; width: 100%; height: 100%; }
.ad-house img { width: 100%; height: 100%; object-fit: contain; }
.ad-house span {
  position: absolute;
  inset: auto 0 0 0;
  padding: 6px 8px;
  font-size: .78rem;
  color: var(--text);
  background: color-mix(in srgb, var(--bg) 70%, transparent);
}
/* A leaderboard cannot fit on a phone · collapse it to the mobile banner box. */
@media (max-width: 760px) {
  .ad-slot[data-size="leaderboard"] { width: 320px; }
  .ad-slot[data-size="leaderboard"] .ad-box { height: 50px; }
  .ad-slot[data-size="half-page"] { width: 300px; }
  .ad-slot[data-size="half-page"] .ad-box { height: 250px; }
}

/* ------------------------------------------------------------ light theme */
html[data-theme="light"] .dcard { box-shadow: var(--shadow-sm); }
html[data-theme="light"] .rail-arrow,
html[data-theme="light"] .share-btn,
html[data-theme="light"] .fav-btn { background: var(--bg-elev); }
html[data-theme="light"] .ad-box { background: var(--panel-2); }

/* --------------------------------------------------------------- desktop  */
@media (min-width: 720px) {
  .rail-item { flex-basis: 300px; }
  .dcard .chip-age { display: inline; }
}

/* ==========================================================================
   Events calendar (/events) and the owner's scheduling form
   --------------------------------------------------------------------------
   Added with src/views/events.js. Appended as one block so a concurrent edit
   elsewhere in this file cannot collide with it.
   ========================================================================== */
.ev-hero { padding: 24px 0 8px; }
.ev-hero h1 { margin: 0 0 6px; }
.ev-hero p { color: var(--muted); max-width: 62ch; margin: 0; }

/* The site-event notice. Loud on purpose: it is the one thing on the page that
   changes what a vote is worth, so it must not read as decoration. */
.ev-banner {
  margin: 16px 0;
  padding: 14px 16px;
  border: 1px solid var(--gold);
  border-left-width: 4px;
  border-radius: var(--r);
  background: color-mix(in srgb, var(--gold) 12%, var(--panel));
  color: var(--text);
  line-height: 1.5;
}

.ev-section { margin: 28px 0; }
.ev-section-title { margin: 0 0 2px; font-family: var(--font-display); font-size: 1.15rem; }
.ev-section-blurb { margin: 0 0 12px; color: var(--muted); font-size: .9rem; }
.ev-empty { color: var(--muted); font-style: italic; margin: 0; }

.ev-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
@media (min-width: 860px) {
  .ev-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.ev-card {
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--panel);
  padding: 14px 16px;
}
.ev-card.is-live { border-color: var(--accent); }
.ev-card.is-site { border-left: 4px solid var(--gold); }

.ev-card-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; }
.ev-title { margin: 0; font-size: 1rem; }

.ev-live {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
}

.ev-mult {
  font-size: .75rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid var(--gold);
  color: var(--gold);
  cursor: help;
}

.ev-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin-top: 6px;
  font-size: .85rem;
  color: var(--muted);
}
.ev-scope { color: var(--text); text-decoration: none; }
.ev-scope:hover { text-decoration: underline; }
.ev-scope-site { color: var(--gold); font-weight: 600; }

.ev-body { margin: 10px 0 0; color: var(--muted); line-height: 1.5; }
.ev-go { margin-top: 12px; }

.ev-howto { margin-top: 32px; }

/* Owner / admin scheduling forms and their booked lists. */
.ev-admin { margin-top: 28px; border-left: 3px solid var(--gold); }
.ev-warning {
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--panel-2);
  padding: 10px 12px;
  color: var(--muted);
  font-size: .88rem;
  line-height: 1.5;
}

.ev-owner-list { list-style: none; margin: 16px 0 0; padding: 0; }
.ev-owner-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-top: 1px solid var(--border-soft);
}
.ev-owner-when { color: var(--muted); font-size: .84rem; font-variant-numeric: tabular-nums; }
.ev-owner-list form.inline { margin: 0 0 0 auto; }
.btn-sm { padding: 3px 9px; font-size: .8rem; }

html[data-theme="light"] .ev-card { box-shadow: var(--shadow-sm); }
