/* ==========================================================================
   Ads. These deliberately break the design rules of style.css: they are loud,
   they blink, they are 1999. Paid ads are calmer and clearly labelled.
   Flashing stays at or below 2 per second, and stops for reduced-motion users.
   ========================================================================== */

@keyframes ad-blink   { 50% { visibility: hidden; } }
@keyframes ad-flash   { 0%, 49% { background: #ff00ff; color: #ffff00; } 50%, 100% { background: #00ffff; color: #ff0000; } }
@keyframes ad-border  { 0%, 49% { border-color: #ffff00; } 50%, 100% { border-color: #ff00ff; } }
@keyframes ad-rainbow { 0% { color: #ff3864; } 25% { color: #f7d51d; } 50% { color: #3bf07a; } 75% { color: #00ffff; } }
@keyframes ad-shake   { 0%, 100% { transform: translate(0, 0); } 25% { transform: translate(-2px, 1px); } 75% { transform: translate(2px, -1px); } }
@keyframes ad-scroll  { from { transform: translateX(0); } to { transform: translateX(-50%); } }

.blink { animation: ad-blink 1s steps(1) infinite; }

/* ---- ticker -------------------------------------------------------------- */

.ticker {
  overflow: hidden;
  background: #000;
  color: #3bf07a;
  border-bottom: 2px solid #3bf07a;
  font-family: var(--display);
  font-size: 11px;
  line-height: 2.4;
  white-space: nowrap;
}
.ticker-track { display: inline-block; animation: ad-scroll 40s linear infinite; }
.ticker-track span { padding-right: 4em; }

/* ---- placement ----------------------------------------------------------- */

.ad-top { max-width: 1000px; margin: calc(var(--px) * 4) auto 0; padding: 0 calc(var(--px) * 4); }
.ad-mid { margin: calc(var(--px) * 8) 0; }

.ad-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: calc(var(--px) * 4);
  margin-top: calc(var(--px) * 14);
}
.ad-sell { text-align: center; margin: calc(var(--px) * 3) 0 0; }

/* ---- the ad itself ------------------------------------------------------- */

.ad {
  position: relative;
  display: flex;
  align-items: center;
  gap: calc(var(--px) * 4);
  color: #000;
  border: var(--px) solid #ffff00;
  box-shadow: var(--shadow);
  overflow: hidden;
  text-decoration: none;
}
.ad:hover { text-decoration: none; filter: invert(1); }

.ad-label {
  position: absolute;
  top: 0;
  right: 0;
  background: #000;
  color: #fff;
  font-family: 'Courier New', monospace;
  font-size: 10px;
  line-height: 1;
  padding: 2px 4px;
}

.ad-banner { min-height: 90px; padding: calc(var(--px) * 3) calc(var(--px) * 5); }
.ad-box {
  flex-direction: column;
  justify-content: center;
  text-align: center;
  min-height: 220px;
  padding: calc(var(--px) * 5) calc(var(--px) * 3);
}

.ad-text { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.ad-kicker { font-family: var(--display); font-size: 11px; }
.ad-head { font-family: var(--display); font-size: clamp(13px, 2.4vw, 20px); line-height: 1.4; }
.ad-box .ad-head { font-size: 13px; }
.ad-body { font-size: 14px; }
.ad-icon { font-size: 48px; line-height: 1; animation: ad-shake 0.5s steps(2) infinite; }

.ad-cta {
  font-family: var(--display);
  font-size: 11px;
  background: #000;
  color: #ffff00;
  border: 2px solid currentColor;
  padding: calc(var(--px) * 2) calc(var(--px) * 3);
  white-space: nowrap;
  animation: ad-blink 1s steps(1) infinite;
}

/* ---- retro colour schemes ------------------------------------------------ */

.r-1 { animation: ad-flash 1s steps(1) infinite, ad-border 0.5s steps(1) infinite; }
.r-2 { background: repeating-linear-gradient(45deg, #ffcc00 0 16px, #000 16px 32px); border-color: #ffcc00; }
.r-2 .ad-text, .r-2 .ad-icon { background: #ffcc00; padding: var(--px) calc(var(--px) * 2); }
.r-3 { background: #ff0066; color: #fff; animation: ad-border 0.5s steps(1) infinite; }
.r-3 .ad-head { animation: ad-rainbow 2s steps(1) infinite; text-shadow: 2px 2px 0 #000; }
.r-4 { background: #fff; color: #0000ee; border-color: #ff0000; font-family: 'Times New Roman', serif; }
.r-4 .ad-kicker { color: #ff0000; }
.r-4 .ad-head { text-decoration: underline; }
.r-5 { background: #000; color: #3bf07a; border-style: dashed; animation: ad-border 0.5s steps(1) infinite; }
.r-5 .ad-head { animation: ad-rainbow 2s steps(1) infinite; }
.r-6 { background: #0000aa; color: #fff; border-color: #c0c0c0; }
.r-6 .ad-head { color: #ffff00; }
.r-6 .ad-cta { background: #c0c0c0; color: #000; border-color: #fff; }

/* ---- paid ---------------------------------------------------------------- */

.ad-paid { background: var(--panel); color: var(--ink); border: 2px solid var(--accent); }
.ad-paid .ad-head { color: var(--accent); }
.ad-paid:hover { filter: none; border-color: var(--ink); }
.ad-paid.ad-img { padding: 0; justify-content: center; background: #000; }
.ad-paid.ad-img img { display: block; width: 100%; height: auto; image-rendering: auto; }
.ad-banner.ad-img img { max-height: 180px; object-fit: contain; }

.ad-thumb { height: 28px; width: auto; vertical-align: middle; margin-right: var(--px); image-rendering: auto; }

@media (max-width: 600px) {
  .ad-banner { flex-wrap: wrap; }
  .ad-icon { font-size: 36px; }
}

@media (prefers-reduced-motion: reduce) {
  .blink, .ticker-track, .ad, .ad * { animation: none !important; }
}
