/* Editorial academic home. Business hooks from index.js are preserved. */

body {
  background: #f6f7fb;
}

.home-hero {
  --hero-glow-x: 78%;
  --hero-glow-y: 42%;
  --md-blue-950: #061a38;
  --md-blue-900: #092347;
  --md-blue-800: #12366a;
  --md-blue-700: #1e4583;
  --md-blue-500: #2a66d8;
  --md-blue-300: #8fb8ff;
  min-height: 520px;
  padding: 1.3rem clamp(1rem, 4vw, 4.75rem) 4.7rem;
  color: #f8fbff;
  background:
    radial-gradient(circle 220px at var(--hero-glow-x) var(--hero-glow-y), rgba(255,255,255,.08), transparent 66%),
    radial-gradient(circle at 78% 42%, rgba(42, 102, 216, .32), transparent 26rem),
    linear-gradient(115deg, var(--md-blue-950) 0%, var(--md-blue-900) 54%, var(--md-blue-700) 100%);
}

.home-nav {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: clamp(1rem, 3vw, 3rem);
  width: min(1400px, 100%);
  margin: 0 auto;
}

.home-brand {
  display: inline-flex;
  align-items: center;
  gap: 1rem;
  color: #fff;
  text-decoration: none;
  white-space: nowrap;
}

.home-brand-mark {
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 2.5vw, 2.35rem);
  font-weight: 600;
  letter-spacing: 0;
}

.home-brand span:last-child {
  font-family: var(--font-display);
  font-weight: 600;
}

.home-nav-links {
  display: flex;
  justify-content: center;
  gap: clamp(.8rem, 2.4vw, 2.5rem);
  min-width: 0;
}

.home-nav .nav-link {
  position: relative;
  min-height: 42px;
  padding: .35rem .1rem;
  border: 0;
  border-radius: 0;
  color: rgba(255,255,255,.7);
  background: transparent;
  box-shadow: none;
  font-family: var(--font-display);
  font-size: .98rem;
  font-weight: 500;
}

.home-nav .nav-link:hover,
.home-nav .nav-link.active {
  color: #fff;
  transform: none;
}

.home-nav .nav-link.active::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  border-radius: 999px;
  background: #dbeafe;
}

.home-hero-grid {
  display: grid;
  grid-template-columns: minmax(0, .98fr) minmax(360px, .9fr);
  gap: clamp(2rem, 6vw, 5rem);
  align-items: center;
  width: min(1400px, 100%);
  margin: clamp(3.5rem, 8vw, 6.4rem) auto 0;
}

.home-hero-copy {
  max-width: 660px;
}

.hero-badge {
  margin: 0 0 .55rem;
  color: #8fb8ff;
  font-size: .82rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.home-hero h1 {
  margin: 0;
  color: #fff;
  font-family: var(--font-display);
  font-size: clamp(3.4rem, 7vw, 6.4rem);
  font-weight: 600;
  line-height: .98;
}

.subhead {
  max-width: 690px;
  margin: 1.35rem 0 0;
  color: rgba(236, 242, 255, .8);
  font-size: clamp(1rem, 1.35vw, 1.28rem);
  line-height: 1.7;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .8rem;
  margin-top: 2rem;
}

.hero-cta,
.hero-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .7rem;
  min-height: 54px;
  padding: .84rem 1.35rem;
  border-radius: 6px;
  text-decoration: none;
  font-family: var(--font-display);
  font-weight: 600;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), border-color var(--transition-fast), background var(--transition-fast);
}

.hero-cta {
  color: #fff;
  background: #2a66d8;
  box-shadow: 0 18px 34px rgba(42, 102, 216, .26);
}

.hero-ghost {
  color: #fff;
  border: 1px solid rgba(255,255,255,.34);
  background: transparent;
  box-shadow: none;
}

.hero-ghost svg {
  width: 20px;
  height: 20px;
}

.hero-cta:hover,
.hero-ghost:hover {
  transform: translateY(-2px);
  box-shadow: 0 20px 36px rgba(4, 10, 28, .22);
}

.math-visuals {
  position: relative;
  min-height: 300px;
  color: rgba(214, 228, 255, .55);
}

