@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,500;9..144,600&family=Inter:wght@400;500;600&family=JetBrains+Mono:wght@400;500;700&display=swap');

:root {
  --paper: #faf9f6;
  --paper-raised: #ffffff;
  --ink: #16181a;
  --ink-soft: #55595e;
  --line: #e4e1d8;
  --line-strong: #cfcbbd;

  --pine: #2b6e5d;      /* easy / streak / success */
  --pine-soft: #e4efec;
  --gold: #a9791e;      /* medium / coins */
  --gold-soft: #f4ecda;
  --brick: #b23a34;     /* hard / danger */
  --brick-soft: #f6e6e4;

  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', Consolas, monospace;

  --radius: 3px;
  --shadow: 0 1px 2px rgba(22, 24, 26, 0.06), 0 1px 1px rgba(22, 24, 26, 0.04);
}

* {
  box-sizing: border-box;
}

html {
  -webkit-font-smoothing: antialiased;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
}

a {
  color: inherit;
}

button, input, textarea, select {
  font-family: inherit;
  font-size: inherit;
}

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

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

/* ── Layout shell ─────────────────────────────────────────────────────── */

.shell {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 20px 64px;
}

.shell--wide {
  max-width: 860px;
}

.shell--narrow {
  max-width: 420px;
}

/* ── Top nav ──────────────────────────────────────────────────────────── */

.topnav {
  border-bottom: 1px solid var(--line);
  background: var(--paper);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topnav-inner {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topnav--wide .topnav-inner {
  max-width: 860px;
}

.brand {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 20px;
  letter-spacing: -0.01em;
  text-decoration: none;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-word {
  display: inline-flex;
  align-items: baseline;
  gap: 2px;
}

.brand-mark {
  flex-shrink: 0;
}

.brand-mark-pulse {
  transform-origin: 16px 11px;
  animation: brandPulse 2.6s ease-out infinite;
}

@keyframes brandPulse {
  0% {
    r: 4;
    opacity: 0.65;
  }
  100% {
    r: 11;
    opacity: 0;
  }
}

.brand-slash {
  color: var(--pine);
  font-family: var(--font-mono);
  font-weight: 700;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 18px;
}

.nav-link {
  text-decoration: none;
  color: var(--ink-soft);
  font-size: 14px;
  font-weight: 500;
}

.nav-link:hover {
  color: var(--ink);
}

.nav-cluster {
  display: flex;
  align-items: center;
  gap: 14px;
}

.streak-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 14px;
  color: var(--pine);
  background: var(--pine-soft);
  border-radius: var(--radius);
  padding: 5px 10px;
  border: 1px solid transparent;
}

.streak-badge svg {
  width: 14px;
  height: 14px;
}

.avatar-link {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--paper);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
  flex-shrink: 0;
}

/* ── Typography helpers ───────────────────────────────────────────────── */

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0 0 8px;
}

h1 {
  font-size: 30px;
}

h2 {
  font-size: 21px;
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
  margin: 0 0 6px;
  animation: fadeSlideIn 0.4s ease-out both;
}

@keyframes fadeSlideIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.lede {
  color: var(--ink-soft);
  margin: 0 0 28px;
}

/* ── Cards ────────────────────────────────────────────────────────────── */

.card {
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
  animation: cardIn 0.45s ease-out both;
}

@keyframes cardIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.card + .card {
  margin-top: 16px;
}

/* ── Difficulty stamp ─────────────────────────────────────────────────── */
/* Signature element: a due-date-stamp treatment for difficulty, since this
   is fundamentally a "show up today" habit product. */

.stamp {
  display: inline-block;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 4px 10px;
  border: 1.5px solid currentColor;
  border-radius: 2px;
  transform: rotate(-2deg);
}

.stamp--easy { color: var(--pine); }
.stamp--medium { color: var(--gold); }
.stamp--hard { color: var(--brick); }

/* ── Buttons ──────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 600;
  font-size: 14px;
  padding: 11px 20px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.08s ease, background 0.15s ease, border-color 0.15s ease;
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.6;
  transform: none;
}

.btn--primary {
  background: var(--ink);
  color: var(--paper);
}

.btn--primary:hover:not(:disabled) {
  background: #2c2f33;
}

.btn--outline {
  background: transparent;
  color: var(--ink);
  border-color: var(--line-strong);
}

.btn--outline:hover:not(:disabled) {
  border-color: var(--ink);
}

.btn--gold {
  background: var(--gold);
  color: #fff;
}

.btn--gold:hover:not(:disabled) {
  background: #906419;
}

.btn--block {
  width: 100%;
}

/* ── Forms ────────────────────────────────────────────────────────────── */

