/* ---------------------------------------------------------------------------
   Niche Factory base stylesheet — editorial / long-form reading.
   Theming via CSS variables set inline by the renderer on the <html> element.
   --------------------------------------------------------------------------- */

:root {
  --color-primary: #1e293b;
  --color-accent: #0d9488;
  --color-text: #1f2937;
  --color-text-muted: #4b5563;
  --color-text-faint: #6b7280;
  --color-bg: #ffffff;
  --color-surface: #f8fafc;
  --color-border: #e2e8f0;
  --color-border-strong: #cbd5e1;
  --font-heading: Georgia, "Times New Roman", serif;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --measure: 68ch;
  --container: 720px;
  --radius: 6px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 16px rgba(15, 23, 42, 0.06);
}

*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.65;
  color: var(--color-text);
  background: var(--color-bg);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

img, svg, video { max-width: 100%; height: auto; display: block; }

/* ----- Layout primitives ------------------------------------------------- */

main {
  max-width: var(--container);
  margin: 2.5rem auto 4rem;
  padding: 0 1.25rem;
}

section,
article > header,
.prose,
.comparison-table,
.faq { margin-bottom: 2.25rem; }

/* ----- Site header ------------------------------------------------------- */

/* P1-1: flat document masthead. Removed position: sticky and the
   backdrop-filter blur — both were the "this is a SaaS app" gesture the
   editorial register cannot afford. */
.site-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1.1rem clamp(1rem, 4vw, 2.5rem);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg);
}

.site-title {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--color-primary);
  text-decoration: none;
}

.site-title:hover { color: var(--color-accent); }

.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.4rem;
  align-items: center;
}

.site-nav a {
  color: var(--color-text-muted);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
  padding: 0.35rem 0;
  border-bottom: 2px solid transparent;
  transition: color 120ms ease, border-color 120ms ease;
  white-space: nowrap;
  max-width: 18ch;
  overflow: hidden;
  text-overflow: ellipsis;
}

.site-nav a:hover {
  color: var(--color-primary);
  border-bottom-color: var(--color-accent);
}

/* ----- Homepage hero ----------------------------------------------------- */

.home-hero {
  max-width: var(--container);
  margin: 3rem auto 2.5rem;
  padding: 0 1.25rem;
  text-align: left;
}

.home-hero h1 {
  font-family: var(--font-heading);
  font-size: clamp(2rem, 4.2vw, 2.85rem);
  line-height: 1.15;
  margin: 0 0 1rem;
  color: var(--color-primary);
  letter-spacing: -0.02em;
}

.home-hero p {
  font-size: 1.2rem;
  line-height: 1.55;
  color: var(--color-text-muted);
  max-width: 60ch;
  margin: 0;
}

/* Design Pass 2: image-backed homepage hero with title overlay. The
   image surface fills the viewport width and clips to a 16:9 box; the
   overlay holds the H1 + subhead with a dark-to-clear gradient so the
   text stays readable on any image. */
.home-hero--image {
  max-width: none;
  padding: 0;
  margin: 0 0 2.5rem;
  position: relative;
}
.home-hero__image-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: 65vh;
  overflow: hidden;
  background: var(--color-surface);
}
.home-hero__image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.home-hero__overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: clamp(1rem, 4vw, 3rem);
  background: linear-gradient(180deg,
    rgba(0,0,0,0) 0%,
    rgba(0,0,0,0.15) 40%,
    rgba(0,0,0,0.65) 100%);
  color: #ffffff;
}
.home-hero__overlay h1 {
  font-family: var(--font-heading);
  font-size: clamp(2rem, 4.6vw, 3rem);
  line-height: 1.1;
  margin: 0 0 0.5rem;
  color: #ffffff;
  letter-spacing: -0.02em;
  text-shadow: 0 2px 16px rgba(0,0,0,0.45);
}
.home-hero__overlay p {
  font-size: clamp(1rem, 1.6vw, 1.2rem);
  line-height: 1.45;
  color: #f3f4f6;
  max-width: 60ch;
  margin: 0;
  text-shadow: 0 1px 8px rgba(0,0,0,0.35);
}
/* Marketing / landing-page variant: title centered horizontally and
   vertically with a darker full overlay so the title reads against any
   image. Toggle via CONFIG_HERO_TITLE_POSITION=center. */
