/*
Theme Name: Punchline
Theme URI: https://example.com/punchline
Author: Muhammad Imran
Description: A fast, lightweight WordPress theme built specifically for joke and humor sites. One stylesheet, no jQuery on the front end, no page-builder bloat — every joke renders as a torn-paper "ticket" card, with a random-joke dispenser, lightweight reactions, and script-free share links.
Version: 1.0.0
Requires at least: 6.0
Requires PHP: 7.4
License: GPL v2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: punchline
*/

/* -----------------------------------------------------------------------
   Design tokens
   ----------------------------------------------------------------------- */
:root {
  --jf-paper: #F7ECD1;
  --jf-surface: #FFFDF6;
  --jf-ink: #241608;
  --jf-muted: #6E5B40;
  --jf-border: #DCC89A;
  --jf-accent: #E8402A;
  --jf-accent-ink: #FFF6F0;
  --jf-pine: #1B6E5B;
  --jf-gold: #F2B705;

  --jf-display: 'Big Shoulders Text', ui-sans-serif, system-ui, sans-serif;
  --jf-body: 'Work Sans', ui-sans-serif, system-ui, -apple-system, sans-serif;
  --jf-mono: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;

  --jf-radius: 22px;
  --jf-max: 720px;
  --jf-gap: clamp(1rem, 2vw, 1.75rem);
}

/* -----------------------------------------------------------------------
   Reset (small and deliberate — no external normalize dependency)
   ----------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}
body {
  margin: 0;
  background: var(--jf-paper);
  color: var(--jf-ink);
  font-family: var(--jf-body);
  font-size: 1.0625rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; height: auto; display: block; }
a { color: var(--jf-pine); text-decoration-thickness: 1.5px; text-underline-offset: 3px; }
a:hover { color: var(--jf-accent); }
h1, h2, h3, h4 {
  font-family: var(--jf-display);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: 0.01em;
  margin: 0 0 0.5em;
}
ul, ol { padding-left: 1.25em; }
button { font-family: inherit; }

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

.jf-container {
  max-width: 1080px;
  margin-inline: auto;
  padding-inline: var(--jf-gap);
}
.jf-narrow { max-width: var(--jf-max); }
.screen-reader-text {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(1px,1px,1px,1px); white-space: nowrap;
}

/* -----------------------------------------------------------------------
   Header
   ----------------------------------------------------------------------- */
.jf-header {
  padding: 1.25rem var(--jf-gap);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  border-bottom: 2px dashed var(--jf-border);
}
.jf-brand {
  font-family: var(--jf-display);
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--jf-ink);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}
.jf-brand:hover { color: var(--jf-accent); }
.jf-brand-stamp {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem; height: 2rem;
  border-radius: 999px;
  background: var(--jf-accent);
  color: var(--jf-accent-ink);
  font-size: 1.1rem;
  transform: rotate(-8deg);
}
.jf-nav ul {
  list-style: none;
  display: flex;
  gap: 1.5rem;
  margin: 0;
  padding: 0;
  flex-wrap: wrap;
}
.jf-nav a {
  font-family: var(--jf-mono);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--jf-ink);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  padding-bottom: 2px;
}
.jf-nav a:hover { border-color: var(--jf-accent); color: var(--jf-accent); }

/* -----------------------------------------------------------------------
   Hero
   ----------------------------------------------------------------------- */
.jf-hero {
  padding: clamp(2rem, 6vw, 4rem) var(--jf-gap) 1rem;
  text-align: center;
}
.jf-hero-eyebrow {
  font-family: var(--jf-mono);
  font-size: 0.8rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--jf-pine);
  margin-bottom: 0.75rem;
}
.jf-hero h1 {
  font-size: clamp(2.25rem, 6vw, 3.75rem);
  max-width: 16ch;
  margin-inline: auto;
}

/* -----------------------------------------------------------------------
   Card grid — preview cards for lists (homepage, archives, related posts).
   Keeps the ticket/paper motif as a decorative touch (the perforated strip
   under the image) without forcing giant display type onto real content.
   ----------------------------------------------------------------------- */
.jf-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--jf-gap);
  margin: 1.5rem 0 2.5rem;
}
.jf-grid--3 { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }

