/* ============================================================
   StoryForSleep — Design Tokens & Phase 2 Styles
   Theme: "dusk reading light" — a calm night-sky palette for a
   bedtime-stories site. Warm moonlight-gold accent against deep
   indigo, literary serif for headlines, clean sans for body.
   ============================================================ */

:root {
  /* Color */
  --ink-950: #12142A;      /* deepest background, night sky */
  --ink-900: #191C38;      /* header / surface */
  --ink-800: #242849;      /* card surface, hover state */
  --parchment: #F1ECDD;    /* primary text, warm off-white */
  --parchment-dim: #B9B4A6;/* secondary text */
  --moonlight: #E8B96B;    /* primary accent, warm gold */
  --moonlight-soft: #F3D9A4;
  --dusk-rose: #C97B84;    /* secondary accent, sparingly */
  --line: rgba(241, 236, 221, 0.12);

  /* Type */
  --font-display: "Playfair Display", Georgia, serif;
  --font-body: "Inter", -apple-system, sans-serif;

  /* Layout */
  --header-h: 52px;
  --hero-pad: clamp(48px, 8vw, 96px);
  --radius: 10px;
  --max-w: 1180px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--ink-950);
  color: var(--parchment);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
a:focus-visible, button:focus-visible {
  outline: 2px solid var(--moonlight);
  outline-offset: 2px;
}

/* ---------- Utility bar (pages left, social right) ---------- */
.sfs-utility-bar {
  background: var(--ink-900);
  border-bottom: 1px solid var(--line);
  padding: 10px clamp(16px, 4vw, 40px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  color: var(--parchment-dim);
}

.sfs-utility-bar .sfs-pages {
  display: flex;
  gap: 20px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.sfs-utility-bar .sfs-pages a:hover { color: var(--moonlight); }

.sfs-utility-bar .sfs-social {
  display: flex;
  align-items: center;
  gap: 14px;
}

.sfs-utility-bar .sfs-social a {
  color: var(--parchment-dim);
  display: flex;
}

.sfs-utility-bar .sfs-social a:hover { color: var(--moonlight); }

.sfs-subscribe-btn {
  border: 1px solid var(--moonlight);
  color: var(--moonlight);
  border-radius: var(--radius);
  padding: 4px 14px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.sfs-subscribe-btn:hover {
  background: var(--moonlight);
  color: var(--ink-950);
}

/* ---------- Hero ---------- */
.sfs-hero {
  position: relative;
  text-align: center;
  padding: var(--hero-pad) 20px;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 50% -10%, color-mix(in srgb, var(--moonlight) 15%, transparent), transparent 60%),
    var(--ink-950);
}

/* Signature element: a soft scatter of stars, pure CSS, no JS */
.sfs-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(1.5px 1.5px at 20% 30%, var(--parchment-dim), transparent),
    radial-gradient(1.5px 1.5px at 75% 20%, var(--parchment-dim), transparent),
    radial-gradient(1px 1px at 60% 55%, var(--parchment-dim), transparent),
    radial-gradient(1.5px 1.5px at 90% 65%, var(--parchment-dim), transparent),
    radial-gradient(1px 1px at 35% 75%, var(--parchment-dim), transparent);
  opacity: 0.35;
}

.sfs-hero-logo {
  width: 52px;
  height: 52px;
  margin: 0 auto 18px;
  border-radius: 50%;
  background: var(--ink-800);
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.sfs-hero-logo svg { width: 24px; height: 24px; color: var(--moonlight); }

.sfs-hero h1 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(32px, 5vw, 48px);
  margin: 0 0 12px;
  position: relative;
}

.sfs-hero p {
  font-size: 16px;
  color: var(--parchment-dim);
  max-width: 480px;
  margin: 0 auto;
  position: relative;
}

/* ---------- Sticky nav (only this stays on scroll) ---------- */
.sfs-nav-wrap {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--ink-900) 80%, transparent);
  backdrop-filter: blur(12px) saturate(180%);
  -webkit-backdrop-filter: blur(12px) saturate(180%);
  border-bottom: 1px solid color-mix(in srgb, var(--moonlight) 15%, transparent);
}

.sfs-nav {
  max-width: var(--max-w);
  margin: 0 auto;
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(16px, 3vw, 32px);
  padding: 0 20px;
  overflow-x: auto;
  list-style: none;
}

