/*
 * Styles for advertising: the ad card in feeds (components/feed-spot.js), the ad-blocker
 * screen, the advertiser's portal and campaign pages, the campaign report, the rate card, the
 * US map and the team's review desk. Loaded on every page by index.html.
 */

/* ---------- The ad itself (components/feed-spot.js) ---------- */

/* An ad card in a feed: the picture edge to edge across the card, then the
   words. Always marked "Ad". */
.spot {
  overflow: hidden;
  padding: 0;
}

.spot__link {
  display: grid;
  color: inherit;
}

/* The picture box takes its shape's proportions (ads.models.Shape) at the
   card's full width. The website shows wide and landscape; tall is the phone
   app's, and only shows here in the portal's preview. */
.spot__picture {
  position: relative;
  display: block;
  overflow: hidden;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: var(--surface-sunken);
}

.spot--tall .spot__picture {
  aspect-ratio: 9 / 16;
}

.spot--landscape .spot__picture {
  aspect-ratio: 4 / 3;
}

.spot__image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.spot__image--empty {
  display: grid;
  place-items: center;
  color: var(--ink-faint);
}

/* The "Ad" label, on the picture's corner. */
.spot__badge {
  position: absolute;
  top: 8px;
  left: 8px;
  padding: 2px 8px;
  border-radius: 6px;
  background: #ffd23f;
  color: #1c1300;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  line-height: 1.4;
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.3);
}

.spot__text {
  display: grid;
  gap: 3px;
  min-width: 0;
  padding: 12px 16px 14px;
}

.spot__headline {
  color: var(--ink);
  font-size: 1.05rem;
  line-height: 1.3;
}

.spot__body {
  color: var(--ink-soft);
  font-size: 0.92rem;
  line-height: 1.4;
}

.spot__domain {
  overflow: hidden;
  color: var(--ink-faint);
  font-size: 0.82rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.spot .spot__link:hover .spot__headline {
  text-decoration: underline;
}

/* In photo and video grids: a square tile like its neighbours, words over the picture. */
.spot--tile {
  position: relative;
  padding: 0;
  overflow: hidden;
  aspect-ratio: 1;
}

.spot--tile .spot__link {
  height: 100%;
}

/* Grids crop every shape square. */
.spot--tile .spot__picture {
  width: 100%;
  height: 100%;
  aspect-ratio: auto;
  border-radius: 0;
}

.spot--tile .spot__text {
  position: absolute;
  inset: auto 0 0;
  padding: 24px 10px 10px;
  background: linear-gradient(transparent, rgb(0 0 0 / 0.75));
}

.spot--tile .spot__headline {
  color: #fff;
  font-size: 0.9rem;
}

/* The corner "Ad" label stays; the rest of the small print doesn't fit a tile. */
.spot--tile .spot__body,
.spot--tile .spot__domain {
  display: none;
}

/* The screen that closes the site while an ad blocker stops our ads (feed-spot.js, lockSite). */
.gate {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgb(0 0 0 / 0.8);
}

.gate__box {
  display: grid;
  gap: 12px;
  max-width: 440px;
  padding: 24px;
}

.gate__box .btn {
  justify-self: start;
}

body.is-gated {
  overflow: hidden;
}

/* ---------- Portal ---------- */

.ad-rules {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
  padding: 0;
  list-style: none;
}

.ad-rules li {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 14px;
  border-radius: var(--radius-sm, 10px);
  background: var(--surface-muted);
  color: var(--ink-soft);
  font-size: 0.9rem;
  line-height: 1.4;
}

.ad-rules .icon {
  flex: none;
  margin-top: 1px;
  color: var(--accent-text);
}

.ad-list {
  display: grid;
}

/* A campaign in the portal's list. */
.ad-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 12px 0;
  border-top: 1px solid var(--line);
  color: inherit;
}

.ad-row:first-child {
  border-top: 0;
}

.ad-row:hover strong {
  text-decoration: underline;
}

.ad-row__image {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  object-fit: cover;
}

.ad-row__text {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.ad-status {
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--surface-sunken);
  color: var(--ink-soft);
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}

