/* =========================================================
   Textbook Landing Page — Styles
   Palette + spacing are defined as CSS variables in :root
   so the whole theme can be retuned from one place.
   ========================================================= */

:root {
  /* Colors */
  --color-bg: #faf8f4;
  --color-bg-alt: #f2ede4;
  --color-surface: #ffffff;
  --color-border: #e4ddd1;

  --color-primary: #1c3454;
  --color-primary-dark: #12233b;
  --color-primary-light: #2f4d75;

  --color-accent: #b8860b;
  --color-accent-dark: #96690a;

  --color-text: #262420;
  --color-text-muted: #6b6459;
  --color-text-on-primary: #f7f4ee;

  /* Type */
  --font-heading: "Lora", Georgia, "Times New Roman", serif;
  --font-body: "Source Sans 3", "Segoe UI", Arial, sans-serif;

  /* Layout */
  --max-width: 1120px;
  --max-width-narrow: 800px;
  --radius: 10px;
  --shadow-sm: 0 1px 3px rgba(28, 52, 84, 0.08);
  --shadow-md: 0 8px 24px rgba(28, 52, 84, 0.10);

  /* Overwritten by JS with the sticky header's real height */
  --header-height: 80px;
}

/* ---------- Reset ---------- */
* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-family: var(--font-heading);
  color: var(--color-primary);
  line-height: 1.25;
  margin: 0 0 0.5em;
}

p {
  margin: 0 0 1em;
}

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

img {
  max-width: 100%;
  display: block;
}

ul, ol {
  padding-left: 1.25em;
}

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
}

.container.narrow {
  max-width: var(--max-width-narrow);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-block;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.95rem;
  text-decoration: none;
  padding: 0.85em 1.6em;
  border-radius: 999px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease, color 0.15s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn-primary {
  background: var(--color-accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--color-accent-dark);
  box-shadow: var(--shadow-sm);
}

.btn-outline {
  background: transparent;
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.btn-outline:hover {
  background: var(--color-primary);
  color: var(--color-text-on-primary);
}

.btn-small {
  padding: 0.55em 1.2em;
  font-size: 0.85rem;
}

.btn-block {
  display: block;
  width: 100%;
  text-align: center;
}

/* ---------- Header / Nav ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(250, 248, 244, 0.92);
  -webkit-backdrop-filter: saturate(180%) blur(8px);
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--color-border);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 14px;
  padding-bottom: 14px;
}

.brand {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  line-height: 1.2;
}

.brand-title {
  font-family: var(--font-heading);
  font-weight: 700;
  color: var(--color-primary);
  font-size: 1.1rem;
}

.brand-sub {
  font-size: 0.78rem;
  color: var(--color-text-muted);
}

.primary-nav {
  display: flex;
  align-items: center;
  gap: 28px;
}

.primary-nav a {
  color: var(--color-text);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
}

.primary-nav a:hover {
  color: var(--color-primary);
}

.primary-nav a.nav-cta {
  display: inline-flex;
  align-items: center;
  line-height: 1;
  background: var(--color-primary);
  color: var(--color-text-on-primary);
  padding: 0.55em 1.2em;
  border-radius: 999px;
  font-weight: 600;
}

.primary-nav a.nav-cta:hover {
  background: var(--color-primary-dark);
}

.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 40px;
  height: 40px;
  background: none;
  border: none;
  cursor: pointer;
}

.nav-toggle span {
  display: block;
  height: 2px;
  width: 100%;
  background: var(--color-primary);
  border-radius: 2px;
}

/* ---------- Hero ---------- */
.hero {
  background: linear-gradient(180deg, var(--color-bg-alt) 0%, var(--color-bg) 100%);
  padding: 72px 0;
  border-bottom: 1px solid var(--color-border);
}

.hero-inner {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 56px;
  align-items: center;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--color-accent-dark);
  margin-bottom: 0.75em;
}

.hero-copy h1 {
  font-size: clamp(2rem, 3.6vw, 2.9rem);
  margin-bottom: 0.4em;
}

.hero-subtitle {
  font-size: 1.15rem;
  color: var(--color-text-muted);
}

.hero-author {
  font-size: 1rem;
  margin-bottom: 1.75em;
}

.hero-actions {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 2em;
}

.hero-meta {
  list-style: none;
  display: flex;
  gap: 18px;
  padding: 0;
  margin: 0;
  flex-wrap: wrap;
}

.hero-meta li {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  padding-left: 1.1em;
  position: relative;
}

.hero-meta li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.5em;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-accent);
}

.hero-cover {
  display: flex;
  justify-content: center;
}

.cover-placeholder {
  width: 100%;
  max-width: 300px;
  aspect-ratio: 2 / 3;
  background: repeating-linear-gradient(
    135deg,
    var(--color-surface),
    var(--color-surface) 10px,
    var(--color-bg-alt) 10px,
    var(--color-bg-alt) 20px
  );
  border: 2px dashed var(--color-border);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--color-text-muted);
  font-family: var(--font-heading);
  font-size: 1rem;
  box-shadow: var(--shadow-md);
}

/* ---------- Sections (shared) ---------- */
.section {
  padding: 72px 0;
  scroll-margin-top: var(--header-height);
}

.hero {
  scroll-margin-top: var(--header-height);
}

.section-alt {
  background: var(--color-bg-alt);
}

.section-title {
  font-size: clamp(1.5rem, 2.4vw, 2rem);
  margin-bottom: 0.6em;
}

