/* Subpage compatibility styles — maps legacy class names to the new TCM design tokens */

:root {
  /* Legacy variable aliases so old inline styles keep working */
  --white: var(--tcm-surface);
  --bg2: var(--tcm-surface-2);
  --bg3: var(--tcm-surface-3);
  --ink: var(--tcm-foreground);
  --ink2: var(--tcm-foreground-secondary);
  --ink3: var(--tcm-foreground-tertiary);
  --green: var(--tcm-primary);
  --green2: var(--tcm-primary-100);
  --rule: var(--tcm-border);
  --maxw: 1280px;
  --radius: 16px;
}

/* Containers */
.container {
  width: 100%;
  max-width: 1280px;
  margin-left: auto;
  margin-right: auto;
  padding-left: 16px;
  padding-right: 16px;
}
@media (min-width: 640px) {
  .container { padding-left: 24px; padding-right: 24px; }
}
@media (min-width: 1024px) {
  .container { padding-left: 32px; padding-right: 32px; }
}

.container-read {
  width: 100%;
  max-width: 768px;
  margin-left: auto;
  margin-right: auto;
  padding-left: 16px;
  padding-right: 16px;
}
@media (min-width: 640px) {
  .container-read { padding-left: 24px; padding-right: 24px; }
}

/* Hub hero */
.hub-hero {
  background-color: var(--tcm-surface-2);
  padding: 48px 0;
}
@media (min-width: 1024px) {
  .hub-hero { padding: 72px 0; }
}
.hub-hero .container { text-align: center; }
.hub-hero h1 {
  font-family: var(--tcm-font-serif);
  font-size: clamp(32px, 3.6vw, 52px);
  line-height: 1.12;
  font-weight: 500;
  letter-spacing: -0.02em;
  color: var(--tcm-foreground);
  margin-bottom: 16px;
}
.hub-hero p {
  font-family: var(--tcm-font-sans);
  font-size: 18px;
  line-height: 1.6;
  color: var(--tcm-foreground-secondary);
  margin: 0 auto;
  max-width: 720px;
}
.hub-hero p + p { margin-top: 12px; }

/* Article header (single guide pages) */
.article-header {
  background-color: var(--tcm-surface-2);
  padding: 48px 0;
  text-align: center;
}
@media (min-width: 1024px) {
  .article-header { padding: 72px 0; }
}
.article-header .cat-badge {
  display: inline-flex;
  padding: 6px 14px;
  border-radius: var(--tcm-radius-pill);
  background-color: var(--tcm-primary-50);
  color: var(--tcm-primary);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 16px;
}
.article-header h1 {
  font-family: var(--tcm-font-serif);
  font-size: clamp(28px, 3.2vw, 44px);
  line-height: 1.12;
  font-weight: 500;
  letter-spacing: -0.02em;
  color: var(--tcm-foreground);
  margin: 0 0 16px;
}
.article-header .subtitle {
  font-family: var(--tcm-font-sans);
  font-size: 18px;
  line-height: 1.6;
  color: var(--tcm-foreground-secondary);
  margin: 0 auto 20px;
  max-width: 720px;
}
.article-header .article-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 16px;
  font-size: 13px;
  color: var(--tcm-foreground-tertiary);
}

/* Breadcrumbs */
.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px 0;
  font-family: var(--tcm-font-sans);
  font-size: 13px;
  color: var(--tcm-foreground-tertiary);
}
.breadcrumbs a { color: var(--tcm-foreground-secondary); text-decoration: none; }
.breadcrumbs a:hover { color: var(--tcm-primary); }
.breadcrumbs .current { color: var(--tcm-foreground); font-weight: 500; }

/* Sections */
.hub-section, section {
  padding: 48px 0;
}
@media (min-width: 1024px) {
  .hub-section, section { padding: 72px 0; }
}
.tight { padding: 24px 0; }

