/* Aditya Beevanapalli author site — Design Specs v3.1 + header-RIGHT cloth wave flag
   Base: parchment + navy (v3 locked). Soft PD hero wash + restrained --flag-red accents.
   Header-right: draped cloth photo (CC BY-SA) fades left; wordmark on parchment alone; nav chip.
   IA locks unchanged: no Videos, Get the book only, locked chapters, no ISBN, Also by heading.
   FORBIDDEN: MAGA red CTA fill, flag on cover, #0C0D0F, #C4A35A, left flag under wordmark. */

@import url("https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,600;9..144,700&family=Source+Sans+3:wght@400;600&display=swap");

:root {
  --bg: #F7F3EB;
  --bg-soft: #EFE8DC;
  --surface: #FFFFFF;
  --border: #D9D0C2;
  --text: #1C1917;
  --muted: #6B645A;
  --accent: #1E3A5F;
  --accent-hover: #152A45;
  --on-accent: #F7F3EB;
  --rule: #C4B8A5;

  /* v3.1 patriotic accents — accent-of-accent only; navy stays primary CTA */
  --flag-red: #9B2C2C;
  --flag-red-hover: #7F2424;
  --flag-red-soft: #F3E8E8;
  --flag-stripe-navy: var(--accent);
  --flag-stripe-red: var(--flag-red);
  --flag-stripe-white: #FFFFFF;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;

  --shell: 1100px;
  --prose: 680px;
  --font-display: "Fraunces", "Source Serif 4", Georgia, serif;
  --font-body: "Source Sans 3", system-ui, -apple-system, sans-serif;
  --shadow-cover: 0 12px 28px rgba(28, 25, 23, 0.12), 0 2px 6px rgba(28, 25, 23, 0.06);
  --shadow-card: 0 1px 3px rgba(28, 25, 23, 0.06);
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 18px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}
a:hover { color: var(--accent-hover); }
em { font-style: italic; }

.shell {
  width: min(100% - 32px, var(--shell));
  margin-inline: auto;
}
@media (min-width: 768px) {
  .shell { width: min(100% - 48px, var(--shell)); }
}
.prose { max-width: var(--prose); }

.author-photo {
  width: min(100%, 340px);
  height: auto;
  margin: 0 0 28px;
  border-radius: 8px;
  box-shadow: var(--shadow-cover);
}

.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: var(--on-accent);
  padding: 8px 16px;
  z-index: 100;
  text-decoration: none;
  font-weight: 600;
}
.skip:focus { left: 16px; top: 16px; }

/* Header — RIGHT cloth-wave flag; brand on parchment alone; nav chip */
.site-header {
  position: sticky;
  top: 0;
  left: 0;
  z-index: 50;
  width: 100%;
  max-width: none;
  background: rgba(247, 243, 235, 0.96);
  border-bottom: 2px solid var(--accent);
  box-shadow: 0 1px 0 var(--flag-red);
  backdrop-filter: blur(8px);
  overflow: hidden;
}
.nav,
.nav--flag-right {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 68px;
  padding-block: 0;
  flex-wrap: wrap;
  z-index: 1;
}
.site-header > .shell {
  position: relative;
  z-index: 1;
}
/* Cloth wave on the RIGHT — fades LEFT; never under wordmark */
.header-flag-right {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 40%;
  right: 0;
  width: auto;
  margin: 0;
  z-index: 0;
  pointer-events: none;
  background-color: #9B1C1C; /* stripe red fallback — never black */
  background-image: url("../assets/us-flag-header-wave-filled.jpg");
  background-size: cover;
  background-position: center right;
  background-repeat: no-repeat;
  -webkit-mask-image: linear-gradient(
    90deg,
    transparent 0%,
    rgba(0, 0, 0, 0.2) 12%,
    rgba(0, 0, 0, 0.7) 30%,
    #000 45%,
    #000 100%
  );
  mask-image: linear-gradient(
    90deg,
    transparent 0%,
    rgba(0, 0, 0, 0.2) 12%,
    rgba(0, 0, 0, 0.7) 30%,
    #000 45%,
    #000 100%
  );
}
.brand {
  position: relative;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 68px;
  padding-inline: 0 1.5rem; /* ≥32px parchment clearance toward flag */
  margin-right: 32px;
  text-decoration: none;
  color: var(--text);
}
.brand:hover { color: var(--accent); }
.flag-mark {
  display: block;
  height: auto;
  max-height: 20px;
  width: auto;
  opacity: 0.85;
  border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(28, 25, 23, 0.08);
}
.flag-mark--footer {
  max-height: 16px;
  width: auto;
  opacity: 0.8;
}
.wordmark {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 1rem;
  color: inherit;
  text-decoration: none;
  letter-spacing: -0.01em;
}
.brand:hover .wordmark { color: var(--accent); }
/* Nav on parchment chip for readability over/near flag */
.nav > nav {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  align-self: center;
  position: relative;
  z-index: 2;
}
.nav-links {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
  list-style: none;
  margin: 0;
  padding: 4px 4px;
  background: rgba(247, 243, 235, 0.92);
  border-radius: 8px;
  backdrop-filter: blur(4px);
  box-shadow: 0 0 0 1px rgba(217, 208, 194, 0.55);
}
.nav-links a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 8px 12px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9375rem;
  border-bottom: 2px solid transparent;
  position: relative;
}
.nav-links a:hover { color: var(--accent); }
.nav-links a.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
/* Micro red end-cap on active underline */
.nav-links a.active::after {
  content: "";
  position: absolute;
  right: 12px;
  bottom: -2px;
  width: 3px;
  height: 2px;
  background: var(--flag-red);
}

