/* layout.css - page structure, nav, skip link, main regions */

:root {
  --hero-h: 100px;
}

/* Skip link */
.skip-link {
  position: fixed;
  top: -100%;
  left: var(--space-4);
  padding: var(--space-2) var(--space-4);
  background: var(--color-accent);
  color: #ffffff;
  text-decoration: none;
  font-weight: 600;
  border-radius: 0 0 var(--radius) var(--radius);
  z-index: 200; /* above the sticky hero (z-index: 100) */
}

.skip-link:focus {
  top: 0;
}

/* Site header */
.site-header {
  border-bottom: 1px solid var(--color-border);
  padding: var(--space-4) 0;
}

.site-header__inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 var(--space-6);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
}

.site-header__logo {
  font-size: var(--font-size-2xl);
  font-weight: 700;
  color: var(--color-text);
  text-decoration: none;
}

.site-header__logo:hover {
  color: var(--color-accent);
}

/* -------------------------------------------------------
   Site hero - index page merged header + title block
   Layout: [brand square] | [eyebrow + h1] | [actions square]
   ------------------------------------------------------- */
.site-hero {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  overflow: hidden;
}

.site-hero__inner {
  display: grid;
  grid-template-columns: var(--hero-h) 1fr var(--hero-h);
  width: 100%;
  height: var(--hero-h);
}

/* Explicit column placement keeps visual order locked even if DOM order
   ever changes for tab-sequence reasons. Current tab order matches DOM:
   skip link → logo (home) → theme toggle → left nav → main content. */
.site-hero__brand   { grid-column: 1; }
.site-hero__text    { grid-column: 2; }
.site-hero__actions { grid-column: 3; }

/* Left square — logo */
.site-hero__brand {
  display: flex;
  align-items: center;
  justify-content: center;
  border-right: 1px solid var(--color-border);
}

.site-hero .site-header__logo {
  font-size: 1.1rem;
  font-weight: 800;
  text-align: center;
  line-height: 1.2;
}

/* Centre — eyebrow + title */
.site-hero__text {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  padding: 0 var(--space-6);
}

.site-hero__eyebrow {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--color-accent);
  margin: 0 0 0.2rem;
}

.site-hero__title {
  font-size: var(--font-size-base);
  font-weight: 700;
  line-height: 1.2;
  color: var(--color-text-muted);
  margin: 0;
}

/* Right square — button fills the full grid cell */
.site-hero__actions {
  border-left: 1px solid var(--color-border);
}

.site-hero__actions .theme-toggle {
  width: 100%;
  height: 100%;
  padding: 0;
  border: none;
  border-radius: 0;
  flex-direction: column;
  justify-content: center;
  gap: var(--space-1);
  font-size: var(--font-size-sm);
  white-space: normal;
}

/* Intro paragraph sitting above the checkpoint list */
.index-intro {
  margin-bottom: var(--space-4);
  color: var(--color-text);
  font-size: var(--font-size-sm);
}

/* Site nav */
.site-nav__list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  gap: var(--space-6);
}

.site-nav__list li {
  margin: 0;
}

.site-nav__list a {
  font-size: var(--font-size-sm);
  font-weight: 500;
  text-decoration: none;
  color: var(--color-text-muted);
}

.site-nav__list a:hover,
.site-nav__list a[aria-current="page"] {
  color: var(--color-accent);
}

/* Main content */
.site-main {
  max-width: 960px;
  margin: 0 auto;
  padding: var(--space-6) var(--space-6) var(--space-12);
  scroll-margin-top: var(--hero-h);
}

/* Page header (per-page title block) */
.page-header {
  margin-bottom: var(--space-12);
  padding-bottom: var(--space-8);
  border-bottom: 1px solid var(--color-border);
}

.page-header__eyebrow {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-2);
}

.page-header__title {
  margin-bottom: var(--space-4);
}

.page-header__meta {
  display: flex;
  gap: var(--space-3);
  align-items: center;
  flex-wrap: wrap;
}

/* Badges */
.badge {
  display: inline-block;
  font-size: var(--font-size-sm);
  font-weight: 600;
  padding: var(--space-1) var(--space-3);
  border-radius: 999px;
  border: 1px solid;
}

.badge--level-a {
  color: #1d4ed8;
  background: #eff6ff;
  border-color: #bfdbfe;
}

.badge--level-aa {
  color: #6d28d9;
  background: #f5f3ff;
  border-color: #ddd6fe;
}

