/* ============================================
   Scradvertise
   Simple, warm, readable. Pixel wordmark + one accent.
   ============================================ */

:root {
  --bg:          #f7f1e4;
  --panel:       #fffaf1;
  --panel-2:     #efe5d2;
  --text:        #241f2e;
  --text-dim:    #6f6478;
  --line:        #241f2e;
  --line-soft:   #d6c6a8;

  --link:        #b8420f;
  --orange:      #ff6b2c;
  --orange-ink:  #241f2e;
  --orange-dark: #e0521a;
  --purple:      #6d4aff;
  --gold:        #b45309;
  --gold-bg:     #ffc233;
  --on-gold:     #241f2e;
  --green:       #178a4e;
  --red:         #d92d20;
  --red-soft:    #ffe3de;

  /* Aliases for admin pages and older markup */
  --accent:      var(--orange);
  --accent-hover:var(--orange-dark);
  --accent-dk:   #c9490f;
  --accent-soft: rgba(255, 107, 44, 0.18);
  --border:      var(--link);
  --border-dim:  var(--line-soft);
  --success:     var(--green);
  --danger:      var(--red);
  --danger-soft: var(--red-soft);
  --radius:      8px;

  color-scheme: light;
}

[data-theme="dark"] {
  --bg:          #141120;
  --panel:       #1d192b;
  --panel-2:     #292238;
  --text:        #f7f0e4;
  --text-dim:    #b3a8c6;
  --line:        #5a4f75;
  --line-soft:   #352d49;

  --link:        #ffa474;
  --orange:      #ff8a4c;
  --orange-ink:  #1d192b;
  --orange-dark: #ffb08a;
  --purple:      #a78bfa;
  --gold:        #ffcf5c;
  --gold-bg:     #ffcf5c;
  --on-gold:     #1d192b;
  --green:       #5fd98a;
  --red:         #ff7a70;
  --red-soft:    #3a1b22;

  --accent-soft: rgba(255, 138, 76, 0.2);
  --accent-dk:   #e0521a;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: "Nunito", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  text-align: left;
  -webkit-font-smoothing: antialiased;
}

[hidden] {
  display: none !important;
}

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

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---- Type ---- */

h1 {
  font-size: clamp(28px, 3vw, 38px);
  font-weight: 900;
  line-height: 1.15;
  letter-spacing: -0.02em;
  color: var(--text);
  margin: 0 0 14px;
}

h2 {
  font-size: 22px;
  font-weight: 800;
  line-height: 1.25;
  letter-spacing: -0.01em;
  color: var(--text);
  margin: 0 0 12px;
}

h3 {
  font-size: 18px;
  font-weight: 800;
  line-height: 1.3;
  color: var(--text);
  margin: 24px 0 10px;
}

h4 {
  font-size: 15px;
  font-weight: 800;
  color: var(--text);
  margin: 8px 0 4px;
}

p {
  margin: 8px 0;
}

a {
  color: var(--link);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.muted {
  color: var(--text-dim);
  font-size: 14px;
}

hr {
  border: none;
  height: 1px;
  margin: 24px 0;
  background: var(--line-soft);
}

.page-head {
  margin: 0 0 18px;
}

.page-head p {
  margin: 8px 0 0;
  color: var(--text-dim);
  max-width: 68ch;
}

/* ---- Site banner ---- */

.site-banner {
  position: sticky;
  top: 0;
  z-index: 70;
  background: var(--orange);
  color: var(--orange-ink);
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  font-weight: 700;
}

.site-banner-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  max-width: 1440px;
  margin: 0 auto;
  padding: 6px 24px;
  text-align: center;
}

.site-banner-message {
  margin: 0;
}

.site-banner-link {
  display: inline-block;
  padding: 2px 9px;
  font-size: 12px;
  font-weight: 800;
  color: var(--panel);
  background: var(--text);
  border: 1px solid var(--line);
  text-decoration: none;
  white-space: nowrap;
}
.site-banner-link:hover {
  color: var(--panel);
  text-decoration: underline;
}

.site-banner-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  margin: 0;
  padding: 0;
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
  color: inherit;
  background: transparent;
  border: 0;
  cursor: pointer;
}
.site-banner-close:hover {
  color: var(--text);
  background: transparent;
}

