/* FactsAndFunny.com — public site styles (light + dark) */

:root {
  --font-display: "Fredoka", "Trebuchet MS", system-ui, sans-serif;
  --font-body: "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;

  --bg: #fff8ee;
  --bg-dot: rgba(255, 127, 0, .09);
  --surface: #ffffff;
  --surface-2: #fdf1e2;
  --text: #22201c;
  --muted: #6b645a;
  --border: #f0e2cf;
  --shadow: 0 1px 2px rgba(80, 50, 10, .06), 0 6px 18px rgba(80, 50, 10, .07);
  --shadow-hover: 0 2px 4px rgba(80, 50, 10, .08), 0 14px 32px rgba(80, 50, 10, .14);

  /* brand: orange = facts, green = funny, blue = motivation (from the logo) */
  --orange: #ff7f00;
  --green: #2fa833;
  --blue: #2a6fdb;
  --fact: #c05200;        /* deep tones: white text passes contrast */
  --funny: #1b7d20;
  --motivation: #2160c4;
  --fact-ink: #b34c00;    /* coloured text on the page background */
  --funny-ink: #18731d;
  --motivation-ink: #1f59b8;

  --link: #b34c00;
  --focus: #2a6fdb;
  --radius: 18px;
  --radius-sm: 10px;
  --wrap: 1240px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14161c;
    --bg-dot: rgba(255, 255, 255, .035);
    --surface: #1d2029;
    --surface-2: #262a35;
    --text: #f1eee9;
    --muted: #a9a59e;
    --border: #2f3441;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 18px rgba(0, 0, 0, .25);
    --shadow-hover: 0 2px 4px rgba(0, 0, 0, .35), 0 14px 32px rgba(0, 0, 0, .4);
    --fact-ink: #ffa04a;
    --funny-ink: #5fd164;
    --motivation-ink: #7fb0ff;
    --link: #ffa04a;
    --focus: #7fb0ff;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #14161c;
  --bg-dot: rgba(255, 255, 255, .035);
  --surface: #1d2029;
  --surface-2: #262a35;
  --text: #f1eee9;
  --muted: #a9a59e;
  --border: #2f3441;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 18px rgba(0, 0, 0, .25);
  --shadow-hover: 0 2px 4px rgba(0, 0, 0, .35), 0 14px 32px rgba(0, 0, 0, .4);
  --fact-ink: #ffa04a;
  --funny-ink: #5fd164;
  --motivation-ink: #7fb0ff;
  --link: #ffa04a;
  --focus: #7fb0ff;
  color-scheme: dark;
}

/* ---------- base */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.55;
  color: var(--text);
  background-color: var(--bg);
  background-image: radial-gradient(var(--bg-dot) 1.2px, transparent 1.3px);
  background-size: 22px 22px;
  overflow-x: hidden;
}
img { max-width: 100%; height: auto; display: block; }
a { color: var(--link); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 600; line-height: 1.2; margin: 0; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: 12px; top: -60px; z-index: 50; background: var(--surface); color: var(--text); padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow); }
.skip-link:focus { top: 12px; }
.wrap { width: 100%; max-width: var(--wrap); margin: 0 auto; padding: 0 16px; }
.icon { flex: none; vertical-align: middle; }

/* ---------- header */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: relative;
}
.site-header::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -5px; height: 5px;
  background: linear-gradient(90deg, var(--orange) 0 33.3%, var(--green) 33.3% 66.6%, var(--blue) 66.6%);
}
.header-row { display: flex; align-items: center; gap: 20px; padding-top: 12px; padding-bottom: 8px; }
.brand { flex: none; display: block; }
.brand img { height: 74px; width: auto; transition: transform .2s ease; }
.brand:hover img { transform: rotate(-2deg) scale(1.03); }