.jf-card {
  position: relative;
  background: var(--jf-surface);
  border: 2px solid var(--jf-border);
  border-radius: var(--jf-radius);
  overflow: hidden;
  box-shadow: 0 10px 24px -18px rgba(36, 22, 8, 0.35);
  display: flex;
  flex-direction: column;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.jf-card:hover { transform: translateY(-3px); box-shadow: 0 16px 28px -16px rgba(36, 22, 8, 0.4); }

.jf-card-media { display: block; aspect-ratio: 16/10; overflow: hidden; position: relative; }
.jf-card-media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.jf-card-media::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -7px;
  height: 14px;
  background-image: radial-gradient(circle, var(--jf-surface) 4.5px, transparent 5px);
  background-size: 16px 16px;
  background-repeat: repeat-x;
}

.jf-card-body { padding: 1.25rem 1.35rem 1.5rem; display: flex; flex-direction: column; gap: 0.6rem; flex: 1; }

.jf-card-eyebrow {
  display: inline-block;
  align-self: flex-start;
  font-family: var(--jf-mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--jf-pine);
  background: rgba(27, 110, 89, 0.1);
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
}
.jf-card-title {
  font-family: var(--jf-display);
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.25;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.jf-card-title a { color: var(--jf-ink); text-decoration: none; }
.jf-card-title a:hover { color: var(--jf-accent); }
.jf-card-excerpt {
  font-size: 0.92rem;
  color: var(--jf-muted);
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.jf-card-cta {
  align-self: flex-start;
  font-size: 0.85rem;
  padding: 0.55rem 1.1rem;
  margin-top: 0.25rem;
}

/* Hero variant — the homepage's featured/swappable card, bigger and split
   into an image + text layout on wider screens. */
.jf-card--hero {
  max-width: var(--jf-max);
  margin: 0 auto;
  border-radius: 28px;
}
@media (min-width: 720px) {
  .jf-card--hero { flex-direction: row; }
  .jf-card--hero .jf-card-media { flex: 0 0 44%; aspect-ratio: auto; }
  .jf-card--hero .jf-card-media::after { display: none; }
  .jf-card--hero .jf-card-body { flex: 1; padding: 1.75rem 2rem; justify-content: center; }
  .jf-card--hero .jf-card-title {
    font-size: clamp(1.4rem, 2.6vw, 1.85rem);
    -webkit-line-clamp: 3;
  }
  .jf-card--hero .jf-card-excerpt { -webkit-line-clamp: 4; }
}

/* Reactions */
.jf-reactions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.4rem;
  flex-wrap: wrap;
}
.jf-react-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border: 2px solid var(--jf-border);
  background: var(--jf-paper);
  border-radius: 999px;
  padding: 0.4rem 0.8rem;
  font-family: var(--jf-mono);
  font-size: 0.8rem;
  cursor: pointer;
  color: var(--jf-ink);
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.jf-react-btn:hover { border-color: var(--jf-accent); transform: translateY(-1px); }
.jf-react-btn[disabled] { opacity: 0.6; cursor: default; transform: none; }
.jf-react-btn .jf-count { font-weight: 600; }

/* Share links — plain anchors, no JS SDKs */
.jf-share {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}
.jf-share a {
  font-family: var(--jf-mono);
  font-size: 0.8rem;
  text-decoration: none;
  border: 2px solid var(--jf-ink);
  color: var(--jf-ink);
  border-radius: 999px;
  padding: 0.4rem 0.85rem;
}
.jf-share a:hover { background: var(--jf-ink); color: var(--jf-paper); }

.jf-copy-btn {
  font-family: var(--jf-mono);
  font-size: 0.8rem;
  border: 2px dashed var(--jf-ink);
  background: transparent;
  color: var(--jf-ink);
  border-radius: 999px;
  padding: 0.38rem 0.85rem;
  cursor: pointer;
}

/* -----------------------------------------------------------------------
   Single article + hand-coded pages
   ----------------------------------------------------------------------- */
.jf-article-header { text-align: center; padding-top: 1rem; }
.jf-article-title {
  font-size: clamp(1.7rem, 4vw, 2.5rem);
  max-width: 22ch;
  margin: 0.75rem auto 0;
}
.jf-article-media {
  margin: 1.5rem 0;
  border-radius: var(--jf-radius);
  overflow: hidden;
  aspect-ratio: 16/9;
}
.jf-article-media img { width: 100%; height: 100%; object-fit: cover; display: block; }

.jf-article-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 1rem;
  padding: 1rem 0;
  margin-bottom: 1rem;
  border-top: 2px dashed var(--jf-border);
  border-bottom: 2px dashed var(--jf-border);
}
.jf-article-toolbar .jf-share { margin-top: 0; }