/* ---- Header ---- */

.site-header {
  position: sticky;
  top: var(--banner-h, 0px);
  z-index: 60;
  background: var(--panel);
  border-bottom: 1px solid var(--line-soft);
}

.nav-inner {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  max-width: 1440px;
  margin: 0 auto;
  padding: 12px 24px;
}

.brand {
  justify-self: start;
  font-family: "Press Start 2P", monospace;
  font-size: 16px;
  line-height: 1.4;
  letter-spacing: 0;
  color: var(--text);
  text-decoration: none;
  padding: 2px 0 4px;
}
.brand:hover {
  color: var(--link);
  text-decoration: none;
}

.nav-links {
  justify-self: center;
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav-links a {
  display: inline-block;
  padding: 8px 10px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-dim);
  text-decoration: none;
  white-space: nowrap;
}
.nav-links a:hover {
  color: var(--text);
  text-decoration: none;
}
.nav-links a.active {
  color: var(--text);
}

.nav-cta-wrap {
  position: relative;
  display: inline-flex;
}

.nav-links a.nav-advertise {
  padding: 8px 14px;
  color: var(--orange-ink);
  background: var(--orange);
  border: 1px solid var(--line);
  border-radius: 0;
}
.nav-links a.nav-advertise:hover {
  color: var(--orange-ink);
  background: var(--orange-dark);
  text-decoration: none;
}

.advertise-hint {
  position: absolute;
  top: 50%;
  left: calc(100% + 10px);
  transform: translateY(-50%);
  z-index: 70;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  color: var(--link);
  pointer-events: none;
}

.nav-actions {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 8px;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  margin: 0;
  padding: 0;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: 0;
  cursor: pointer;
}
.theme-toggle:hover {
  background: var(--panel-2);
}
.theme-toggle svg {
  width: 16px;
  height: 16px;
}

.btn-donate {
  display: inline-flex;
  align-items: center;
  padding: 8px 13px;
  font-size: 14px;
  font-weight: 800;
  color: var(--on-gold);
  background: var(--gold-bg);
  border: 1px solid var(--line);
  border-radius: 0;
  text-decoration: none;
  white-space: nowrap;
}
.btn-donate:hover {
  color: var(--on-gold);
  text-decoration: none;
  filter: brightness(1.04);
}

/* ---- Page ---- */

.page {
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 28px 24px 8px;
}

.page-narrow {
  max-width: 760px;
}

/* ---- Featured ad ---- */

.featured {
  margin: 0 0 22px;
}

.featured-banner {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
  height: clamp(220px, 25vh, 320px);
  padding: clamp(20px, 2.4vw, 32px);
  color: var(--text);
  text-decoration: none;
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: 0;
}
.featured-banner:hover {
  color: var(--text);
  text-decoration: none;
  border-color: var(--orange);
}

.featured-label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--link);
}

.featured-banner h2 {
  margin: 0;
  font-size: clamp(24px, 2.6vw, 38px);
  font-weight: 900;
  line-height: 1.12;
  letter-spacing: -0.02em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.featured-banner p {
  margin: 0;
  max-width: 75ch;
  color: var(--text-dim);
  font-size: clamp(14px, 1.1vw, 16px);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.featured-bottom {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 4px;
}

.featured-meta {
  font-size: 13px;
  color: var(--text-dim);
}

.featured-cta {
  margin-left: auto;
  font-size: 14px;
  font-weight: 800;
  color: var(--link);
}
.featured-banner:hover .featured-cta {
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ---- Filters ---- */

.controls {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 1.5fr) minmax(0, 1.5fr) minmax(0, 1.5fr) minmax(96px, 0.9fr);
  gap: 10px;
  width: 100%;
  max-width: none;
  margin: 0 0 24px;
  padding: 0;
  background: none;
  border: 0;
}

.controls input,
.controls select {
  margin-top: 0;
  height: 42px;
  min-width: 0;
}

.controls button {
  margin-top: 0;
  height: 42px;
  padding: 0 10px;
  white-space: nowrap;
}

/* ---- Ad grid ---- */

.ads-grid,
#ads {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  align-items: stretch;
}

#ads > p {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--text-dim);
  padding: 40px 0;
}

