/* =========================================================
   Buildboard — design system
   Light theme · warm paper · electric indigo → violet → coral
   ========================================================= */

:root {
  /* palette */
  --bg: #f6f5f1;
  --surface: #ffffff;
  --surface-2: #fbfaf7;
  --ink: #14151a;
  --ink-soft: #33353d;
  --muted: #6a6f7a;
  --line: #eceae3;
  --line-strong: #e2dfd6;

  --primary: #5b4df0;
  --primary-ink: #4234d8;
  --violet: #9b5cf6;
  --coral: #ff6b57;
  --gold: #f6b100;
  --emerald: #10b981;

  --grad: linear-gradient(118deg, #5b4df0 0%, #8a5cf6 46%, #ff6b57 100%);
  --grad-soft: linear-gradient(118deg, rgba(91,77,240,.14), rgba(255,107,87,.12));

  /* rhythm — 8px grid */
  --s1: 8px; --s2: 16px; --s3: 24px; --s4: 32px; --s5: 48px; --s6: 64px; --s7: 96px;

  --radius: 16px;
  --radius-sm: 10px;
  --radius-lg: 26px;

  --shadow-sm: 0 1px 2px rgba(20,21,26,.05), 0 1px 3px rgba(20,21,26,.06);
  --shadow-md: 0 10px 30px -12px rgba(40,30,110,.20);
  --shadow-lg: 0 34px 70px -30px rgba(45,30,120,.34);

  --font-display: "Space Grotesk", ui-sans-serif, system-ui, sans-serif;
  --font-body: "Inter", ui-sans-serif, system-ui, -apple-system, sans-serif;

  --maxw: 1120px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; overflow-x: hidden; }

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

/* buttons inherit ink so children never fall back to system buttontext */
button { color: inherit; font-family: inherit; }

h1, h2, h3 { font-family: var(--font-display); font-weight: 600; letter-spacing: -0.02em; margin: 0; }
a { color: inherit; text-decoration: none; }

.wrap { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 24px; }

.grad-text {
  background: var(--grad);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}

/* ---------------- ambient aurora ---------------- */
.aurora { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.blob { position: absolute; border-radius: 50%; filter: blur(70px); opacity: .5; }
.b1 { width: 520px; height: 520px; top: -180px; left: -120px;
      background: radial-gradient(circle at 30% 30%, #6a5cff, transparent 70%); }
.b2 { width: 460px; height: 460px; top: -60px; right: -140px;
      background: radial-gradient(circle at 50% 50%, #ff8a76, transparent 70%); opacity: .38; }
.b3 { width: 420px; height: 420px; top: 460px; left: 40%;
      background: radial-gradient(circle at 50% 50%, #b57cff, transparent 70%); opacity: .3; }

/* ---------------- buttons ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid transparent; border-radius: 999px;
  padding: 10px 18px; font-size: 14.5px; font-weight: 600;
  cursor: pointer; white-space: nowrap; transition: transform .12s ease, box-shadow .2s ease, background .2s ease, border-color .2s ease;
  background: transparent;
}
.btn:active { transform: translateY(1px); }
.btn-lg { padding: 14px 26px; font-size: 16px; }

.btn-primary { background: var(--ink); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: #000; box-shadow: var(--shadow-md); }

.btn-gradient { background: var(--grad); color: #fff; box-shadow: var(--shadow-md); }
.btn-gradient:hover { filter: brightness(1.05); }

.btn-ghost { background: var(--surface); border-color: var(--line-strong); color: var(--ink); box-shadow: var(--shadow-sm); }
.btn-ghost:hover { border-color: var(--ink); }

.btn-quiet { background: transparent; color: var(--ink-soft); }
.btn-quiet:hover { color: var(--ink); background: rgba(20,21,26,.05); }

.btn-block { width: 100%; }

/* ---------------- nav ---------------- */
.nav {
  position: sticky; top: 0; z-index: 40;
  backdrop-filter: saturate(160%) blur(14px);
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  border-bottom: 1px solid transparent;
  transition: border-color .2s ease, background .2s ease;
}
.nav.scrolled { border-bottom-color: var(--line); background: color-mix(in srgb, var(--bg) 88%, transparent); }
.nav-inner { display: flex; align-items: center; gap: 24px; height: 68px; }

.brand { display: inline-flex; align-items: center; gap: 10px; font-family: var(--font-display); font-weight: 700; letter-spacing: -.02em; font-size: 18px; }
.brand-mark { display: inline-flex; align-items: flex-end; gap: 3px; height: 22px; padding: 0 1px; }
.brand-mark i { width: 5px; border-radius: 3px; background: var(--grad); display: block; }
.brand-mark i:nth-child(1) { height: 10px; }
.brand-mark i:nth-child(2) { height: 20px; }
.brand-mark i:nth-child(3) { height: 14px; }
.brand-mark.small { height: 18px; }
.brand-mark.small i:nth-child(2) { height: 16px; }

.nav-links { display: flex; gap: 6px; margin-left: 8px; }
.nav-links a { color: var(--muted); font-size: 14.5px; font-weight: 500; padding: 8px 12px; border-radius: 10px; }
.nav-links a:hover { color: var(--ink); background: rgba(20,21,26,.05); }
.nav-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.user-chip { display: inline-flex; align-items: center; gap: 10px; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  font-family: var(--font-display); font-weight: 700; font-size: 14px; color: #fff;
  background: var(--grad); box-shadow: var(--shadow-sm);
}
.user-name { font-weight: 600; font-size: 14px; }

/* ---------------- hero ---------------- */
.hero { padding: clamp(56px, 9vw, 104px) 0 clamp(40px, 6vw, 72px); }
.hero-inner { text-align: center; display: flex; flex-direction: column; align-items: center; }
/* flex-column children shrink to content by default — keep them inside the viewport */
.hero-inner > * { max-width: 100%; }
.eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 600; letter-spacing: .02em; color: var(--primary-ink);
  background: var(--surface); border: 1px solid var(--line-strong);
  padding: 7px 14px; border-radius: 999px; box-shadow: var(--shadow-sm);
}
.eyebrow::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--emerald); box-shadow: 0 0 0 4px rgba(16,185,129,.18); }
.hero-title { font-size: clamp(38px, 8vw, 76px); line-height: 1.02; margin: 22px 0 0; font-weight: 700; overflow-wrap: break-word; }
.hero-sub { max-width: min(560px, 100%); margin: 20px 0 0; font-size: clamp(16px, 2.4vw, 19px); color: var(--ink-soft); }
.hero-sub strong { color: var(--ink); }
.hero-cta { display: flex; gap: 12px; margin-top: 30px; flex-wrap: wrap; justify-content: center; }

.stats { display: flex; flex-wrap: wrap; justify-content: center; gap: clamp(20px, 5vw, 56px); margin: 46px 0 0; padding: 0; max-width: 100%; }
.stats div { text-align: center; }
.stats dt { font-size: 13px; color: var(--muted); font-weight: 500; margin: 0; }
.stats dd { margin: 4px 0 0; font-family: var(--font-display); font-weight: 700; font-size: clamp(26px, 5vw, 34px); letter-spacing: -.02em; }
.stats .pct { font-size: .55em; color: var(--muted); margin-left: 2px; }

/* ---------------- section chrome ---------------- */
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 28px; }
.section-head.center { justify-content: center; text-align: center; }
.section-head h2 { font-size: clamp(26px, 4vw, 38px); }
.section-sub { margin: 8px 0 0; color: var(--muted); max-width: 52ch; font-size: 16px; }

.board { padding: clamp(20px, 4vw, 40px) 0 clamp(48px, 7vw, 88px); }

/* ---------------- podium (top 3) ---------------- */
.podium { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 20px; }
.p-card {
  position: relative; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: 22px 20px 20px; box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; gap: 14px; min-height: 190px;
  transition: transform .16s ease, box-shadow .2s ease;
}
.p-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.p-card.rank-1 { border-color: transparent; box-shadow: var(--shadow-lg); background:
  linear-gradient(var(--surface), var(--surface)) padding-box,
  var(--grad) border-box; border: 1.5px solid transparent; }
.p-medal {
  position: absolute; top: -14px; left: 20px; width: 40px; height: 40px; border-radius: 12px;
  display: grid; place-items: center; font-family: var(--font-display); font-weight: 700; font-size: 17px;
  color: #fff; box-shadow: var(--shadow-md); transform: rotate(-4deg);
}
.rank-1 .p-medal { background: linear-gradient(135deg, #ffd66b, #f6a100); color: #4a3400; }
.rank-2 .p-medal { background: linear-gradient(135deg, #e8ecf2, #b9c2ce); color: #3a4250; }
.rank-3 .p-medal { background: linear-gradient(135deg, #ffc7a8, #e08a58); color: #4a2a12; }
.p-top { margin-top: 8px; }
.p-cat { display: inline-block; font-size: 11.5px; font-weight: 600; color: var(--primary-ink);
  background: var(--grad-soft); padding: 4px 10px; border-radius: 999px; margin-bottom: 8px; }
.p-name { font-size: 20px; font-family: var(--font-display); font-weight: 600; letter-spacing: -.02em; }
.p-tag { color: var(--ink-soft); font-size: 14.5px; margin-top: 4px; }
.p-foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.p-author { font-size: 12.5px; color: var(--muted); display: inline-flex; align-items: center; gap: 7px; min-width: 0; }
.p-author .mini-av { width: 22px; height: 22px; border-radius: 50%; background: var(--grad); color: #fff;
  display: grid; place-items: center; font-size: 10px; font-weight: 700; font-family: var(--font-display); flex: none; }
.p-author span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------------- vote button ---------------- */
.vote {
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1px; min-width: 62px; padding: 8px 10px; border-radius: 14px;
  border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--ink);
  cursor: pointer; font-family: var(--font-display); font-weight: 700; line-height: 1;
  transition: transform .12s ease, background .2s ease, border-color .2s ease, box-shadow .2s ease, color .2s ease;
  flex: none;
}
.vote .caret { font-size: 15px; line-height: 1; transition: transform .16s ease; }
.vote .count { font-size: 17px; }
.vote .lbl { font-size: 10px; font-weight: 600; color: var(--muted); letter-spacing: .04em; text-transform: uppercase; }
.vote:hover { border-color: var(--primary); color: var(--primary-ink); }
.vote:hover .caret { transform: translateY(-2px); }
.vote.voted { background: var(--grad); border-color: transparent; color: #fff; box-shadow: var(--shadow-md); }
.vote.voted .lbl { color: rgba(255,255,255,.85); }
.vote.bump { animation: bump .32s ease; }
@keyframes bump { 0%{transform:scale(1)} 40%{transform:scale(1.12)} 100%{transform:scale(1)} }

/* ---------------- ranked rows (4–10) ---------------- */
.rows { display: flex; flex-direction: column; gap: 10px; }
.row {
  display: flex; align-items: center; gap: 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow-sm);
  transition: transform .16s ease, box-shadow .2s ease, border-color .2s ease;
}
.row:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--line-strong); }
.row-rank { font-family: var(--font-display); font-weight: 700; font-size: 18px; color: var(--muted); width: 34px; text-align: center; flex: none; }
.row-main { min-width: 0; flex: 1; }
.row-title { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.row-name { font-family: var(--font-display); font-weight: 600; font-size: 17px; letter-spacing: -.01em; }
.row-cat { font-size: 11px; font-weight: 600; color: var(--primary-ink); background: var(--grad-soft); padding: 3px 9px; border-radius: 999px; }
.row-tag { color: var(--ink-soft); font-size: 14px; margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-author { font-size: 12.5px; color: var(--muted); margin-top: 4px; display: inline-flex; align-items: center; gap: 7px; }
.row-author .mini-av { width: 20px; height: 20px; border-radius: 50%; background: var(--grad); color: #fff; display: grid; place-items: center; font-size: 9.5px; font-weight: 700; font-family: var(--font-display); }
.row-link { font-size: 12.5px; color: var(--primary-ink); font-weight: 600; }

/* empty + skeleton */
.empty { text-align: center; padding: 56px 20px; background: var(--surface); border: 1px dashed var(--line-strong); border-radius: var(--radius-lg); }
.empty h3 { font-size: 22px; }
.empty p { color: var(--muted); margin: 8px auto 20px; max-width: 40ch; }
.skeleton-list { display: flex; flex-direction: column; gap: 12px; }
.sk-row { height: 76px; border-radius: var(--radius); background:
  linear-gradient(100deg, var(--surface) 30%, var(--surface-2) 50%, var(--surface) 70%);
  background-size: 200% 100%; animation: shimmer 1.3s infinite; border: 1px solid var(--line); }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------------- how it works ---------------- */
.how { padding: clamp(48px, 8vw, 96px) 0; }
.steps { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.step { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 28px 24px; box-shadow: var(--shadow-sm); position: relative; overflow: hidden; }
.step::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 4px; background: var(--grad); opacity: .9; }
.step-no { font-family: var(--font-display); font-weight: 700; font-size: 14px; color: var(--primary-ink); background: var(--grad-soft); padding: 5px 11px; border-radius: 999px; }
.step h3 { font-size: 21px; margin: 16px 0 8px; }
.step p { color: var(--ink-soft); margin: 0; font-size: 15px; }
.step p strong { color: var(--ink); }

/* ---------------- rewards ---------------- */
.rewards { padding: clamp(20px, 4vw, 40px) 0 clamp(56px, 9vw, 104px); }
.rewards-inner { display: grid; grid-template-columns: 1.15fr .85fr; gap: 40px; align-items: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: clamp(28px, 5vw, 52px); box-shadow: var(--shadow-md); position: relative; overflow: hidden; }
.rewards-inner::after { content: ""; position: absolute; width: 320px; height: 320px; right: -120px; top: -120px;
  background: var(--grad); opacity: .1; filter: blur(30px); border-radius: 50%; pointer-events: none; }
.rewards-copy h2 { font-size: clamp(26px, 4vw, 40px); line-height: 1.05; }
.rewards-copy > p { color: var(--ink-soft); margin: 16px 0 20px; font-size: 16px; max-width: 46ch; }
.ticks { list-style: none; padding: 0; margin: 0 0 26px; display: flex; flex-direction: column; gap: 12px; }
.ticks li { position: relative; padding-left: 32px; font-weight: 500; color: var(--ink-soft); }
.ticks li::before { content: "✓"; position: absolute; left: 0; top: -1px; width: 22px; height: 22px; border-radius: 7px;
  background: var(--grad); color: #fff; display: grid; place-items: center; font-size: 12px; font-weight: 700; }

.rewards-card { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow-sm); }
.rc-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px dashed var(--line-strong); font-size: 14.5px; color: var(--ink-soft); }
.rc-row b { color: var(--emerald); font-size: 16px; }
.rc-split { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 18px; }
.rc-half { border-radius: var(--radius-sm); padding: 16px; text-align: center; background: var(--grad); color: #fff; }
.rc-half.alt { background: var(--ink); }
.rc-half span { display: block; font-size: 12px; opacity: .85; }
.rc-half strong { font-family: var(--font-display); font-size: 30px; letter-spacing: -.02em; }

/* ---------------- footer ---------------- */
.footer { border-top: 1px solid var(--line); padding: 34px 0; background: var(--surface); }
.footer-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.footer-note { color: var(--muted); font-size: 13.5px; margin: 0; }

/* ---------------- toast ---------------- */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 20px);
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px;
  font-size: 14px; font-weight: 500; box-shadow: var(--shadow-lg); z-index: 80;
  opacity: 0; pointer-events: none; transition: opacity .22s ease, transform .22s ease; max-width: min(92vw, 420px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: #d23b2f; }
.toast.success { background: #0e9f6e; }

/* ---------------- modal ---------------- */
.modal-root { position: fixed; inset: 0; z-index: 60; display: none; }
.modal-root.open { display: block; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(20,18,40,.42); backdrop-filter: blur(4px); animation: fade .2s ease; }
.modal {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(460px, calc(100vw - 32px)); max-height: calc(100dvh - 40px); overflow: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); padding: 28px; animation: pop .22s cubic-bezier(.2,.9,.3,1.2);
}
.modal.wide { width: min(560px, calc(100vw - 32px)); }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translate(-50%, -46%) scale(.97); } }

.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.modal-head h2 { font-size: 24px; }
.modal-head p { margin: 6px 0 0; color: var(--muted); font-size: 14.5px; }
.modal-close { width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--surface); cursor: pointer; font-size: 18px; line-height: 1; color: var(--muted); flex: none; }
.modal-close:hover { color: var(--ink); border-color: var(--ink); }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--ink-soft); }
.field input, .field textarea, .field select {
  width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line-strong);
  background: var(--surface-2); font-family: inherit; font-size: 15px; color: var(--ink); transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.field textarea { resize: vertical; min-height: 88px; }
.field input:focus, .field textarea:focus, .field select:focus { outline: none; border-color: var(--primary); background: var(--surface); box-shadow: 0 0 0 4px rgba(91,77,240,.14); }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 6px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.form-error { background: #fdecea; color: #b3261e; border: 1px solid #f6c9c4; padding: 10px 12px; border-radius: 10px; font-size: 13.5px; margin-bottom: 14px; display: none; }
.form-error.show { display: block; }

.modal-alt { margin-top: 16px; text-align: center; font-size: 14px; color: var(--muted); }
.modal-alt button { background: none; border: none; color: var(--primary-ink); font-weight: 600; cursor: pointer; font-size: 14px; padding: 0; }
.modal-alt button:hover { text-decoration: underline; }

/* ---------------- responsive ---------------- */
@media (max-width: 860px) {
  .nav-links { display: none; }
  .podium { grid-template-columns: 1fr; }
  .p-card { min-height: 0; }
  .steps { grid-template-columns: 1fr; }
  .rewards-inner { grid-template-columns: 1fr; gap: 28px; }
  .rewards-card { order: -1; }
}
@media (max-width: 560px) {
  .wrap { padding: 0 18px; }
  .section-head { flex-direction: column; align-items: flex-start; }
  .section-head .btn { align-self: stretch; }
  .stats { gap: 22px; }
  .row { gap: 12px; padding: 12px; }
  .row-rank { width: 22px; font-size: 15px; }
  .row-tag { white-space: normal; }
  .field-row { grid-template-columns: 1fr; }
}
@media (max-width: 380px) {
  .wrap { padding: 0 14px; }
  .nav-inner { gap: 8px; }
  .brand { font-size: 16px; gap: 8px; }
  .brand-mark { height: 18px; }
  .nav-actions { gap: 6px; }
  .nav-actions .btn { padding: 8px 13px; font-size: 13.5px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; scroll-behavior: auto; }
}