/* Long-form content typography — used for both single articles and
   hand-written Pages, so custom HTML gets real styling automatically
   instead of falling back to plain unstyled text. */
.jf-content { font-size: 1.05rem; line-height: 1.75; }
.jf-content > *:first-child { margin-top: 0; }
.jf-content h2 {
  font-size: clamp(1.3rem, 2.6vw, 1.65rem);
  margin: 2.25rem 0 0.85rem;
  padding-bottom: 0.4rem;
  border-bottom: 3px solid var(--jf-gold);
  display: inline-block;
}
.jf-content h3 {
  font-size: 1.2rem;
  margin: 1.75rem 0 0.6rem;
  color: var(--jf-pine);
}
.jf-content h4 {
  font-size: 1.05rem;
  margin: 1.4rem 0 0.5rem;
}
.jf-content p { margin: 0 0 1.1rem; }
.jf-content ul, .jf-content ol { margin: 0 0 1.25rem; padding-left: 1.4em; }
.jf-content li { margin-bottom: 0.5rem; }
.jf-content li::marker { color: var(--jf-accent); font-weight: 700; }
.jf-content strong { color: var(--jf-ink); background: rgba(242, 183, 5, 0.28); padding: 0 0.15em; border-radius: 3px; }
.jf-content a { text-decoration-color: var(--jf-pine); }
.jf-content blockquote {
  margin: 1.5rem 0;
  padding: 1rem 1.25rem;
  border-left: 4px solid var(--jf-accent);
  background: var(--jf-surface);
  border-radius: 0 12px 12px 0;
  font-style: italic;
  color: var(--jf-muted);
}
.jf-content img {
  border-radius: var(--jf-radius);
  margin: 1.5rem 0;
}
.jf-content hr {
  border: none;
  border-top: 2px dashed var(--jf-border);
  margin: 2.5rem 0;
}
.jf-content table { width: 100%; border-collapse: collapse; margin: 1.5rem 0; font-size: 0.95rem; }
.jf-content th, .jf-content td { border: 1px solid var(--jf-border); padding: 0.6rem 0.8rem; text-align: left; }
.jf-content th { background: var(--jf-surface); font-family: var(--jf-mono); font-size: 0.85rem; text-transform: uppercase; }
.jf-copy-btn:hover { border-style: solid; }

/* -----------------------------------------------------------------------
   Dispenser button ("tear off another joke")
   ----------------------------------------------------------------------- */
.jf-dispenser {
  text-align: center;
  margin: 1.5rem 0 3rem;
}
.jf-tear-btn {
  font-family: var(--jf-display);
  font-weight: 700;
  font-size: 1.1rem;
  background: var(--jf-accent);
  color: var(--jf-accent-ink);
  border: none;
  border-radius: 999px;
  padding: 0.9rem 2rem;
  cursor: pointer;
  box-shadow: 0 10px 24px -12px rgba(232, 64, 42, 0.55);
  transition: transform 0.15s ease;
}
.jf-tear-btn:hover { transform: translateY(-2px); }
.jf-tear-btn:active { transform: translateY(0); }
.jf-tear-btn[aria-busy="true"] { opacity: 0.7; cursor: wait; }

@keyframes jf-print-in {
  from { opacity: 0; transform: translateY(-14px); }
  to   { opacity: 1; transform: translateY(0); }
}
.jf-just-printed { animation: jf-print-in 0.35s ease; }

/* -----------------------------------------------------------------------
   Category chip rail
   ----------------------------------------------------------------------- */
.jf-chip-rail {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  justify-content: center;
  padding: 0 var(--jf-gap) 2rem;
}
.jf-chip {
  font-family: var(--jf-mono);
  font-size: 0.8rem;
  text-decoration: none;
  color: var(--jf-ink);
  background: var(--jf-surface);
  border: 2px solid var(--jf-border);
  border-radius: 999px;
  padding: 0.4rem 0.9rem;
}
.jf-chip:hover, .jf-chip.is-active { border-color: var(--jf-pine); color: var(--jf-pine); }

