@layer layout {
  /* ===================================================
     TGK Structure: Page Containers & Sections
     File: /structure/page-structure.css
     Version: 1.3 – Tokenised & Responsive
     =================================================== */

  /* 🌐 Core Content Container */
  .content-container,
  .site-main {
    max-width: var(--grid-max-width, 1400px);
    margin: 0 auto;
    padding: var(--space-vs) var(--space-md);
    line-height: var(--font-base-line);
  }

  /* 🧱 Reusable Section Block */
  .section-block {
    margin: var(--space-xl) 0;
    padding: var(--space-lg);
    background: linear-gradient(
      to bottom,
      var(--section-bg-top),
      var(--section-bg-bottom)
    );
    border: 0.5px solid var(--section-border);
    border-left: 2px solid var(--section-border);
    border-radius: var(--border-radius-base);
    box-shadow: var(--page-shadow-soft);
    overflow-x: hidden;
  }

  @media (max-width: 600px) {
    .section-block { padding: var(--space-sm); }
  }

  /* ========================================
     Chart Wrapper
     ======================================== */
  .chart-wrapper {
    width: 100%;
    height: 500px;
    margin: var(--space-lg) auto;
    max-height: 90vh;
  }

  .chart-wrapper canvas {
    width: 100% !important;
    height: 100% !important;
    display: block;
    max-width: 100%;
    max-height: 100%;
    outline: none;
  }

  .chart-caption {
    text-align: center;
    font-size: var(--font-base-size);
    margin-top: var(--space-md);
    color: var(--text-secondary);
  }

  @media (max-width: 600px) {
    .chart-caption { font-size: var(--font-size-vs); }
  }

  /* ========================================
     Section Headings
     ======================================== */
  .section-heading {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-size-lg);
    font-family: var(--font-display);
    color: var(--text-accent);
    letter-spacing: 0.05em;
    text-transform: uppercase;
    text-align: center;
    margin-bottom: var(--space-md);
    gap: var(--space-sm);
  }

  .section-heading::before,
  .section-heading::after {
    content: "";
    flex: 1;
    height: 1px;
    background-color: var(--text-accent);
    opacity: 0.4;
  }

  @media (max-width: 600px) {
    .section-heading {
      font-size: var(--font-size-base);
      letter-spacing: 0.03em;
    }
  }

  /* ✴️ Emphasis */
  strong {
    font-weight: 600;
    color: var(--strong-text, var(--text-accent));
    font-family: var(--font-serif);
    letter-spacing: 0.3px;
  }

  /* 🚪 Threshold Messages */
  .welcome-text {
    font-size: var(--font-size-lg);
    font-weight: 600;
    color: var(--welcome-text, var(--text-accent));
    text-align: center;
    margin: var(--space-lg) 0 var(--space-md);
    font-family: var(--font-display);
    letter-spacing: 0.05em;
  }

  .door-callout {
    font-size: var(--font-size-base);
    font-style: italic;
    color: var(--door-callout-color, var(--text-primary));
    text-align: center;
    max-width: 40ch;
    margin: 0 auto;
    line-height: var(--font-base-line);
    opacity: 0.9;
  }

  .section-subtitle {
    font-size: var(--font-size-md);
    font-weight: 400;
    color: var(--text-primary);
    font-family: var(--font-serif);
    margin: -0.5rem 0 var(--space-lg);
    line-height: var(--font-base-line);
    text-align: left;
  }

  /* ========================================
     Page Title Block
     ======================================== */
    .page-title-block {
      text-align: center;
      margin: var(--space-md) auto;
      max-width: 960px;
      padding: 0 var(--space-md);
    }

    .page-title {
      text-align: center;
      font-size: var(--font-size-xl);
      font-weight: bold;
      font-family: var(--page-title);
      color: var(--text-accent);
      line-height: var(--font-base-line);
      margin-bottom: var(--space-md);
    }

    .page-title::after {
    content: "";
    display: block;
    width: 60px;
    height: 2px;
    background: var(--highlight);
    margin: var(--space-sm) auto 0;
    border-radius: 2px;
    box-shadow: 0 0 8px var(--shadow-glow);
  }
  
  /* ========================================
     Fullscreen Center Wrapper
     ======================================== */
  .center-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    width: 100%;
    padding: var(--space-md);
    box-sizing: border-box;
  }

  /* Global pageing */
  html { scroll-behavior: auto; scroll-padding-top: var(--space-lg); }
  html, body { min-height: 100%; }
  *, *::before, *::after { box-sizing: border-box; }

  body {
    margin: 0;
    color: var(--text-primary, #eaeaea); /* ✅ fallback added */
    position: relative;
    isolation: isolate;
    background: transparent !important; /* painter only */
  }

  .template-base {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: transparent;
    color: var(--text-primary);
  }

  /* 🎨 Background Painter */
  body::before {
    content: "";
    position: fixed;
    inset: 0;
    background:
      var(--overlay-bg-gradient, var(--bg-gradient, none)),
      var(--overlay-img, none);
    background-size: cover, cover;
    background-position: center, center;
    background-repeat: no-repeat, no-repeat;
    background-attachment: fixed, fixed;
    opacity: var(--bg-opacity, 1);
    pointer-events: none;
    z-index: 0;
  }

  body > * { position: relative; z-index: 1; }

  .background-overlay {
    position: fixed;
    inset: 0;
    z-index: -1;
    opacity: 0;
    pointer-events: none;
    transition: background-image 0.5s ease, opacity 0.3s ease;
  }

  /* 🔔 Toast */
  .tgk-toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    background: var(--soft-gold, #e5c47a);
    color: #111;
    padding: 0.75em 1.25em;
    border-radius: 2em;
    font-weight: bold;
    z-index: 9999;
    opacity: 0.95;
    box-shadow: 0 0 0.5em rgba(0,0,0,0.3);
  }

  /* 📜 Footnotes */
  .footnote {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 1rem;
    padding-left: 1rem;
    border-left: 2px solid var(--accent-obsidian, var(--text-accent));
    font-style: italic;
    line-height: 1.4;
  }

  /* ♿ Accessibility: Skip link */
  .skip-link {
    position: absolute;
    left: -9999px;
    width: 1px; height: 1px;
    overflow: hidden;
  }
  .skip-link:focus {
    position: fixed;
    left: 1rem;
    top: 1rem;
    width: auto; height: auto;
    background: var(--highlight);
    color: var(--bg-primary);
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    z-index: 9999;
  }
}