/* ========================================
   AI UGC E-book — Premium Design System
   Matched to aicreator.co reference
   ======================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap');

/* ---------- Variables ---------- */
:root {
  --bg-page: #F2F0FF;
  --bg-white: #FFFFFF;
  --bg-callout: #F7F6FE;
  --bg-table-alt: #FAFAFF;
  --bg-table-header: #F2F0FF;

  --text-primary: #141427;
  --text-body: #3D3D5C;
  --text-muted: #9494B8;
  --text-white: #FFFFFF;

  --accent: #4F46E5;
  --accent-light: #6366F1;
  --accent-dark: #3730A3;
  --gradient: linear-gradient(135deg, #6366F1 0%, #4F46E5 50%, #3730A3 100%);

  --border: #E6E3F4;
  --border-strong: #D4D0E8;

  --shadow-img: 0 2px 16px rgba(0,0,0,0.06), 0 0 0 1px rgba(0,0,0,0.02);
  --shadow-card: 0 1px 3px rgba(0,0,0,0.04);

  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --sidebar-w: 272px;
  --content-w: 680px;
  --radius: 10px;
  --radius-sm: 8px;
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  scroll-behavior: smooth;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.8;
  color: var(--text-body);
  background: var(--bg-page);
  overflow-x: hidden;
}

a { color: var(--accent); }

/* ---------- Progress Bar ---------- */
.progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  width: 0%;
  height: 2px;
  background: var(--gradient);
  z-index: 1000;
  transition: width 0.1s linear;
}

/* ---------- Sidebar ---------- */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--bg-white);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  z-index: 100;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s ease;
}

.sidebar-header {
  padding: 24px 20px 18px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-logo {
  margin-bottom: 14px;
  line-height: 0;
}

.sidebar-logo svg {
  height: 22px;
  width: auto;
  display: block;
}

.sidebar-title {
  font-size: 14px;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.35;
  letter-spacing: -0.01em;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.sidebar-nav::-webkit-scrollbar { width: 3px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }

.nav-chapter { margin-bottom: 0; }

.nav-chapter-title {
  display: flex;
  align-items: center;
  padding: 7px 20px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
  transition: background 0.15s;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  line-height: 1.4;
}

.nav-chapter-title:hover { background: var(--bg-callout); }
.nav-chapter-title.active { color: var(--accent); }

.nav-chapter-title .chevron {
  margin-right: 6px;
  font-size: 8px;
  transition: transform 0.2s;
  color: var(--text-muted);
  width: 12px;
  flex-shrink: 0;
}

.nav-chapter-title.expanded .chevron { transform: rotate(90deg); }

.nav-sections { display: none; padding: 0; list-style: none; }
.nav-sections.open { display: block; }

.nav-section-link {
  display: block;
  padding: 4px 20px 4px 38px;
  font-size: 11.5px;
  color: var(--text-muted);
  text-decoration: none;
  transition: all 0.15s;
  line-height: 1.45;
}

.nav-section-link:hover { color: var(--accent); background: var(--bg-callout); }
.nav-section-link.active {
  color: var(--accent);
  font-weight: 600;
  background: var(--bg-callout);
  border-right: 2px solid var(--accent);
}

/* ---------- Mobile Menu ---------- */
.mobile-menu-btn {
  display: none;
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 200;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: var(--bg-white);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-card);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 4px;
}

.mobile-menu-btn span {
  display: block;
  width: 18px;
  height: 1.5px;
  background: var(--text-primary);
  border-radius: 1px;
  transition: all 0.2s;
}

.mobile-menu-btn.open span:nth-child(1) { transform: rotate(45deg) translate(4px, 4px); }
.mobile-menu-btn.open span:nth-child(2) { opacity: 0; }
.mobile-menu-btn.open span:nth-child(3) { transform: rotate(-45deg) translate(4px, -4px); }

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.2);
  z-index: 90;
}

/* ---------- Main Content ---------- */
.main-content {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
}

.content-wrapper {
  max-width: var(--content-w);
  margin: 0 auto;
  padding: 48px 32px 80px;
}

/* ---------- Sections ---------- */
.ebook-section {
  margin-bottom: 56px;
  padding-bottom: 56px;
  border-bottom: 1px solid var(--border);
}

.ebook-section:last-child { border-bottom: none; }

/* ---------- Typography ---------- */
/* ---------- Chapter Divider ---------- */
.chapter-divider {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 32px;
  padding-top: 8px;
}

.chapter-divider-line {
  flex: 1;
  height: 1px;
  background: var(--border);
}

.chapter-divider-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  white-space: nowrap;
}

.chapter-divider-num {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.14em;
}

.chapter-divider-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.02em;
}

.section-title {
  font-size: 28px;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.2;
  margin-bottom: 20px;
  letter-spacing: -0.02em;
}

.section-title:not(:first-child) {
  margin-top: 0;
}

.subsection-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
  margin-top: 40px;
  margin-bottom: 16px;
  letter-spacing: -0.01em;
}

.body-text {
  font-size: 15px;
  line-height: 1.8;
  color: var(--text-body);
  margin-bottom: 16px;
}