.badge--level-aaa {
  color: #065f46;
  background: #ecfdf5;
  border-color: #a7f3d0;
}

.badge--status-placeholder {
  color: var(--color-text-muted);
  background: var(--color-surface);
  border-color: var(--color-border);
  font-weight: 400;
}

.badge--status-done {
  color: var(--color-pass);
  background: var(--color-pass-bg);
  border-color: var(--color-pass);
}

.badge--status-skipped {
  color: #92400e;
  background: #fffbeb;
  border-color: #b45309;
  font-weight: 400;
}

.badge--status-obsolete {
  color: var(--color-text-muted);
  background: var(--color-surface);
  border-color: var(--color-border);
  font-weight: 400;
  text-decoration: line-through;
}

/* Content sections */
.content-section {
  margin-bottom: var(--space-12);
}

.content-section h2 {
  margin-bottom: var(--space-4);
}

.content-section h3 {
  margin-bottom: var(--space-3);
}

/* Principle group sections on index */
.principle-group {
  margin-bottom: var(--space-12);
}

.principle-group__heading {
  font-size: var(--font-size-sm);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--color-border);
}

/* Index checkpoint list */
.checkpoint-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.checkpoint-list li {
  margin: 0;
}

.checkpoint-card {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  column-gap: var(--space-3);
  row-gap: var(--space-1);
  padding: var(--space-2) var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--color-text);
  background: var(--color-surface);
}

/* Demo-ready cards (always <a> elements): brighter bg to invite interaction */
a.checkpoint-card {
  background: var(--color-bg);
}

a.checkpoint-card:hover {
  border-color: var(--color-accent);
  background: #f0f4ff;
}

/* Non-interactive cards: skipped, AAA, obsolete */
.checkpoint-card--skipped,
.checkpoint-card--aaa,
.checkpoint-card--obsolete {
  cursor: default;
}

.checkpoint-card--skipped .checkpoint-card__id,
.checkpoint-card--aaa .checkpoint-card__id,
.checkpoint-card--obsolete .checkpoint-card__id {
  color: var(--color-text-muted);
}

/* AAA: dashed border to signal aspirational-only */
.checkpoint-card--aaa {
  border-style: dashed;
}

/* Obsolete: strikethrough title */
.checkpoint-card--obsolete .checkpoint-card__title {
  text-decoration: line-through;
  color: var(--color-text-muted);
}

/* Unbox header — id and badges join the first flex row */
.checkpoint-card__header {
  display: contents;
}

/* Code number — row 1, col 1 */
.checkpoint-card__id {
  order: 1;
  font-size: var(--font-size-lg);
  font-weight: 800;
  font-family: var(--font-family-mono);
  color: var(--color-accent);
  flex-shrink: 0;
}

/* Title — row 1, col 2, fills remaining space */
.checkpoint-card__title {
  order: 2;
  flex: 1;
  font-weight: 600;
  font-size: var(--font-size-base);
  min-width: 0;
}

/* Badges — row 1, after title */
.checkpoint-card__header .badge {
  order: 3;
  flex-shrink: 0;
  font-size: 0.75rem;
  padding: 1px var(--space-2);
}

/* Summary — forced to its own full-width row */
.checkpoint-card__summary {
  order: 4;
  flex: 0 0 100%;
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  margin: 0;
}

/* Note — forced to its own full-width row, smaller and separated */
.checkpoint-card__note {
  order: 5;
  flex: 0 0 100%;
  font-size: 0.8rem;
  color: var(--color-text-muted);
  font-style: italic;
  margin: 0;
  padding-top: var(--space-1);
  border-top: 1px solid var(--color-border);
}

/* Index page: two-column layout with checkpoint nav */
.index-layout {
  display: flex;
  max-width: 1360px;
  margin: 0 auto;
}

.checkpoint-nav {
  width: 300px;
  flex-shrink: 0;
  position: sticky;
  top: var(--hero-h);
  max-height: calc(100vh - var(--hero-h));
  overflow-y: auto;
  border-right: none;
  padding: var(--space-6) var(--space-4) var(--space-6) var(--space-6);
  /* Firefox */
  scrollbar-width: thin;
  scrollbar-color: var(--color-border) var(--color-bg);
}
/* Chromium/Safari */
.checkpoint-nav::-webkit-scrollbar {
  width: 6px;
}
.checkpoint-nav::-webkit-scrollbar-track {
  background: var(--color-bg);
}
.checkpoint-nav::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 3px;
}
.checkpoint-nav::-webkit-scrollbar-thumb:hover {
  background: var(--color-text-muted);
}