/* Section header */
.section-header {
  max-width: 768px;
  margin-bottom: 32px;
}
.section-eyebrow {
  display: inline-block;
  font-family: var(--tcm-font-sans);
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--tcm-primary);
  margin-bottom: 8px;
}
.section-header h2 {
  font-family: var(--tcm-font-serif);
  font-size: clamp(26px, 2.6vw, 38px);
  line-height: 1.18;
  font-weight: 500;
  letter-spacing: -0.015em;
  color: var(--tcm-foreground);
  margin-bottom: 12px;
}
.section-header p {
  font-family: var(--tcm-font-sans);
  font-size: 16px;
  line-height: 1.65;
  color: var(--tcm-foreground-secondary);
}
.divider {
  width: 48px;
  height: 3px;
  background-color: var(--tcm-primary);
  border-radius: 2px;
  margin: 16px 0;
}

/* Article typography */
.article-body, .legal-page {
  font-family: var(--tcm-font-sans);
  font-size: 16px;
  line-height: 1.65;
  color: var(--tcm-foreground-secondary);
}
.article-body h2, .legal-page h2 {
  font-family: var(--tcm-font-serif);
  font-size: clamp(26px, 2.6vw, 38px);
  line-height: 1.18;
  font-weight: 500;
  letter-spacing: -0.015em;
  color: var(--tcm-foreground);
  margin-top: 48px;
  margin-bottom: 16px;
}
.article-body h3, .legal-page h3 {
  font-family: var(--tcm-font-sans);
  font-size: 20px;
  line-height: 1.28;
  font-weight: 600;
  color: var(--tcm-foreground);
  margin-top: 32px;
  margin-bottom: 12px;
}
.article-body h4, .legal-page h4 {
  font-family: var(--tcm-font-sans);
  font-size: 18px;
  font-weight: 600;
  color: var(--tcm-foreground);
  margin-top: 24px;
  margin-bottom: 8px;
}
.article-body p, .legal-page p {
  margin-bottom: 16px;
}
.article-body ul, .article-body ol, .legal-page ul, .legal-page ol {
  margin-bottom: 16px;
  padding-left: 24px;
}
.article-body li, .legal-page li {
  margin-bottom: 8px;
}
.article-body a, .legal-page a {
  color: var(--tcm-primary);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.article-body a:hover, .legal-page a:hover {
  color: var(--tcm-primary-600);
}
.article-body strong, .legal-page strong { color: var(--tcm-foreground); font-weight: 600; }

/* Key takeaways */
.takeaways {
  padding: 24px;
  border-radius: var(--tcm-radius-lg);
  background-color: var(--tcm-primary-50);
  border: 1px solid var(--tcm-primary-200);
  margin: 32px 0;
}
.takeaways h4 {
  font-family: var(--tcm-font-sans);
  font-size: 16px;
  font-weight: 700;
  color: var(--tcm-foreground);
  margin: 0 0 12px;
}
.takeaways ul {
  margin: 0;
  padding-left: 20px;
}
.takeaways li {
  margin-bottom: 8px;
  color: var(--tcm-foreground-secondary);
}

/* Article grid & cards */
.article-grid {
  display: grid;
  gap: 24px;
}
@media (min-width: 640px) { .article-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .article-grid { grid-template-columns: repeat(3, 1fr); } }

.article-card {
  display: flex;
  flex-direction: column;
  background-color: var(--tcm-card);
  border: 1px solid var(--tcm-border);
  border-radius: var(--tcm-radius-lg);
  box-shadow: var(--tcm-shadow-1);
  overflow: hidden;
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}
.article-card:hover {
  box-shadow: var(--tcm-shadow-2);
  transform: translateY(-2px);
}
.article-card-img {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  margin: 24px 24px 0;
  border-radius: var(--tcm-radius-md);
  background-color: var(--tcm-primary-50);
  font-size: 24px;
  line-height: 1;
}
.article-card-body {
  padding: 20px 24px 24px;
  flex: 1;
  display: flex;
  flex-direction: column;
}
.article-card-cat {
  display: inline-flex;
  align-self: flex-start;
  padding: 4px 10px;
  border-radius: var(--tcm-radius-pill);
  background-color: var(--tcm-primary-50);
  color: var(--tcm-primary);
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 10px;
}
.article-card h3 {
  font-family: var(--tcm-font-sans);
  font-size: 18px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--tcm-foreground);
  margin: 0 0 10px;
}
.article-card h3 a {
  color: inherit;
  text-decoration: none;
}
.article-card h3 a:hover {
  color: var(--tcm-primary);
}
.article-card p {
  font-size: 15px;
  line-height: 1.55;
  color: var(--tcm-foreground-secondary);
  margin-bottom: 16px;
  flex: 1;
}
.article-card-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--tcm-foreground-tertiary);
}
.tag.outline {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border: 1px solid var(--tcm-border);
  border-radius: var(--tcm-radius-pill);
  font-size: 12px;
  font-weight: 600;
  color: var(--tcm-foreground-secondary);
}

