/* =========================================================
  1) ROOT TOKENS
  Site-wide colors, typography, and layout limits
========================================================= */

:root {
  --bg: #ffffff;
  --text: #111827;
  --muted: #4b5563;
  --accent: #1f3b67;
  --card: #f3f4f6;
  --max: 980px;

  /* Typography */
  --font-body: "Open Sans", system-ui, -apple-system, Segoe UI, Arial, sans-serif;
  --font-heading: "Roboto", system-ui, -apple-system, Segoe UI, Arial, sans-serif;
}


/* =========================================================
  2) GLOBAL BASE
  Reset + base typography + smooth scrolling
========================================================= */

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 18px;          /* modern readable base */
  line-height: 1.6;         /* readable paragraph rhythm */
  background: var(--bg);
  color: var(--text);
}

h1, h2, h3, h4, h5, h6,
.brand {
  font-family: var(--font-heading);
  letter-spacing: 0.01em;
}

h1 {
  font-size: 2.25rem;       /* ~40px */
  margin-bottom: 0.75rem;
}

h2 {
  font-size: 1.5rem;        /* ~27px */
  margin-top: 0;
  margin-bottom: 0;
}

h3 {
  font-size: 1.2rem;
  margin-bottom: 0;
  margin-top: 0.75rem;
}


/* =========================================================
   3) LAYOUT CONTAINER
   Keeps site bounded to a readable max width
========================================================= */

.container {
  width: min(var(--max), calc(100% - 2rem));
  margin: 0 auto;
}


/* =========================================================
    4) HEADER + NAVIGATION
    Desktop nav + mobile nav scaffolding
========================================================= */

#site-header {
  background: var(--accent);
  color: white;
}

.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 0;
  gap: 1rem;
}

.brand {
  color: white;
  text-decoration: none;
  font-family: var(--font-heading);
  font-weight: 700;

  font-size: 1.75rem;
  line-height: 1;           /* prevents header growth */
  letter-spacing: 0.02em;

  display: flex;
  align-items: center;
}

.nav {
  display: flex;
  gap: 1rem;
}

.nav a {
  color: white;
  text-decoration: none;
  opacity: 0.95;
}

.nav a:hover {
  opacity: 1;
  text-decoration: underline;
}

.menu-button {
  display: none;
  border: 0;
  background: transparent;
  color: white;
  font-size: 1.5rem;
  cursor: pointer;
}

.mobile-nav {
  display: none;
  padding: 0.75rem 0;
  border-top: 1px solid rgba(255,255,255,0.2);
}

.mobile-nav a {
  display: block;
  color: white;
  text-decoration: none;
  padding: 0.5rem 0;
}


/* =========================================================
    5) SECTION HEADERS
    Used on pages like Research/Projects
========================================================= */

.section-header {
  margin: 0.5rem 0 0;
}

.section-header-title {
  margin: 0;
}

.section-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  margin-top: 0.35rem;
  margin-bottom: 0;
}

.section-header-lead {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 0;
  margin-bottom: 0;
}

.section-header-actions {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

.section-label {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0.5rem 0 0.75rem;
}

/* Home hero underline accent bar */
.home-hero::after {
  content: "";
  display: block;
  width: 80px;
  height: 4px;
  background: var(--accent);
  margin: 1.25rem 0;
  border-radius: 2px;
}

/* Section header responsiveness */
@media (max-width: 800px) {
  .section-header-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }
}


/* =========================================================
   6) SECTION SUB-NAV
   Tab-like anchors within pages
========================================================= */

.section-subnav {
  display: flex;
  gap: 1.25rem;
  font-family: var(--font-heading);
  font-size: 0.9rem;
  border-bottom: 1px solid color-mix(in srgb, var(--text) 10%, transparent);
  padding-bottom: 0.5rem;
}

.section-subnav a {
  color: var(--muted);
  text-decoration: none;
  position: relative;
  padding-bottom: 2px;
}

.section-subnav a::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 0%;
  height: 2px;
  background: var(--accent);
  transition: width 0.2s ease;
}

.section-subnav a:hover {
  color: var(--text);
}

.section-subnav a:hover::after {
  width: 100%;
}

