/* ==========================================================================
   Curated Resource Directory — Styles
   Phase 2: Visual Structuring
   Design tokens from docs/briefing.md
   Aesthetic: motherfuckingwebsite.com (readability) + stripe.dev (polish)
   ========================================================================== */

/* --- Base --- */

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

/* Explicit [hidden] rule — do not rely solely on UA stylesheet (fixes D7) */
[hidden] {
  display: none !important;
}

html {
  color: #1a1a1a;
  background-color: #f4f4f4;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  font-size: 1em;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  scroll-behavior: smooth;
}

body {
  max-width: 650px;
  margin: 0 auto;
  padding: 0 1rem 2rem;
  background-color: #ffffff;
}

/* --- Typography --- */

h1, h2, h3, h4, h5, h6 {
  color: #1a1a1a;
  letter-spacing: -0.01em;
}

h1, h2 {
  font-family: Georgia, "Times New Roman", serif;
}

/* ==========================================================================
   Hero Section — Full-Screen Typography
   Sits outside <main>; breaks out of body max-width.
   Neo-brutalist aesthetic via heavy type, tight spacing, web fonts.
   ========================================================================== */

.hero {
  width: 100vw;
  margin-left: calc(-50vw + 50%);
  margin-top: 0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem 1rem;
  background-color: #f4f4f4;
  overflow-x: hidden;
}

.hero-content {
  text-align: center;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 1rem;
}

.hero-title {
  font-family: 'Bricolage Grotesque', Georgia, serif;
  font-size: clamp(1.5rem, 8vw, 11rem);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.04em;
  color: #1a1a1a;
  text-transform: uppercase;
  margin: 0 0 1rem;
  padding: 0 0.25rem;
}

.hero-not {
  font-family: 'Bricolage Grotesque', Georgia, serif;
  font-weight: 800;
  font-size: 1.25em;
  color: #d32f2f;
  display: inline-block;
  vertical-align: baseline;
  margin-right: -0.05em;
}

@media (min-width: 768px) {
  .hero-title {
    font-size: clamp(4rem, 11vw, 11rem);
    line-height: 1.2;
    margin-bottom: 1.5rem;
    padding: 0 0.5rem;
  }
}

.hero-meta {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: clamp(0.875rem, 1.5vw, 1.125rem);
  font-weight: 400;
  line-height: 1.6;
  letter-spacing: 0.01em;
  color: #666666;
  max-width: 540px;
  margin: 0 auto;
}

/* --- End Hero Section --- */

h2 {
  font-size: 2em;
  line-height: 1.3;
  font-weight: bold;
  margin: 0 0 0.5rem;
}

/* Section description directly after h2 */
h2 + p {
  color: #666666;
  margin-bottom: 0;
}

h3 {
  font-size: 1.5em;
  line-height: 1.4;
  font-weight: bold;
  margin: 2rem 0 1rem;
}

/* Tighten spacing: h3 followed by blockquote */
h3 + blockquote {
  margin-top: 0.5rem;
}

/* --- Body text --- */

p {
  margin: 0 0 1rem;
}

small, .meta {
  font-size: 0.9em;
  line-height: 1.5;
  color: #666666;
}

/* --- Links --- */

a {
  color: #0066cc;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  transition: color 0.15s ease;
}

a:hover {
  color: #004499;
}

a:focus-visible {
  outline: 2px solid #0066cc;
  outline-offset: 2px;
  border-radius: 2px;
}

/* --- Lists --- */

ul {
  list-style: disc;
  padding-left: 1.5em;
  margin: 0 0 1rem;
}

li {
  margin-bottom: 0.5rem;
}

li:last-child {
  margin-bottom: 0;
}

/* Sub-category label paragraphs (e.g. "Desktop Browsers:") */
p + ul {
  margin-top: -0.5rem;
}

/* --- Blockquote (introductory questions) --- */

blockquote {
  margin: 0 0 1rem;
  padding: 0.625rem 0 0.625rem 1.25rem;
  border-left: 3px solid #0066cc;
  color: #666666;
  font-style: italic;
  font-size: 1.05em;
}

blockquote p {
  margin: 0;
}

/* --- Aside (Important / Tip callouts) --- */

aside {
  margin: 1.5rem 0;
  padding: 1rem 1.25rem;
  border-left: 3px solid #666666;
  background-color: #fafafa;
  border-radius: 0 4px 4px 0;
  color: #1a1a1a;
  font-size: 0.9em;
  line-height: 1.6;
}

aside p {
  margin: 0;
}

aside strong {
  color: #1a1a1a;
}

/* --- Sections — structural separation --- */

main {
  padding-top: 2rem;
}

main > section {
  padding: 2.5rem 0;
  background-color: #ffffff;
}

main > section:first-child {
  padding-top: 2rem;
}

main > section + section {
  border-top: 4px solid #e0e0e0;
  margin-top: 0;
}

/* Subsections get 2rem gap */
section > section + hr {
  margin: 2rem 0;
}

/* --- Horizontal rules (subsection separators) --- */

hr {
  border: none;
  border-top: 1px solid #e0e0e0;
  margin: 2rem 0;
}

/* --- Code (inline) --- */

code {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.875em;
  background-color: #f5f5f5;
  padding: 0.15em 0.4em;
  border-radius: 3px;
  word-break: break-word;
}

/* --- Sub-category headings (bold labels within lists) --- */

strong {
  font-weight: 600;
}

/* --- Selection highlight --- */

::selection {
  background-color: #0066cc;
  color: #ffffff;
}

/* --- Responsive: desktop (768px+) --- */

@media (min-width: 768px) {
  body {
    max-width: 750px;
    padding: 0 2rem 4rem;
  }

  main {
    padding-top: 3rem;
  }

  /* Hero — larger padding + spacing */
  .hero {
    padding: 3rem 2rem;
  }

  .hero-title {
    margin-bottom: 2rem;
  }

  h2 {
    font-size: 2.25em;
  }

  h3 {
    font-size: 1.625em;
  }

  blockquote {
    font-size: 1.1em;
  }
}

/* --- Responsive: large desktop (1200px+) --- */

@media (min-width: 1200px) {
  body {
    max-width: 900px;
  }

  .hero {
    padding: 4rem 2rem;
  }
}

/* ==========================================================================
   CSS Custom Properties
   ========================================================================== */

:root {
  --nav-offset: 0px;     /* No fixed header — stays 0px. Update here if one is added. */
  --sidebar-width: 240px;
}

/* ==========================================================================
   Scroll Margin — anchor targets inside <main> only (excludes #hero)
   ========================================================================== */

main section[id] {
  scroll-margin-top: var(--nav-offset);
}

/* ==========================================================================
   Skip Link (accessibility)
   ========================================================================== */

.skip-link {
  position: absolute;
  top: -100%;
  left: 4rem;  /* offset past hamburger button (left:1rem + width:2.5rem + 0.5rem gap) */
  z-index: 200;
  padding: 0.5rem 1rem;
  background: #1a1a1a;
  color: #ffffff;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: 0 0 4px 4px;
  text-decoration: none;
  transition: top 0.15s ease;
}

.skip-link:focus-visible {
  top: 0;
  outline: 2px solid #0066cc;
  outline-offset: 2px;
}

/* ==========================================================================
   Navigation — Hamburger button + Off-canvas left drawer with accordion
   Universal: identical trigger on all screen sizes (no separate desktop layout).
   Drawer slides in from the left edge; full height; overlay blocks background.
   On mobile (≤480px) the drawer expands to full width.
   ========================================================================== */

/* --- Hamburger button (fixed, always visible on all viewports) --- */

#sidebar-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 200;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  background: #1a1a1a;
  color: #ffffff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  transition: background-color 0.15s ease;
}

#sidebar-toggle:hover {
  background: #333333;
}

#sidebar-toggle:focus-visible {
  outline: 2px solid #0066cc;
  outline-offset: 2px;
}

/* Hamburger bars — animate to × when nav is open */
.hamburger-bar {
  display: block;
  position: absolute;
  width: 18px;
  height: 2px;
  background: currentColor;
  border-radius: 1px;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.hamburger-bar:nth-child(1) { transform: translateY(-5px); }
.hamburger-bar:nth-child(2) { transform: translateY(0); }
.hamburger-bar:nth-child(3) { transform: translateY(5px); }

body.nav-open .hamburger-bar:nth-child(1) { transform: translateY(0) rotate(45deg); }
body.nav-open .hamburger-bar:nth-child(2) { opacity: 0; transform: translateY(0) scaleX(0); }
body.nav-open .hamburger-bar:nth-child(3) { transform: translateY(0) rotate(-45deg); }

/* --- Navigation panel (off-canvas left drawer) --- */

#sidebar {
  position: fixed;
  top: 0;
  left: 0;
  height: 100%;
  z-index: 199;
  width: var(--sidebar-width, 240px);
  background: #ffffff;
  border-right: 1px solid #e0e0e0;
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.12);
  padding: 3.75rem 0 1rem; /* clears the fixed toggle button (top:1rem + height:2.5rem + 0.25rem gap) */
  overflow-y: auto;
  overscroll-behavior: contain;
  /*
    Hidden state:
    - visibility:hidden removes it from keyboard Tab order and AT traversal (fixes D4).
    - transform slides it off-screen to the left.
    - visibility delay (0s 0.25s) holds hidden until the slide-out transition finishes.
  */
  visibility: hidden;
  transform: translateX(-110%);
  transition: transform 0.25s ease, visibility 0s linear 0.25s;
}

body.nav-open #sidebar {
  visibility: visible;
  transform: translateX(0);
  transition: transform 0.25s ease, visibility 0s linear 0s;
}

/* Prevent background scroll while drawer is open (fixes D9) */
body.nav-open {
  overflow: hidden;
}

/* Mobile: full-width drawer */
@media (max-width: 480px) {
  #sidebar {
    width: 100%;
    border-right: none;
    box-shadow: none;
  }
}

#sidebar ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

#sidebar li {
  margin: 0;
}

#sidebar > ul > li {
  border-bottom: 1px solid #f0f0f0;
}

#sidebar > ul > li:last-child {
  border-bottom: none;
}

/* --- Category buttons (accordion toggles) --- */

.nav-cat {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0.625rem 1rem;
  background: none;
  border: none;
  border-left: 2px solid transparent;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  color: #1a1a1a;
  text-align: left;
  cursor: pointer;
  transition: color 0.15s ease, background-color 0.15s ease, border-left-color 0.15s ease;
}

.nav-cat:hover {
  color: #0066cc;
  background-color: #f0f7ff;
}

.nav-cat:focus-visible {
  outline: 2px solid #0066cc;
  outline-offset: -2px;
}

.nav-cat.nav-link-active {
  color: #0066cc;
  border-left-color: #0066cc;
  background-color: #f0f7ff;
}

/* Chevron — rotates 180° when category is expanded */
.nav-chevron {
  flex-shrink: 0;
  margin-left: 0.5rem;
  transition: transform 0.2s ease;
}

.nav-cat[aria-expanded="true"] .nav-chevron {
  transform: rotate(180deg);
}

/* --- Sub-section list (accordion body) --- */

.nav-sub {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 0.22s ease, opacity 0.18s ease;
}

.nav-sub.nav-sub-open {
  /*
    600px capacity — tallest current sub-list: 5 items × ~40px per item = ~200px.
    3× headroom for future growth. If ever exceeded, set a larger value here;
    do not rely on this being an implicit assertion (fixes D8).
  */
  max-height: 600px;
  opacity: 1;
}

.nav-sub a {
  display: block;
  padding: 0.3125rem 1rem 0.3125rem 1.5rem;
  font-size: 0.8125rem;
  color: #555555;
  text-decoration: none;
  border-left: 2px solid transparent;
  transition: color 0.15s ease, background-color 0.15s ease;
}

.nav-sub a:hover {
  color: #0066cc;
  background-color: #f0f7ff;
}

.nav-sub a.nav-link-active {
  color: #0066cc;
  border-left-color: #0066cc;
  background-color: #f0f7ff;
}

.nav-sub a:focus-visible {
  outline: 2px solid #0066cc;
  outline-offset: -2px;
}

/* --- Overlay (closes drawer when user clicks outside) --- */

#sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.25);
  z-index: 198;
  /*
    Visibility is CSS-driven via body.nav-open — no JS .hidden toggling (fixes D3, D10).
    visibility:hidden removes it from pointer and AT interaction when closed.
    Delay on close matches drawer transition duration so it fades in sync.
  */
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0s linear 0.25s;
}

body.nav-open #sidebar-overlay {
  opacity: 1;
  pointer-events: auto;
  visibility: visible;
  transition: opacity 0.25s ease, visibility 0s linear 0s;
}

/* --- Print --- */

@media print {
  html {
    background-color: #ffffff;
  }

  body {
    max-width: 100%;
    padding: 0;
    background-color: #ffffff;
  }

  /* Hero — collapse for print */
  .hero {
    min-height: auto;
    width: 100%;
    margin-left: 0;
    padding: 1rem 0 2rem;
    background-color: #ffffff;
  }

  .hero-title {
    font-size: 3rem;
  }

  main > section {
    background-color: transparent !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
  }

  main > section + section {
    border-top: 1px solid #1a1a1a;
  }

  a[href^="http"]::after {
    content: " (" attr(href) ")";
    font-size: 0.8em;
    color: #666666;
  }

  aside {
    border-left-color: #1a1a1a;
    background: none;
  }

  /* Hide all navigation chrome in print */
  #sidebar,
  #sidebar-toggle,
  #sidebar-overlay,
  .skip-link {
    display: none !important;
  }
}