.body-text:last-child { margin-bottom: 0; }

.body-text strong {
  color: var(--text-primary);
  font-weight: 600;
}

/* ---------- Callout Box ---------- */
.callout-box {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin: 24px 0;
}

.callout-label {
  display: block;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-bottom: 8px;
}

.callout-content {
  font-size: 15px;
  line-height: 1.7;
  color: var(--text-body);
}

.callout-box.prompt-example {
  border-left: 3px solid var(--accent-light);
  border-top: 1px solid var(--border);
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

/* ---------- Gradient CTA ---------- */
.gradient-cta {
  background: var(--gradient);
  border-radius: var(--radius);
  padding: 36px 32px;
  margin: 32px 0;
  text-align: center;
}

.gradient-cta-label {
  display: block;
  font-size: 10px;
  font-weight: 700;
  color: rgba(255,255,255,0.75);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  margin-bottom: 8px;
}

.gradient-cta-text {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-white);
  line-height: 1.5;
}

/* ---------- Tables ---------- */
.table-wrapper {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin: 24px 0;
}

.table-component {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  line-height: 1.5;
}

.table-component thead th {
  padding: 14px 20px;
  text-align: left;
  font-weight: 700;
  font-size: 13px;
  color: var(--text-primary);
  background: var(--bg-callout);
  border-bottom: 1px solid var(--border);
}

.table-component tbody td {
  padding: 12px 20px;
  color: var(--text-body);
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.table-component tbody tr:last-child td { border-bottom: none; }

.table-component tbody tr:nth-child(even) {
  background: rgba(242, 240, 255, 0.3);
}

/* ---------- Step Cards ---------- */
.step-card {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin: 28px 0 8px;
}

.step-number {
  flex-shrink: 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--accent);
  min-width: 22px;
}

.step-number::after {
  content: ".";
}

.step-content {
  flex: 1;
}

.step-content h4 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.4;
}

.step-content p {
  font-size: 14px;
  color: var(--text-body);
  line-height: 1.7;
  margin-top: 4px;
}

/* Content after a step card should be indented to align */
.step-card + p,
.step-card + .body-text,
.step-card + .hero-image,
.step-card + .callout-box,
.step-card + ul,
.step-card + ol {
  margin-left: 34px;
}

/* ---------- Lists ---------- */
.styled-list {
  margin: 12px 0 20px;
  padding-left: 20px;
}

.styled-list li {
  margin-bottom: 6px;
  color: var(--text-body);
  line-height: 1.7;
  font-size: 15px;
}

.styled-list li strong {
  color: var(--text-primary);
  font-weight: 600;
}

.styled-list li::marker {
  color: var(--accent);
  font-weight: 600;
}

ul.styled-list { list-style: disc; }
ul.styled-list li::marker { color: var(--border-strong); }

/* ---------- Comparison Table ---------- */
.comparison-table-wrap { margin: 24px 0; overflow-x: auto; }
.comparison-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.comparison-table th { text-align: left; padding: 12px 16px; font-weight: 700; color: var(--text-heading); background: var(--bg-table-header); border-bottom: 2px solid var(--border); }
.comparison-table td { padding: 10px 16px; border-bottom: 1px solid var(--border); color: var(--text-body); }
.comparison-table td:first-child { font-weight: 600; color: var(--text-heading); white-space: nowrap; }
.comparison-table tbody tr:nth-child(even) td { background: var(--bg-table-alt); }

/* ---------- Ratio Grid ---------- */
.ratio-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin: 8px 0;
}

.ratio-card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 20px;
  text-align: center;
}

.ratio-preview {
  background: var(--bg-callout);
  border: 1.5px solid var(--border);
  border-radius: 6px;
  margin: 0 auto 16px;
}

.ratio-1-1 { width: 56px; height: 56px; }
.ratio-9-16 { width: 38px; height: 64px; }
.ratio-16-9 { width: 64px; height: 38px; }

.ratio-title {
  font-size: 20px;
  font-weight: 800;
  color: var(--accent);
  margin-bottom: 2px;
}

.ratio-subtitle {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 14px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.ratio-list {
  list-style: none;
  padding: 0;
  text-align: left;
}

.ratio-list li {
  font-size: 13px;
  color: var(--text-body);
  padding: 3px 0;
  line-height: 1.5;
}

.ratio-list li::before {
  content: "·";
  color: var(--border-strong);
  font-weight: 700;
  margin-right: 8px;
}

@media (max-width: 580px) {
  .ratio-grid { grid-template-columns: 1fr; }
}

/* ---------- Formula Bar ---------- */
.formula-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 20px 0;
}

.formula-piece {
  display: inline-flex;
  align-items: center;
  padding: 8px 18px;
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: 100px;
  gap: 6px;
}

.formula-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.formula-desc {
  display: none;
}

.formula-plus {
  font-size: 14px;
  font-weight: 500;
  color: var(--border-strong);
  padding: 0 2px;
}

/* ---------- Flow Steps ---------- */
.flow-steps {
  display: flex;
  align-items: center;
  justify-content: space-evenly;
  margin: 28px 0;
  padding: 32px 24px;
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.flow-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.flow-num {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--bg-callout);
  border: 1.5px solid var(--border);
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
}

