/* ============================================
   AI STUDY METHOD — SHARED STYLESHEET
   aistudymethod.com
============================================ */

@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;0,600;0,700;0,900;1,400&family=DM+Sans:wght@300;400;500;600&family=DM+Mono:wght@400;500&display=swap');

/* ============================================
   CSS CUSTOM PROPERTIES
============================================ */
:root {
  --bg-primary:    #faf9f7;
  --bg-secondary:  #f3f1ed;
  --bg-card:       #ffffff;
  --bg-card-hover: #f8f6f2;
  --bg-alt:        #f0ede8;
  --bg-dark:       #1a1a2e;
  --bg-nav:        rgba(250, 249, 247, 0.95);

  --accent:        #0a6b5e;
  --accent-dark:   #075248;
  --accent-soft:   rgba(10, 107, 94, 0.08);
  --accent-glow:   rgba(10, 107, 94, 0.2);
  --accent2:       #4a3fa0;
  --accent2-soft:  rgba(74, 63, 160, 0.08);

  --text-primary:   #1a1a2e;
  --text-secondary: #4a5568;
  --text-muted:     #9aa3b2;

  --border:        rgba(0,0,0,0.08);
  --border-accent: rgba(10, 107, 94, 0.2);

  --velvet-gradient: linear-gradient(135deg, #0a6b5e 0%, #4a3fa0 100%);
  --hero-gradient:   radial-gradient(ellipse at 70% 50%, rgba(74,63,160,0.06) 0%, transparent 60%),
                     radial-gradient(ellipse at 20% 80%, rgba(10,107,94,0.06) 0%, transparent 50%);

  --shadow:      0 20px 60px rgba(0,0,0,0.08);
  --shadow-card: 0 4px 24px rgba(0,0,0,0.06);
  --shadow-sm:   0 2px 8px rgba(0,0,0,0.06);

  --radius:    12px;
  --radius-lg: 20px;
  --radius-xl: 28px;

  --nav-h: 68px;
}

/* ============================================
   RESET & BASE
============================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  overflow-x: hidden;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* Noise texture */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  opacity: 0.02;
  pointer-events: none;
  z-index: 999;
}

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

/* ============================================
   NAVIGATION
============================================ */
nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  background: var(--bg-nav);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
}

.nav-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 2rem;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  flex-shrink: 0;
}

.logo-mark {
  width: 34px; height: 34px;
  background: var(--velvet-gradient);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Playfair Display', serif;
  font-size: 16px;
  font-weight: 900;
  color: white;
  flex-shrink: 0;
}

.logo-text { display: flex; flex-direction: column; line-height: 1.1; }

.logo-primary {
  font-family: 'Playfair Display', serif;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.3px;
}

.logo-secondary {
  font-family: 'DM Mono', monospace;
  font-size: 9px;
  font-weight: 500;
  color: var(--accent);
  letter-spacing: 2px;
  text-transform: uppercase;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  list-style: none;
}

.nav-links a {
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 13.5px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 6px;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--text-primary);
  background: var(--accent-soft);
}