.section-intro {
  color: var(--color-text-muted);
  margin-bottom: 2em;
}

.section-body p {
  color: var(--color-text);
}

.feature-list {
  list-style: none;
  padding: 0;
  margin-top: 1.5em;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px 24px;
}

.feature-list li {
  padding-left: 1.6em;
  position: relative;
  color: var(--color-text);
}

.feature-list li::before {
  content: "\2713";
  position: absolute;
  left: 0;
  color: var(--color-accent-dark);
  font-weight: 700;
}

/* ---------- Author ---------- */
.author-block {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 36px;
  align-items: start;
}

.photo-placeholder {
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background: var(--color-surface);
  border: 2px dashed var(--color-border);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--color-text-muted);
  font-family: var(--font-heading);
  font-size: 0.9rem;
}

.author-title {
  color: var(--color-text-muted);
  font-size: 0.9rem;
  margin-bottom: 1.2em;
}

/* ---------- Table of Contents ---------- */
.toc-list {
  border-top: 1px solid var(--color-border);
}

.toc-item {
  border-bottom: 1px solid var(--color-border);
}

.toc-header {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 16px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 18px 4px;
  text-align: left;
  font-family: var(--font-body);
}

.toc-number {
  font-family: var(--font-heading);
  font-weight: 600;
  color: var(--color-accent-dark);
  font-size: 0.9rem;
  min-width: 56px;
}

.toc-name {
  flex: 1;
  font-size: 1.05rem;
  color: var(--color-primary);
  font-weight: 600;
}

.toc-chevron {
  color: var(--color-text-muted);
  transition: transform 0.2s ease;
}

.toc-header[aria-expanded="true"] .toc-chevron {
  transform: rotate(180deg);
}

.toc-panel {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.25s ease;
}

.toc-panel > ol {
  overflow: hidden;
  min-height: 0;
  margin: 0;
  padding-left: 4.4em;
  color: var(--color-text-muted);
}

.toc-item.open .toc-panel {
  grid-template-rows: 1fr;
}

.toc-item.open .toc-panel > ol {
  padding-bottom: 16px;
}

/* ---------- Sample Chapter ---------- */
.sample-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: var(--shadow-sm);
}

.sample-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 1em;
}

.sample-card-header h3 {
  margin: 0;
}

.sample-text {
  max-height: 9.6em;
  overflow: hidden;
  position: relative;
  transition: max-height 0.3s ease;
  -webkit-mask-image: linear-gradient(to bottom, black 70%, transparent 100%);
  mask-image: linear-gradient(to bottom, black 70%, transparent 100%);
}

.sample-text.expanded {
  max-height: none;
  -webkit-mask-image: none;
  mask-image: none;
}

.sample-toggle {
  margin-top: 1.2em;
  background: none;
  border: none;
  color: var(--color-primary);
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  font-size: 0.95rem;
  text-decoration: underline;
}

/* ---------- Instructor Resources ---------- */
.instructor-card {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 28px;
}

.instructor-icon {
  font-size: 1.6rem;
  line-height: 1;
}

/* ---------- Purchase ---------- */
.section-purchase {
  background: var(--color-primary);
}

.section-purchase .section-title,
.section-purchase .section-intro {
  color: var(--color-text-on-primary);
}

.section-purchase .section-intro {
  opacity: 0.8;
}

.purchase-options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
}

.purchase-card {
  display: flex;
  flex-direction: column;
  background: var(--color-surface);
  border-radius: var(--radius);
  padding: 28px;
  text-align: center;
  box-shadow: var(--shadow-md);
}

.purchase-card .btn {
  margin-top: auto;
}

.purchase-card h3 {
  margin-bottom: 0.3em;
}

.purchase-card p {
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

.price-placeholder {
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  font-family: var(--font-heading);
  font-size: 1.5rem;
  color: var(--color-primary);
  margin: 0.4em 0 1em;
}

.price-list {
  list-style: none;
  margin: 0.6em 0 1.2em;
  padding: 0;
  text-align: left;
}

.price-list li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 0.4em 0;
  border-bottom: 1px solid var(--color-border);
  font-size: 0.9rem;
}

.price-list li:last-child {
  border-bottom: none;
}

.price-list-format {
  color: var(--color-text-muted);
}

.price-list-price {
  font-family: var(--font-heading);
  color: var(--color-primary);
  font-weight: 600;
}

/* ---------- Footer ---------- */
.site-footer {
  background: var(--color-primary-dark);
  color: var(--color-text-on-primary);
  padding: 28px 0;
}

.footer-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
  font-size: 0.85rem;
  opacity: 0.85;
}

.footer-inner p {
  margin: 0;
}

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .hero-inner {
    grid-template-columns: 1fr;
  }

  .hero-cover {
    order: -1;
  }

  .author-block {
    grid-template-columns: 1fr;
    text-align: left;
  }

  .photo-placeholder {
    margin: 0 auto;
  }

  .purchase-options {
    grid-template-columns: 1fr;
  }

  .feature-list {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .nav-toggle {
    display: flex;
  }

  .primary-nav {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
    padding: 8px 24px 20px;
    display: none;
  }

  .primary-nav.open {
    display: flex;
  }

  .primary-nav a {
    width: 100%;
    padding: 12px 0;
    border-bottom: 1px solid var(--color-border);
  }

  .primary-nav a.nav-cta {
    margin-top: 12px;
    text-align: center;
  }
}