/* Type */
.eyebrow {
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 12px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.star-motif {
  width: 10px;
  height: 10px;
  flex-shrink: 0;
  color: var(--accent);
  opacity: 0.85;
}
h1 {
  font-family: var(--font-display);
  font-weight: 700;
  font-optical-sizing: auto;
  font-size: 2.5rem;
  line-height: 1.15;
  margin: 0 0 20px;
  color: var(--text);
  letter-spacing: -0.02em;
}
h2 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.5rem;
  line-height: 1.25;
  margin: 0 0 16px;
  color: var(--text);
}
.muted { color: var(--muted); }
.lead { margin: 0 0 16px; }

/* Pass 3: quieter cover caption */
.caption {
  font-size: 11px;
  font-weight: 400;
  color: var(--muted);
  opacity: 0.55;
  margin: 14px 0 0;
  text-align: center;
  letter-spacing: 0.02em;
  line-height: 1.4;
}

/* Cover frame — elevated book object; never overflow grid cell */
.cover-wrap {
  width: min(100%, 220px);
  max-width: 100%;
  margin-inline: auto;
  box-sizing: border-box;
}
.cover-frame {
  aspect-ratio: 2 / 3;
  width: 100%;
  background: #FBF8F2;
  border: 1px solid var(--border);
  border-radius: 4px;
  box-shadow: var(--shadow-cover);
  position: relative;
  overflow: hidden;
}
.cover-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Buttons */
.cta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 28px;
  align-items: center;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 12px 22px;
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 600;
  border-radius: 6px;
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 150ms ease, border-color 150ms ease, color 150ms ease, opacity 150ms ease;
}
.btn-primary {
  background: var(--accent);
  color: var(--on-accent);
  border-color: var(--accent);
  /* Restrained red left edge — NOT full red fill */
  box-shadow: inset 3px 0 0 var(--flag-red);
}
.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: var(--on-accent);
  box-shadow: inset 3px 0 0 var(--flag-red-hover);
}
.btn-secondary {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.btn-sm {
  min-height: 40px;
  padding: 8px 16px;
  font-size: 0.9375rem;
}

/* Quiet text link (KDP hardcover) */
.link-quiet {
  display: inline-block;
  margin-top: 12px;
  font-size: 0.8125rem;
  font-weight: 400;
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}
.link-quiet:hover { color: var(--accent); }

/* Book page: keep media contact visually separate from the also-by card */
.also-by {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 24px;
  box-shadow: var(--shadow-card);
  max-width: 680px;
}
.also-by h2 { font-size: 1.25rem; }
.also-by p { margin: 0 0 16px; }
.media-inquiries {
  margin-top: 40px;
  padding-top: 32px;
  border-top: 1px solid var(--rule);
}
.media-inquiries h2 {
  margin-bottom: 12px;
}

/* Sections */
.section { padding: 48px 0; }
.section-soft { background: var(--bg-soft); }
.section-rule {
  border: 0;
  border-top: 1px solid var(--rule);
  margin: 0;
}
/* Dual navy/red rule — once per page max (Home after hero) */
.section-rule-flag {
  border: 0;
  height: 2px;
  margin: 0;
  background: linear-gradient(to bottom, var(--accent) 0 1px, var(--flag-red) 1px 2px);
}

/* Hero with soft PD flag wash (RIGHT) under parchment veil */
.hero {
  position: relative;
  isolation: isolate;
  overflow: hidden;
}
.hero__flag {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  width: 100%;
  z-index: 0;
  pointer-events: none;
  background-image:
    linear-gradient(
      105deg,
      var(--bg) 0%,
      rgba(247, 243, 235, 0.97) 38%,
      rgba(247, 243, 235, 0.88) 55%,
      rgba(247, 243, 235, 0.78) 78%,
      rgba(247, 243, 235, 0.72) 100%
    ),
    url("../assets/us-flag-official-1920.png");
  background-size: cover, cover;
  background-position: center, right center;
  background-repeat: no-repeat;
}
.hero {
  overflow: hidden;
}
.section.hero {
  width: 100%;
  max-width: none;
}
.hero > .shell { position: relative; z-index: 1; }

/* Hero — Pass 3: cover↔copy gap --space-6 (32px) on desktop */
.hero-grid {
  display: grid;
  gap: 40px;
  align-items: center;
}
.hero-copy p { margin: 0 0 12px; }
.hero-copy p + p { margin-top: 16px; }

/* Book page: optional quieter flag wash far right — never on cover */
.book-hero-wrap {
  position: relative;
  isolation: isolate;
  overflow: hidden;
}
.book-hero-wrap__flag {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    linear-gradient(
      100deg,
      var(--bg) 0%,
      rgba(247, 243, 235, 0.98) 50%,
      rgba(247, 243, 235, 0.90) 72%,
      rgba(247, 243, 235, 0.78) 100%
    ),
    url("../assets/us-flag-official-1920.png");
  background-size: cover, 55% auto;
  background-position: center, right -10% center;
  background-repeat: no-repeat;
  opacity: 0.95;
}
.book-hero-wrap > .shell { position: relative; z-index: 1; }

/* Watch / Videos page removed (Aditya fix pass) — YouTube in footer only */

/* Soft CTA / media */
.soft-cta {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 32px 24px;
  box-shadow: var(--shadow-card);
  max-width: 680px;
}
.soft-cta h2 {
  font-size: 1.375rem;
  margin-bottom: 8px;
}
.soft-cta p { margin: 0 0 16px; }

/* Book page — desktop cover left; title, themes, and buy stay together on the right */
.book-hero {
  display: grid;
  column-gap: var(--space-6);
  row-gap: 24px;
  align-items: start;
  grid-template-columns: 1fr;
  grid-template-areas:
    "prose"
    "cover"
    "inside"
    "buy";
}
.book-hero > .prose,
.book-hero > .cover-wrap,
.book-hero > .book-inside,
.book-hero > .buy-block {
  min-width: 0; /* allow wrap; prevent grid blowout */
  overflow-wrap: anywhere;
}
.book-hero > .prose { grid-area: prose; }
.book-hero > .cover-wrap { grid-area: cover; }
.book-hero > .book-inside { grid-area: inside; }
.book-hero > .buy-block { grid-area: buy; }
.book-hero h1 {
  font-size: 1.85rem;
  overflow-wrap: break-word;
  hyphens: auto;
}
.whats-inside {
  list-style: none;
  margin: 0;
  padding: 0;
  max-width: var(--prose);
}
.whats-inside li {
  position: relative;
  padding: 4px 0 4px 24px;
  line-height: 1.3;
}
.whats-inside li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 1.05em;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
}