.nav-links a.active {
  color: var(--accent);
  font-weight: 600;
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

/* ============================================
   BUTTONS
============================================ */
.btn-primary {
  background: var(--velvet-gradient);
  color: white;
  border: none;
  padding: 10px 22px;
  border-radius: 8px;
  font-family: 'DM Sans', sans-serif;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
  white-space: nowrap;
  box-shadow: 0 4px 15px var(--accent-glow);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px var(--accent-glow);
}

.btn-secondary {
  background: transparent;
  color: var(--text-primary);
  border: 1.5px solid var(--border);
  padding: 10px 22px;
  border-radius: 8px;
  font-family: 'DM Sans', sans-serif;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.btn-secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-outline {
  background: transparent;
  color: var(--accent);
  border: 1.5px solid var(--border-accent);
  padding: 10px 22px;
  border-radius: 8px;
  font-family: 'DM Sans', sans-serif;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.btn-outline:hover {
  background: var(--accent-soft);
}

/* Soft-filled secondary button: more visible than a bare outline, still clearly
   secondary to the gradient primary CTA. */
.btn-outline.btn-soft { background: rgba(10,107,94,0.10); border-color: rgba(10,107,94,0.30); }
.btn-outline.btn-soft:hover { background: rgba(10,107,94,0.18); }

/* ============================================
   PAGE HERO (non-homepage pages)
============================================ */
.page-hero {
  padding: calc(var(--nav-h) + 60px) 2rem 60px;
  background: var(--hero-gradient), var(--bg-primary);
  position: relative;
  overflow: hidden;
}

.page-hero::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 80px 80px;
  mask-image: radial-gradient(ellipse at center, transparent 20%, black 100%);
  pointer-events: none;
}

.page-hero-inner {
  max-width: 1280px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

.page-hero-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--accent-soft);
  border: 1px solid var(--border-accent);
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  padding: 5px 14px;
  border-radius: 30px;
  margin-bottom: 1.2rem;
  font-family: 'DM Mono', monospace;
}

.page-hero h1 {
  font-family: 'Playfair Display', serif;
  font-size: clamp(2rem, 4vw, 3.2rem);
  font-weight: 700;
  line-height: 1.15;
  color: var(--text-primary);
  margin-bottom: 1rem;
  max-width: 700px;
}

.page-hero h1 em {
  font-style: normal;
  background: var(--velvet-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.page-hero p {
  font-size: 17px;
  color: var(--text-secondary);
  max-width: 600px;
  line-height: 1.7;
  margin-bottom: 2rem;
}

/* ============================================
   SECTIONS
============================================ */
.section {
  padding: 90px 2rem;
}

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

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

.section-inner {
  max-width: 1280px;
  margin: 0 auto;
}

.section-label {
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 10px;
}

.section-divider {
  width: 40px;
  height: 3px;
  background: var(--velvet-gradient);
  border-radius: 3px;
  margin-bottom: 1.2rem;
}

.section-title {
  font-family: 'Playfair Display', serif;
  font-size: clamp(1.8rem, 2.8vw, 2.6rem);
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
  margin-bottom: 1rem;
}

.section-title em {
  font-style: normal;
  background: var(--velvet-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.section-body {
  font-size: 16px;
  color: var(--text-secondary);
  max-width: 560px;
  line-height: 1.7;
  margin-bottom: 3rem;
}

/* ============================================
   CARDS
============================================ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.card:hover {
  border-color: var(--border-accent);
  transform: translateY(-3px);
  box-shadow: var(--shadow-card);
}

.card-top-accent::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--velvet-gradient);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.card-top-accent:hover::before { opacity: 1; }

/* ============================================
   TAGS & BADGES
============================================ */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--accent-soft);
  border: 1px solid var(--border-accent);
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  padding: 4px 10px;
  border-radius: 20px;
  font-family: 'DM Mono', monospace;
}

.velvet-letter {
  width: 24px; height: 24px;
  background: var(--velvet-gradient);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Playfair Display', serif;
  font-size: 13px;
  font-weight: 900;
  color: white;
  flex-shrink: 0;
}

/* ============================================
   FOOTER
============================================ */
footer {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  padding: 60px 2rem 30px;
}

.footer-inner { max-width: 1280px; margin: 0 auto; }

.footer-top {
  display: grid;
  grid-template-columns: 1.5fr 1fr 1fr 1fr;
  gap: 3rem;
  margin-bottom: 3rem;
}

.footer-brand p {
  font-size: 13.5px;
  color: var(--text-muted);
  line-height: 1.6;
  margin-top: 12px;
  max-width: 260px;
}

.footer-col h5 {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 16px;
  font-family: 'DM Mono', monospace;
}

.footer-col ul { list-style: none; display: flex; flex-direction: column; gap: 8px; }

.footer-col ul li a {
  text-decoration: none;
  font-size: 13.5px;
  color: var(--text-muted);
  transition: color 0.2s ease;
}

.footer-col ul li a:hover { color: var(--accent); }

.footer-bottom {
  border-top: 1px solid var(--border);
  padding-top: 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.footer-bottom p {
  font-size: 12px;
  color: var(--text-muted);
  font-family: 'DM Mono', monospace;
}

.footer-velvet {
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.footer-velvet span {
  background: var(--velvet-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-weight: 700;
}

/* ============================================
   SCROLL ANIMATIONS
============================================ */
.fade-up {
  opacity: 0;
  transform: translateY(22px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.fade-up.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ============================================
   MOBILE NAV TOGGLE (hamburger)
   Hidden on desktop; shown on tablet/phone.
============================================ */
.nav-toggle {
  display: none;
  background: none;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  width: 44px; height: 44px;
  padding: 0;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--text-primary);
  transition: border-color 0.2s ease;
}

/* Drawer-only CTA — only visible inside the mobile drawer, never in the desktop nav row */
.nav-drawer-cta { display: none; }
.nav-toggle:hover { border-color: var(--accent); color: var(--accent); }
.nav-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.nav-toggle svg { width: 22px; height: 22px; }

.nav-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15,17,23,0.45);
  backdrop-filter: blur(4px);
  z-index: 95;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.nav-backdrop.open { opacity: 1; pointer-events: auto; }

/* ============================================
   RESPONSIVE
============================================ */

/* Tablet down */
@media (max-width: 1024px) {
  .nav-inner { padding: 0 1.25rem; gap: 1rem; }
  .footer-top { grid-template-columns: 1fr 1fr; gap: 2rem; }
  .section { padding: 70px 1.5rem; }
}

/* Tablet portrait / mobile landscape */
@media (max-width: 820px) {
  /* Hamburger menu */
  .nav-toggle { display: inline-flex; }
  .nav-right .btn-primary { display: none; } /* drop the "View the Course" CTA from nav — appears in drawer */

  .nav-links {
    position: fixed;
    top: var(--nav-h);
    right: 0;
    /* iOS Safari clips drawer using `bottom: 0` because the bottom toolbar
       overlaps the viewport. Set explicit height via 100dvh (dynamic viewport
       height) so the drawer resizes as Safari's chrome appears/disappears.
       Older browsers without dvh fall back to the calc(100vh - nav) line. */
    height: calc(100vh - var(--nav-h));
    height: calc(100dvh - var(--nav-h));
    width: min(86vw, 320px);
    background: var(--bg-card);
    border-left: 1px solid var(--border);
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    margin: 0;
    /* Bottom padding respects the iOS home-indicator safe area so the last
       nav item / drawer CTA isn't hidden behind the gesture bar. */
    padding: 18px 14px max(24px, calc(24px + env(safe-area-inset-bottom))) 14px;
    padding-inline-start: 14px;  /* reset ul default 40px */
    list-style: none;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;  /* momentum scroll on older iOS */
    overscroll-behavior: contain;        /* don't propagate scroll to body */
    transform: translateX(100%);
    transition: transform 0.28s cubic-bezier(.2,.7,.3,1);
    box-shadow: -12px 0 36px rgba(0,0,0,0.08);
    z-index: 96;
    display: flex !important;  /* override the old hide-on-mobile rule below */
  }
  .nav-links.mobile-open { transform: translateX(0); }

  .nav-links li {
    display: block;
    width: 100%;
    list-style: none;
    margin: 0;
  }
  .nav-links li + li { margin-top: 4px; }

  .nav-links a {
    display: block;
    width: 100%;
    padding: 14px 14px;
    font-size: 16px;
    border-radius: 10px;
    color: var(--text-primary);
    box-sizing: border-box;
  }
  .nav-links a:hover,
  .nav-links a.active { background: var(--accent-soft); color: var(--accent); }

  /* Drawer CTA — appended by script.js, only revealed inside the mobile drawer */
  .nav-drawer-cta {
    display: block !important;
    margin-top: 16px;
    padding: 14px;
    background: var(--velvet-gradient);
    color: white;
    text-align: center;
    border-radius: 10px;
    font-weight: 600;
    text-decoration: none;
  }

  /* Hero / page paddings */
  .page-hero { padding: calc(var(--nav-h) + 36px) 1.25rem 40px; }
  .page-hero p { font-size: 15.5px; }
  .section { padding: 56px 1.25rem; }
  .section-body { font-size: 15px; margin-bottom: 2rem; }
}

/* Phone */
@media (max-width: 600px) {
  :root { --nav-h: 60px; }
  .nav-inner { padding: 0 1rem; }
  .logo-secondary { display: none; } /* save horizontal space */
  .logo-mark { width: 30px; height: 30px; font-size: 14px; }
  .logo-primary { font-size: 13px; }

  .page-hero { padding: calc(var(--nav-h) + 28px) 1rem 32px; }
  .page-hero h1 { font-size: clamp(1.7rem, 7vw, 2.4rem); }
  .page-hero-label { font-size: 10px; padding: 4px 12px; margin-bottom: 0.9rem; }
  .page-hero p { font-size: 15px; }
  .section { padding: 44px 1rem; }
  .section-title { font-size: clamp(1.5rem, 6vw, 2rem); }
  .card { padding: 20px; border-radius: 14px; }

  footer { padding: 40px 1rem 24px; }
  .footer-top { grid-template-columns: 1fr; gap: 1.5rem; margin-bottom: 1.75rem; }
  .footer-bottom { flex-direction: column; align-items: flex-start; gap: 0.5rem; }

  /* Make tap targets generous on phones */
  .btn-primary, .btn-secondary, .btn-outline { padding: 12px 20px; font-size: 14px; }
}

/* Tiny phones (< 380px) */
@media (max-width: 380px) {
  .page-hero h1 { font-size: 1.55rem; }
  .section-title { font-size: 1.4rem; }
}

/* ============================================
   MOBILE PATCH — global overrides for pages
   whose inline styles bypass standard breakpoints
   (velvet-method, parents, about, courses, ai-study-guide)
============================================ */
@media (max-width: 820px) {
  /* Collapse any inline-styled multi-column grids to a single column */
  section[style*="grid-template-columns"][style*="1fr"],
  div[style*="grid-template-columns"][style*="1fr"] {
    grid-template-columns: 1fr !important;
    gap: 2rem !important;
  }
  /* Reduce inline 80px section padding */
  section[style*="padding:80px"],
  section[style*="padding: 80px"],
  section[style*="padding:72px"],
  section[style*="padding: 72px"] {
    padding-top: 48px !important;
    padding-bottom: 48px !important;
    padding-left: 1.25rem !important;
    padding-right: 1.25rem !important;
  }
  /* Card paddings — courses flagship, parent form, author card, lab prompts */
  .flagship-card-content,
  .flagship-pricing,
  .form-card,
  .author-card,
  .prompt-card,
  .engines-intro,
  .module-card,
  .coming-card {
    padding: 26px 22px !important;
  }
  /* AI Lab tier nav: stack vertically rather than horizontal-scroll */
  .tier-nav-inner { flex-wrap: wrap !important; overflow-x: visible !important; }
  .tier-nav-inner a, .tier-nav-inner button { flex: 1 1 auto; min-width: 0; }

  /* Subjects-page format-strip: prevent pill overflow */
  .format-strip a {
    font-size: 11.5px !important;
    padding: 4px 10px !important;
  }
  /* Big inline display:flex with gaps — let them wrap */
  .hero-designed-by-row, .parent-reassurance, .hero-proof-strip { flex-wrap: wrap; }
}

@media (max-width: 600px) {
  section[style*="padding:80px"],
  section[style*="padding: 80px"],
  section[style*="padding:72px"],
  section[style*="padding: 72px"] {
    padding-top: 38px !important;
    padding-bottom: 38px !important;
    padding-left: 1rem !important;
    padding-right: 1rem !important;
  }
  .flagship-card-content,
  .flagship-pricing,
  .form-card,
  .author-card,
  .prompt-card,
  .engines-intro,
  .module-card,
  .coming-card {
    padding: 22px 18px !important;
  }
  .pricing-now { font-size: clamp(48px, 13vw, 68px) !important; }
}

/* Books page — keep covers ≥130px wide at very narrow viewports */
@media (max-width: 400px) {
  .books-grid {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)) !important;
    gap: 18px 14px !important;
  }
  .book-title { font-size: 0.85rem !important; }
}