.related {
    margin-top: 2.5rem;
    font-size: 0.95rem;
    opacity: 0.85;
    text-align: center;
}



/* =========================================================
   7) HERO (HOME PAGE)
========================================================= */

.hero {
  display: grid;
  grid-template-columns: 1.3fr 0.7fr;
  gap: 2rem;
  padding: 1.5rem;
  align-items: start;
}

.hero h1 {
  margin-top: 0;
  font-size: 2rem;
}

.hero-text p {
  color: var(--muted);
  font-size: 1rem;
}

.hero-photo {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hero-photo img {
  width: 100%;
  max-width: 320px;
  border-radius: 16px;
  display: block;
}


/* =========================================================
   8) LINKS, CHIPS, ACTION BUTTONS
   Used for link rows and consistent button language
========================================================= */

.links-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.25rem;
  margin-bottom: 0.5rem;
}

.chip {
  display: inline-block;
  background: var(--card);
  color: var(--text);
  text-decoration: none;
  padding: 0.4rem 0.7rem;
  border-radius: 999px;
  font-weight: 600;
  font-family: var(--font-heading);
  font-size: 0.85rem;
}

.chip:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;

  padding: 0.45rem 0.85rem;
  border-radius: 999px;

  background: color-mix(in srgb, var(--card) 85%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);

  font-family: var(--font-heading);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;

  transition:
    transform 0.18s ease,
    background-color 0.18s ease,
    border-color 0.18s ease,
    box-shadow 0.18s ease;
}

/* Single focus rule for action buttons (duplicate removed safely) */
.action-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* Internal site navigation buttons (page-to-page) */
.action-internal {
  background: transparent;
  border: none;

  font-family: var(--font-heading);
  font-size: 0.85rem;
  font-weight: 600;

  color: var(--accent);
  text-decoration: none;

  padding: 0.35rem 0;
  position: relative;

  transition:
    transform 0.18s ease,
    color 0.18s ease;
}

.action-internal::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -2px;
  width: 100%;
  height: 2px;
  background: var(--accent);
  opacity: 0.4;

  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.18s ease, opacity 0.18s ease;
}

.action-internal:hover {
  transform: translateY(-2px);
}

.action-internal:hover::after {
  transform: scaleX(1);
  opacity: 1;
}

.action-internal:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}

.home-actions {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex-wrap: wrap;
}

/* Secondary internal links grouped together */
.home-secondary-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding-left: 0.25rem;
}

/* Make internal links slightly quieter in hero context */
.home-secondary-actions .action-internal {
  font-size: 0.8rem;
  font-weight: 500;
  opacity: 0.85;
}

.home-secondary-actions .action-internal:hover {
  opacity: 1;
}

.home-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* Secondary inline navigation */
.home-secondary-inline {
  font-size: 0.75rem;

  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.home-secondary-inline a {

  text-decoration: none;
  font-weight: 500;
}

.home-secondary-inline a:hover {
  color: var(--accent);
  text-decoration: underline;
}

.home-secondary-inline .sep {

  opacity: 0.6;
}



/* Specialized button variants */
.action-link {
  background: transparent;
  border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
  color: var(--text);
}

.action-link:hover {
  transform: translateY(-2px);
  text-decoration: underline;
}

.action-pdf {
  background: color-mix(in srgb, var(--accent) 12%, var(--card));
  border: 1px solid color-mix(in srgb, var(--accent) 55%, transparent);
  color: var(--text);
}

.action-pdf:hover {
  transform: translateY(-2px);
  background: color-mix(in srgb, var(--accent) 18%, var(--card));
}

/* Project-report tag style */
.project-report {
  background: color-mix(in srgb, var(--accent) 12%, var(--card));
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
}


/* =========================================================
  9) CARD SYSTEM + FADE-IN
  Cards fade/slide in via IntersectionObserver (JS)
========================================================= */

.card {
  background: var(--card);
  border-radius: 18px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.05);

  will-change: opacity, transform;
  opacity: 0;
  transform: translateY(12px);

  transition: opacity 0.4s ease, transform 0.4s ease;
  transition-delay: var(--fade-delay, 0ms);

  margin-bottom: 2rem;
}

.card:last-child {
  margin-bottom: 1rem;
}