/* Pass 3: buy row = exactly 3 solid navy + quiet KDP link */
.buy-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 8px;
}
.buy-block .link-quiet { margin-top: 14px; }
.buy-block .buy-lede {
  margin: 0 0 16px;
  max-width: 680px;
  color: var(--muted);
}

/* Videos grid removed (Aditya fix pass) */
.page-lede {
  margin: 0 0 24px;
  max-width: var(--prose);
  color: var(--muted);
}

/* Contact form */
.contact-kit {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 24px;
  box-shadow: var(--shadow-card);
  max-width: var(--prose);
  margin-bottom: 32px;
}
.contact-kit p { margin: 0; }
.contact-form {
  max-width: 560px;
  display: grid;
  gap: 20px;
}
.form-field {
  display: grid;
  gap: 6px;
}
.form-field label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
}
.form-field .hint {
  font-size: 0.8125rem;
  color: var(--muted);
  font-weight: 400;
}
.form-field input,
.form-field select,
.form-field textarea {
  font-family: var(--font-body);
  font-size: 1rem;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  min-height: 44px;
}
.form-field textarea {
  min-height: 140px;
  resize: vertical;
}
.form-field input:focus-visible,
.form-field select:focus-visible,
.form-field textarea:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent);
  border-color: var(--accent);
}
.form-field[aria-invalid="true"] input,
.form-field[aria-invalid="true"] select,
.form-field[aria-invalid="true"] textarea,
.form-field input[aria-invalid="true"],
.form-field select[aria-invalid="true"],
.form-field textarea[aria-invalid="true"] {
  border-color: #8B3A3A;
}
.form-error {
  font-size: 0.8125rem;
  color: #8B3A3A;
  margin: 0;
  display: none;
}
.form-field.is-error .form-error { display: block; }
.form-success {
  display: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px 24px;
  max-width: 560px;
  margin-top: 16px;
  box-shadow: var(--shadow-card);
}
.form-success.is-visible { display: block; }
.form-success p { margin: 0; color: var(--text); }