/* Method grid & cards */
.method-grid {
  display: grid;
  gap: 20px;
}
@media (min-width: 640px) { .method-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .method-grid { grid-template-columns: repeat(3, 1fr); } }
.method-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 24px;
  background-color: var(--tcm-card);
  border: 1px solid var(--tcm-border);
  border-radius: var(--tcm-radius-lg);
  box-shadow: var(--tcm-shadow-1);
  text-decoration: none;
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}
.method-card:hover {
  box-shadow: var(--tcm-shadow-2);
  transform: translateY(-2px);
}
.method-card .icon {
  font-size: 28px;
  line-height: 1;
  margin-bottom: 4px;
}
.method-card h3 {
  font-family: var(--tcm-font-sans);
  font-size: 18px;
  font-weight: 600;
  color: var(--tcm-foreground);
  margin: 0;
}
.method-card p {
  font-size: 14px;
  line-height: 1.5;
  color: var(--tcm-foreground-secondary);
  margin: 0;
}

/* Symptom grid & cards */
.symptom-grid {
  display: grid;
  gap: 20px;
}
@media (min-width: 640px) { .symptom-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .symptom-grid { grid-template-columns: repeat(3, 1fr); } }
.symptom-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 24px;
  background-color: var(--tcm-card);
  border: 1px solid var(--tcm-border);
  border-radius: var(--tcm-radius-lg);
  box-shadow: var(--tcm-shadow-1);
  text-decoration: none;
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}
.symptom-card:hover {
  box-shadow: var(--tcm-shadow-2);
  transform: translateY(-2px);
}
.symptom-card .icon {
  font-size: 28px;
  line-height: 1;
  margin-bottom: 4px;
}
.symptom-card h3 {
  font-family: var(--tcm-font-sans);
  font-size: 18px;
  font-weight: 600;
  color: var(--tcm-foreground);
  margin: 0;
}
.symptom-card p {
  font-size: 14px;
  line-height: 1.5;
  color: var(--tcm-foreground-secondary);
  margin: 0;
  flex: 1;
}
.symptom-card .count {
  font-size: 13px;
  font-weight: 600;
  color: var(--tcm-primary);
  margin-top: 8px;
}

/* Callouts */
.callout {
  padding: 24px;
  border-radius: var(--tcm-radius-lg);
  background-color: var(--tcm-surface-2);
  border: 1px solid var(--tcm-border);
  margin: 24px 0;
}
.callout-title {
  font-family: var(--tcm-font-sans);
  font-size: 16px;
  font-weight: 600;
  color: var(--tcm-foreground);
  margin-bottom: 8px;
}
.callout p { margin-bottom: 12px; }
.callout p:last-child { margin-bottom: 0; }
.callout.warn {
  background-color: #FDF8F3;
  border-color: #F0D9B8;
}
.callout.info {
  background-color: var(--tcm-primary-50);
  border-color: var(--tcm-primary-200);
}
.callout.danger {
  background-color: #FDF2F2;
  border-color: #F0C2C2;
}