.home-hero__overlay--center {
  justify-content: center;
  align-items: center;
  text-align: center;
  background: linear-gradient(180deg,
    rgba(0,0,0,0.35) 0%,
    rgba(0,0,0,0.45) 50%,
    rgba(0,0,0,0.55) 100%);
}
.home-hero__overlay--center h1 {
  margin-left: auto;
  margin-right: auto;
}
.home-hero__overlay--center p {
  max-width: 50ch;
  margin-left: auto;
  margin-right: auto;
}

/* Category page hero: medium 16:9, no overlay. */
.category-hero {
  margin: 0 0 1.5rem;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
}
.category-hero__image {
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: 380px;
  object-fit: cover;
  display: block;
}

/* Article-top hero: 4:3 frame, no overlay; lazy-loaded by HTML. */
.article-hero {
  margin: 1.25rem 0 1.75rem;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
}
.article-hero__image {
  width: 100%;
  aspect-ratio: 4 / 3;
  max-height: 520px;
  object-fit: cover;
  display: block;
}

/* ----- Article header / breadcrumbs ------------------------------------- */

article > header { margin-bottom: 1.75rem; }

article > header h1 {
  font-family: var(--font-heading);
  font-size: clamp(1.8rem, 3.6vw, 2.55rem);
  line-height: 1.2;
  margin: 0.4rem 0 0.75rem;
  color: var(--color-primary);
  letter-spacing: -0.015em;
}

.reading-time {
  margin: 0;
  font-size: 0.875rem;
  color: var(--color-text-faint);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}

.breadcrumbs {
  font-size: 0.85rem;
  color: var(--color-text-faint);
  margin-bottom: 1rem;
}

.breadcrumbs a {
  color: var(--color-text-muted);
  text-decoration: none;
}

.breadcrumbs a:hover {
  color: var(--color-accent);
  text-decoration: underline;
}

.breadcrumbs span[aria-current="page"] {
  color: var(--color-primary);
  font-weight: 500;
}

/* ----- Hero image -------------------------------------------------------- */

figure.hero {
  margin: 1.5rem 0 2rem;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--color-surface);
  box-shadow: var(--shadow-md);
}

figure.hero img {
  width: 100%;
  height: auto;
  object-fit: cover;
}

/* ----- Prose ------------------------------------------------------------- */

.prose {
  max-width: var(--measure);
  font-size: 1.05rem;
  color: var(--color-text);
}

.prose h2 {
  font-family: var(--font-heading);
  font-size: 1.65rem;
  line-height: 1.25;
  margin: 2.4rem 0 0.85rem;
  color: var(--color-primary);
  letter-spacing: -0.01em;
}

.prose h3 {
  font-family: var(--font-heading);
  font-size: 1.3rem;
  margin: 1.8rem 0 0.7rem;
  color: var(--color-primary);
}