.field {
  margin-bottom: 16px;
}

.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--ink-soft);
}

.field input,
.field textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--paper-raised);
  color: var(--ink);
}

.field textarea {
  resize: vertical;
  min-height: 80px;
}

.field input:focus,
.field textarea:focus {
  border-color: var(--pine);
}

.form-error {
  background: var(--brick-soft);
  color: var(--brick);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 16px;
  display: none;
}

.form-error.is-visible {
  display: block;
}

.form-foot {
  margin-top: 18px;
  font-size: 13px;
  color: var(--ink-soft);
  text-align: center;
}

/* ── Stats row ────────────────────────────────────────────────────────── */

.stats-row {
  display: flex;
  gap: 12px;
  margin: 20px 0 0;
}

.stat {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  text-align: center;
}

.stat-value {
  font-family: var(--font-mono);
  font-size: 24px;
  font-weight: 700;
  display: block;
}

.stat-label {
  font-size: 12px;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ── Leaderboard table ────────────────────────────────────────────────── */

.board {
  width: 100%;
  border-collapse: collapse;
}

.board th {
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-soft);
  padding: 10px 12px;
  border-bottom: 1px solid var(--line-strong);
}

.board td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}

.board tr:last-child td {
  border-bottom: none;
}

.board .rank {
  font-family: var(--font-mono);
  color: var(--ink-soft);
  width: 40px;
}

.board .streak-cell {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--pine);
  text-align: right;
}

.board tr.is-you {
  background: var(--pine-soft);
}

/* ── Misc ─────────────────────────────────────────────────────────────── */

.divider {
  border: none;
  border-top: 1px solid var(--line);
  margin: 24px 0;
}

.muted {
  color: var(--ink-soft);
  font-size: 13px;
}

.discord-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--ink-soft);
  text-decoration: none;
}

.discord-link:hover {
  color: var(--ink);
}

.state-block {
  text-align: center;
  padding: 40px 20px;
  color: var(--ink-soft);
}

.completed-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--pine-soft);
  color: var(--pine);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-weight: 600;
  font-size: 14px;
}

.problem-title {
  font-family: var(--font-display);
  font-size: 24px;
  margin: 12px 0 8px;
}

.problem-topic {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-soft);
}

.problem-desc {
  color: var(--ink-soft);
  margin: 14px 0 22px;
}

.action-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.resource-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.resource-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  padding: 8px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--line-strong);
  color: var(--ink-soft);
  background: transparent;
  cursor: pointer;
}

.resource-link:hover {
  color: var(--ink);
  border-color: var(--ink);
}

.resource-link--locked {
  color: var(--gold);
  border-color: var(--gold-soft);
  background: var(--gold-soft);
}

.resource-link--locked:hover {
  border-color: var(--gold);
}

.resource-link--unlocked {
  color: var(--pine);
  border-color: var(--pine-soft);
  background: var(--pine-soft);
}

.solution-warning {
  font-size: 12px;
  color: var(--brick);
  margin-top: 8px;
  display: none;
}

.solution-warning.is-visible {
  display: block;
}

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

.footer-note {
  text-align: center;
  padding: 32px 0 8px;
}

/* ── Cookie consent banner ────────────────────────────────────────────── */

#cookie-consent-banner {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 200;
  background: var(--ink);
  color: var(--paper);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  flex-wrap: wrap;
  box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.15);
}

#cookie-consent-banner p {
  margin: 0;
  font-size: 13px;
  color: var(--paper);
  max-width: 560px;
  line-height: 1.5;
}

.cookie-consent-actions {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
}

#cookie-consent-banner .btn--outline {
  color: var(--paper);
  border-color: rgba(250, 249, 246, 0.4);
}

#cookie-consent-banner .btn--outline:hover {
  border-color: var(--paper);
}

@media (max-width: 520px) {
  .shell {
    padding: 0 16px 48px;
  }

  .card {
    padding: 20px;
  }

  .stats-row {
    flex-direction: column;
  }

  .nav-links {
    display: none;
  }
}