.tree-diagram {
  position: absolute;
  left: 0;
  top: 12px;
  width: 260px;
  opacity: .86;
}

.venn-diagram {
  position: absolute;
  right: 7%;
  top: 70px;
  width: 240px;
  opacity: .84;
}

.formula {
  position: absolute;
  font-family: var(--font-display);
  color: rgba(231, 239, 255, .46);
  font-size: clamp(1rem, 1.3vw, 1.28rem);
  font-style: italic;
  white-space: nowrap;
}

.formula-union {
  right: 10%;
  top: 4px;
}

.formula-comb {
  left: 28%;
  bottom: 0;
}

.home-main {
  background: #fff;
}

.chapter-section,
.academic-footer {
  width: min(1480px, calc(100% - 4.5rem));
  margin: 0 auto;
}

.chapter-section {
  padding: 2.7rem 0 2.25rem;
}

.chapter-section h2,
.academic-footer h2 {
  margin: 0;
  color: #071733;
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 600;
}

.chapter-track {
  position: relative;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: clamp(1.35rem, 3.2vw, 4.3rem);
  margin-top: 1.65rem;
}

.chapter-line {
  position: absolute;
  left: 8%;
  right: 8%;
  top: 50%;
  border-top: 1px dashed rgba(71, 85, 105, .32);
}

.chapter-card {
  position: relative;
  z-index: 1;
  min-height: 190px;
  padding: 1.45rem 1.3rem 1.28rem;
  border: 1px solid rgba(15, 23, 42, .1);
  border-radius: 8px;
  color: #0b1835;
  background: rgba(255,255,255,.96);
  box-shadow: 0 18px 42px rgba(15, 23, 42, .08);
  text-decoration: none;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), border-color var(--transition-fast);
}

.chapter-card:hover {
  transform: translateY(-2px);
  border-color: rgba(37, 99, 235, .24);
  box-shadow: 0 24px 52px rgba(15, 23, 42, .12);
}

.chapter-number {
  color: #12366a;
  font-family: var(--font-display);
  font-weight: 600;
}

.chapter-card h3 {
  min-height: 2.5em;
  margin: .35rem 0 1rem;
  font-family: var(--font-display);
  font-size: 1.02rem;
  line-height: 1.15;
}

.chapter-card p {
  margin: 1rem 0 0;
  color: #4b5875;
  font-size: .88rem;
  line-height: 1.45;
}

.mini-viz {
  height: 42px;
  color: #3978db;
}