.sfs-nav a {
  font-size: 14px;
  font-weight: 600;
  color: var(--parchment-dim);
  white-space: nowrap;
  padding: 6px 2px;
  position: relative;
}

.sfs-nav a.is-active { color: var(--parchment); }

.sfs-nav a.is-active::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -2px;
  height: 2px;
  background: var(--moonlight);
  border-radius: 2px;
}

.sfs-nav a:hover { color: var(--moonlight-soft); }

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}

@media (max-width: 640px) {
  .sfs-utility-bar .sfs-pages { gap: 12px; overflow-x: auto; }
  .sfs-utility-bar { gap: 12px; }
}

/* ---------- Section wrapper ---------- */
.sfs-section {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 40px 20px 8px;
}

.sfs-section h2 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 22px;
  margin: 0 0 18px;
}

/* ---------- Categories grid ---------- */
.sfs-cat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 12px;
}

.sfs-cat-card {
  background: var(--ink-900);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 10px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.sfs-cat-card:hover {
  border-color: var(--moonlight);
  transform: translateY(-4px) scale(1.02);
  box-shadow: 0 12px 24px color-mix(in srgb, var(--moonlight) 12%, transparent);
}

.sfs-cat-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--ink-800);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--moonlight);
  font-size: 18px;
}

.sfs-cat-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--parchment);
}

/* ---------- Trending grid ---------- */
.sfs-trend-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
}

.sfs-trend-card {
  background: var(--ink-900);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  display: block;
  transition: border-color 0.15s ease;
}

.sfs-trend-card:hover { 
  border-color: var(--moonlight); 
  transform: translateY(-4px);
  box-shadow: 0 12px 24px color-mix(in srgb, var(--moonlight) 12%, transparent);
}

.sfs-trend-img-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background-color: var(--ink-800);
  overflow: hidden;
}

.sfs-trend-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.sfs-hot-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  background: rgba(201, 123, 132, 0.9);
  color: var(--ink-950);
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  gap: 3px;
}

.sfs-trend-title {
  font-size: 13px;
  font-weight: 600;
  margin: 10px 12px 4px;
  line-height: 1.35;
}

.sfs-trend-views {
  font-size: 11px;
  color: var(--parchment-dim);
  margin: 0 12px 12px;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ---------- Latest posts grid ---------- */
.sfs-post-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
}

.sfs-post-card {
  background: var(--ink-900);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  display: block;
  transition: border-color 0.15s ease;
}

.sfs-post-card:hover { 
  border-color: var(--moonlight); 
  transform: translateY(-4px);
  box-shadow: 0 12px 24px color-mix(in srgb, var(--moonlight) 12%, transparent);
}

.sfs-post-img {
  width: 100%;
  aspect-ratio: 16 / 9;
  background-color: var(--ink-800);
  object-fit: contain;
  display: block;
}

.sfs-post-title {
  font-size: 13px;
  font-weight: 600;
  margin: 10px 12px 4px;
  line-height: 1.35;
}

.sfs-post-excerpt {
  font-size: 12px;
  color: var(--parchment-dim);
  margin: 0 12px 12px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.sfs-pagination {
  text-align: center;
  margin-top: 24px;
}

.sfs-next-page {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--moonlight);
  border: 1px solid var(--moonlight);
  border-radius: var(--radius);
  padding: 8px 18px;
}

.sfs-next-page:hover {
  background: var(--moonlight);
  color: var(--ink-950);
}

/* ---------- Footer ---------- */
.sfs-footer {
  background: var(--ink-900);
  border-top: 1px solid var(--line);
  margin-top: 48px;
  padding: 40px 20px;
  text-align: center;
}

.sfs-footer-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 18px;
  margin: 0 0 8px;
}

.sfs-footer-about {
  font-size: 13px;
  color: var(--parchment-dim);
  max-width: 420px;
  margin: 0 auto 16px;
}

.sfs-footer-social {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-bottom: 20px;
}

.sfs-footer-social a:not(.sfs-subscribe-btn) {
  color: var(--parchment-dim);
  font-size: 16px;
}

.sfs-footer-social a:not(.sfs-subscribe-btn):hover { color: var(--moonlight); }

.sfs-footer-pages {
  display: flex;
  justify-content: center;
  gap: 18px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--parchment-dim);
  margin-bottom: 16px;
}

.sfs-footer-pages a:hover { color: var(--moonlight); }

