/* Top Funny Jokes — single stylesheet, light + dark, no dependencies */

:root {
  --bg: #faf7f0;
  --surface: #ffffff;
  --surface-2: #f4f0e6;
  --text: #1c1b17;
  --muted: #7a746a;
  --border: #e7e2d6;
  --accent: #d97706;
  --accent-contrast: #ffffff;
  --accent-weak: #fdf1de;
  --up: #e8590c;
  --down: #5c7cfa;
  --danger: #c92a2a;
  --shadow: 0 1px 2px rgb(28 27 23 / 0.05), 0 4px 14px rgb(28 27 23 / 0.05);
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101014;
    --surface: #1a1a21;
    --surface-2: #22222b;
    --text: #edecea;
    --muted: #9d9a92;
    --border: #2b2b35;
    --accent: #f5a623;
    --accent-contrast: #17130a;
    --accent-weak: #2b2417;
    --up: #ff7a33;
    --down: #7c96ff;
    --danger: #ff6b6b;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 6px 18px rgb(0 0 0 / 0.35);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.55;
}
a { color: var(--accent); }
img { max-width: 100%; }

.wrap { max-width: 780px; margin: 0 auto; padding: 0 16px; }

.skip {
  position: absolute; left: -9999px; top: 0;
  background: var(--accent); color: var(--accent-contrast);
  padding: 8px 14px; border-radius: 0 0 8px 0; z-index: 100;
}
.skip:focus { left: 0; }

