/* Progressive enhancements for recruiter-facing polish.
   Safe fallbacks are built in: unsupported features are ignored. */

@supports (view-transition-name: none) {
  @view-transition {
    navigation: auto;
  }

  .navbar-brand {
    view-transition-name: nav-brand;
  }

  .page-hero h1,
  .hero-title {
    view-transition-name: hero-title;
  }

  ::view-transition-old(root),
  ::view-transition-new(root) {
    animation-duration: 220ms;
    animation-timing-function: cubic-bezier(0.2, 0.8, 0.2, 1);
  }
}

@media (prefers-reduced-motion: reduce) {
  @supports (view-transition-name: none) {
    ::view-transition-old(root),
    ::view-transition-new(root) {
      animation-duration: 1ms !important;
    }
  }
}

.quick-peek-btn {
  position: absolute;
  top: 0.7rem;
  right: 0.7rem;
  z-index: 6;
  border: 1px solid rgba(18, 52, 59, 0.26);
  background: rgba(255, 255, 255, 0.9);
  color: #12343b;
  border-radius: 999px;
  padding: 0.22rem 0.55rem;
  font-size: 0.74rem;
  font-weight: 700;
  line-height: 1.1;
  backdrop-filter: blur(4px);
}

.quick-peek-btn:hover {
  background: rgba(255, 255, 255, 0.98);
  border-color: rgba(18, 52, 59, 0.42);
}

.quick-peek-btn:focus-visible {
  outline: 2px solid #2d545e;
  outline-offset: 1px;
}

:root[data-theme="dark"] .quick-peek-btn {
  border-color: rgba(216, 237, 242, 0.34);
  background: rgba(15, 23, 26, 0.82);
  color: #e2edf0;
}

:root[data-theme="dark"] .quick-peek-btn:hover {
  background: rgba(15, 23, 26, 0.94);
  border-color: rgba(216, 237, 242, 0.5);
}

.quick-peek-popover {
  width: min(34rem, calc(100vw - 2rem));
  max-height: min(62vh, 28rem);
  overflow: auto;
  border: 1px solid rgba(18, 52, 59, 0.22);
  border-radius: 0.9rem;
  padding: 0.75rem 0.85rem;
  color: #12343b;
  background: #ffffff;
  box-shadow: 0 0.9rem 2rem rgba(0, 0, 0, 0.18);
}

:root[data-theme="dark"] .quick-peek-popover {
  border-color: rgba(216, 237, 242, 0.28);
  background: #162126;
  color: #e2edf0;
  box-shadow: 0 0.9rem 2rem rgba(0, 0, 0, 0.45);
}

.quick-peek-popover:popover-open {
  animation: quickPeekIn 160ms ease-out;
}

.quick-peek-popover h4 {
  margin: 0 0 0.45rem;
  font-size: 0.99rem;
  line-height: 1.25;
}

.quick-peek-row {
  display: grid;
  grid-template-columns: 6.7rem 1fr;
  gap: 0.45rem;
  align-items: start;
  margin-top: 0.38rem;
  font-size: 0.88rem;
  line-height: 1.35;
}

.quick-peek-row span:first-child {
  font-weight: 700;
  opacity: 0.88;
}

.quick-peek-row span:last-child {
  opacity: 0.96;
}