/* -----------------------------------------------------------------------
   Lists / archive
   ----------------------------------------------------------------------- */
.jf-section-title {
  font-family: var(--jf-mono);
  font-size: 0.85rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--jf-muted);
  text-align: center;
  margin: 0 0 1rem;
}
.jf-pagination {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  margin: 2rem 0 4rem;
  font-family: var(--jf-mono);
}
.jf-pagination a, .jf-pagination span {
  padding: 0.4rem 0.8rem;
  border: 2px solid var(--jf-border);
  border-radius: 8px;
  text-decoration: none;
  color: var(--jf-ink);
}
.jf-pagination .current { background: var(--jf-ink); color: var(--jf-paper); border-color: var(--jf-ink); }

/* -----------------------------------------------------------------------
   Single joke page
   ----------------------------------------------------------------------- */
.jf-related-title {
  text-align: center;
  font-family: var(--jf-mono);
  text-transform: uppercase;
  font-size: 0.85rem;
  letter-spacing: 0.1em;
  color: var(--jf-muted);
  margin: 3rem 0 0.5rem;
}

/* -----------------------------------------------------------------------
   404
   ----------------------------------------------------------------------- */
.jf-404 { text-align: center; padding: 3rem var(--jf-gap); }

/* -----------------------------------------------------------------------
   Footer
   ----------------------------------------------------------------------- */
.jf-footer {
  border-top: 2px dashed var(--jf-border);
  padding: 2.5rem var(--jf-gap);
  margin-top: 2rem;
}
.jf-footer-inner {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1.5rem;
  font-family: var(--jf-mono);
  font-size: 0.8rem;
  color: var(--jf-muted);
}
.jf-footer-nav ul { list-style: none; display: flex; gap: 1.25rem; padding: 0; margin: 0; flex-wrap: wrap; }
.jf-footer-nav a { color: var(--jf-muted); text-decoration: none; }
.jf-footer-nav a:hover { color: var(--jf-accent); }
.jf-widget-title { font-family: var(--jf-mono); font-size: 0.8rem; text-transform: uppercase; }

@media (max-width: 640px) {
  .jf-header { justify-content: center; text-align: center; }
  .jf-footer-inner { flex-direction: column; text-align: center; align-items: center; }
}

/* -----------------------------------------------------------------------
   Optional sidebar layout — off by default (see Customizer). When on,
   switches single/archive content to a two-column grid.
   ----------------------------------------------------------------------- */
.jf-layout {
  display: block;
}
body.has-sidebar .jf-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: var(--jf-gap);
  align-items: start;
  max-width: 1080px;
  margin-inline: auto;
  padding-inline: var(--jf-gap);
}
body.has-sidebar .jf-layout .jf-narrow {
  max-width: none;
  padding-inline: 0;
  margin: 0;
}
.jf-sidebar { display: flex; flex-direction: column; gap: 1.5rem; }
.jf-sidebar .jf-widget {
  background: var(--jf-surface);
  border: 2px solid var(--jf-border);
  border-radius: 16px;
  padding: 1.25rem;
}
@media (max-width: 860px) {
  body.has-sidebar .jf-layout { grid-template-columns: 1fr; }
}

/* -----------------------------------------------------------------------
   Next/previous post navigation
   ----------------------------------------------------------------------- */
.jf-post-nav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin: 2rem 0;
  font-family: var(--jf-mono);
  font-size: 0.85rem;
}
.jf-post-nav .nav-previous, .jf-post-nav .nav-next { flex: 1; }
.jf-post-nav .nav-next { text-align: right; }
.jf-post-nav a { text-decoration: none; color: var(--jf-ink); }
.jf-post-nav a:hover { color: var(--jf-accent); }
.jf-post-nav .nav-subtitle {
  display: block;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.7rem;
  color: var(--jf-muted);
  margin-bottom: 0.2rem;
}
.jf-post-nav .nav-title { font-family: var(--jf-display); font-size: 1.05rem; font-weight: 700; }
