/* ShieldTech — 2026 platform layer.
   Everything here is progressive: gated behind @supports, so engines that
   don't have it render exactly as before. No color, font, or grid changes.

   1. Cross-document view transitions — pages morph instead of blink
   2. Scroll-driven CSS animation — motion tied to the scroll timeline, off the main thread
   3. Container queries — components respond to their own width, not the viewport
   4. :has() relational styling — real state without extra markup
   5. Optical text trimming, color-mix accents, discrete transitions */

/* ── 1. VIEW TRANSITIONS ──────────────────────────────────────────────── */
@view-transition { navigation: auto; }

@media (prefers-reduced-motion: no-preference) {
  ::view-transition-old(root) { animation: stFadeOut .22s cubic-bezier(.4,0,1,1) both; }
  ::view-transition-new(root) { animation: stRise .38s cubic-bezier(.2,.7,.2,1) both; }
}
@keyframes stFadeOut { to { opacity: 0; } }
@keyframes stRise { from { opacity: 0; transform: translateY(10px); } }

/* the header and logo persist across navigations instead of re-drawing */
header { view-transition-name: st-header; }
header img[alt="ShieldTech Security"] { view-transition-name: st-logo; }
::view-transition-group(st-header),
::view-transition-group(st-logo) { animation-duration: .38s; animation-timing-function: cubic-bezier(.2,.7,.2,1); }

/* ── 2. SCROLL-DRIVEN ANIMATION ───────────────────────────────────────── */
@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) and (min-width: 769px) {
    /* section headlines resolve as they enter — timeline-driven, not JS */
    main > section h2 {
      animation: stEnter linear both;
      animation-timeline: view();
      animation-range: entry 8% cover 26%;
    }
    /* figures and canvases gain a subtle depth parallax as they pass */
    main > section figure {
      animation: stFigure linear both;
      animation-timeline: view();
      animation-range: entry 0% exit 100%;
    }
    /* hairline section seams draw themselves in */
    main > section[style*="border-top: 1px solid"] {
      animation: stSeam linear both;
      animation-timeline: view();
      animation-range: entry 0% entry 40%;
    }
  }
  @keyframes stEnter { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
  @keyframes stFigure { from { transform: translateY(14px) scale(0.994); } to { transform: translateY(-14px) scale(1); } }
  @keyframes stSeam { from { border-top-color: transparent; } to { border-top-color: rgba(255,255,255,0.055); } }
}

/* ── 3. CONTAINER QUERIES ─────────────────────────────────────────────── */
@supports (container-type: inline-size) {
  main article,
  main a[style*="border-radius: 18px"],
  main div[style*="border-radius: 18px"] { container-type: inline-size; }

  /* a card that finds itself narrow tightens its own typography and padding —
     independent of what the viewport happens to be */
  @container (max-width: 260px) {
    h3 { font-size: 20px !important; letter-spacing: -0.01em !important; }
    p { font-size: 13px !important; line-height: 1.62 !important; }
  }
  @container (min-width: 520px) {
    h3 { font-size: 25px !important; }
  }
}

/* ── 4. :has() RELATIONAL STATE ───────────────────────────────────────── */
@supports selector(:has(*)) {
  /* an open accordion dims its neighbours so the eye stays on the answer */
  main div:has(> details[open]) > details:not([open]) { opacity: 0.55; }
  main div:has(> details[open]) > details:not([open]):hover { opacity: 1; }

  /* a filled field keeps its accent border — progress is visible at a glance */
  label:has(input:not(:placeholder-shown)) input,
  label:has(textarea:not(:placeholder-shown)) textarea,
  label:has(select:valid) select { border-color: rgba(92,184,255,0.4) !important; }

  /* A card group dims its siblings around the hovered link. No transform here —
     the lift belongs to refine.css and only to genuinely clickable elements. */
  @media (hover: hover) and (min-width: 769px) {
    main div[style*="grid-template-columns"]:has(> a[href]:hover) > a[href]:not(:hover) { opacity: 0.62; }
    main div[style*="grid-template-columns"] > a[href] { transition: opacity .3s cubic-bezier(.2,.7,.2,1), transform .34s cubic-bezier(.2,.7,.2,1), border-color .34s cubic-bezier(.2,.7,.2,1), box-shadow .34s cubic-bezier(.2,.7,.2,1); }
  }
}

/* ── 5. TYPE + COLOR + DISCRETE TRANSITIONS ───────────────────────────── */
@supports (text-box: trim-both cap alphabetic) {
  h1, h2, h3 { text-box: trim-both cap alphabetic; } /* optical cap alignment */
}
@supports (color: color-mix(in oklch, white, black)) {
  main a[style*="linear-gradient(135deg, rgb(0, 112, 248)"]:hover {
    background-image: linear-gradient(135deg,
      color-mix(in oklch, #0070f8 88%, #5cb8ff),
      color-mix(in oklch, #2f8ff8 84%, #9fd0ff)) !important;
  }
}
@supports (transition-behavior: allow-discrete) {
  details > div, details > p {
    transition: opacity .3s ease, transform .3s cubic-bezier(.2,.7,.2,1);
  }
  details[open] > div, details[open] > p { opacity: 1; transform: none; }
  @starting-style {
    details[open] > div, details[open] > p { opacity: 0; transform: translateY(-6px); }
  }
}
@supports (field-sizing: content) {
  textarea { field-sizing: content; min-height: 90px; max-height: 320px; }
}
