/* ============================================
   Custom Theme — Modern teal/emerald palette
   ============================================ */

:root,
[data-md-color-scheme="default"] {
  --md-primary-fg-color: #0d9488;
  --md-primary-fg-color--light: #14b8a6;
  --md-primary-fg-color--dark: #0f766e;
  --md-accent-fg-color: #f59e0b;
  --md-default-bg-color: #ffffff;
  --tx-sidebar-bg: #f8fafb;
  --tx-sidebar-hover: #e8f5f3;
  --tx-sidebar-active: #d1fae5;
  --tx-sidebar-active-text: #065f46;
  --tx-sidebar-border: #e5e7eb;
  --tx-card-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --tx-card-shadow-hover: 0 10px 25px rgba(0,0,0,0.08), 0 4px 10px rgba(0,0,0,0.04);
  --tx-hero-gradient: linear-gradient(135deg, #0d9488 0%, #0ea5e9 50%, #6366f1 100%);
}

[data-md-color-scheme="slate"] {
  --md-primary-fg-color: #2dd4bf;
  --md-primary-fg-color--light: #5eead4;
  --md-primary-fg-color--dark: #14b8a6;
  --md-accent-fg-color: #fbbf24;
  --tx-sidebar-bg: #1e2433;
  --tx-sidebar-hover: #262d3e;
  --tx-sidebar-border: #2d3548;
  --tx-sidebar-active: #0d3d38;
  --tx-sidebar-active-text: #5eead4;
  --tx-card-shadow: 0 1px 3px rgba(0,0,0,0.2);
  --tx-card-shadow-hover: 0 10px 25px rgba(0,0,0,0.3);
  --tx-hero-gradient: linear-gradient(135deg, #134e4a 0%, #0c4a6e 50%, #312e81 100%);
}

/* ============================================
   Header
   ============================================ */

.md-header {
  background: var(--md-primary-fg-color--dark);
  box-shadow: 0 1px 3px rgba(0,0,0,0.12);
}

[data-md-color-scheme="slate"] .md-header {
  background: #151b28;
}

.md-header__button.md-logo {
  padding: 0.2rem;
}

/* ============================================
   Sidebar — modern app-style nav
   ============================================ */

.md-sidebar {
  background: var(--tx-sidebar-bg);
  border-right: 1px solid var(--tx-sidebar-border);
}

.md-sidebar__scrollwrap {
  padding: 0.5rem;
}

.md-nav__title {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--md-default-fg-color--light);
  padding: 0.8rem 0.75rem 0.4rem;
}

.md-nav__item .md-nav__link {
  border-radius: 0.5rem;
  padding: 0.5rem 0.75rem;
  margin: 1px 0;
  font-size: 0.8rem;
  font-weight: 450;
  color: var(--md-default-fg-color--light);
  transition: all 0.15s ease;
}

.md-nav__item .md-nav__link:hover {
  background: var(--tx-sidebar-hover);
  color: var(--md-default-fg-color);
}

.md-nav__item .md-nav__link--active,
.md-nav__item .md-nav__link--active:hover {
  background: var(--tx-sidebar-active);
  color: var(--tx-sidebar-active-text);
  font-weight: 600;
}

.md-nav__item--nested > .md-nav__link {
  font-weight: 600;
  color: var(--md-default-fg-color);
}

.md-nav--primary .md-nav__title[for="__drawer"] {
  background: var(--md-primary-fg-color);
  color: white;
  border-radius: 0;
}

/* ============================================
   Content area polish
   ============================================ */

.md-content {
  max-width: none;
}

.md-typeset h1 {
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--md-default-fg-color);
}

.md-typeset h2 {
  font-weight: 700;
  border-bottom: 2px solid var(--tx-sidebar-border);
  padding-bottom: 0.4rem;
}

/* ============================================
   Home — Hero
   ============================================ */

.tx-hero,
.tx-stats {
  width: 100vw;
  position: relative;
  left: 50%;
  right: 50%;
  margin-left: -50vw;
  margin-right: -50vw;
}

.tx-hero {
  padding: 5rem 1rem;
  background: var(--tx-hero-gradient);
  color: white;
  text-align: center;
}

.tx-hero h1 {
  font-size: 3rem;
  font-weight: 800;
  margin-bottom: 0.5rem;
  color: white;
  letter-spacing: -0.03em;
}

.tx-hero .tx-hero__tagline {
  font-size: 1.2rem;
  opacity: 0.9;
  margin-bottom: 2.5rem;
  max-width: 560px;
  margin-left: auto;
  margin-right: auto;
  line-height: 1.7;
}

.tx-hero .md-button {
  font-size: 1rem;
  padding: 0.75rem 2rem;
  border-radius: 0.5rem;
  margin: 0.4rem;
  font-weight: 600;
  transition: all 0.2s ease;
}