.flow-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  text-align: center;
  white-space: nowrap;
}

.flow-arrow {
  display: flex;
  align-items: center;
  margin-bottom: 24px;
}

/* ---------- Images ---------- */
.hero-image {
  margin: 24px 0;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-img);
  position: relative;
  cursor: zoom-in;
}

.hero-image img {
  width: 100%;
  height: auto;
  display: block;
}

.hero-image figcaption {
  padding: 8px 12px;
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
}

/* ---------- Video ---------- */
.video-player {
  margin: 24px 0;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-img);
  background: #000;
}

.video-player video {
  width: 100%;
  height: auto;
  display: block;
}

.video-placeholder {
  margin: 24px 0;
  border-radius: var(--radius);
  background: var(--bg-callout);
  border: 1.5px dashed var(--border-strong);
  padding: 32px 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}

.video-placeholder .icon {
  font-size: 1.5rem;
  margin-bottom: 6px;
}

/* ---------- Tag Pills ---------- */
.tag-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0;
}

.tag-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 100px;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid;
}

.tag-pill.green { background: #F0FDF4; color: #16A34A; border-color: #BBF7D0; }
.tag-pill.red { background: #FEF2F2; color: #DC2626; border-color: #FECACA; }

/* ---------- Checklist ---------- */
.checklist-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 24px;
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin: 24px 0;
}

.checklist-group h4 {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 10px;
}

.checklist-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
  font-size: 13px;
  color: var(--text-body);
}

.checklist-item .checkbox {
  width: 14px;
  height: 14px;
  border: 1.5px solid var(--border-strong);
  border-radius: 3px;
  flex-shrink: 0;
}

/* ---------- Cover Page ---------- */
.cover-page {
  min-height: 80vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 80px 32px;
}

.cover-page .cover-badge {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  margin-bottom: 20px;
}

.cover-page h1 {
  font-size: clamp(2.2rem, 5.5vw, 3.8rem);
  font-weight: 900;
  color: var(--text-primary);
  line-height: 1.08;
  margin-bottom: 16px;
  letter-spacing: -0.03em;
}

.cover-page h1 .accent {
  background: var(--gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.cover-page .cover-subtitle {
  font-size: 17px;
  color: var(--text-body);
  max-width: 440px;
  margin-bottom: 28px;
  line-height: 1.6;
}

.cover-page .cover-logo {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  font-style: italic;
}

/* ---------- Inline ---------- */
code {
  background: var(--bg-callout);
  padding: 2px 5px;
  border-radius: 4px;
  font-size: 0.88em;
  font-family: 'SF Mono', 'Fira Code', Menlo, monospace;
  color: var(--accent-dark);
}

/* ---------- Code Blocks ---------- */
.code-block {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: 24px 0;
  overflow: hidden;
}

.code-block pre {
  margin: 0;
  padding: 20px 24px;
  overflow-x: auto;
  max-height: 480px;
  overflow-y: auto;
  font-size: 12.5px;
  line-height: 1.7;
  font-family: 'SF Mono', 'Fira Code', Menlo, monospace;
  color: var(--text-body);
  white-space: pre-wrap;
  word-break: break-word;
}

.callout-box pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-x: auto;
  font-size: 12.5px;
  line-height: 1.7;
  font-family: 'SF Mono', 'Fira Code', Menlo, monospace;
}

blockquote {
  border-left: 2px solid var(--accent-light);
  padding: 12px 20px;
  margin: 20px 0;
  background: var(--bg-callout);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-style: italic;
  color: var(--text-body);
  font-size: 14px;
}

/* ---------- Animations ---------- */
.ebook-section {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.ebook-section.visible {
  opacity: 1;
  transform: translateY(0);
}

.cover-page {
  opacity: 1;
  transform: none;
}

/* ---------- Lightbox ---------- */
.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.92);
  z-index: 500;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
  padding: 32px;
}

.lightbox.open { display: flex; }

.lightbox img {
  max-width: 92%;
  max-height: 92vh;
  border-radius: var(--radius);
  object-fit: contain;
}

/* ---------- Responsive ---------- */
@media (max-width: 1024px) {
  :root { --sidebar-w: 256px; }
  .content-wrapper { padding: 36px 24px 64px; }
}

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); width: 272px; }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.open { display: block; }
  .mobile-menu-btn { display: flex; }
  .main-content { margin-left: 0; }
  .content-wrapper { padding: 24px 20px 48px; padding-top: 72px; }
  .section-title { font-size: 24px; }
  .subsection-title { font-size: 18px; }
  .step-card + p,
  .step-card + .body-text,
  .step-card + .hero-image,
  .step-card + .callout-box,
  .step-card + ul,
  .step-card + ol { margin-left: 0; }
}

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

/* ---------- Print ---------- */
@media print {
  .sidebar, .mobile-menu-btn, .progress-bar, .sidebar-overlay { display: none !important; }
  .main-content { margin-left: 0; }
  .ebook-section { page-break-inside: avoid; opacity: 1; transform: none; }
  .gradient-cta { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  body { background: white; }
}