.prose h4 {
  font-family: var(--font-body);
  font-size: 1.05rem;
  font-weight: 700;
  margin: 1.4rem 0 0.5rem;
  color: var(--color-primary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.prose p { margin: 0 0 1.15rem; }

.prose a {
  color: var(--color-accent);
  text-decoration: none;
  border-bottom: 1px solid currentColor;
  transition: opacity 120ms ease;
}

.prose a:hover { opacity: 0.75; }

.prose ul,
.prose ol { padding-left: 1.4rem; margin: 0 0 1.25rem; }

.prose li { margin: 0.4rem 0; }

.prose code {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.9em;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  padding: 0.08em 0.35em;
}

.prose strong { color: var(--color-primary); font-weight: 700; }
.prose em { font-style: italic; }

/* ----- Pullquote -------------------------------------------------------- */

.pullquote {
  margin: 2rem 0;
  padding: 0.5rem 0 0.5rem 1.4rem;
  border-left: 4px solid var(--color-accent);
  font-family: var(--font-heading);
}

.pullquote blockquote {
  margin: 0;
  font-size: 1.35rem;
  line-height: 1.45;
  color: var(--color-primary);
  font-style: italic;
  font-weight: 500;
}

.pullquote-attribution {
  display: block;
  margin-top: 0.6rem;
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-style: normal;
  color: var(--color-text-faint);
  letter-spacing: 0.02em;
}

/* ----- Comparison table ------------------------------------------------- */

.comparison-table {
  margin: 2rem 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.comparison-table table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.95rem;
  background: var(--color-bg);
  box-shadow: var(--shadow-sm);
  border-radius: var(--radius);
  overflow: hidden;
}

.comparison-table caption {
  caption-side: top;
  text-align: left;
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--color-primary);
  padding: 0.25rem 0 0.85rem;
}

.comparison-table thead th {
  background: var(--color-surface);
  color: var(--color-primary);
  font-weight: 600;
  text-align: left;
  padding: 0.7rem 0.9rem;
  border-bottom: 2px solid var(--color-border-strong);
}

.comparison-table tbody th,
.comparison-table tbody td {
  padding: 0.65rem 0.9rem;
  border-bottom: 1px solid var(--color-border);
  vertical-align: top;
}

.comparison-table tbody th {
  text-align: left;
  font-weight: 600;
  color: var(--color-primary);
  background: var(--color-surface);
  width: 12rem;
}

.comparison-table tbody tr:last-child th,
.comparison-table tbody tr:last-child td { border-bottom: 0; }

/* ----- FAQ -------------------------------------------------------------- */

.faq h2 {
  font-family: var(--font-heading);
  font-size: 1.55rem;
  color: var(--color-primary);
  margin: 0 0 1rem;
}

.faq details {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  margin: 0.6rem 0;
  background: var(--color-bg);
  transition: box-shadow 120ms ease;
}

.faq details[open] { box-shadow: var(--shadow-sm); }

.faq summary {
  font-weight: 600;
  color: var(--color-primary);
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-right: 0.25rem;
}

.faq summary::-webkit-details-marker { display: none; }

.faq summary::after {
  content: "+";
  font-size: 1.4rem;
  line-height: 1;
  color: var(--color-accent);
  transition: transform 160ms ease;
}

.faq details[open] summary::after { content: "−"; }

.faq details > div {
  margin-top: 0.6rem;
  color: var(--color-text-muted);
  line-height: 1.6;
}

.faq details > div p { margin: 0 0 0.6rem; }
.faq details > div p:last-child { margin-bottom: 0; }

/* ----- Footer ----------------------------------------------------------- */

.site-footer {
  margin-top: 4rem;
  padding: 3rem 1.5rem 1.5rem;
  border-top: 1px solid var(--color-border);
  color: var(--color-text-muted);
  font-size: 0.92rem;
  background: var(--color-surface);
}

.site-footer__columns {
  display: grid;
  gap: 2rem;
  max-width: 1100px;
  margin: 0 auto 2rem;
}

.site-footer__columns--3 { grid-template-columns: 1.4fr 1fr 1fr; }
.site-footer__columns--2 { grid-template-columns: 1fr 1fr; }
.site-footer__columns--1 { grid-template-columns: 1fr; }
.site-footer__col { min-width: 0; }
.site-footer__heading {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-heading);
  margin: 0 0 0.85rem;
}
.site-footer__subheading {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-text);
  margin: 0.75rem 0 0.35rem;
}
.site-footer__category-groups { list-style: none; margin: 0; padding: 0; }
.site-footer__category-group + .site-footer__category-group { margin-top: 0.5rem; }
.site-footer__links { list-style: none; margin: 0; padding: 0; }
.site-footer__links li { margin: 0.25rem 0; }
.site-footer__links a {
  color: var(--color-text-muted);
  text-decoration: none;
  font-size: 0.92rem;
}
.site-footer__links a:hover { color: var(--color-accent); text-decoration: underline; }

.site-footer__legal {
  border-top: 1px solid var(--color-border);
  padding-top: 1rem;
  text-align: center;
  color: var(--color-text-faint);
  font-size: 0.85rem;
  max-width: 1100px;
  margin: 0 auto;
}
.site-footer__legal p { margin: 0; }

/* ----- Responsive ------------------------------------------------------- */

@media (max-width: 768px) {
  body { font-size: 16px; }
  main { margin: 1.5rem auto 3rem; }
  .site-header {
    flex-direction: column;
    align-items: flex-start;
    padding: 0.85rem 1rem;
  }
  .site-nav { gap: 0.25rem 1rem; }
  .home-hero { margin: 2rem auto 1.75rem; }
  .home-hero h1 { font-size: 1.85rem; }
  .home-hero p { font-size: 1.05rem; }
  article > header h1 { font-size: 1.7rem; }
  .prose h2 { font-size: 1.4rem; margin-top: 2rem; }
  .pullquote blockquote { font-size: 1.15rem; }
  .comparison-table tbody th { width: auto; }
  .site-footer__columns--3,
  .site-footer__columns--2 { grid-template-columns: 1fr; }
}