/* ---------- header ---------- */
.site-head {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.head-row {
  display: flex; align-items: center; gap: 14px;
  min-height: 58px; flex-wrap: wrap; padding-top: 6px; padding-bottom: 6px;
}
.brand {
  display: flex; align-items: center; gap: 8px;
  text-decoration: none; color: var(--text); font-size: 1.15rem; letter-spacing: -0.01em;
}
.brand-emoji { font-size: 1.5rem; }
.brand-text b { color: var(--accent); }
.tabs { display: flex; gap: 2px; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a {
  padding: 7px 13px; border-radius: 999px;
  color: var(--muted); text-decoration: none; font-weight: 600; font-size: 0.95rem;
  white-space: nowrap;
}
.tabs a:hover { color: var(--text); background: var(--surface-2); }
.tabs a.active { color: var(--accent-contrast); background: var(--accent); }
.head-actions { display: flex; gap: 8px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 15px; border-radius: 999px; border: 1px solid transparent;
  font: inherit; font-weight: 650; font-size: 0.93rem;
  text-decoration: none; cursor: pointer; line-height: 1.2;
}
.btn.primary { background: var(--accent); color: var(--accent-contrast); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.ghost { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { background: transparent; color: var(--danger); border-color: currentColor; }
.btn.danger:hover { background: var(--danger); color: #fff; }
.btn.sm { padding: 4px 10px; font-size: 0.85rem; }

/* ---------- page head ---------- */
.page-head { margin: 26px 0 14px; }
.page-head h1 { margin: 0 0 4px; font-size: 1.45rem; line-height: 1.25; letter-spacing: -0.015em; }
.page-head h1 em { color: var(--accent); font-style: normal; }
.page-head .sub { margin: 0; color: var(--muted); font-size: 0.98rem; }
.page-head.center { text-align: center; margin-top: 60px; }
.err-code { font-size: 4rem; font-weight: 800; margin: 0; color: var(--accent); line-height: 1; }

.subtabs { display: flex; gap: 6px; margin: 0 0 14px; }
.subtabs a {
  padding: 5px 12px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); color: var(--muted);
  text-decoration: none; font-size: 0.88rem; font-weight: 600;
}
.subtabs a.active { background: var(--accent-weak); border-color: var(--accent); color: var(--accent); }

/* ---------- cards ---------- */
.cards { display: flex; flex-direction: column; gap: 14px; margin-bottom: 26px; }
.card {
  display: flex; gap: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px 12px 8px;
}
.card.detail { margin-top: 24px; }
.card-main { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.card-title { margin: 2px 0 8px; font-size: 1.13rem; line-height: 1.35; letter-spacing: -0.01em; }
.card.detail .card-title { font-size: 1.35rem; }
.card-title a { color: var(--text); text-decoration: none; }
.card-title a:hover { color: var(--accent); }
.card-body { font-size: 1.02rem; }
.card-body p { margin: 0 0 10px; white-space: pre-line; }
.card-body p:last-child { margin-bottom: 6px; }
.card-meta {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-top: 8px; font-size: 0.85rem;
}
.muted { color: var(--muted); }
.permalink { text-decoration: none; margin-left: auto; }
.permalink:hover { color: var(--accent); }

.chips { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.chip {
  background: var(--surface-2); color: var(--muted);
  border-radius: 999px; padding: 3px 10px;
  font-size: 0.8rem; font-weight: 600; text-decoration: none;
}
.chip:hover { background: var(--accent-weak); color: var(--accent); }

/* ---------- vote rail ---------- */
.vote {
  display: flex; flex-direction: column; align-items: center;
  gap: 2px; min-width: 46px; padding-top: 2px;
}
.vote-btn {
  display: grid; place-items: center;
  width: 34px; height: 30px;
  background: transparent; border: 0; border-radius: 8px;
  color: var(--muted); cursor: pointer;
}
.vote-btn:hover { background: var(--surface-2); }
.vote-btn.up:hover { color: var(--up); }
.vote-btn.down:hover { color: var(--down); }
.vote-btn.up.on { color: var(--up); background: color-mix(in srgb, var(--up) 12%, transparent); }
.vote-btn.down.on { color: var(--down); background: color-mix(in srgb, var(--down) 12%, transparent); }
.score { font-weight: 750; font-size: 0.98rem; font-variant-numeric: tabular-nums; }
.vote .score.pop { animation: pop 0.25s ease; }
@keyframes pop { 50% { transform: scale(1.35); } }

/* ---------- share ---------- */
.share { position: relative; }
.share-btn {
  list-style: none; cursor: pointer; user-select: none;
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 11px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface);
  font-size: 0.83rem; font-weight: 650; color: var(--muted);
}
.share-btn::-webkit-details-marker { display: none; }
.share-btn:hover { color: var(--text); background: var(--surface-2); }
.share-count:not(:empty) { color: var(--accent); }
.share-menu {
  position: absolute; z-index: 10; margin: 6px 0 0; padding: 6px;
  list-style: none; min-width: 170px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow);
}
.share-menu li { margin: 0; }
.share-link {
  display: block; width: 100%; text-align: left;
  padding: 8px 10px; border: 0; border-radius: 8px;
  background: none; font: inherit; font-size: 0.9rem;
  color: var(--text); text-decoration: none; cursor: pointer;
}
.share-link:hover { background: var(--surface-2); }

/* ---------- lists / misc ---------- */
.pager { display: flex; justify-content: space-between; gap: 10px; margin: 0 0 40px; }
.pager a:only-child { margin-left: auto; }
.empty { color: var(--muted); text-align: center; margin: 40px 0; }

.joke-actions { display: flex; gap: 10px; margin: 18px 0 26px; flex-wrap: wrap; }
.related {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 20px; margin-bottom: 40px;
}
.related h2 { margin: 0 0 10px; font-size: 1.02rem; }
.related ul { margin: 0; padding-left: 20px; }
.related li { margin: 6px 0; }
.related a { color: var(--text); text-decoration: none; }
.related a:hover { color: var(--accent); }

.cat-grid {
  list-style: none; padding: 0; margin: 0 0 40px;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px;
}
.cat-grid a {
  display: flex; flex-direction: column; gap: 3px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px;
  text-decoration: none; color: var(--text); box-shadow: var(--shadow);
}
.cat-grid a:hover { border-color: var(--accent); }
.cat-grid .muted { font-size: 0.85rem; }
.cat-grid a.cat-empty { opacity: 0.62; box-shadow: none; border-style: dashed; }
.cat-grid a.cat-empty:hover { opacity: 1; }

/* ---------- forms ---------- */
.submit-form { max-width: 560px; margin-bottom: 50px; display: flex; flex-direction: column; gap: 14px; }
.submit-form.narrow { max-width: 380px; }
.submit-form label { display: flex; flex-direction: column; gap: 5px; font-weight: 650; font-size: 0.92rem; }
.submit-form input, .submit-form textarea, .submit-form select {
  font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 9px 12px;
}
.submit-form textarea { resize: vertical; }
.submit-form input:focus, .submit-form textarea:focus, .submit-form select:focus {
  outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent;
}
.form-row { display: flex; gap: 14px; flex-wrap: wrap; }
.form-row label { flex: 1; min-width: 180px; }
.form-error { color: var(--danger); font-weight: 600; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.submit-form .btn { align-self: flex-start; }

/* ---------- admin ---------- */
.card.mod { padding-left: 16px; }
.mod-actions { display: flex; gap: 8px; margin-top: 10px; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 0.92rem; margin-bottom: 30px; }
.admin-table th, .admin-table td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--border); }
.admin-table a { color: var(--text); text-decoration: none; }
.admin-table a:hover { color: var(--accent); }

/* ---------- prose / footer ---------- */
.prose { max-width: 640px; margin-bottom: 50px; }
.prose li { margin: 6px 0; }
.site-foot {
  border-top: 1px solid var(--border);
  padding: 22px 0 34px; color: var(--muted); font-size: 0.88rem;
  background: var(--surface);
}
.site-foot p { margin: 0 0 6px; }
.site-foot a { color: var(--muted); }
.site-foot a:hover { color: var(--accent); }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(20px);
  background: var(--text); color: var(--bg);
  padding: 10px 18px; border-radius: 999px; font-size: 0.9rem; font-weight: 600;
  opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s; z-index: 50;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- a11y + responsive ---------- */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

@media (max-width: 560px) {
  .hide-sm { display: none; }
  .head-row { gap: 8px; }
  .tabs { order: 3; flex-basis: 100%; overflow-x: auto; padding-bottom: 4px; }
  .brand { margin-right: auto; }
  .card { padding: 12px 12px 10px 4px; }
  .permalink { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