.search { margin-left: auto; display: flex; align-items: center; background: var(--surface-2); border: 2px solid var(--border); border-radius: 999px; padding: 3px 3px 3px 16px; width: min(360px, 100%); transition: border-color .15s; }
.search:focus-within { border-color: var(--orange); }
.search input { flex: 1; min-width: 0; border: 0; background: transparent; color: var(--text); font: inherit; font-size: 16px; padding: 6px 0; outline: none; }
.search input::placeholder { color: var(--muted); }
.search input::-webkit-search-cancel-button { filter: grayscale(1); }
.search button { flex: none; width: 38px; height: 38px; border-radius: 50%; border: 0; background: var(--orange); color: #1a1205; display: grid; place-items: center; cursor: pointer; }
.search button:hover { background: #ff9530; }

.icon-btn { flex: none; width: 44px; height: 44px; border-radius: 50%; border: 2px solid var(--border); background: var(--surface); color: var(--text); display: grid; place-items: center; cursor: pointer; transition: transform .15s, border-color .15s; }
.icon-btn:hover { border-color: var(--orange); transform: rotate(-12deg); }
.theme-toggle .when-dark { display: none; }
:root[data-theme="dark"] .theme-toggle .when-dark { display: block; }
:root[data-theme="dark"] .theme-toggle .when-light { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .when-dark { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .when-light { display: none; }
}

.main-nav { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 22px; padding-bottom: 14px; }
.pills { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.pill {
  --c: var(--text);
  display: inline-flex; align-items: center; height: 40px; padding: 0 18px; border-radius: 999px;
  font-family: var(--font-display); font-weight: 600; font-size: 16px; text-decoration: none;
  color: var(--text); background: var(--surface-2); border: 2px solid transparent;
  transition: background .15s, color .15s, border-color .15s, transform .15s;
}
.pill:hover { border-color: var(--c); transform: translateY(-1px); }
.pill--fact { --c: var(--fact); }
.pill--funny { --c: var(--funny); }
.pill--motivation { --c: var(--motivation); }
.pill--all { --c: var(--text); }
.pill.is-active { background: var(--c); color: #fff; border-color: var(--c); }
.pill--all.is-active { color: var(--bg); }

.hot { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 14px; font-size: 15px; }
.hot-label { display: inline-flex; align-items: center; gap: 4px; font-weight: 800; color: #e0281b; text-transform: uppercase; letter-spacing: .04em; font-size: 13px; }
:root[data-theme="dark"] .hot-label { color: #ff6b5e; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .hot-label { color: #ff6b5e; } }
.hot a { color: var(--text); text-decoration: none; font-weight: 600; }
.hot a:hover { color: var(--link); text-decoration: underline; }

/* ---------- layout */
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 36px; padding-top: 30px; padding-bottom: 56px; }
.content { min-width: 0; }
.page-head { margin-bottom: 22px; }
.page-head h1 { font-size: clamp(30px, 4vw, 42px); font-weight: 700; letter-spacing: -.01em; }
.page-head--facts h1 { color: var(--fact-ink); }
.page-head--funny h1 { color: var(--funny-ink); }
.page-head--motivation h1 { color: var(--motivation-ink); }
.lede { font-size: 19px; color: var(--muted); margin: 8px 0 0; max-width: 62ch; }
.count { margin: 6px 0 0; color: var(--muted); font-weight: 700; font-size: 15px; }
.empty { color: var(--muted); font-size: 18px; }
.notice { background: #fff3c4; color: #4a3b00; border-radius: var(--radius-sm); padding: 10px 14px; font-weight: 700; }
.crumbs { font-size: 14px; color: var(--muted); margin-bottom: 14px; display: flex; gap: 8px; flex-wrap: wrap; }
.crumbs a { color: var(--muted); }
.section-title { font-size: 26px; margin: 0 0 16px; }

/* ---------- cards */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 22px; }
.card {
  --c: var(--fact); --ink: var(--fact-ink);
  display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
  transition: transform .18s ease, box-shadow .18s ease;
}
.card:hover { transform: translateY(-4px) rotate(-.3deg); box-shadow: var(--shadow-hover); }
.card--funny { --c: var(--funny); --ink: var(--funny-ink); }
.card--motivation { --c: var(--motivation); --ink: var(--motivation-ink); }
.card-media { display: block; position: relative; aspect-ratio: 4 / 3; background: var(--surface-2); border-bottom: 5px solid var(--c); overflow: hidden; }
.card-media::before { content: ""; position: absolute; inset: -24px; background: var(--fill) center / cover no-repeat; filter: blur(18px) saturate(1.1) brightness(.85); }
.card-media img { position: relative; width: 100%; height: 100%; object-fit: contain; transition: transform .35s ease; }
.card:hover .card-media img { transform: scale(1.04); }
.card-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.card-title { font-family: var(--font-body); font-size: 17px; font-weight: 700; line-height: 1.4; }
.card-title a { color: var(--text); text-decoration: none; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.card-title a:hover { color: var(--ink); }
.card-title a::after { content: ""; position: absolute; inset: 0; } /* whole card clickable */
.card { position: relative; }
.card .tags { margin-top: auto; position: relative; z-index: 1; }

.card--featured { grid-column: 1 / -1; flex-direction: row; }
.card--featured .card-media { flex: 0 0 58%; aspect-ratio: auto; min-height: 320px; border-bottom: 0; border-right: 6px solid var(--c); }
.card--featured .card-body { padding: 28px; justify-content: center; gap: 14px; }
.card--featured .card-title { font-family: var(--font-display); font-size: clamp(22px, 2.4vw, 30px); font-weight: 600; line-height: 1.25; }
.card--featured .card-title a { -webkit-line-clamp: 6; }
.card--featured .tags { margin-top: 4px; }

.badge {
  align-self: flex-start; display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-family: var(--font-display); font-size: 13px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  color: #fff; background: var(--fact);
}
.badge--funny { background: var(--funny); }
.badge--motivation { background: var(--motivation); }

.tags { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.tags a {
  display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 14px; font-weight: 700;
  background: var(--surface-2); color: var(--muted); text-decoration: none; border: 1px solid transparent;
}
.tags a:hover { color: var(--text); border-color: var(--border); }
.tags--cloud { gap: 8px; }

/* ---------- ads */
.ad { text-align: center; min-height: 0; }
.ad-label { display: block; font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.ad--grid { grid-column: 1 / -1; padding: 8px 0; }
.ad--post { margin: 28px 0; }
.ad--side { margin-bottom: 22px; }

/* ---------- pager */
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 36px 0 8px; flex-wrap: wrap; }
.pager-step, .pager-pages a, .pager-pages span {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px; min-width: 44px; height: 44px; padding: 0 14px;
  border-radius: 999px; font-family: var(--font-display); font-weight: 600; font-size: 16px; text-decoration: none;
  background: var(--surface); color: var(--text); border: 2px solid var(--border);
}
.pager-step:hover, .pager-pages a:hover { border-color: var(--orange); }
.pager-step.is-disabled { opacity: .45; }
.pager-pages { list-style: none; margin: 0; padding: 0; display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.pager-pages .is-current { background: var(--orange); border-color: var(--orange); color: #1a1205; }
.pager-pages .gap { align-self: center; color: var(--muted); padding: 0 4px; }

/* ---------- post */
.post { --c: var(--fact); --ink: var(--fact-ink); }
.post--funny { --c: var(--funny); --ink: var(--funny-ink); }
.post--motivation { --c: var(--motivation); --ink: var(--motivation-ink); }
.post-figure { margin: 0; padding: 10px; background: var(--c); border-radius: calc(var(--radius) + 6px); box-shadow: var(--shadow); }
.post-figure img { width: auto; max-width: 100%; max-height: 82vh; margin: 0 auto; border-radius: var(--radius); background: var(--surface-2); }
.post-body { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px clamp(18px, 3vw, 32px) 26px; margin-top: 18px; box-shadow: var(--shadow); }
.kicker { margin: 0 0 10px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; color: var(--muted); font-weight: 700; font-size: 15px; }
.post-title { font-size: clamp(24px, 3vw, 34px); font-weight: 600; line-height: 1.28; }
.bonus { margin: 22px 0; padding: 16px 18px; border-radius: var(--radius-sm); background: color-mix(in srgb, var(--c) 10%, var(--surface)); border-left: 5px solid var(--c); }
.bonus-title { font-size: 16px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink); margin-bottom: 4px; }
.bonus p { margin: 0; }
.post-body > .tags { margin-top: 18px; }
.share { display: flex; align-items: center; gap: 8px; margin-top: 22px; flex-wrap: wrap; }
.share-label { font-weight: 800; font-size: 14px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-right: 4px; }
.share-btn { position: relative; width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--text); border: 2px solid var(--border); cursor: pointer; text-decoration: none; transition: transform .15s, border-color .15s; }
.share-btn:hover { transform: translateY(-2px); border-color: var(--c); }
.copied { position: absolute; top: -30px; left: 50%; transform: translateX(-50%); font-size: 12px; font-weight: 700; white-space: nowrap; background: var(--text); color: var(--bg); padding: 2px 8px; border-radius: 6px; opacity: 0; pointer-events: none; transition: opacity .2s; }
.copied.show { opacity: 1; }
.source { margin: 16px 0 0; font-size: 15px; color: var(--muted); }

.post-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 22px; }
.post-nav-link { display: flex; align-items: center; gap: 12px; padding: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); text-decoration: none; color: var(--text); box-shadow: var(--shadow); transition: transform .15s; font-weight: 700; font-size: 15px; line-height: 1.35; }
.post-nav-link:hover { transform: translateY(-2px); }
.post-nav-link img { width: 96px; height: 72px; object-fit: cover; border-radius: 10px; flex: none; }
.post-nav-link small { display: flex; align-items: center; gap: 2px; font-family: var(--font-display); font-size: 14px; color: var(--link); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 2px; }
.post-nav-link--next { flex-direction: row-reverse; text-align: right; grid-column: 2; }
.post-nav-link--next small { justify-content: flex-end; }
.related { margin-top: 36px; }

/* ---------- sidebar */
.sidebar { min-width: 0; }
.box { display: block; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 18px 20px; box-shadow: var(--shadow); margin-bottom: 22px; }
.box-title { font-size: 20px; margin-bottom: 12px; }
.link-list { list-style: none; margin: 0; padding: 0; }
.link-list li + li { border-top: 1px dashed var(--border); }
.link-list a { display: block; padding: 8px 2px; color: var(--text); text-decoration: none; font-weight: 700; }
.link-list a:hover, .link-list a[aria-current] { color: var(--link); }
.box--fb { display: flex; align-items: center; gap: 14px; text-decoration: none; color: var(--text); }
.box--fb:hover { border-color: #1877f2; }
.box--fb strong { display: block; font-family: var(--font-display); font-size: 19px; font-weight: 600; text-transform: uppercase; }
.box--fb small { color: var(--muted); font-size: 14px; }
.fb-icon { width: 52px; height: 52px; border-radius: 14px; background: #1877f2; color: #fff; display: grid; place-items: center; flex: none; }
.about { margin-top: 36px; }
.about p { margin: 0; }

/* ---------- footer */
.site-footer { background: var(--surface); border-top: 1px solid var(--border); padding-top: 40px; font-size: 15px; }
.footer-grid { display: grid; grid-template-columns: 1.4fr 1fr 1.4fr .8fr; gap: 32px; }
.footer-brand img { width: 180px; height: auto; margin-bottom: 10px; }
.site-footer p { color: var(--muted); margin: 0; max-width: 42ch; }
.site-footer h2 { font-size: 17px; margin-bottom: 10px; }
.site-footer ul { list-style: none; margin: 0; padding: 0; }
.site-footer li { margin: 0 0 6px; }
.site-footer ul a { color: var(--text); text-decoration: none; }
.site-footer ul a:hover { color: var(--link); text-decoration: underline; }
.site-footer .cols { columns: 2; column-gap: 20px; }
.social { display: flex; gap: 8px; flex-wrap: wrap; }
.social a { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--text); border: 2px solid var(--border); }
.social a:hover { border-color: var(--orange); }
.footer-base { margin-top: 32px; padding-top: 16px; padding-bottom: 24px; border-top: 1px solid var(--border); color: var(--muted); font-size: 14px; }

/* ---------- responsive */
@media (max-width: 1040px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .sidebar { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 0 22px; }
  .ad--side { display: none; }
  .footer-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 760px) {
  body { font-size: 16px; }
  .header-row { flex-wrap: wrap; gap: 10px 12px; }
  .brand img { height: 56px; }
  .theme-toggle { margin-left: auto; }
  .search { order: 3; width: 100%; margin-left: 0; }
  .pills { width: 100%; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
  .pills::-webkit-scrollbar { display: none; }
  .pill { white-space: nowrap; height: 38px; padding: 0 14px; font-size: 15px; }
  .layout { padding-top: 22px; gap: 24px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr)); gap: 16px; }
  .card--featured { flex-direction: column; }
  .card--featured .card-media { flex: none; min-height: 0; aspect-ratio: 4 / 3; border-right: 0; border-bottom: 5px solid var(--c); }
  .card--featured .card-body { padding: 16px; }
  .post-nav { grid-template-columns: 1fr; }
  .post-nav-link--next { grid-column: auto; }
  .post-figure { padding: 6px; border-radius: calc(var(--radius) + 2px); }
  .pager { justify-content: center; }
  .pager-step { flex: 1; }
  .pager-pages { order: 3; width: 100%; }
  .footer-grid { grid-template-columns: 1fr; gap: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}