.ad-status--running,
.ad-status--scheduled,
.ad-status--approved {
  background: var(--success-soft);
  color: var(--success);
}

.ad-status--changes,
.ad-status--pay,
.ad-status--clearing,
.ad-status--review,
.ad-status--pending {
  background: var(--accent-soft);
  color: var(--ink);
}

.ad-status--rejected {
  background: var(--danger-soft);
  color: var(--danger);
}

.ad-note {
  padding: 12px 16px;
  border-radius: var(--radius-sm, 10px);
  background: var(--surface-muted);
  color: var(--ink-soft);
}

.ad-note--approved {
  background: var(--success-soft);
  color: var(--success);
}

.ad-note--rejected {
  background: var(--danger-soft);
  color: var(--danger);
}

/* ---------- Rate card ---------- */

.rate-card {
  display: grid;
  gap: 8px;
}

.rate-card h3 {
  font-size: 1rem;
}

.rate-card__table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.rate-card__table th,
.rate-card__table td {
  padding: 8px 6px;
  border-top: 1px solid var(--line);
  text-align: left;
}

.rate-card__table th {
  color: var(--ink-faint);
  font-size: 0.8rem;
  font-weight: 600;
}

.rate-card__table tr.is-full td {
  color: var(--ink-faint);
}

/* ---------- New campaign ---------- */

.ad-form__preview .spot {
  max-width: 340px;
}

/* A tall (phone app) ad, previewed at about a phone's width. */
.spot--preview.spot--tall {
  justify-self: center;
  width: min(100%, 320px);
}

.ad-flights {
  border: 0;
  padding: 0;
}

.ad-flights__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px;
}

/* One booked week (a flight) of a campaign. */
.ad-flight {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 8px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm, 10px);
  cursor: pointer;
}

.ad-flight .muted {
  grid-column: 2;
}

.ad-flight:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.ad-flight.is-full {
  cursor: not-allowed;
  opacity: 0.55;
}

.ad-flights__total {
  font-weight: 600;
}

/* ---------- One campaign ---------- */

.ad-detail {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
}

.ad-totals {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(84px, 1fr));
  gap: 8px;
}

.ad-total {
  display: grid;
  padding: 10px;
  border-radius: var(--radius-sm, 10px);
  background: var(--surface-muted);
}

.ad-total strong {
  font-size: 1.2rem;
}

.ad-total span {
  color: var(--ink-faint);
  font-size: 0.8rem;
}

/* ---------- The campaign report (components/ad-report.js) ---------- */

.report__totals {
  display: grid;
  gap: 8px;
}

.report__section {
  display: grid;
  gap: 10px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.report__head {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  align-items: center;
  justify-content: space-between;
}

.report__head h3 {
  font-size: 1rem;
}

.report__picker {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.report__chip {
  padding: 4px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: none;
  color: var(--ink-soft);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}

.report__chip.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--ink);
}

/* Day by day: one bar per day, scrolling sideways on a long campaign. */
.report__bars {
  display: flex;
  gap: 4px;
  align-items: flex-end;
  height: 160px;
  overflow-x: auto;
  padding-bottom: 22px;
}

.report__bar {
  position: relative;
  display: flex;
  flex: 1 0 18px;
  align-items: flex-end;
  height: 100%;
}

.report__bar-fill {
  width: 100%;
  min-height: 2px;
  border-radius: 4px 4px 0 0;
  background: var(--accent);
}

.report__bar-day {
  position: absolute;
  bottom: -20px;
  left: 50%;
  color: var(--ink-faint);
  font-size: 0.7rem;
  white-space: nowrap;
  transform: translateX(-50%);
}

/* Show every third day's date, so they don't run into each other. */
.report__bar:not(:nth-child(3n + 1)) .report__bar-day {
  display: none;
}

/* Where: the map, with each region's number beside it. */
.report__where {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(160px, 1fr);
  gap: 16px;
  align-items: center;
}

.report__legend {
  display: grid;
  gap: 8px;
  padding: 0;
  list-style: none;
}

.report__legend li {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
}