/* Ad zone placeholder */
.ad-zone {
  min-height: 90px;
  background-color: var(--tcm-surface-3);
  border: 1px dashed var(--tcm-border);
  border-radius: var(--tcm-radius-md);
  margin: 24px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--tcm-foreground-tertiary);
  font-size: 13px;
}
.ad-zone::before { content: "Advertisement"; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 24px;
  border-radius: var(--tcm-radius-pill);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  transition: background-color 0.2s ease;
}
.btn-primary {
  background-color: var(--tcm-primary);
  color: #fff;
}
.btn-primary:hover { background-color: var(--tcm-primary-600); }
.btn-outline {
  border: 1px solid var(--tcm-primary);
  color: var(--tcm-primary);
  background-color: transparent;
}
.btn-outline:hover { background-color: var(--tcm-primary-50); }

.updated {
  font-size: 13px;
  color: var(--tcm-foreground-tertiary);
  margin-bottom: 24px;
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 24px 0;
  font-size: 15px;
}
th, td {
  padding: 12px;
  border: 1px solid var(--tcm-border);
  text-align: left;
}
th {
  background-color: var(--tcm-surface-2);
  font-weight: 600;
  color: var(--tcm-foreground);
}

/* Filter bar from All Guides page */
.filter-bar {
  background-color: var(--tcm-surface);
  border-bottom: 1px solid var(--tcm-border);
  position: sticky;
  top: 64px;
  z-index: 40;
  box-shadow: var(--tcm-shadow-1);
}
.filter-tabs {
  max-width: 1280px;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}
@media (min-width: 640px) { .filter-tabs { padding: 12px 24px; } }
.filter-tabs a {
  flex: 0 0 auto;
  padding: 8px 16px;
  border-radius: var(--tcm-radius-pill);
  font-size: 14px;
  font-weight: 600;
  color: var(--tcm-foreground-secondary);
  background-color: var(--tcm-surface-2);
  border: 1px solid var(--tcm-border);
  text-decoration: none;
  white-space: nowrap;
  transition: all 0.2s ease;
}
.filter-tabs a:hover {
  background-color: var(--tcm-primary);
  color: #fff;
  border-color: var(--tcm-primary);
}
.filter-tabs a.active {
  background-color: var(--tcm-primary);
  color: #fff;
  border-color: var(--tcm-primary);
}


/* ========================================
   MOBILE RESPONSIVE ENHANCEMENTS
   Added for full mobile compatibility
   ======================================== */

/* --- Global Image Responsiveness --- */
img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* --- Figure / Article Hero Image --- */
figure.article-hero-image {
  margin: 0 0 32px 0;
  border-radius: var(--tcm-radius-lg, 16px);
  overflow: hidden;
  max-width: 100%;
}
figure.article-hero-image img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: var(--tcm-radius-lg, 16px);
}
figure.article-hero-image figcaption {
  padding: 12px 16px;
  font-size: 14px;
  color: var(--tcm-foreground-tertiary, #8A8780);
  font-style: italic;
  text-align: center;
}

/* --- Table Mobile Scroll --- */
.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 24px 0;
}
.table-wrapper table {
  min-width: 480px;
}
@media (max-width: 640px) {
  table {
    font-size: 14px;
  }
  th, td {
    padding: 8px 10px;
  }
}