@keyframes quickPeekIn {
  from {
    opacity: 0;
    transform: translateY(5px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (max-width: 575.98px) {
  .quick-peek-btn {
    top: 0.5rem;
    right: 0.5rem;
    font-size: 0.7rem;
    padding: 0.2rem 0.5rem;
  }

  .quick-peek-row {
    grid-template-columns: 1fr;
    gap: 0.15rem;
  }
}

/* ─────────────────────────────────────────────────────────────
   Rendering performance: skip layout/paint for off-screen cards.
   contain-intrinsic-size reserves space so the scrollbar stays
   stable and in-page anchors still land correctly.
   Guarded by @supports; unsupported browsers simply ignore it.
   ───────────────────────────────────────────────────────────── */
@supports (content-visibility: auto) {
  /* NOTE: content-visibility:auto implies `contain: layout style paint`,
     and paint containment CLIPS descendants to the card's box — the same
     way overflow:hidden would. Any popper-positioned layer that escapes
     the card (a dropdown menu, tooltip or popover) would be cut off.
     So the containment is dropped for a card that currently owns an open
     overlay; the card is on-screen at that moment anyway, which is
     exactly when content-visibility has nothing left to skip. */
  .app-card:not(:has(.dropdown-menu.show, .tooltip, .popover)),
  .project-card:not(:has(.dropdown-menu.show, .tooltip, .popover)) {
    content-visibility: auto;
    contain-intrinsic-size: auto 460px;
  }

  /* Screenshot modals are heavy (many carousel images) and always
     start off-screen — never paint them until they open. */
  .modal:not(.show) .carousel-inner {
    content-visibility: auto;
    contain-intrinsic-size: auto 600px;
  }
}

/* ─────────────────────────────────────────────────────────────
   Site-wide reduced-motion guard.
   Most pages carry their own @media (prefers-reduced-motion)
   block, but a few only declare hover `transition:` rules and
   were never covered. This applies to all 21 pages at once, so
   a new page inherits it without needing to remember.
   Motion is near-eliminated rather than set to 0s: scroll-reveal
   effects that animate opacity need to still reach their end
   state, and `animation: none` would strand them invisible.
   ───────────────────────────────────────────────────────────── */
@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;
  }
}


/* ==========================================================================
   Print: Bootstrap renders in LIGHT mode on paper, whatever the screen theme
   ==========================================================================
   Every page sets data-bs-theme on <html> to mirror data-theme, so in the
   dark theme Bootstrap 5.3.8's dark mode is live - and an attribute does not
   change for print. Without this block its dark root tokens and component
   overrides reach paper: #dee2e6 body ink, #212529 component fills (accordion,
   dropdown, modal, card and table all inherit --bs-body-bg), #6ea8fe links and
   chevrons, #000 carousel indicators, inverted close and carousel glyphs. With
   "Background graphics" ON that is dark ink on dark fills; OFF, pale ink on
   white paper.

   These values are GENERATED, not hand-typed: each declaration in the three
   [data-bs-theme=dark]{} root blocks of the shipped bootstrap@5.3.8
   bootstrap.min.css, paired with the same property in its
   :root,[data-bs-theme=light]{} blocks. Bootstrap writes two light values
   as an empty custom property; 'none' is used for those because it computes
   to the same filter without relying on empty-value support.

   Specificity is deliberate. :root[data-bs-theme=dark] is (0,2,0): it beats
   Bootstrap's (0,1,0) dark block, and it TIES each page's own
   :root[data-theme="dark"]{--bs-*} overrides - this file loads after every
   inline <style>, so it wins that tie. The invariant is simple: on paper,
   every Bootstrap ROOT token is its light value. A token a page sets on a
   specific ELEMENT (e.g. .slide-footer{--bs-border-color:...}) still beats
   an inherited root token and stays that page's responsibility, exactly as it
   was before data-bs-theme existed.

   Deliberately not reset:
   - .navbar-dark and [data-bs-theme=dark] .navbar-toggler-icon - the navbar
     is display:none in the print block of all 21 pages.
   - [data-bs-theme=dark] .form-select / .form-switch - no page uses either.
   ========================================================================== */
@media print {
    :root[data-bs-theme=dark] {
        color-scheme: light;
        --bs-body-color: #212529;
        --bs-body-color-rgb: 33,37,41;
        --bs-body-bg: #fff;
        --bs-body-bg-rgb: 255,255,255;
        --bs-emphasis-color: #000;
        --bs-emphasis-color-rgb: 0,0,0;
        --bs-secondary-color: rgba(33, 37, 41, 0.75);
        --bs-secondary-color-rgb: 33,37,41;
        --bs-secondary-bg: #e9ecef;
        --bs-secondary-bg-rgb: 233,236,239;
        --bs-tertiary-color: rgba(33, 37, 41, 0.5);
        --bs-tertiary-color-rgb: 33,37,41;
        --bs-tertiary-bg: #f8f9fa;
        --bs-tertiary-bg-rgb: 248,249,250;
        --bs-primary-text-emphasis: #052c65;
        --bs-secondary-text-emphasis: #2b2f32;
        --bs-success-text-emphasis: #0a3622;
        --bs-info-text-emphasis: #055160;
        --bs-warning-text-emphasis: #664d03;
        --bs-danger-text-emphasis: #58151c;
        --bs-light-text-emphasis: #495057;
        --bs-dark-text-emphasis: #495057;
        --bs-primary-bg-subtle: #cfe2ff;
        --bs-secondary-bg-subtle: #e2e3e5;
        --bs-success-bg-subtle: #d1e7dd;
        --bs-info-bg-subtle: #cff4fc;
        --bs-warning-bg-subtle: #fff3cd;
        --bs-danger-bg-subtle: #f8d7da;
        --bs-light-bg-subtle: #fcfcfd;
        --bs-dark-bg-subtle: #ced4da;
        --bs-primary-border-subtle: #9ec5fe;
        --bs-secondary-border-subtle: #c4c8cb;
        --bs-success-border-subtle: #a3cfbb;
        --bs-info-border-subtle: #9eeaf9;
        --bs-warning-border-subtle: #ffe69c;
        --bs-danger-border-subtle: #f1aeb5;
        --bs-light-border-subtle: #e9ecef;
        --bs-dark-border-subtle: #adb5bd;
        --bs-heading-color: inherit;
        --bs-link-color: #0d6efd;
        --bs-link-hover-color: #0a58ca;
        --bs-link-color-rgb: 13,110,253;
        --bs-link-hover-color-rgb: 10,88,202;
        --bs-code-color: #d63384;
        --bs-highlight-color: #212529;
        --bs-highlight-bg: #fff3cd;
        --bs-border-color: #dee2e6;
        --bs-border-color-translucent: rgba(0, 0, 0, 0.175);
        --bs-form-valid-color: #198754;
        --bs-form-valid-border-color: #198754;
        --bs-form-invalid-color: #dc3545;
        --bs-form-invalid-border-color: #dc3545;
        --bs-btn-close-filter: none;
        --bs-carousel-indicator-active-bg: #fff;
        --bs-carousel-caption-color: #fff;
        --bs-carousel-control-icon-filter: none;
    }

    /* Bootstrap declares the dark chevron directly on the pseudo-element, so
       a root token reset cannot reach it: #6ea8fe on white paper is 2.4151:1,
       under the 3:1 a state indicator needs. These are Bootstrap's own light
       chevrons, #212529 collapsed and #052c65 expanded. (0,3,1) beats
       Bootstrap's (0,2,1). */
    :root[data-bs-theme=dark] .accordion-button::after {
        --bs-accordion-btn-icon: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23212529' stroke-linecap='round' stroke-linejoin='round'%3e%3cpath d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
        --bs-accordion-btn-active-icon: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23052c65' stroke-linecap='round' stroke-linejoin='round'%3e%3cpath d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
    }

    /* Quick View is an interactive control injected by enhancements.js. Its
       dark-theme ink is the literal #e2edf0, which no token reset reaches, so
       on white paper it printed at 1.1928:1. A button means nothing on paper
       and the popover only restates the card, so neither is printed. */
    .quick-peek-btn,
    .quick-peek-popover {
        display: none !important;
    }
}