@media (max-width: 640px) {
  .report__where {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* When: a row of 24 hour cells for each weekday. */
.report__hours {
  display: grid;
  gap: 3px;
  overflow-x: auto;
}

.report__hours-row,
.report__hours-axis {
  display: grid;
  grid-template-columns: 36px repeat(24, minmax(12px, 1fr));
  gap: 3px;
  align-items: center;
}

.report__hours-day {
  color: var(--ink-faint);
  font-size: 0.75rem;
}

.report__hour {
  aspect-ratio: 1;
  border-radius: 3px;
  background: var(--surface-sunken);
}

.report__hours-axis span {
  grid-column: span 6;
  color: var(--ink-faint);
  font-size: 0.7rem;
}

.report__hours-axis span:first-child {
  grid-column: 2 / span 6;
}

/* How to count purchases: two snippets to copy. */
.report__setup summary {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  font-weight: 600;
  cursor: pointer;
}

.report__setup[open] {
  display: grid;
  gap: 10px;
}

.report__snippet {
  position: relative;
}

.report__snippet pre {
  margin: 0;
  padding: 12px;
  overflow-x: auto;
  border-radius: var(--radius-sm, 10px);
  background: var(--surface-sunken);
  font-size: 0.78rem;
  line-height: 1.5;
}

.report__snippet .btn {
  position: absolute;
  top: 6px;
  right: 6px;
}

/* ---------- The US map (components/us-map.js) ---------- */

.us-map {
  display: block;
  width: 100%;
  height: auto;
}

.us-map text {
  fill: #1c1c1c;
  font-size: 13px;
  font-weight: 600;
  pointer-events: none;
}

.ad-regions-map__swatch {
  flex: none;
  width: 12px;
  height: 12px;
  border-radius: 3px;
}

.ad-regions-map .report__legend {
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

.ad-regions-map .report__legend li {
  justify-content: flex-start;
}

.ad-edit__toggle summary {
  cursor: pointer;
  font-weight: 600;
}

.ad-edit {
  margin-top: 12px;
}

.ad-add-flight {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.ad-add-flight .input {
  flex: 1;
}

.ad-paid {
  display: inline-flex;
  gap: 6px;
  align-items: center;
}

.ad-cancel {
  justify-self: start;
}

.ad-decision textarea {
  width: 100%;
}

/* ---------- Messages ---------- */

.ad-thread {
  display: grid;
  gap: 10px;
}

/* One message between the advertiser and the review team. */
.ad-message {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 14px;
  background: var(--surface-muted);
}

.ad-message--mine {
  justify-self: end;
  background: var(--accent-soft);
}

.ad-message__meta {
  margin-bottom: 4px;
  color: var(--ink-faint);
  font-size: 0.8rem;
}

.ad-message__email {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  margin-left: 6px;
}

.ad-thread__composer {
  display: grid;
  gap: 8px;
  margin-top: 6px;
}

@media (max-width: 560px) {
  .ad-row {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .ad-row .ad-status {
    grid-column: 2;
    justify-self: start;
  }
}

/* ---------- Regions ---------- */

/* Five columns of prices don't fit a phone: let the table scroll sideways inside its card. */
.rate-card__scroll {
  overflow-x: auto;
}

.rate-card__scroll .rate-card__table {
  min-width: 560px;
}

.rate-card__table td.is-full {
  color: var(--ink-faint);
}

.rate-card__left {
  display: block;
  color: var(--ink-faint);
  font-size: 0.78rem;
}

.rate-card__credit {
  font-size: 0.8rem;
}

/* The price per 1,000 verified impressions, above the table. */
.rate-card__cpm {
  margin: 0 0 4px;
  font-size: 1.05rem;
}

.ad-regions {
  border: 0;
  padding: 0;
}

.ad-regions__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
}

.ad-region {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 8px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm, 10px);
  cursor: pointer;
}

.ad-region .muted {
  grid-column: 2;
  font-size: 0.8rem;
}

.ad-region:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
}

/* ---------- Choosing an ad shape (pages/advertise.js) ---------- */

.ad-shapes {
  margin: 0;
  padding: 0;
  border: 0;
}

.ad-shapes__grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.ad-shape {
  display: grid;
  justify-items: start;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.ad-shape:has(input:checked) {
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}

.ad-shape input {
  position: absolute;
  opacity: 0;
}

.ad-shape .muted {
  font-size: 0.85rem;
}

.ad-shape__downloads {
  color: var(--ink-faint);
  font-size: 0.85rem;
}

.ad-shape a {
  font-size: 0.85rem;
  font-weight: 600;
}

/* A small outline of the shape itself. */
.ad-shape__frame {
  height: 44px;
  margin-bottom: 4px;
  border: 2px solid var(--ink-faint);
  border-radius: 4px;
  background: var(--surface-sunken);
}

.ad-shape__frame--wide {
  aspect-ratio: 16 / 9;
}

.ad-shape__frame--tall {
  aspect-ratio: 9 / 16;
}

.ad-shape__frame--landscape {
  aspect-ratio: 4 / 3;
}

@media (max-width: 560px) {
  .ad-shapes__grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

.rate-card__terms {
  padding: 10px 14px;
  border-radius: var(--radius-sm, 10px);
  background: var(--surface-muted);
  color: var(--ink-soft);
  font-size: 0.9rem;
}

/* ---------- Waiting on the advertiser, and paying (pages/advertise.js) ---------- */

.ad-needs {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-sm, 10px);
  background: var(--accent-soft);
  list-style: none;
}

.ad-needs li {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
  align-items: center;
}

.ad-pay {
  border-color: var(--accent);
}

/* ---------- How pricing works (pages/ad-pricing.js) ---------- */

/* The page centres itself and breathes, so it also reads well to logged-out visitors with no app shell. */
.ad-pricing {
  width: 100%;
  max-width: 960px;
  margin-inline: auto;
  padding: 32px 20px 56px;
  gap: 20px;
}

.ad-pricing .page__header {
  flex-wrap: wrap;
  gap: 14px 20px;
  padding-bottom: 4px;
}

.ad-pricing .page__title {
  font-family: var(--font-serif);
  font-size: clamp(1.9rem, 4.5vw, 2.6rem);
  letter-spacing: -0.02em;
}

.ad-steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  padding: 0;
  list-style: none;
  counter-reset: step;
}

.ad-steps li {
  position: relative;
  display: grid;
  gap: 6px;
  align-content: start;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  color: var(--ink-soft);
  font-size: 0.9rem;
  line-height: 1.45;
  counter-increment: step;
}

/* A step number in the corner, so the five read as a path. */
.ad-steps li::after {
  content: counter(step);
  position: absolute;
  top: 14px;
  right: 14px;
  color: var(--ink-faint);
  font-family: var(--font-serif);
  font-size: 1.3rem;
  font-weight: 700;
  line-height: 1;
}

.ad-steps strong {
  color: var(--ink);
  font-size: 1rem;
}

.ad-steps .icon {
  box-sizing: content-box;
  padding: 8px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent-text);
}

.ad-pricing .settings__card {
  padding: 22px 24px;
}

.ad-pricing .settings__card > p {
  max-width: 68ch;
  line-height: 1.6;
}

.ad-pricing__formula {
  padding: 12px 14px;
  border-radius: var(--radius-sm, 10px);
  background: var(--surface-sunken);
  font-family: var(--font-mono, monospace);
  font-size: 0.9rem;
}

/* ---------- An agency's clients (pages/advertise.js) ---------- */

.ad-brands {
  display: grid;
  padding: 0;
  list-style: none;
}

.ad-brands__row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  align-items: center;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.ad-brands__row:first-child {
  border-top: 0;
}

.ad-brands__row .btn {
  margin-left: auto;
}

.ad-brands__add {
  margin-top: 8px;
}

/* ---------- Helpers on the admin page (pages/admin.js) ---------- */

.admin__powers {
  display: grid;
  gap: 6px;
  margin: 8px 0 12px;
}

.admin__power {
  display: flex;
  gap: 8px;
  align-items: center;
}