.dots-grid {
  width: 82px;
  background-image: radial-gradient(circle, #3978db 2.8px, transparent 3.4px);
  background-size: 17px 14px;
}

.pigeon-viz {
  display: flex;
  align-items: center;
  gap: .55rem;
}

.pigeon-viz i {
  width: 28px;
  height: 32px;
  border: 1px solid #c8d3e5;
  background:
    radial-gradient(circle at 50% 35%, #3978db 3px, transparent 4px),
    #fff;
}

.arrows-viz,
.binomial-viz {
  width: 128px;
  background:
    radial-gradient(circle at 8px 11px, #3978db 3px, transparent 4px),
    radial-gradient(circle at 28px 11px, #3978db 3px, transparent 4px),
    radial-gradient(circle at 78px 11px, #3978db 3px, transparent 4px),
    radial-gradient(circle at 108px 11px, #cbd5e1 3px, transparent 4px),
    linear-gradient(90deg, transparent 42px, #3978db 42px 70px, transparent 70px);
}

.binomial-viz {
  width: 136px;
  background:
    radial-gradient(circle at 10px 22px, #3978db 5px, transparent 6px),
    radial-gradient(circle at 34px 22px, #3978db 5px, transparent 6px),
    radial-gradient(circle at 58px 22px, transparent 4px, #3978db 5px, transparent 6px),
    radial-gradient(circle at 82px 22px, transparent 4px, #aab7cc 5px, transparent 6px),
    radial-gradient(circle at 106px 22px, transparent 4px, #aab7cc 5px, transparent 6px),
    radial-gradient(circle at 130px 22px, transparent 4px, #aab7cc 5px, transparent 6px);
}

.bayes-viz {
  position: relative;
  width: 132px;
  height: 42px;
}

.density {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 4px;
  height: 34px;
  border-bottom: 1px solid rgba(18, 54, 106, .22);
}

.density::before {
  content: "";
  position: absolute;
  inset: 0;
  background-repeat: no-repeat;
  background-size: 100% 100%;
}

.density-prior::before {
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 132 34' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M4 31 C22 31 25 11 46 11 C68 11 72 31 92 31 C108 31 116 22 128 22' fill='none' stroke='%2312366a' stroke-width='2.2' stroke-linecap='round'/%3E%3C/svg%3E");
  opacity: .55;
}

.density-posterior::before {
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 132 34' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M5 31 C27 31 42 27 53 19 C64 10 72 4 84 4 C102 4 105 31 128 31' fill='none' stroke='%232a66d8' stroke-width='2.4' stroke-linecap='round'/%3E%3C/svg%3E");
}

.academic-footer {
  display: grid;
  grid-template-columns: .95fr .95fr 1.08fr;
  gap: clamp(2.5rem, 4vw, 4.25rem);
  padding: 2.55rem 0 3.1rem;
  border-top: 1px solid rgba(15, 23, 42, .11);
}

.footer-column {
  min-width: 0;
  padding-right: clamp(2rem, 3.4vw, 3.35rem);
  border-right: 1px solid rgba(15, 23, 42, .09);
}

.academic-footer,
.academic-footer * {
  transform: none !important;
}

.academic-footer .footer-column {
  transition: none;
}

.footer-column:last-child {
  padding-right: 0;
  border-right: 0;
}

.footer-column h2::after {
  content: "";
  display: block;
  width: 18px;
  height: 2px;
  margin-top: .72rem;
  background: #2a66d8;
}

.footer-column p {
  color: #4b5875;
  font-size: .9rem;
  line-height: 1.72;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: .6rem;
  margin-top: 1.8rem;
}

.chip-row span {
  padding: .24rem .62rem;
  border: 1px solid rgba(15, 23, 42, .1);
  border-radius: 7px;
  color: #1e5cb8;
  background: #fbfdff;
  font-size: .78rem;
}

.reference-column {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 1.45rem;
  align-content: start;
}

.reference-column h2 {
  grid-column: 1 / -1;
}

.book-cover {
  width: 120px;
  height: 164px;
  object-fit: cover;
  border-radius: 4px;
  box-shadow: 0 12px 28px rgba(15, 23, 42, .18);
}

.reference-column h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.02rem;
  line-height: 1.2;
}

.book-author {
  margin: .35rem 0 .55rem;
  color: #0b1835;
}

.team-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.65rem 1.9rem;
  margin: 1.45rem 0 0;
}

.team-list p {
  display: grid;
  grid-template-columns: 42px 1fr;
  column-gap: 1rem;
  row-gap: .18rem;
  align-items: center;
  margin: 0;
}

.team-list span {
  position: relative;
  grid-row: span 2;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #f2f5fa;
  border: 1px solid rgba(15, 23, 42, .04);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.75);
}

.team-list span::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 10px;
  width: 10px;
  height: 10px;
  transform: translateX(-50%);
  border: 2px solid #6b7280;
  border-radius: 50%;
  background: transparent;
}

.team-list span::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 9px;
  width: 21px;
  height: 11px;
  transform: translateX(-50%);
  border: 2px solid #6b7280;
  border-top-left-radius: 999px;
  border-top-right-radius: 999px;
  border-bottom: 0;
  background: transparent;
}

.team-list strong {
  color: #0b1835;
  font-size: .9rem;
  line-height: 1.25;
}

.team-list small {
  color: #4b5875;
  font-size: .84rem;
  line-height: 1.2;
}

.page-footer {
  margin: 0;
  padding: 1.65rem 1rem;
  border-top: 1px solid rgba(15, 23, 42, .08);
  color: #7b8499;
  background: #f6f7fb;
  text-align: center;
}

#home-ai-toggle {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 2147482999;
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  min-height: 54px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  color: #fff;
  background: #12366a;
  box-shadow: 0 18px 36px rgba(18, 54, 106, .24);
}

#home-ai-toggle svg {
  width: 24px;
  height: 24px;
}

#home-ai-panel {
  position: fixed;
  right: 20px;
  bottom: 86px;
  z-index: 2147483000;
  display: none;
  width: 390px;
  max-width: calc(100vw - 32px);
  max-height: min(620px, calc(100vh - 120px));
  flex-direction: column;
  border: 1px solid rgba(15,23,42,.1);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow-lift);
  overflow: hidden;
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

#home-ai-panel.open {
  display: flex;
  opacity: 1 !important;
  transform: none !important;
}

.home-ai-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .9rem 1rem;
  color: #fff;
  background: #061a38;
}

.home-ai-header strong,
.home-ai-header span {
  display: block;
}

.home-ai-header span {
  color: rgba(255,255,255,.72);
  font-size: .82rem;
}

.home-ai-header button {
  min-height: 34px;
  padding: .42rem .65rem;
  border: 1px solid rgba(255,255,255,.24);
  border-radius: 7px;
  color: #fff;
  background: rgba(255,255,255,.12);
  box-shadow: none;
}

.home-ai-body {
  height: 300px;
  overflow: auto;
  padding: .9rem;
  background: #f7f9fc;
}

.home-ai-message {
  width: fit-content;
  max-width: 88%;
  margin: 0 0 .7rem;
  padding: .68rem .78rem;
  border-radius: 8px;
  white-space: pre-wrap;
  word-break: break-word;
  box-shadow: var(--shadow-soft);
}

.home-ai-message--bot {
  color: #0b1835;
  background: #fff;
  border: 1px solid rgba(15, 23, 42, .09);
}

.home-ai-message--user {
  margin-left: auto;
  color: #fff;
  background: #12366a;
}

.home-ai-message--status {
  color: #64748b;
  background: transparent;
  box-shadow: none;
}

.home-ai-form {
  display: flex;
  gap: .55rem;
  padding: .8rem;
  border-top: 1px solid rgba(15,23,42,.09);
  background: #fff;
}

.home-ai-form input {
  flex: 1;
  min-width: 0;
  min-height: 42px;
  padding: .6rem .72rem;
  border: 1px solid rgba(15,23,42,.12);
  border-radius: 7px;
}

.home-ai-form button {
  min-height: 42px;
  padding: .6rem .86rem;
  border: 0;
  border-radius: 7px;
  color: #fff;
  background: #2a66d8;
}

@media (max-width: 1040px) {
  .home-nav {
    grid-template-columns: 1fr auto;
  }

  .home-nav-links {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-content: flex-start;
    overflow-x: auto;
    padding-bottom: .25rem;
  }

  .home-hero-grid {
    grid-template-columns: 1fr;
  }

  .math-visuals {
    min-height: 230px;
  }

  .chapter-track {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.4rem;
  }

  .chapter-line {
    display: none;
  }

  .academic-footer {
    grid-template-columns: 1fr 1fr;
    width: min(1480px, calc(100% - 2rem));
  }
}

@media (max-width: 640px) {
  .home-hero {
    padding-bottom: 3rem;
  }

  .home-brand span:last-child {
    display: none;
  }

  .home-hero h1 {
    font-size: clamp(3rem, 17vw, 4.8rem);
  }

  .math-visuals {
    min-height: 190px;
  }

  .tree-diagram {
    width: 180px;
  }

  .venn-diagram {
    width: 170px;
  }

  .formula {
    font-size: .9rem;
  }

  .chapter-track,
  .academic-footer,
  .team-list {
    grid-template-columns: 1fr;
  }

  .chapter-section,
  .academic-footer {
    width: min(100% - 1.25rem, 1480px);
  }

  .chapter-section {
    padding-top: 2rem;
  }

  .footer-column {
    padding-right: 0;
    border-right: 0;
  }

  .hero-cta,
  .hero-ghost {
    width: 100%;
  }

  #home-ai-panel {
    right: 10px;
    bottom: 84px;
    max-width: calc(100vw - 20px);
  }

  .home-ai-form {
    flex-direction: column;
  }
}