.card.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
  .card {
    opacity: 1;
    transform: none;
    transition: none;
  }
}


/* =========================================================
   10) GENERAL CONTENT HELPERS
========================================================= */

.bullets {
  margin: 0.5rem 0 0 1.2rem;
}


/* =========================================================
   11) FOOTER
========================================================= */

.site-footer {
  border-top: 1px solid #e5e7eb;
  padding: 1.25rem 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.footer-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}


/* =========================================================
   12) RESPONSIVE NAV + HERO
   Collapses top nav and hides content logos on small screens
========================================================= */

@media (max-width: 820px) {
  .hero { grid-template-columns: 1fr; }
  .nav { display: none; }
  .menu-button { display: inline-block; }
  .content-logo { display: none; }
}


/* =========================================================
   13) RESUME PAGE
========================================================= */

.resume-actions {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.resume-embed {
  width: 100%;
  height: 85vh;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid #e5e7eb;
}

.resume-embed iframe {
  width: 100%;
  height: 100%;
  border: none;
}


/* =========================================================
  14) CONTACT PAGE
========================================================= */

.contact-card h1 {
  margin-top: 0;
}

.contact-intro {
  margin-bottom: 1.5rem;
}

.contact-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2rem;
  margin-bottom: 0.6rem;
}

.contact-grid > div {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}


.contact-card-header {
  margin-bottom: 0.75rem;
}

.contact-card-header h2 {
  font-size: 1.4rem;
  margin: 0;
}


.contact-grid > div {
  padding-left: 1rem;
  border-left: 2px solid color-mix(in srgb, var(--accent) 30%, transparent);
}

.contact-grid > div:first-child {
  border-left: none;
  padding-left: 0;
}


.contact-grid > div:nth-child(2) p {
  margin-top: 0.2rem;
}



.contact-grid h2 {
  font-size: 1.05rem;
  margin-bottom: 0.35rem;
}

.contact-links {
  list-style: none;
  padding: 0;
  margin: 0;

  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
    margin-top: 0.45rem;
}


.contact-links a {
  text-decoration: none;
  font-weight: 600;
  display: grid;
  grid-template-columns: repeat(2, max-content);
  gap: 0.6rem 0.75rem;
}

.contact-links a:hover {
  text-decoration: underline;
}



.contact-email {
  display: inline-flex;
  flex-direction: column;
  gap: 0.15rem;

  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.1rem;

  color: var(--accent);
  text-decoration: none;

  margin:0,0,0,0;
}

.contact-email span {

  font-weight: 500;
  color: var(--muted);
  text-align: left;
  font-size: 0.65rem;
  opacity: 0.75;
  margin:0,0,0,0;
}

.contact-email:hover {
  text-decoration: underline;
}


@media (max-width: 800px) {
  .contact-grid {
    grid-template-columns: 1fr;
  }
}

.contact-note {
  margin:0,0,0,0;
  font-size: 0.85rem;
  color: var(--muted);
}

.action-link {
  border-color: color-mix(in srgb, var(--accent) 18%, transparent);
}



/* =========================================================
  15) CONTENT CARDS (Projects/Research entries)
========================================================= */

.content-card {
  background: linear-gradient(
    to bottom,
    color-mix(in srgb, var(--card) 97%, transparent),
    var(--card)
  );
  border-radius: 25px;
  padding: 1.25rem 1.5rem;
  box-shadow: 0 8px 24px rgba(0,0,0,0.06);
  max-width: 1100px;
  margin: 0;

  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.card:hover .content-card {
  transform: translateY(-1px);
  box-shadow: 0 12px 32px rgba(0,0,0,0.08);
}

.card:focus-within .content-card {
  transform: translateY(-5px);
  box-shadow: 0 12px 32px rgba(0,0,0,0.08);
}

@media (prefers-reduced-motion: reduce) {
  .content-card {
    transition: none;
  }

  .card:hover .content-card,
  .card:focus-within .content-card {
    transform: none;
    box-shadow: 0 8px 24px rgba(0,0,0,0.06);
  }
}

/* Left accent border for content blocks */
.content-block {
  border-left: 5px solid color-mix(in srgb, var(--accent) 85%, transparent);
}

/* Deep link highlight (when navigating to #id) */
.deep-link-highlight {
  background: color-mix(in srgb, var(--accent) 8%, var(--card));
  outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent);
  outline-offset: 6px;
}