.checkpoint-nav__group {
  margin-bottom: var(--space-3);
}

.checkpoint-nav__heading {
  display: block;
  font-size: 0.875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  text-decoration: none;
  margin-bottom: var(--space-1);
  padding-bottom: var(--space-1);
  border-bottom: 1px solid var(--color-border);
}

.checkpoint-nav__heading:hover,
.checkpoint-nav__heading:focus {
  color: var(--color-accent);
}

.checkpoint-nav__list {
  list-style: none;
  padding: 0 0 0 0.55rem;
  margin: 0;
}

.checkpoint-nav__list li {
  margin: 0;
}

/* Criteria (1.1.1) — deepest indent, no extra line */
.checkpoint-nav__link {
  display: flex;
  gap: 0.35em;
  align-items: baseline;
  padding: 0.15em 0.3em 0.15em 0.65rem;
  border-radius: 3px;
  text-decoration: none;
  color: var(--color-text);
  font-size: 0.8125rem;
  line-height: 1.4;
  font-weight: 600;
  border-left: 3px solid var(--color-accent);
  background: var(--color-surface);
}

.checkpoint-nav__link:hover,
.checkpoint-nav__link:focus {
  background: var(--color-surface);
  color: var(--color-accent);
}

/* Active page in navigation */
.checkpoint-nav__link--active,
.checkpoint-nav__link[aria-current="page"] {
  background: var(--color-accent);
  color: #ffffff;
  font-weight: 600;
}

.checkpoint-nav__link--active:hover,
.checkpoint-nav__link[aria-current="page"]:hover {
  background: var(--color-accent);
  color: #ffffff;
}

/* Child elements inherit parent link color */

/* Guideline (1.1) — medium indent */
.checkpoint-nav__guideline {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--color-text-muted);
  text-decoration: none;
  padding: 0.35em 0.3em 0.1em 0.35em;
  margin-top: 0.3em;
}

.checkpoint-nav__guideline:hover,
.checkpoint-nav__guideline:focus {
  color: var(--color-accent);
}

/* Criteria that have no page on this site */
.checkpoint-nav__link--unavailable {
  font-weight: 400;
  color: var(--color-text-muted);
  border-left: 3px solid transparent;
  background: none;
}

.checkpoint-nav__link--unavailable:hover {
  color: var(--color-accent);
}

.checkpoint-nav__code {
  font-family: var(--font-family-mono);
  flex-shrink: 0;
  font-size: 0.8125rem;
}

.checkpoint-nav__title {
  white-space: normal;
}

/* site-main overrides inside index layout */
.index-layout .site-main {
  flex: 1;
  min-width: 0;
  max-width: none;
  margin: 0;
  padding-left: var(--space-8);
}

/* Site footer */
.site-footer {
  border-top: 1px solid var(--color-border);
  padding: var(--space-8) 0;
  margin-top: var(--space-16);
}

.site-footer__inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 var(--space-6);
  font-size: var(--font-size-base);
  color: var(--color-text-muted);
}

.site-footer__inner a {
  color: var(--color-accent);
  text-decoration: underline;
  font-weight: 500;
}

.site-footer__inner a:hover {
  text-decoration: none;
}

/* -------------------------------------------------------
   Dark mode toggle button
   Light mode: dark button (moon icon)
   Dark mode:  light button (sun icon)
   Colors are hardcoded so they stay consistent in both themes.
   ------------------------------------------------------- */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-3);
  font-family: var(--font-family);
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: #ffffff;
  background: #1a1a1a;
  border: 1px solid #1a1a1a;
  border-radius: var(--radius);
  cursor: pointer;
  white-space: nowrap;
}

.theme-toggle:focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 2px;
}

.theme-toggle:hover {
  background: #333333;
  border-color: #333333;
}

/* aria-pressed="true" = dark mode is active - show light button with sun */
.theme-toggle[aria-pressed="true"] {
  color: #1a1a1a;
  background: #f1f5f9;
  border-color: #f1f5f9;
}

.theme-toggle[aria-pressed="true"]:hover {
  background: #e2e8f0;
  border-color: #e2e8f0;
}

.theme-toggle__icon {
  display: inline-block;
  transition: none; /* icon uses its own animation, not the global theme transition */
  animation: theme-icon-in 0.25s ease both;
}

@media (prefers-reduced-motion: reduce) {
  .theme-toggle__icon {
    animation: none;
  }
}

/* -------------------------------------------------------
   Dark mode overrides for hardcoded colors
   ------------------------------------------------------- */