.sfs-footer-copy {
  font-size: 11px;
  color: var(--parchment-dim);
  opacity: 0.7;
  margin: 0;
}

/* ---------- Category page header ---------- */
.sfs-cat-page-header {
  text-align: center;
  padding: 48px 20px 8px;
  max-width: var(--max-w);
  margin: 0 auto;
}

.sfs-cat-icon-lg {
  width: 56px;
  height: 56px;
  font-size: 24px;
  margin: 0 auto 14px;
}

.sfs-cat-page-header h1 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(26px, 4vw, 36px);
  margin: 0 0 8px;
}

.sfs-cat-page-header p {
  color: var(--parchment-dim);
  font-size: 14px;
  max-width: 420px;
  margin: 0 auto;
}

.sfs-empty-state {
  color: var(--parchment-dim);
  font-size: 14px;
  text-align: center;
  grid-column: 1 / -1;
  padding: 32px 0;
}

/* ---------- Single post: 3-column layout ---------- */
.sfs-post-layout {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 40px 20px 64px;
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr) 240px;
  gap: 32px;
  align-items: start;
}

.sfs-sidebar {
  background: var(--ink-900);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  font-size: 13px;
  color: var(--parchment-dim);
}

.sfs-sidebar-left {
  /* non-sticky, as specified */
}

.sfs-sidebar-right {
  position: sticky;
  top: calc(var(--header-h) + 20px);
}

.sfs-sidebar-placeholder {
  margin: 0;
  font-style: italic;
  opacity: 0.7;
}

.sfs-post-article {
  min-width: 0;
}

.sfs-post-header h1 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(28px, 4vw, 40px);
  line-height: 1.2;
  margin: 0 0 12px;
}

.sfs-post-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--parchment-dim);
  margin: 0 0 28px;
}

/* Post content typography — clean, readable, book-like */
.sfs-post-content {
  font-size: 17px;
  line-height: 1.8;
  color: var(--parchment);
}

.sfs-post-content p { margin: 0 0 22px; }

.sfs-post-content h2 {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 600;
  margin: 40px 0 16px;
}

.sfs-post-content h3 {
  font-family: var(--font-display);
  font-size: 21px;
  font-weight: 600;
  margin: 32px 0 14px;
}

.sfs-post-content a {
  color: var(--moonlight);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.sfs-post-content blockquote {
  border-left: 3px solid var(--moonlight);
  margin: 24px 0;
  padding: 4px 0 4px 20px;
  color: var(--parchment-dim);
  font-style: italic;
}

.sfs-post-content ul, .sfs-post-content ol {
  margin: 0 0 22px;
  padding-left: 22px;
}

.sfs-post-content li { margin-bottom: 8px; }

.sfs-post-content img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
  margin: 24px 0;
}

@media (max-width: 900px) {
  .sfs-post-layout {
    grid-template-columns: 1fr;
  }
  .sfs-sidebar-right { position: static; }
}

/* ---------- Static pages (About, Contact, Privacy) ---------- */
.sfs-static-page {
  max-width: 720px;
  margin: 0 auto;
  padding: 48px 20px 64px;
}

.sfs-static-page h1 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(28px, 4vw, 38px);
  margin: 0 0 24px;
}

.sfs-static-page p { line-height: 1.7; color: var(--parchment-dim); }

/* ---------- Ads (Phase 15) ---------- */
.sfs-ad-slot {
  min-height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sfs-between-posts-ad {
  grid-column: 1 / -1;
}

@media (min-width: 641px) {
  .sfs-ad-mobile-only { display: none; }
}
@media (max-width: 640px) {
  .sfs-ad-desktop-only { display: none; }
}

.sfs-cookie-banner {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--ink-900);
  border-top: 1px solid var(--line);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  z-index: 100;
  font-size: 13px;
  flex-wrap: wrap;
}

.sfs-cookie-banner p { margin: 0; color: var(--parchment-dim); }

.sfs-cookie-banner button {
  background: var(--moonlight);
  color: var(--ink-950);
  border: none;
  border-radius: 8px;
  padding: 8px 18px;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  flex-shrink: 0;
}

/* ---------- Table of Contents ---------- */
.sfs-toc {
  background: var(--ink-900);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin: 24px 0;
  font-size: 14px;
}

.sfs-toc strong { display: block; margin-bottom: 8px; }
.sfs-toc ul { margin: 0; padding-left: 18px; }
.sfs-toc li { margin-bottom: 6px; }
.sfs-toc a { color: var(--moonlight); }

