/* ============================================================
   SWAP — MACRO LAYOUT (Region grid)
   LAYER: View
   Regions use grid. Everything inside a region uses flexbox.
   ============================================================ */

*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-family);
  font-size: var(--font-base);
  line-height: var(--leading-normal);
  color: var(--color-text);
  background: var(--color-bg);
}

/* ------------------------------------------------------------
   THE ADULT PAGE SHELL
   ------------------------------------------------------------ */
.SWAPstyles.shell {
  display: grid;
  min-height: 100vh;
  grid-template-areas: var(--mobile-layout);
  grid-template-columns: var(--mobile-columns);
  grid-template-rows: var(--header-height) 1fr auto;
}

.SWAPstyles.region--header  { grid-area: header; }
.SWAPstyles.region--sidebar { grid-area: sidebar; }
.SWAPstyles.region--main    { grid-area: main; }
.SWAPstyles.region--panel   { grid-area: panel; }
.SWAPstyles.region--footer  { grid-area: footer; }

.SWAPstyles.region--sidebar,
.SWAPstyles.region--panel { display: none; }

.SWAPstyles.region--main {
  padding: var(--content-padding);
  display: flex;
  flex-direction: column;
  gap: var(--section-gap);
  min-width: 0; /* WHY: lets wide tables scroll instead of stretching the grid */
}

/* Tablet — the sidebar appears, the panel folds into main */
@media (min-width: 768px) {
  .SWAPstyles.shell {
    grid-template-areas: var(--tablet-layout);
    grid-template-columns: var(--tablet-columns);
  }
  .SWAPstyles.region--sidebar { display: block; }
}

/* Desktop — the full three-column layout */
@media (min-width: 1024px) {
  .SWAPstyles.shell {
    grid-template-areas: var(--desktop-layout);
    grid-template-columns: var(--desktop-columns);
  }
  .SWAPstyles.region--panel { display: block; }
}

@media (min-width: 1440px) {
  .SWAPstyles.region--main { max-width: 1400px; width: 100%; margin: 0 auto; }
}

/* ------------------------------------------------------------
   HEADER
   ------------------------------------------------------------ */
.SWAPstyles.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--component-gap);
  padding: 0 var(--content-padding);
  height: var(--header-height);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.SWAPstyles.header__brand {
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  color: var(--color-primary);
  text-decoration: none;
  letter-spacing: -0.02em;
}

.SWAPstyles.header__nav {
  display: none;
  align-items: center;
  gap: var(--space-4);
}

@media (min-width: 768px) {
  .SWAPstyles.header__nav { display: flex; }
}

.SWAPstyles.header__link {
  color: var(--color-text-muted);
  text-decoration: none;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  padding: var(--space-2) 0;
  border-bottom: 2px solid transparent;
}

.SWAPstyles.header__link:hover { color: var(--color-text); }

.SWAPstyles.header__link--active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}

/* ------------------------------------------------------------
   SIDEBAR
   ------------------------------------------------------------ */
.SWAPstyles.sidebar {
  padding: var(--content-padding) var(--space-4);
  border-right: 1px solid var(--color-border);
  background: var(--color-surface);
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.SWAPstyles.sidebar__group { display: flex; flex-direction: column; gap: var(--space-2); }

.SWAPstyles.sidebar__label {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  font-weight: var(--weight-semibold);
}

.SWAPstyles.sidebar__link {
  display: block;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  color: var(--color-text);
  text-decoration: none;
  font-size: var(--text-sm);
}

.SWAPstyles.sidebar__link:hover { background: var(--color-primary-light); }

.SWAPstyles.sidebar__link--active {
  background: var(--color-primary-light);
  color: var(--color-primary-dark);
  font-weight: var(--weight-semibold);
}

/* ------------------------------------------------------------
   PANEL & FOOTER
   ------------------------------------------------------------ */
.SWAPstyles.panel {
  padding: var(--content-padding);
  border-left: 1px solid var(--color-border);
  background: var(--color-surface);
  display: flex;
  flex-direction: column;
  gap: var(--section-gap);
}

.SWAPstyles.footer {
  min-height: var(--footer-height);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  padding: var(--space-3) var(--content-padding);
  border-top: 1px solid var(--color-border);
  color: var(--color-text-muted);
  font-size: var(--text-xs);
  background: var(--color-surface);
  flex-wrap: wrap;
}

/* ------------------------------------------------------------
   SECTIONS & GRIDS — flexbox inside regions
   ------------------------------------------------------------ */
.SWAPstyles.section {
  display: flex;
  flex-direction: column;
  gap: var(--component-gap);
}

.SWAPstyles.section__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--component-gap);
  flex-wrap: wrap;
}

.SWAPstyles.section__title {
  margin: 0;
  font-size: var(--text-xl);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-tight);
}

.SWAPstyles.section__hint {
  margin: 0;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

.SWAPstyles.grid {
  display: grid;
  gap: var(--component-gap);
  grid-template-columns: repeat(var(--card-columns-mobile), minmax(0, 1fr));
}

@media (min-width: 768px) {
  .SWAPstyles.grid { grid-template-columns: repeat(var(--card-columns-tablet), minmax(0, 1fr)); }
}

@media (min-width: 1024px) {
  .SWAPstyles.grid { grid-template-columns: repeat(var(--card-columns), minmax(0, 1fr)); }
}

.SWAPstyles.stack { display: flex; flex-direction: column; gap: var(--space-3); }
.SWAPstyles.row   { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.SWAPstyles.row--end { justify-content: flex-end; }
.SWAPstyles.spacer { flex: 1 1 auto; }

/* WHY every wide element gets its own scroller: STANDARDS §2 responsiveness —
   the page body must never scroll horizontally, but a results table legitimately
   can be wider than a phone. */
.SWAPstyles.scroller { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.SWAPstyles.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