/* Skip link: white text fails on the new light-blue accent
   in dark mode - swap to dark text instead */
[data-theme="dark"] .skip-link {
  color: var(--color-bg);
}

/* Card hover tint - dark equivalent for demo-ready (<a>) cards */
[data-theme="dark"] a.checkpoint-card:hover {
  background: #1e3358;
}

/* Level badges - each uses a distinct hue; override all three */
[data-theme="dark"] .badge--level-a {
  color: #93c5fd;     /* blue-300  - 7.7:1 on bg */
  background: #1e3358;
  border-color: #3b82f6;
}

[data-theme="dark"] .badge--level-aa {
  color: #c4b5fd;     /* violet-300 - 7.9:1 on bg */
  background: #2d1b69;
  border-color: #7c3aed;
}

[data-theme="dark"] .badge--level-aaa {
  color: #6ee7b7;     /* emerald-300 - 8.1:1 on bg */
  background: #064e3b;
  border-color: #10b981;
}

/* Status badges */
[data-theme="dark"] .badge--status-done {
  border-color: #22c55e;
}

[data-theme="dark"] .badge--status-skipped {
  color: #fcd34d;     /* amber-300 - 9.9:1 on bg */
  background: #451a03;
  border-color: #d97706;
}

/* -------------------------------------------------------
   Responsive - Tablet (≤1024px)
   ------------------------------------------------------- */
@media (max-width: 1024px) {
  .checkpoint-nav {
    width: 170px;
    padding: var(--space-4) var(--space-3) var(--space-4) var(--space-4);
  }
}

/* -------------------------------------------------------
   Responsive - Mobile breakpoint (≤768px) — hamburger menu
   ------------------------------------------------------- */
@media (max-width: 768px) {
  .checkpoint-nav-hamburger {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 100;
  }

  .checkpoint-nav-hamburger summary {
    cursor: pointer;
    padding: var(--space-3);
    font-size: 1.5rem;
    font-weight: bold;
    user-select: none;
    background-color: var(--color-primary);
    color: var(--color-primary-text);
    border: none;
    display: flex;
    align-items: center;
    height: 44px;
    min-width: 44px;
  }

  .checkpoint-nav-hamburger summary:focus-visible {
    outline: 2px solid var(--color-focus);
    outline-offset: 2px;
  }

  .checkpoint-nav-hamburger summary:hover {
    background-color: var(--color-primary-dark);
  }

  .checkpoint-nav-hamburger nav {
    display: none;
    position: absolute;
    top: 44px;
    left: 0;
    background-color: var(--color-surface);
    border-right: 1px solid var(--color-border);
    max-height: calc(100vh - 44px);
    overflow-y: auto;
    width: 250px;
    z-index: 101;
  }

  .checkpoint-nav-hamburger[open] nav {
    display: block;
  }

  .checkpoint-nav-hamburger .checkpoint-nav {
    display: flex;
    flex-direction: column;
    gap: 0;
  }

  .checkpoint-nav-hamburger .checkpoint-nav a {
    padding: var(--space-3) var(--space-4);
    border-left: 4px solid transparent;
  }

  .checkpoint-nav-hamburger .checkpoint-nav a:focus-visible {
    outline: 2px solid var(--color-focus);
    outline-offset: -2px;
  }

  /* Add top padding to prevent fixed hamburger from overlapping content */
  .index-layout {
    padding-top: 44px;
  }

  main {
    padding-top: var(--space-4);
  }
}

/* -------------------------------------------------------
   Responsive - Mobile (≤640px)
   ------------------------------------------------------- */
@media (max-width: 640px) {
  /* Header: allow logo + nav to wrap to second line */
  .site-header__inner {
    flex-wrap: wrap;
    padding: 0 var(--space-4);
    gap: var(--space-3);
  }

  /* Hero: shrink height and squares on mobile */
  .site-hero__inner {
    --hero-h: 72px;
  }

  .site-hero__text {
    padding: 0 var(--space-3);
  }

  /* Page padding: tighter sides */
  .site-main {
    padding: var(--space-8) var(--space-4);
  }

  /* Index layout: single-column, no sidebar */
  .index-layout {
    display: block;
  }

  .checkpoint-nav {
    display: none;
  }

  .index-layout .site-main {
    padding-left: var(--space-4);
  }

  /* Cards already flex-wrap; nothing extra needed for header */

  /* Footer padding */
  .site-footer__inner {
    padding: 0 var(--space-4);
  }
}