/* ---------- FAQs ---------- */
.sfs-faqs {
  margin: 32px 0;
}

.sfs-faqs h2 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 20px;
  margin: 0 0 14px;
}

.sfs-faq-item {
  background: var(--ink-900);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 10px;
}

.sfs-faq-item summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
}

.sfs-faq-item p {
  margin: 10px 0 0;
  font-size: 14px;
  color: var(--parchment-dim);
  line-height: 1.6;
}

/* ---------- PDF/HTML Viewer ---------- */
.sfs-pdf-viewer {
  margin: 32px 0;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
  aspect-ratio: 3 / 4;
  max-height: 800px;
}

.sfs-pdf-viewer iframe {
  width: 100%;
  height: 100%;
  border: 0;
  background: var(--ink-900);
}

/* ---------- Star Rating ---------- */
.sfs-rating {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 24px 0;
}

.sfs-stars { display: flex; gap: 2px; }

.sfs-star {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
  color: rgba(255, 255, 255, 0.4);
  padding: 2px;
  transition: color 0.1s ease;
}

.sfs-star.is-filled { color: var(--moonlight); }
.sfs-star:not([disabled]):hover { color: var(--moonlight-soft); }
.sfs-star[disabled] { cursor: default; opacity: 0.8; }

.sfs-rating-summary {
  font-size: 13px;
  color: var(--parchment-dim);
}

/* ---------- Views badge ---------- */
.sfs-views-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  color: var(--parchment-dim);
}

/* ---------- Social Share ---------- */
.sfs-share {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 32px 0;
  padding: 14px 16px;
  background: var(--ink-900);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.sfs-share-icons { display: flex; gap: 8px; }

.sfs-share-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--ink-800);
  color: var(--parchment-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  cursor: pointer;
}

.sfs-share-btn:hover { color: var(--moonlight); background: var(--ink-950); }

.sfs-share-count {
  font-size: 13px;
  color: var(--parchment-dim);
  font-weight: 600;
}

/* ---------- Related posts ---------- */
.sfs-related {
  margin: 48px 0 32px;
}

.sfs-related h2 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 20px;
  margin: 0 0 16px;
}

.sfs-post-grid-3 {
  grid-template-columns: repeat(3, 1fr);
}

@media (max-width: 640px) {
  .sfs-post-grid-3 { grid-template-columns: 1fr; }
}

/* ---------- Author box ---------- */
.sfs-author-box {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 32px 0;
  padding: 16px;
  background: var(--ink-900);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.sfs-author-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background-color: var(--moonlight);
  background-size: cover;
  background-position: center;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-950);
  font-weight: 700;
  font-size: 18px;
  flex-shrink: 0;
}

.sfs-author-name {
  font-weight: 700;
  font-size: 14px;
  margin: 0 0 4px;
}

.sfs-author-bio {
  font-size: 13px;
  color: var(--parchment-dim);
  margin: 0;
  line-height: 1.5;
}

/* ---------- Comments ---------- */
.sfs-comments {
  margin: 40px 0;
}

.sfs-comments h2 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 20px;
  margin: 0 0 20px;
}

.sfs-comments-list {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-bottom: 28px;
}

.sfs-comment {
  display: flex;
  gap: 12px;
}

.sfs-comment-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--ink-800);
  color: var(--moonlight);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}

.sfs-comment-meta {
  font-size: 12px;
  color: var(--parchment-dim);
  margin: 0 0 4px;
}

.sfs-comment-name { color: var(--parchment); font-weight: 600; }

.sfs-comment-text {
  font-size: 14px;
  line-height: 1.6;
  margin: 0;
}

.sfs-comment-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--ink-900);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
}

.sfs-form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.sfs-comment-form input,
.sfs-comment-form textarea {
  background: var(--ink-950);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--parchment);
  font-family: var(--font-body);
  font-size: 14px;
}

.sfs-comment-form textarea { resize: vertical; }

.sfs-comment-form button {
  align-self: flex-start;
  background: var(--moonlight);
  color: var(--ink-950);
  border: none;
  border-radius: var(--radius);
  padding: 10px 22px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
}

.sfs-comment-status {
  font-size: 13px;
  color: var(--parchment-dim);
  margin: 0;
  min-height: 18px;
}

@media (max-width: 480px) {
  .sfs-form-row { grid-template-columns: 1fr; }
}
