/* =========================================================================
   FILENAME: frame.css
   ROLE: Central Structure, Device Viewport Containment & Page Boundaries
   SCOPE: Layout geometry, max-widths, flex/grid templates, and responsiveness.
          STRICTLY HAS NO PAINT RESPONSIBILITY (NO COLOURS, NO THEMES).
   ========================================================================= */

/* =========================================================================
   LAYOUT VARIABLES
   ========================================================================= */

:root {
  --frame-width: clamp(640px, 90dvw, 1024px); /* iPad Pro, portrait mode constraint */
  --surface-padding: 2rem;

  /* Dashboard Grid Matrix Sizing Tokens */
  --nav-grid-gap: 10px;
  --radius: 8px;
}

/* =========================================================================
   APP FRAME ENVIRONMENT (Tablet-style containment)
   ========================================================================= */

body {
  margin: 0; /* Layout reset belongs here, not in base.css overrides */
}

/* Engine frame (Standalone viewport usage) */
.engine-layer__frame {
  max-width: min(var(--frame-width), 92dvw);
  margin: 0 auto;
  height: 100dvh;
  /* display: flex;
  flex-direction: column; */
}

/* Primary Document/Landing Page Frame Context */
.app-frame {
  width: 100%;
  padding-left: 1.5rem;
  padding-right: 1.5rem;
  max-width: min(var(--frame-width), 92dvw);
  margin: 2rem auto;
  position: relative;
}

/* =========================================================================
   SYMMETRICAL PAGE LAYOUT GRID (Unified Vertical Axis)
   ========================================================================= */

/* Dropped the asymmetric 1fr/fixed split. Everything now follows a 
   completely balanced, centered single-column sequence. */
.page-body {
  gap: 1.5rem;
  margin-top: 0.75rem;
  margin-bottom: 0.75rem;
}


/* =========================================================================
   TOP MATRIX DASHBOARD GEOMETRY (Decoupled Grid Layout)
   ========================================================================= */

.app-top-nav { 
  position: sticky;         
  top: 0;
  z-index: 1000;
  width: 100%;
}

.top-nav-matrix {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: var(--nav-grid-gap, 10px);
  width: 100%;
}

/* Individual accordion navigation items */
.nav-matrix-item {
  display: block; 
  position: relative; /* Anchor point for absolute coordinates */
  border-radius: 6px;
 
  /* CRITICAL ROOT FIX: 
     We completely remove 'overflow: hidden' so absolute children 
     can float outside this container boundary. */
  overflow: visible !important; 
}

/* Elevate the active open column above its neighbors */
.nav-matrix-item[open] {
  z-index: 1010;
}

.nav-matrix-summary {
  /* display: flex;
  justify-content: center;
  align-items: center; */
  gap: 6px;
  padding: 12px 8px;
  cursor: pointer;
  list-style: none;
  font-weight: 600;
  text-align: center;
  user-select: none;
}

/* Hide native browser disclosure triangles */
.nav-matrix-summary::-webkit-details-marker { display: none; }
.nav-matrix-summary::marker { display: none; }


/* =========================================================================
   THE CLEAN VISIBILITY TRACKING ENGINE
   ========================================================================= */

/* Rule A: Natively, if the container is closed, hide the panel completely */
.nav-matrix-item .nav-matrix-dropdown {
  display: none; 
}