.tx-hero .md-button--primary {
  background-color: white;
  color: var(--md-primary-fg-color--dark);
  border: none;
  box-shadow: 0 4px 14px rgba(0,0,0,0.15);
}

.tx-hero .md-button--primary:hover {
  background-color: #f0fdf4;
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.2);
}

.tx-hero .md-button--secondary {
  border: 2px solid rgba(255,255,255,0.6);
  color: white;
  background: rgba(255,255,255,0.1);
  backdrop-filter: blur(4px);
}

.tx-hero .md-button--secondary:hover {
  background: rgba(255,255,255,0.2);
  border-color: white;
  transform: translateY(-1px);
}

/* ============================================
   Home — Stats bar
   ============================================ */

.tx-stats {
  display: flex;
  justify-content: center;
  gap: 4rem;
  padding: 2.5rem 1rem;
  background: var(--tx-sidebar-bg);
  border-bottom: 1px solid var(--tx-sidebar-border);
  text-align: center;
  flex-wrap: wrap;
}

.tx-stat strong {
  display: block;
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--md-primary-fg-color);
  letter-spacing: -0.02em;
}

.tx-stat span {
  font-size: 0.75rem;
  font-weight: 600;
  opacity: 0.5;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

/* ============================================
   Home — Feature cards
   ============================================ */

.tx-features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.5rem;
  padding: 3.5rem 1rem;
  max-width: 960px;
  margin: 0 auto;
}

.tx-feature {
  text-align: center;
  padding: 2rem 1.5rem;
  border-radius: 1rem;
  background: var(--md-default-bg-color);
  border: 1px solid var(--tx-sidebar-border);
  box-shadow: var(--tx-card-shadow);
  transition: all 0.25s ease;
}

.tx-feature:hover {
  box-shadow: var(--tx-card-shadow-hover);
  transform: translateY(-3px);
}

.tx-feature .tx-feature__icon {
  font-size: 2.5rem;
  margin-bottom: 1rem;
}

.tx-feature h3 {
  margin: 0 0 0.5rem;
  font-size: 1.05rem;
  font-weight: 700;
}

.tx-feature p {
  margin: 0;
  opacity: 0.65;
  font-size: 0.88rem;
  line-height: 1.6;
}

/* ============================================
   Home — Chapters grid
   ============================================ */

.tx-chapters {
  max-width: 960px;
  margin: 2rem auto;
  padding: 0 1rem 3rem;
}

.tx-chapters h2 {
  text-align: center;
  margin-bottom: 1.5rem;
  border: none;
}

.tx-chapters ol {
  grid-template-columns: repeat(2, 1fr);
}

.tx-chapters ol li a::before {
  display: none;
}

/* ============================================
   Chapter index — pattern family cards
   ============================================ */

.md-content ol {
  display: grid !important;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.75rem;
  padding: 0;
  margin: 1.5rem 0;
  counter-reset: pattern-counter;
}

@media (min-width: 768px) {
  .md-content ol {
    grid-template-columns: repeat(2, 1fr);
  }
}

.md-content ol li {
  list-style: none;
  margin: 0;
  padding: 0;
  counter-increment: pattern-counter;
}

.md-content ol li a {
  display: block;
  padding: 0.85rem 1rem;
  border-radius: 0.6rem;
  border: 1px solid var(--tx-sidebar-border);
  text-decoration: none;
  color: var(--md-default-fg-color);
  transition: all 0.2s ease;
  font-weight: 500;
  font-size: 0.88rem;
  background: var(--md-default-bg-color);
  box-shadow: var(--tx-card-shadow);
}

.md-content ol li a:hover {
  background: var(--md-primary-fg-color);
  color: white;
  border-color: var(--md-primary-fg-color);
  transform: translateY(-2px);
  box-shadow: var(--tx-card-shadow-hover);
}

.md-content ol li a::before {
  content: counter(pattern-counter) ".";
  font-weight: 800;
  color: var(--md-primary-fg-color);
  margin-right: 0.5rem;
  font-size: 0.85rem;
}

.md-content ol li a:hover::before {
  color: white;
}

/* ============================================
   Contact section on home
   ============================================ */

.tx-contact {
  text-align: center;
  padding: 1rem 1rem 3rem;
  max-width: 960px;
  margin: 0 auto;
}

/* ============================================
   Footer
   ============================================ */

.md-footer {
  background: var(--md-primary-fg-color--dark);
}

[data-md-color-scheme="slate"] .md-footer {
  background: #151b28;
}

/* ============================================
   Responsive
   ============================================ */

@media (max-width: 600px) {
  .tx-hero h1 {
    font-size: 2.2rem;
  }
  .tx-hero .tx-hero__tagline {
    font-size: 1rem;
  }
  .tx-chapters ol {
    grid-template-columns: 1fr;
  }
  .tx-stats {
    gap: 2rem;
  }
}