@media (prefers-reduced-motion: reduce) {
  .deep-link-highlight {
    transition: none;
  }
}

/* Header layout inside each content entry card */
.content-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 2.5rem;
}

.content-header-text {
  flex: 1;
}

/* Type badge (Research / Project / Poster) */
.content-badge {
  display: inline-block;
  font-family: var(--font-heading);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;

  padding: 0.25rem 0.5rem;
  border-radius: 999px;
  margin-bottom: 0.35rem;

  background: color-mix(in srgb, var(--accent) 12%, var(--card));
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
}

.content-badge-project { }
.content-badge-research { }
.content-badge-poster { opacity: 0.9; }

/* Meta row aligns badge and meta on one line */
.content-meta-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.25rem;
}

.content-meta-row .content-meta {
  margin: 0;
}

/* Title sizing inside content cards */
.content-header-text h2 {
  margin-top: 0;
  margin-bottom: 0.25rem;
  font-size: 1.8rem;
}

/* External title link styling */
.content-title-link {
  color: inherit;
  text-decoration: none;
  position: relative;
}

.content-title-link:focus-visible {
  text-decoration: underline;
}

.content-title-link::after {
  content: "↗";
  font-size: 0.75em;
  margin-left: 0.35rem;
  opacity: 0.4;
  display: inline-block;
  transform: translate(0, 0);
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.content-title-link:hover::after {
  transform: translate(5px, -5px);
  opacity: 0.75;
}

.content-title-link:hover {
  text-decoration: underline;
}

/* Meta text under title */
.content-meta {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 0;
  margin-bottom: 0;
}

/* Right-side logo block */
.content-logo {
  padding-top: 0.25rem;
}

.content-logo img {
  width: 120px;
  opacity: 0.95;
  filter: contrast(1);
}

.content-logo:hover img {
  filter: contrast(1) brightness(1.75);
}

@media (max-width: 900px) {
  .content-logo { display: none; }
}

.content-logo a {
  display: inline-block;
}

.content-logo a:hover img {
  opacity: 0.9;
  transform: translateY(-5px);
}

/* Lead and summary blocks */
.content-lead {
  font-size: 1.05rem;
  margin-top: 0.5rem;
  margin-bottom: 0;
}

.content-summary {
  line-height: 1.65;
  margin-top: 0;
  margin-bottom: 0;
}

/* Summary collapse wrapper for "Show more" behavior */
.content-summary-wrapper {
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transition: max-height 0.25s ease, opacity 0.3s ease;
}

.content-body.expanded .content-summary-wrapper {
  max-height: 500px;
  opacity: 1;
}

/* Show more button */
.content-toggle {
  background: none;
  border: none;
  color: var(--accent);
  font-family: var(--font-heading);
  font-size: 0.85rem;
  cursor: pointer;
  padding: 0;
  margin-bottom: 0;
}

.content-toggle:hover {
  text-decoration: underline;
}

/* Divider inside content cards */
.content-divider {
  height: 3px;
  background: color-mix(in srgb, var(--text) 12%, transparent);
  margin: 1rem 0 1rem 0;
}

/* Media box inside content cards */
.content-media {
  background: color-mix(in srgb, var(--card) 92%, transparent);
  border-radius: 18px;
}

.content-media h3 {
  margin-top: 0;
  margin-bottom: 0.5rem;
}

/* Action links area */
.content-links {
  margin-top: 0;
  margin-bottom: 0.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.content-actions {
  margin-bottom: 1rem;
}


/* =========================================================
   16) NEWS SECTION
========================================================= */

.news-list {
  list-style: none;
  padding: 0;
  margin: 0;
  max-height: 260px;
  overflow-y: auto;
}

.news-list li {
  margin-bottom: 0.6rem;
  line-height: 1.45;
  color: var(--text);
}

.news-date {
  font-weight: 600;
  color: var(--muted);
  margin-right: 0.25rem;
}

.news-list strong {
  color: var(--accent);
  font-weight: 600;
}

.news-header {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 0.5rem;
}

.news-sort-toggle {
  background: none;
  border: none;
  color: var(--accent);
  font-family: var(--font-heading);
  font-size: 0.85rem;
  cursor: pointer;
  padding: 0;
}

.news-sort-toggle:hover {
  text-decoration: underline;
}

/* Scroll fade mask around the news list (enabled only while scrolling) */
.news-scroll-mask {
  position: relative;
}

.news-scroll-mask::before,
.news-scroll-mask::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 24px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s ease;
  z-index: 2;
}

.news-scroll-mask::before {
  top: 0;
  background: linear-gradient(to bottom, var(--card), transparent);
}

.news-scroll-mask::after {
  bottom: 0;
  background: linear-gradient(to top, var(--card), transparent);
}

.news-scroll-mask.is-scrolling::before,
.news-scroll-mask.is-scrolling::after {
  opacity: 1;
}


/* =========================================================
   17) YOUTUBE (legacy grid)
   Kept to avoid breaking any existing markup still using it
========================================================= */

.youtube-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.youtube-embed iframe {
  width: 100%;
  height: 160px;
  border-radius: 14px;
  border: none;
  background: #000;
}


/* =========================================================
   18) VIDEO STYLING (shared)
   Used by your existing render video system
========================================================= */

.video-caption {
  opacity: 0;
  transform: translateY(-5px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  font-size: 0.9rem;
  line-height: 1.35;
  color: var(--muted);
  pointer-events: none;
  text-align: center;
}

.video:hover .video-caption {
  transition-delay: 0.05s;
  opacity: 1;
  transform: translateY(0);
}

/* Horizontal scroll row of videos */
.video-scroll {
  display: flex;
  gap: 0.75rem;
  overflow-x: auto;
  align-items: flex-start;
  padding-bottom: 0.25rem;
}

.video-scroll .video {
  margin: 0;
  flex: 0 0 300px;
  max-width: 300px;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.video-scroll .video iframe {
  width: 100%;
  height: 150px;
  border: none;
  border-radius: 14px;
  background: #000;
  display: block;
  filter: saturate(0.5) contrast(0.95) brightness(0.95);
}

/* Hover effect for focused video inside the scroll row */
.video-scroll:hover .video:hover iframe {
  filter: saturate(1) brightness(1);
  transform: translateY(-5px);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 8px 20px rgba(0,0,0,0.12);
}

/* Subtle iframe effect inside cards */
.card:hover .video iframe,
.card:focus-within .video iframe {
  filter: saturate(0.8) contrast(1) brightness(1);
  transition: filter 0.25s ease;
}

/* Scrollbar styling (WebKit) */
.video-scroll::-webkit-scrollbar {
  height: 8px;
}

.video-scroll::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,0.25);
  border-radius: 4px;
}


/* =========================================================
   19) DARK THEME
   Token swap + a few component bumps
========================================================= */

html[data-theme="dark"] {
  --bg: #0f172a;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --accent: #1e3a8a;
  --card: #050505;
}

html[data-theme="dark"] .card {
  box-shadow: 0 6px 24px rgba(0,0,0,0.4);
}

/* Dark mode readability bump for captions */
html[data-theme="dark"] .video-caption {
  color: color-mix(in srgb, var(--muted) 90%, white 10%);
}

/* Dark mode scrollbar */
html[data-theme="dark"] .video-scroll::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.25);
}

/* Keep a single dark-mode iframe rule (duplicate removed safely) */
html[data-theme="dark"] .video iframe {
  background: #0b0b0b;
  border-radius: 14px;
  box-shadow: 0 10px 28px rgba(0,0,0,0.6);
}

/* Theme toggle button */
.theme-toggle {
  background: transparent;
  border: 1px solid var(--muted);
  color: var(--text);
  font-family: var(--font-heading);
  font-size: 0.85rem;
  padding: 0.3rem 0.6rem;
  border-radius: 6px;
  cursor: pointer;
}

.theme-toggle:hover {
  background: rgba(0,0,0,0.05);
}


/* =========================================================
   20) MODAL (PDF REPORT VIEWER)
========================================================= */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;

  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  background: var(--card);
  width: min(900px, 95%);
  height: 85vh;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;

  transform: translateY(30px);
  opacity: 0;
  transition: transform 0.25s ease, opacity 0.25s ease;
}

.modal-overlay.active .modal {
  transform: translateY(0);
  opacity: 1;
}

/* Modal header row */
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid color-mix(in srgb, var(--text) 15%, transparent);
}

/* Close button */
.modal-close {
  background: transparent;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text);
}

/* Modal content area */
.modal-content {
  flex: 1;
}

.modal-content iframe {
  width: 100%;
  height: 100%;
  border: none;
}