/* Rule B: ONLY force display: block when the parent carries the native HTML5 [open] token */
.nav-matrix-item[open] .nav-matrix-dropdown {
  display: block; 
  position: absolute; 
  top: 100%;          /* Snaps cleanly below the trigger button */
  left: 0;
  width: 100%;        /* Tracks flawlessly to the Grid track width */
  margin-top: 4px;    
  padding: 12px;
  font-size: 0.85rem;
  line-height: 1.4;

  /* Presentation Layer Surface */
  background-color: #ffffff; 
  border: 1px solid var(--surface-border, #d2dfe6);
  border-radius: 6px;
  box-shadow: 0 6px 16px rgba(18, 28, 38, 0.15);
}

.nav-matrix-dropdown a {
  display: block;
  text-decoration: none;
  color: var(--text-secondary, #2e3e4e);
}
.nav-matrix-dropdown a:hover {
  color: var(--action-primary, #007a5e);
}

/* =========================================================================
   RESPONSIVE MATRIX BREAKPOINTS
   ========================================================================= */

/* Tablet Viewports: Transition seamlessly into a clean 3-column / 2-column distribution */
@media (max-width: 768px) {
  .top-nav-matrix {
    grid-template-columns: repeat(3, 1fr);
  }

  /* STH - Reduce summary padding at tablet to recover vertical space */
  .nav-matrix-summary {
    padding: 8px 4px;
    font-size: 0.85rem;
  }

  .footer-nav-matrix-summary {
    padding: 8px 4px;
    font-size: 0.85rem;
  }

  /* STH - Hide + symbol on mobile, label text is sufficient */
  .nav-matrix-summary::after,
  .footer-nav-matrix-summary::after {
    display: none;
  }

  /* STH - Primary Document/Landing Page Frame Context */
  .app-frame {
    padding-left: 0rem;
    padding-right: 0rem;
    margin: 1rem auto;
  }
}

/* Portrait Mobile Viewports: Shift to an easy-to-tap 2-column matrix layout block */
@media (max-width: 480px) {
  :root {
    --surface-padding: 1rem;
  }

  /* STH - Further reduce summary padding on phones to minimise nav height */
  .nav-matrix-summary {
    padding: 6px 4px;
    font-size: 0.8rem;
  }

  .footer-nav-matrix-summary {
    padding: 6px 4px;
    font-size: 0.8rem;
  }
}

/* Optional tuning: Ensures target sections don't hide behind the sticky nav */
html {
  scroll-behavior: smooth;
  scroll-padding-top: 4rem; /* Match this roughly to the height of your navbar */
}


/* =========================================================================
   FOOTER MATRIX DASHBOARD GEOMETRY - CATEGORY FOLDERS
   ========================================================================= */

.app-footer-nav { 
  /* position: sticky;         
  top: 0; */
  z-index: 1000;
  background-color: #ffffff; 
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05); 
  width: 100%;
  margin-bottom: 0.5em;
 }


.footer-nav-matrix {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: var(--nav-grid-gap, 10px);
  width: 100%;
}

.footer-nav-matrix-item {
  display: block; 
  position: relative; /* Anchor point for absolute coordinates */
  border: 1px solid var(--surface-border, #d2dfe6);
  border-radius: 6px;
  background-color: var(--surface-secondary, #f0f4f7);
  
  /* CRITICAL ROOT FIX: 
     We completely remove 'overflow: hidden' so absolute children 
     can float outside this container boundary. */
  overflow: visible !important; 
}

/* Elevate the active open column above its neighbors */
.footer-nav-matrix-item[open] {
  z-index: 1010;
}

.footer-nav-matrix-summary {
  /* display: flex;
  justify-content: center;
  align-items: center; */
  gap: 6px;
  padding: 12px 8px;
  cursor: pointer;
  list-style: none;
  font-weight: 600;
  text-align: center;
  user-select: none;
}

/* Hide native browser disclosure triangles */
.footer-nav-matrix-summary::-webkit-details-marker { display: none; }
.footer-nav-matrix-summary::marker { display: none; }


/* =========================================================================
   THE CLEAN VISIBILITY TRACKING ENGINE
   ========================================================================= */

/* Rule A: Natively, if the container is closed, hide the panel completely */
.footer-nav-matrix-item .nav-matrix-dropdown {
  display: none; 
}

/* Rule B: ONLY force display: block when the parent carries the native HTML5 [open] token */
.footer-nav-matrix-item[open] .footer-nav-matrix-dropdown {
  display: block; 
  position: absolute; 
  top: 100%;          /* Snaps cleanly below the trigger button */
  left: 0;
  width: 100%;        /* Tracks flawlessly to the Grid track width */
  margin-top: 4px;    
  padding: 12px;
  font-size: 0.85rem;
  line-height: 1.4;

  /* Presentation Layer Surface */
  background-color: #ffffff; 
  border: 1px solid var(--surface-border, #d2dfe6);
  border-radius: 6px;
  box-shadow: 0 6px 16px rgba(18, 28, 38, 0.15);
}

.footer-nav-matrix-dropdown a {
  display: block;
  text-decoration: none;
  color: var(--text-secondary, #2e3e4e);
}
.footer-nav-matrix-dropdown a:hover {
  color: var(--action-primary, #007a5e);
}


/* =========================================================================
   RESPONSIVE MATRIX BREAKPOINTS
   ========================================================================= */

  .footer-top-nav-matrix {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }