/* ================================================================
   nunn.law — state-of-the-art & accessibility upgrade layer
   Applies to nunn.law (home), nunn.law/blog, and nunn.law/scotus.
   Intentionally minimal and additive: no existing selectors are
   overridden beyond the surgical fixes documented inline.
   ================================================================ */

/* ---------------------------------------------------------------
   Design tokens — single source of truth for colors & motion.
   Kept scoped to the layer so existing hardcoded values continue
   to work; these just make new rules consistent.
--------------------------------------------------------------- */
:root {
  --nl-cyan: #00E5FF;
  --nl-orange: #FF8C42;
  --nl-navy: #0C111F;
  --nl-deep: #000030;
  --nl-text-light: #e6f2ff;
  --nl-focus-ring: rgba(0, 229, 255, 0.9);
  --nl-selection-bg: rgba(0, 229, 255, 0.35);
  --nl-selection-fg: #ffffff;
  --nl-motion-fast: 160ms;
  --nl-motion-med: 260ms;
}

/* ---------------------------------------------------------------
   ::selection — brand-tuned highlight color on every surface.
--------------------------------------------------------------- */
::selection {
  background: var(--nl-selection-bg);
  color: var(--nl-selection-fg);
}

/* ---------------------------------------------------------------
   Smooth scroll for in-page anchors, disabled when user has
   prefers-reduced-motion on.
--------------------------------------------------------------- */
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

/* Give anchor targets breathing room from the fixed top header. */
:target { scroll-margin-top: 80px; }

/* ---------------------------------------------------------------
   :focus-visible — keyboard focus ring. Applied broadly so every
   interactive element gets a visible ring without overriding the
   stylish existing hover states.
--------------------------------------------------------------- */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[role="button"]:focus-visible,
[tabindex]:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--nl-focus-ring);
  outline-offset: 2px;
  border-radius: 6px;
}

/* Keep mouse clicks clean — only keyboard users see the ring. */
a:focus:not(:focus-visible),
button:focus:not(:focus-visible),
input:focus:not(:focus-visible),
select:focus:not(:focus-visible),
textarea:focus:not(:focus-visible) {
  outline: none;
}

/* ---------------------------------------------------------------
   Reduced-motion users: kill animations, transitions, smooth
   scroll, and blur effects that can induce vestibular issues.
--------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------------------------------------------------------------
   Minimum tap target 44x44 on coarse pointers (phones / tablets).
   Applied to the floating nav buttons the site uses everywhere.
--------------------------------------------------------------- */
@media (pointer: coarse) {
  .home-button .home-btn,
  .hamburger-menu .menu-toggle-btn,
  .filter-toggle-fixed .filter-toggle-btn,
  .home-btn-fixed a {
    min-width: 44px;
    min-height: 44px;
  }
}

/* ---------------------------------------------------------------
   Skip-link utility — keyboard users can jump past the repeated
   nav. The class is ready for templates that add <a class="skip-link">.
--------------------------------------------------------------- */
.skip-link {
  position: absolute;
  left: -9999px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
  z-index: -1;
}
.skip-link:focus,
.skip-link:focus-visible {
  position: fixed;
  left: 12px;
  top: 12px;
  width: auto;
  height: auto;
  padding: 8px 14px;
  background: var(--nl-navy);
  color: var(--nl-text-light);
  border: 1px solid rgba(0, 229, 255, 0.5);
  border-radius: 8px;
  text-decoration: none;
  z-index: 2147483647;
}

/* ---------------------------------------------------------------
   Mobile header: make the centered page title coexist with the
   fixed home-button + hamburger without being clipped.
   The floating buttons occupy the right ~100px on mobile; we
   reserve equivalent padding both sides so the centered title
   stays visually centered and never collides with the buttons.
   Also scales the title with clamp() so extreme narrow viewports
   (≤ 360px) still render the full title.
--------------------------------------------------------------- */
@media (max-width: 768px) {
  /* Blog + home (shared header block).
     The floating home button + hamburger on mobile together occupy the
     right ~155px of the viewport. Reserve that much + a small gutter
     so the centered title never collides with them. */
  .blog-header-title,
  .site-header {
    box-sizing: border-box;
    padding-left: 56px !important;
    padding-right: 160px !important;
    max-width: 100% !important;
    width: 100% !important;
    min-height: 64px;
    display: flex;
    flex-direction: column;
    justify-content: center;
  }
  /* Re-establish flow for the inner anchor link so flex children render. */
  .blog-header-title > a,
  .site-header > a {
    display: block;
    width: 100%;
  }

  /* Move the "Subscribe, it's free!" nudge off the top-left (where it
     collided with the centered title) to a sticky bottom-left pill —
     mirroring the coffee button on the right. */
  .subscribe-nudge-button {
    top: auto !important;
    bottom: 20px !important;
    left: 12px !important;
    right: auto !important;
    z-index: 1000;
  }

  /* Use clamp() so the title fluidly shrinks as the viewport narrows.
     Max caps at 1.8rem to guarantee the title fits inside the padded
     safe zone even on 320px viewports. */
  .blog-header-title .blog-title {
    font-size: clamp(1.15rem, 5.2vw, 1.8rem) !important;
    white-space: normal !important;
    line-height: 1.15 !important;
    overflow-wrap: anywhere;
  }

  /* Subtitle should wrap gracefully; tighter leading helps. */
  .blog-header-title > a > div,
  .blog-header-title .blog-subtitle {
    line-height: 1.25;
    white-space: normal !important;
    font-size: clamp(0.75rem, 2.8vw, 1rem) !important;
  }

  /* /scotus site-header title */
  .site-header .site-title {
    font-size: clamp(0.95rem, 4vw, 1.2rem) !important;
    white-space: normal !important;
    line-height: 1.2 !important;
    overflow-wrap: anywhere;
  }
  .site-header .site-subtitle,
  .site-header .site-update-notice {
    font-size: clamp(0.6rem, 2.4vw, 0.75rem) !important;
    white-space: normal !important;
  }
}

/* Very narrow viewports (older phones, split-screen, Galaxy Fold):
   shrink nav buttons and pull the button cluster in so the title has
   enough room. */
@media (max-width: 380px) {
  .blog-header-title,
  .site-header {
    padding-left: 44px !important;
    padding-right: 150px !important;
  }
  .blog-header-title .blog-title {
    font-size: clamp(1rem, 4.8vw, 1.4rem) !important;
  }
}

/* ---------------------------------------------------------------
   Home page body copy — bump line-height to a readable 1.55.
   The bespoke `.home-body-content p` rule in blog2/home.html sets
   `line-height: 1.2` which is too tight for sustained reading.
   Uses !important to beat the inline <style> block in the template,
   which declares line-height:1.2 after the external sheet link.
--------------------------------------------------------------- */
.home-body-content p,
.home-body-content li {
  line-height: 1.55 !important;
}

/* ---------------------------------------------------------------
   Print styles — when the user prints an article, drop chrome,
   switch to high-contrast text, let the content flow.
--------------------------------------------------------------- */
@media print {
  html, body {
    background: #ffffff !important;
    color: #000000 !important;
  }
  body.blog-body {
    background-image: none !important;
  }
  .home-button,
  .home-btn-fixed,
  .hamburger-menu,
  .filter-toggle-fixed,
  .corner-coffee,
  .subscribe-nudge-button,
  .upgrade-nudge-button,
  .social-nav,
  .version-notice,
  #chat-container,
  .view-nav,
  .sort-bar,
  .active-filters-bar,
  .pagination,
  .sidebar,
  .blog-sidebar,
  .footer,
  .modal {
    display: none !important;
  }
  .container,
  .blog-view-container,
  .blog-content-wrapper,
  .main-view-container,
  .content-wrapper,
  .blog-content {
    display: block !important;
    box-shadow: none !important;
    border: none !important;
    background: transparent !important;
    height: auto !important;
    max-width: 100% !important;
    padding: 0 !important;
  }
  .blog-content,
  .blog-entry-content,
  .home-body-content,
  .home-body-content p,
  .blog-entry-content p,
  .blog-entry-content a {
    color: #000 !important;
  }
  a[href^="http"]::after {
    content: " (" attr(href) ")";
    font-size: 0.85em;
    color: #555;
  }
}

/* ---------------------------------------------------------------
   Content-visibility: auto on the SCOTUS long citation list.
   Large offscreen lists render incrementally, reducing layout
   work on mobile. Safe on Chromium/Safari/Firefox.
--------------------------------------------------------------- */
.citations-list > .citation-card {
  content-visibility: auto;
  contain-intrinsic-size: 140px;
}

/* ---------------------------------------------------------------
   Prevent horizontal scroll surprises at any viewport. The base
   templates already set overflow-x:hidden on body; this guards
   against a rogue child extending past the viewport root.
--------------------------------------------------------------- */
html { overflow-x: hidden; }

/* ---------------------------------------------------------------
   Forced-colors (Windows high-contrast) mode: keep interactive
   text readable and buttons outlined.
--------------------------------------------------------------- */
@media (forced-colors: active) {
  a:focus-visible,
  button:focus-visible,
  [role="button"]:focus-visible {
    outline: 2px solid CanvasText;
  }
}