/* =========================================================
  21) ACCESSIBILITY (GLOBAL)
  Ensures keyboard focus is visible site-wide
========================================================= */

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}


/* FAVORITES */


/* Favorites page container */
.favorites-intro {
  max-width: 60ch;
  margin: 2rem 0 3rem 0;
  font-size: 1rem;
  color: #444;
}

.favorites-tech-note {
  max-width: 65ch;
  font-size: 0.85rem;
  color: #555;
  margin-bottom: 3rem;
}






#favorites-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1.5rem;
  margin-top: 2rem;
}


.favorite-card {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;

  background: var(--card-bg, #ffffff);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 12px;
  overflow: hidden;

  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.favorite-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
}

.favorites-controls {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}

.favorites-filters button {
  background: none;
  border: none;
  font-size: 0.85rem;
  padding: 0.3rem 0.6rem;
  cursor: pointer;
  border-bottom: 2px solid transparent;
}

.favorites-filters button.active {
  border-color: #2563eb;
  font-weight: 600;
}



.favorite-image {
  width: 100%;
  aspect-ratio: 1 / 1;
  background: #f2f2f2;

  display: flex;
  align-items: center;
  justify-content: center;
}

.favorite-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}


.favorite-text {
  padding: 0.75rem 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.favorite-text h3 {
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.3;
  margin: 0;
}

.favorite-text p {
  font-size: 0.85rem;
  color: #555;
  margin: 0;
}

.favorite-text small {
  font-size: 0.75rem;
  color: #777;
}


.favorite-source {
  margin-top: 0.4rem;
  align-self: flex-start;

  font-size: 0.65rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;

  padding: 0.15rem 0.4rem;
  border-radius: 6px;

  background: #eef2f7;
  color: #334155;
}

.favorites-section {
  transition: opacity 0.2s ease;
}



html[data-theme="dark"] .favorite-card { 
  background: #121212;
  border-color: rgba(255, 255, 255, 0.08);
}

html[data-theme="dark"] .favorite-text p,
html[data-theme="dark"] .favorite-text small {
  color: #bbb;
}

html[data-theme="dark"] .favorite-source {
  background: #1e293b;
  color: #cbd5f5;
}




.favorites-section {
  margin-bottom: 3rem;
}

.favorites-heading {
  font-size: 1.4rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.favorites-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1.5rem;
}

.favorite-featured {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;

  padding: 0.2rem 0.45rem;
  border-radius: 6px;

  background: #fde68a;
  color: #92400e;

  align-self: flex-start;
}

@media (max-width: 600px) {
  .favorites-controls {
    flex-direction: column;
    align-items: flex-start;
  }

  .favorites-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  }
}


/* Animated visibility for sections */
.favorites-section {
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.favorites-section.is-hidden {
  opacity: 0;
  transform: translateY(6px);
  pointer-events: none;
  height: 0;
  overflow: hidden;
  margin: 0;
}


.favorites-controls {
  position: sticky;
  top: 0;
  z-index: 20;

  background: var(--page-bg, #fff);
  padding: 0.75rem 0;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid rgba(0,0,0,0.06);
}


/* Headings breathe */
.favorites-heading {
  margin: 1.25rem 0 0.75rem;
}

/* Grid spacing consistency */
.favorites-grid {
  margin-top: 0.5rem;
}

/* Intro + tech note alignment */
.favorites-intro,
.favorites-tech-note {
  max-width: 65ch;
}

.favorites-tech-note {
  margin-top: 0.75rem;
}

html {
  scroll-behavior: smooth;
}

section[id], h2[id] {
  scroll-margin-top: 96px;
}


