/*
Theme Name: Thinking Naughty
Theme URI: https://thinkingnaughty.com
Author: Thinking Naughty
Description: A relationship and humor blog theme with a dark-first, Linear-and-editorial-inspired magazine layout, full Customizer support, and WooCommerce styling for future merch.
Version: 1.0.0
Requires at least: 6.0
Requires PHP: 7.4
Text Domain: thinkingnaughty
*/

/* ==========================================================================
   Design tokens
   Dark mode is the default. Light mode overrides via [data-theme="light"]
   on the html element, toggled client-side and persisted in localStorage.
   ========================================================================== */

:root {
  /* Dark mode, default */
  --bg: #0A0A0D;
  --bg-raised: #16161B;
  --bg-card: #1C1C22;
  --border: rgba(255,255,255,0.08);
  --border-strong: rgba(255,255,255,0.14);

  --text: #EDEDF0;
  --text-dim: #9B9BA5;
  --text-faint: #6B6B75;

  --red: #B43331;
  --red-text: #D65450;   /* WCAG AA-safe (4.94:1) variant for small text/links on dark bg; base red only clears 3.26:1 */
  --red-tint: rgba(180,51,49,0.14);

  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, monospace;

  --measure: 68ch;
  --radius: 10px;
  --shadow: 0 8px 30px rgba(0,0,0,0.35);
}

[data-theme="light"] {
  --bg: #FBF9F6;
  --bg-raised: #FFFFFF;
  --bg-card: #FFFFFF;
  --border: rgba(20,16,14,0.10);
  --border-strong: rgba(20,16,14,0.18);

  --text: #211C19;
  --text-dim: #5C5651;
  --text-faint: #8A837C;

  --red: #B43331;
  --red-text: #8F2A28;  /* deepened variant (7.90:1) for small text/links on light bg */
  --red-tint: rgba(180,51,49,0.08);

  --shadow: 0 8px 30px rgba(20,16,14,0.08);
}

/* ==========================================================================
   Reset and base
   ========================================================================== */

*, *::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;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.25s ease, color 0.25s ease;
}

img { max-width: 100%; height: auto; display: block; }
a { color: var(--red-text); text-decoration: none; }
a:hover, a:focus-visible { text-decoration: underline; }
a:focus-visible, button:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--red-text);
  outline-offset: 3px;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.15;
  color: var(--text);
  margin: 0 0 0.5em;
}

.wrap { max-width: 1160px; margin: 0 auto; padding: 0 24px; }
.wrap-narrow { max-width: 760px; margin: 0 auto; padding: 0 24px; }

/* ==========================================================================
   Site header
   ========================================================================== */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.site-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 16px 24px;
  max-width: 1160px;
  margin: 0 auto;
}
.site-logo img { height: 32px; width: auto; }
.site-logo-text {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--text);
}
.primary-nav ul {
  list-style: none;
  display: flex;
  gap: 28px;
  margin: 0;
  padding: 0;
}
.primary-nav a {
  color: var(--text-dim);
  font-size: 0.92rem;
  font-weight: 500;
}
.primary-nav a:hover, .primary-nav a:focus-visible { color: var(--text); text-decoration: none; }
.header-right { display: flex; align-items: center; gap: 16px; }

.theme-toggle {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 7px 14px;
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  cursor: pointer;
  transition: border-color 0.2s ease, color 0.2s ease;
}
.theme-toggle:hover { border-color: var(--border-strong); color: var(--text); }

.menu-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  font-size: 1.4rem;
  cursor: pointer;
}

@media (max-width: 720px) {
  .primary-nav { display: none; }
  .primary-nav.is-open {
    display: flex;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-raised);
    border-bottom: 1px solid var(--border);
    padding: 16px 24px;
  }
  .primary-nav.is-open ul { flex-direction: column; gap: 18px; }
  .menu-toggle { display: block; }
}

/* ==========================================================================
   Homepage magazine feed
   ========================================================================== */

.feed-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 32px 0 8px;
}
.feed-tab {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  letter-spacing: 0.02em;
  color: var(--text-dim);
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 7px 16px;
}
.feed-tab.is-active { color: var(--text); border-color: var(--red); background: var(--red-tint); }
.feed-tab:hover { color: var(--text); }

.feed-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 20px;
  padding: 24px 0 60px;
}
.feed-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color 0.2s ease, transform 0.2s ease;
}
.feed-card:hover { border-color: var(--border-strong); transform: translateY(-2px); }
.feed-card.is-featured { grid-column: span 3; grid-row: span 2; }
.feed-card:not(.is-featured) { grid-column: span 3; }
.feed-card-media { aspect-ratio: 16/9; overflow: hidden; background: var(--bg-raised); }
.feed-card-media img { width: 100%; height: 100%; object-fit: cover; }
.feed-card-body { padding: 20px 22px 22px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.feed-card-cat {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--red-text);
}
.feed-card h2, .feed-card h3 {
  font-size: 1.15rem;
  margin: 0;
}
.feed-card.is-featured h2 { font-size: 1.7rem; }
.feed-card-excerpt { color: var(--text-dim); font-size: 0.92rem; margin: 0; flex: 1; }
.feed-card-meta { font-family: var(--font-mono); font-size: 0.76rem; color: var(--text-faint); margin-top: 4px; }