/* Footer */
.site-footer {
  background: var(--bg-soft);
  border-top: 1px solid var(--rule);
  padding: 40px 0 48px;
  margin-top: 0;
}
.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  list-style: none;
  margin: 0 0 20px;
  padding: 0;
}
.footer-links a {
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9375rem;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}
.footer-links a:hover { color: var(--accent); }
.footer-social {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 24px;
  margin: 0 0 16px;
  font-size: 0.9375rem;
}
.footer-social a {
  color: var(--muted);
  text-decoration: none;
}
.footer-social a:hover { color: var(--accent); }
.footer-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.footer-copy {
  margin: 0;
  font-size: 0.8125rem;
  color: var(--muted);
}
.footer-credit {
  margin: 10px 0 0;
  font-size: 0.6875rem;
  line-height: 1.45;
  color: var(--muted);
  max-width: 42rem;
}
.footer-credit a {
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.footer-credit a:hover { color: var(--accent); }

/* Focus */
:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent);
}

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

@media (min-width: 768px) {
  h1 { font-size: 3.5rem; }
  h2 { font-size: 1.75rem; }
  .section { padding: 64px 0; }
  .hero-grid {
    grid-template-columns: minmax(220px, 300px) minmax(0, 1fr);
    gap: var(--space-6); /* 32px — Pass 3 */
    align-items: center;
  }
  .hero-grid .cover-wrap {
    margin-inline: 0;
    width: 100%;
    max-width: 300px;
  }
  /* Book: cover left; all decision content stays in the right column */
  .book-hero {
    grid-template-columns: minmax(200px, 280px) minmax(0, 1fr);
    column-gap: var(--space-6); /* 32px — cover↔copy; never absolute overlap */
    row-gap: 16px;
    grid-template-areas:
      "cover prose"
      "cover inside"
      "cover buy";
    align-items: start;
  }
  .book-hero h1 { font-size: 2.35rem; }
  .book-hero .cover-wrap {
    margin-inline: 0;
    width: 100%;
    max-width: 280px;
  }
  /* Read the chapter list down the left column, then down the right (1–5 / 6–10). */
  .whats-inside {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: repeat(5, auto);
    grid-auto-flow: column;
    column-gap: var(--space-5);
    row-gap: 2px;
    max-width: none;
  }
}

/* Mobile: title and pitch first, then the visible cover, themes, and buy links */
@media (max-width: 767px) {
  /* Brand left on parchment; compact cloth-flag chip on the RIGHT — never under wordmark */
  .nav--flag-right {
    align-items: center;
  }
  .brand {
    min-height: 44px;
    max-width: calc(100% - 100px);
    margin-right: 0;
    padding-inline: 0 32px;
    flex: 1 1 auto;
  }
  .header-flag-right {
    top: 2px;
    right: 0;
    bottom: auto;
    width: 84px;
    height: 40px;
    border-radius: 6px 0 0 6px;
    background-image: url("../assets/us-flag-header-wave-filled.jpg");
    background-size: cover;
    background-position: right center;
    box-shadow: 0 0 0 1px rgba(28, 25, 23, 0.1);
    -webkit-mask-image: none;
    mask-image: none;
  }
  .nav > nav {
    flex: 1 1 100%;
    order: 3;
    padding-left: 0;
  }
  .nav-links {
    width: 100%;
    justify-content: flex-start;
  }
  /* Softer / less busy hero flag on small screens */
  .hero__flag {
    background-image:
      linear-gradient(
        180deg,
        rgba(247, 243, 235, 0.94) 0%,
        rgba(247, 243, 235, 0.88) 55%,
        var(--bg) 100%
      ),
      url("../assets/us-flag-official-1920.png");
    background-position: center, center top;
    opacity: 0.85;
  }
  .book-hero-wrap__flag { opacity: 0.55; }
  .hero-grid {
    grid-template-columns: 1fr;
    gap: 40px;
  }
  .book-hero {
    grid-template-columns: 1fr;
    row-gap: 32px;
    grid-template-areas:
      "prose"
      "cover"
      "inside"
      "buy";
  }
}