/* --- Mobile Typography Adjustments --- */
@media (max-width: 640px) {
  /* Reduce hero padding on mobile */
  .hub-hero {
    padding: 32px 0;
  }
  .article-header {
    padding: 32px 0;
  }
  .hub-section, section {
    padding: 32px 0;
  }

  /* Smaller headings on mobile */
  .hub-hero h1 {
    font-size: 28px;
  }
  .article-header h1 {
    font-size: 26px;
  }
  .section-header h2 {
    font-size: 24px;
  }
  .article-body h2, .legal-page h2 {
    font-size: 24px;
    margin-top: 32px;
  }
  .article-body h3, .legal-page h3 {
    font-size: 18px;
  }

  /* Body text adjustments */
  .hub-hero p,
  .article-header .subtitle {
    font-size: 16px;
  }
  .article-body, .legal-page {
    font-size: 15px;
  }

  /* Reduce card padding on mobile */
  .article-card-body {
    padding: 16px 18px 18px;
  }
  .method-card,
  .symptom-card {
    padding: 18px;
  }

  /* Takeaways and callouts */
  .takeaways,
  .callout {
    padding: 18px;
    margin: 20px 0;
  }

  /* Breadcrumbs */
  .breadcrumbs {
    font-size: 12px;
    padding: 12px 0;
  }

  /* Article meta */
  .article-header .article-meta {
    gap: 10px;
    font-size: 12px;
  }

  /* Lists */
  .article-body ul,
  .article-body ol,
  .legal-page ul,
  .legal-page ol {
    padding-left: 20px;
  }
}

/* --- Mobile Grid: Single Column --- */
@media (max-width: 639px) {
  .article-grid,
  .method-grid,
  .symptom-grid {
    grid-template-columns: 1fr !important;
    gap: 16px;
  }
}

/* --- Mobile Navigation Fix --- */
@media (max-width: 767px) {
  /* Ensure nav doesn't overflow */
  header.sticky nav {
    flex-wrap: nowrap;
  }
  /* Mobile menu button visible */
  header.sticky button[aria-label="Open menu"] {
    display: inline-flex;
    flex-shrink: 0;
  }
  /* Hide desktop nav links on mobile */
  header.sticky ul.hidden.md\:flex {
    display: none !important;
  }
  /* Hide start here button on very small screens */
  header.sticky a.hidden.sm\:inline-flex {
    display: none !important;
  }
}

/* --- Touch Target Sizing (accessibility) --- */
@media (max-width: 640px) {
  .btn,
  .filter-tabs a,
  .article-card h3 a,
  .method-card,
  .symptom-card {
    min-height: 44px;
  }
  .filter-tabs a {
    padding: 10px 16px;
  }
}

/* --- Prevent Horizontal Scroll --- */
html, body {
  overflow-x: hidden;
  max-width: 100%;
}

/* --- Code Block Mobile Scroll --- */
pre, code {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  word-wrap: break-word;
  word-break: break-word;
}

/* --- Ad Zone Mobile --- */
@media (max-width: 640px) {
  .ad-zone {
    min-height: 60px;
    margin: 16px 0;
  }
}

/* --- Footer Mobile --- */
@media (max-width: 640px) {
  footer .grid {
    grid-template-columns: 1fr !important;
    gap: 24px;
  }
  footer .text-sm {
    font-size: 13px;
  }
}

/* --- Homepage Hero Mobile --- */
@media (max-width: 640px) {
  #section-hero {
    padding: 40px 0 !important;
  }
  #section-hero .grid.lg\:grid-cols-2 {
    grid-template-columns: 1fr !important;
    gap: 24px;
  }
  #section-hero .tcm-display {
    font-size: 32px !important;
  }
  #section-hero .tcm-h1 {
    font-size: 28px !important;
  }
  #section-hero .tcm-body-lg {
    font-size: 16px !important;
  }
}

/* --- Popular Guides / Cards on Mobile --- */
@media (max-width: 640px) {
  .max-w-\[1280px\] .grid {
    gap: 16px;
  }
}

/* --- Smooth Scrolling --- */
html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

/* --- Safe Area for Notched Phones --- */
@supports (padding: max(0px)) {
  body {
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }
}

/* --- Print Optimization --- */
@media print {
  header, footer, .ad-zone, .filter-bar, .btn {
    display: none !important;
  }
  body {
    color: #000;
    background: #fff;
  }
}

/* --- Fix: Article hero image width constraint --- */
figure.article-hero-image {
  max-width: 768px;
  margin-left: auto;
  margin-right: auto;
  margin-bottom: 32px;
}
@media (min-width: 640px) {
  figure.article-hero-image {
    padding-left: 24px;
    padding-right: 24px;
  }
}