@media (max-width: 900px) {
  .feed-grid { grid-template-columns: repeat(2, 1fr); }
  .feed-card.is-featured { grid-column: span 1; grid-row: span 1; }
  .feed-card:not(.is-featured) { grid-column: span 1; }
}
@media (max-width: 560px) {
  .feed-grid { grid-template-columns: 1fr; }
  .feed-card.is-featured, .feed-card:not(.is-featured) { grid-column: span 1; }
}

/* ==========================================================================
   Single post
   ========================================================================== */

.single-post { padding: 56px 0 80px; }
.single-post-header { max-width: var(--measure); margin: 0 auto 32px; }
.single-post-cat {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--red-text);
  margin-bottom: 14px;
}
.single-post-header h1 { font-size: clamp(1.9rem, 4vw, 2.6rem); }
.single-post-meta { font-family: var(--font-mono); font-size: 0.82rem; color: var(--text-faint); margin-top: 10px; }
.single-post-media { margin: 32px auto; max-width: 900px; border-radius: var(--radius); overflow: hidden; }
.single-post-content { max-width: var(--measure); margin: 0 auto; font-size: 1.08rem; }
.single-post-content p { margin: 0 0 1.4em; color: var(--text); }
.single-post-content h2, .single-post-content h3 { margin-top: 1.6em; }
.single-post-content a { border-bottom: 1px solid var(--red-tint); }
.single-post-content blockquote {
  border-left: 3px solid var(--red);
  margin: 1.6em 0;
  padding: 0.2em 0 0.2em 1.4em;
  color: var(--text-dim);
  font-style: italic;
}
.single-post-tags { max-width: var(--measure); margin: 40px auto 0; display: flex; gap: 10px; flex-wrap: wrap; }
.single-post-tags a {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-dim);
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 5px 12px;
}

/* ==========================================================================
   Archive
   ========================================================================== */

.archive-header { padding: 48px 0 8px; text-align: center; }
.archive-header h1 { font-size: clamp(1.7rem, 4vw, 2.2rem); }
.archive-list { display: flex; flex-direction: column; gap: 32px; padding: 32px 0 60px; max-width: var(--measure); margin: 0 auto; }
.archive-item { display: flex; gap: 22px; }
.archive-item-media { width: 160px; flex-shrink: 0; aspect-ratio: 4/3; border-radius: var(--radius); overflow: hidden; }
.archive-item-media img { width: 100%; height: 100%; object-fit: cover; }
.archive-item h2 { font-size: 1.2rem; margin: 0 0 6px; }
.archive-item-excerpt { color: var(--text-dim); font-size: 0.94rem; margin: 6px 0 0; }
@media (max-width: 560px) {
  .archive-item { flex-direction: column; }
  .archive-item-media { width: 100%; aspect-ratio: 16/9; }
}

/* ==========================================================================
   Footer
   ========================================================================== */

.site-footer {
  border-top: 1px solid var(--border);
  padding: 40px 0;
  margin-top: 40px;
}
.site-footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  max-width: 1160px;
  margin: 0 auto;
  padding: 0 24px;
}
.footer-links { list-style: none; display: flex; gap: 20px; margin: 0; padding: 0; }
.footer-links a { color: var(--text-dim); font-size: 0.88rem; }
.footer-links a:hover { color: var(--text); }
.footer-copy { color: var(--text-faint); font-size: 0.82rem; }

/* ==========================================================================
   WooCommerce
   ========================================================================== */

.woocommerce ul.products { display: grid; grid-template-columns: repeat(4, 1fr); gap: 24px; list-style: none; padding: 0; }
.woocommerce ul.products li.product {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  text-align: left;
}
.woocommerce ul.products li.product img { border-radius: 6px; margin-bottom: 12px; }
.woocommerce ul.products li.product h2 { font-size: 1rem; color: var(--text); }
.woocommerce ul.products li.product .price { color: var(--red-text); font-family: var(--font-mono); font-weight: 600; }
.woocommerce span.onsale {
  background: var(--red);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  border-radius: 4px;
  padding: 3px 8px;
}
.woocommerce div.product .product_title { font-family: var(--font-display); }
.woocommerce a.button, .woocommerce button.button, .woocommerce input.button,
.woocommerce #respond input#submit {
  background: var(--red);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 12px 22px;
  font-family: var(--font-body);
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s ease;
}
.woocommerce a.button:hover, .woocommerce button.button:hover, .woocommerce input.button:hover {
  background: color-mix(in srgb, var(--red) 85%, black);
}
.woocommerce nav.woocommerce-pagination ul { border-color: var(--border); }
.woocommerce nav.woocommerce-pagination ul li { border-color: var(--border); }
.woocommerce nav.woocommerce-pagination ul li a, .woocommerce nav.woocommerce-pagination ul li span {
  color: var(--text-dim);
}
.woocommerce table.shop_table { border-color: var(--border); }
.woocommerce table.shop_table th { color: var(--text); }
.woocommerce table.shop_table td { border-color: var(--border); color: var(--text-dim); }
.woocommerce-checkout input, .woocommerce-checkout select, .woocommerce-checkout textarea,
.woocommerce form .form-row input.input-text, .woocommerce form .form-row textarea {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 10px 12px;
}

@media (max-width: 900px) {
  .woocommerce ul.products { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
  .woocommerce ul.products { grid-template-columns: 1fr; }
}