.card {
  display: flex;
  flex-direction: column;
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: 0;
  color: var(--text);
  text-decoration: none;
  overflow: hidden;
}

.card:hover {
  color: var(--text);
  text-decoration: none;
  border-color: var(--orange);
}

#ads .card {
  height: 172px;
}

.card h3 {
  margin: 0 0 6px;
  font-size: 17px;
  font-weight: 800;
  line-height: 1.3;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card:hover h3 {
  color: var(--link);
}

.card p {
  margin: 0;
  color: var(--text-dim);
  font-size: 14px;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card small {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: auto;
  padding-top: 10px;
  font-size: 12.5px;
  color: var(--text-dim);
}

.card-meta {
  display: inline-block;
  color: var(--text-dim);
  font-size: 13px;
}

/* ---- Rating chips ---- */

.rating {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.01em;
  padding: 2px 7px;
  border-radius: 0;
  color: #fff;
  vertical-align: middle;
  white-space: nowrap;
}

.rating-1  { background: #7f1d1d; }
.rating-2  { background: #991b1b; }
.rating-3  { background: #b91c1c; }
.rating-4  { background: #dc2626; }
.rating-5  { background: #b45309; }
.rating-6  { background: #d97706; color: #1a1a1a; }
.rating-7  { background: #eab308; color: #1a1a1a; }
.rating-8  { background: #65a30d; color: #0a0a14; }
.rating-9  { background: #16a34a; color: #0a0a14; }
.rating-10 { background: #22c55e; color: #0a0a14; }

.rating-none {
  background: var(--panel-2);
  color: var(--text-dim);
  border: 1px solid var(--line-soft);
}

/* ---- Forms ---- */

form {
  display: block;
  max-width: none;
  margin: 20px 0;
  padding: 20px;
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: 0;
}

form label {
  display: block;
  margin-bottom: 16px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

input,
textarea,
select {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 9px 11px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.4;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: 0;
  outline: none;
}

input::placeholder,
textarea::placeholder {
  color: var(--text-dim);
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--orange);
}

textarea {
  min-height: 120px;
  resize: vertical;
}

/* ---- Buttons ---- */

button,
.btn {
  display: inline-block;
  margin-top: 8px;
  padding: 9px 14px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 800;
  line-height: 1.2;
  color: var(--orange-ink);
  background: var(--orange);
  border: 1px solid var(--line);
  border-radius: 0;
  cursor: pointer;
}
button:hover {
  background: var(--orange-dark);
}
button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-alt {
  color: var(--text);
  background: var(--panel-2);
  border-color: var(--line-soft);
}
.btn-alt:hover {
  background: var(--panel);
}

.btn-boost.boosted {
  background: var(--gold-bg);
  color: var(--on-gold);
}

/* ---- Errors ---- */

#error,
.error {
  display: block;
  color: var(--red);
  background: var(--red-soft);
  font-size: 14px;
  font-weight: 700;
  padding: 9px 11px;
  margin-top: 14px;
  border: 1px solid var(--red);
  border-radius: 0;
}

#error:empty {
  display: none;
}

/* ---- Pager ---- */

#pager {
  text-align: center;
  margin: 28px 0 8px;
}

/* ---- Ad detail ---- */

.back-link {
  margin: 0 0 12px;
  font-weight: 700;
}

.ad-meta {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.ad-title {
  margin: 0 0 10px;
}

.ad-desc {
  color: var(--text-dim);
  font-size: 17px;
}

.countdown {
  margin: 12px 0;
  font-size: 14px;
  color: var(--text-dim);
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin: 16px 0;
}

.action-row button {
  margin-top: 0;
}

.action-msg {
  color: var(--text-dim);
  font-size: 14px;
  margin: 0;
}

.player {
  margin: 16px 0;
}
.player:empty {
  display: none;
}
.player iframe {
  display: block;
  max-width: 100%;
  border: 1px solid var(--line-soft);
  border-radius: 0;
  background: #000;
}

/* ---- Scratch preview ---- */

.scratch-preview {
  margin: 14px 0 4px;
  font-size: 14px;
  color: var(--text-dim);
}

.scratch-preview strong {
  display: inline;
  font-size: 16px;
  font-weight: 800;
  line-height: 1.3;
  color: var(--text);
  margin-right: 6px;
}

.scratch-preview span {
  font-size: 14px;
  margin-right: 6px;
}

.scratch-preview a {
  font-size: 14px;
  font-weight: 700;
}

.preview-box {
  margin: 4px 0 16px;
}
.preview-box .scratch-preview {
  margin: 0;
}

/* ---- Ratings summary ---- */

.avg-rating {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin: 16px 0;
  font-size: 16px;
}

.avg-rating .rating {
  font-size: 15px;
  padding: 4px 10px;
}

/* ---- Reviews ---- */

.review {
  padding: 18px 0;
  border-bottom: 2px solid var(--line-soft);
}

.review:last-child {
  border-bottom: 0;
}

.review-title {
  margin: 2px 0 2px;
  font-size: 19px;
  font-weight: 800;
  line-height: 1.3;
  color: var(--text);
}

.review-by {
  margin: 0 0 6px;
  font-size: 14px;
  color: var(--text-dim);
}

.review-by a {
  font-weight: 700;
}

.review-body {
  margin: 6px 0 0;
  color: var(--text-dim);
  font-size: 15px;
}

.review .rating {
  float: right;
  margin-left: 12px;
}

/* ---- Donors ---- */

.donor-tier {
  margin: 24px 0 10px;
}

.donor-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.donor-list li {
  padding: 7px 12px;
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: 0;
  color: var(--link);
  font-weight: 700;
}

.donor-empty {
  padding: 16px;
  border: 1px dashed var(--line-soft);
  border-radius: 0;
  color: var(--text-dim);
  text-align: center;
}

/* ---- Form note ---- */

.form-note {
  color: var(--text-dim);
  font-size: 13px;
  margin-top: -4px;
}

/* ---- Footer ---- */

.site-footer,
footer {
  max-width: 1440px;
  margin: 40px auto 0;
  padding: 20px 24px 30px;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  border-top: 1px solid var(--line-soft);
}

.site-footer p,
footer p {
  margin: 0;
}

.site-footer a,
footer a {
  color: var(--text-dim);
}
.site-footer a:hover,
footer a:hover {
  color: var(--text);
}

/* ---- Responsive ---- */

@media (max-width: 900px) {
  .ads-grid,
  #ads {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .controls {
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }
  .controls input[name="q"] {
    grid-column: 1 / -1;
  }
  .controls button {
    grid-column: 1 / -1;
  }
  .advertise-hint {
    display: none;
  }
}

@media (max-width: 760px) {
  .site-banner {
    font-size: 12px;
  }
  .site-banner-inner {
    padding: 6px 12px;
    gap: 8px;
  }
  .nav-inner {
    grid-template-columns: 1fr auto;
    row-gap: 8px;
    padding: 8px 16px;
  }
  .brand {
    grid-column: 1;
    grid-row: 1;
    font-size: 13px;
  }
  .nav-actions {
    grid-column: 2;
    grid-row: 1;
  }
  .nav-links {
    grid-column: 1 / -1;
    grid-row: 2;
    flex-wrap: wrap;
    justify-content: center;
  }
  .nav-links a {
    padding: 6px 9px;
    font-size: 13px;
  }
  .nav-links a.nav-advertise {
    padding: 6px 11px;
  }
  .btn-donate {
    padding: 7px 10px;
    font-size: 13px;
  }

  .page {
    padding: 20px 16px 4px;
  }

  .featured-banner {
    height: auto;
    min-height: 200px;
    padding: 18px;
  }
  .featured-banner h2 {
    font-size: 24px;
  }
  .featured-cta {
    margin-left: 0;
  }

  .ads-grid,
  #ads {
    grid-template-columns: 1fr;
  }
  #ads .card {
    height: auto;
  }

  .site-footer,
  footer {
    padding: 18px 16px 26px;
  }
}

@media (max-width: 520px) {
  .controls {
    grid-template-columns: 1fr;
  }
  .controls input[name="q"],
  .controls button {
    grid-column: auto;
  }
  .nav-actions {
    gap: 6px;
  }
  .theme-toggle {
    width: 34px;
    height: 34px;
  }
}
