/* A connected visual story from the first screen to the final signature. */
@media screen {
  main > section:not(.hero) { position: relative; isolation: isolate; }
  main > section:not(.hero)::before {
    content: ''; position: absolute; inset: 0 0 auto; height: min(650px, 70vh); z-index: -1; pointer-events: none;
    background: url('/assets/atmosphere-v2.jpg') 85% 65% / cover;
    opacity: .1; mask-image: linear-gradient(transparent, #0007 35%, transparent);
    -webkit-mask-image: linear-gradient(transparent, #0007 35%, transparent);
  }
  main > section:not(.hero)::after {
    content: ''; position: absolute; top: 0; left: 30%; width: 40%; height: 1px; pointer-events: none;
    background: linear-gradient(90deg, transparent, #dfbd7b66, #74c8d955, transparent);
    animation: chapter-boundary 16s ease-in-out infinite alternate;
  }
  :root[data-theme=light] main > section:not(.hero)::before { opacity: .045; mix-blend-mode: multiply; }
  :is(#research, #skills, #about) > .section-heading {
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); align-items: center;
    grid-template-rows: auto auto auto; column-gap: 3rem; row-gap: 1.2rem;
  }
  :is(#research, #skills, #about) > .section-heading > :not(.chapter-art) { grid-column: 1; }
  :is(#research, #skills, #about) > .section-heading > .chapter-art { grid-column: 2; grid-row: 1 / 4; }
  :is(#research, #skills, #about) > .section-heading > p { align-self: start; }
  .chapter-art {
    width: 100%; height: clamp(270px, 26vw, 380px); position: relative; isolation: isolate;
    pointer-events: none; contain: layout paint;
    mask-image: radial-gradient(ellipse, #000 45%, #000c 65%, transparent 77%);
    -webkit-mask-image: radial-gradient(ellipse, #000 45%, #000c 65%, transparent 77%);
  }
  .chapter-art::before {
    content: ''; position: absolute; inset: 6%; z-index: -1;
    background: radial-gradient(ellipse, #74c8d917, transparent 66%);
  }
  [data-chapter-scene] { display: block; width: 100%; height: 100%; pointer-events: none; }
  [data-chapter-scene][hidden] { display: none; }
  .credential-strip { position: relative; overflow: hidden; }
  .credential-strip > div { position: relative; }
  .credential-strip > div::before {
    content: ''; position: absolute; left: -1px; top: 0; bottom: 0; width: 1px;
    background: linear-gradient(transparent, var(--accent), var(--cyan), transparent);
    background-size: 100% 200%; animation: credential-current 7s ease-in-out infinite;
  }
  .credential-strip > div:nth-child(2n)::before { animation-delay: -3s; }
  .publication-year { position: relative; overflow: hidden; }
  .publication-year::before {
    content: ''; position: absolute; top: 0; bottom: 0; left: 0; width: 18%; pointer-events: none;
    background: linear-gradient(90deg, transparent, #74c8d90a, transparent);
    transform: skewX(-20deg); animation: publication-light 18s ease-in-out infinite;
  }
  .publication-year:nth-of-type(2n)::before { animation-delay: -8s; }
  .publication-year::after {
    content: ''; position: absolute; top: 1px; left: 12%; right: 12%; height: 1px;
    background: linear-gradient(90deg, transparent, #74c8d972, transparent); pointer-events: none;
  }
  .ip-card { isolation: isolate; overflow: hidden; }
  .ip-card::before {
    content: ''; position: absolute; right: -45px; top: -45px; width: 150px; height: 150px; z-index: -1;
    border: 1px solid #74c8d91f; border-radius: 24px;
    box-shadow: 0 0 0 15px #74c8d908, 0 0 0 35px #74c8d905;
    transform: rotate(30deg); animation: crystal-light 20s ease-in-out infinite alternate; pointer-events: none;
  }
  .ip-card[data-kind=design]::before { border-color: #dfbd7b30; box-shadow: 0 0 0 15px #dfbd7b08, 0 0 0 35px #dfbd7b05; }
  #experience .chapter-art { height: clamp(220px, 23vw, 330px); margin-top: 2rem; }
  .experience-row > div:last-child { position: relative; overflow: hidden; }
  .experience-row > div:last-child::before {
    content: ''; position: absolute; inset: 0; pointer-events: none;
    background: radial-gradient(ellipse at 100% 0, #74c8d911, transparent 58%);
  }
  .timeline-node { box-shadow: 0 0 14px #dfbd7b66, 0 0 32px #74c8d93d; }
  .project-visual { min-height: 520px; padding: 0; }
  .project-visual::before { display: none; }
  .project-visual::after { opacity: .24; }
  .project-world { position: absolute; inset: 50px 0 auto; height: calc(100% - 200px); }
  .project-visual svg {
    position: absolute; bottom: 15px; left: 5%; width: 90%; height: 150px;
    transform: none; filter: none; opacity: .9;
  }
  .project-visual .visual-label { z-index: 2; }
  .project-visual .diagram-boxes rect { fill: #0c1c27dd; }
  .project-card .project-body { position: relative; }
  .project-card .project-body::before {
    content: ''; position: absolute; top: 0; left: 10%; right: 10%; height: 1px;
    background: linear-gradient(90deg, transparent, #74c8d945, transparent);
  }
  .project-card .signal-flow { animation-duration: 4s; }
  .tool-grid { perspective: 1100px; }
  .tool-card { padding-top: 2rem; }
  .tool-card .tool-logo {
    position: relative; transform-origin: center; transform: perspective(550px) rotateX(7deg) rotateY(-4deg);
    box-shadow: 0 18px 20px -13px #0009, 0 3px 0 #b9c9d5, 0 5px 0 #7b8b99, 0 10px 30px -14px #74c8d9cc;
    animation: floating-logo 7s ease-in-out infinite; animation-play-state: paused; animation-delay: var(--stagger, 0ms);
  }
  .tool-card.in-view .tool-logo { animation-play-state: running; }
  .tool-card:nth-child(even) .tool-logo { animation-direction: reverse; }
  .tool-card h4, .tool-card p { transform: none; }
  .tool-card .tool-light { background: linear-gradient(115deg, transparent 30%, #74c8d912 50%, transparent 70%); }
  .tool-card::after {
    display: block; left: 15%; width: 70%; bottom: 0; height: 1px;
    background: linear-gradient(90deg, transparent, var(--cyan), var(--accent), transparent);
  }
  .education article { position: relative; padding-left: 1.4rem; }
  .education article::before {
    content: ''; position: absolute; left: 0; top: 2rem; bottom: 2rem; width: 1px;
    background: linear-gradient(var(--accent), #74c8d966, transparent);
    box-shadow: 0 0 12px #74c8d922;
  }
  .recognition { isolation: isolate; }
  .award-visual > canvas { position: absolute; inset: -12%; width: 124%; height: 124%; z-index: -1; }
  .award-visual > img { filter: drop-shadow(0 0 12px #dfbd7b22); }
  .recognition.in-view .award-visual > img { animation: laurel-glow 8s ease-in-out infinite alternate; }
  .recognition::after {
    content: ''; position: absolute; top: 0; bottom: 0; width: 28%; left: -40%; z-index: -1;
    background: linear-gradient(90deg, transparent, #dfbd7b0d, transparent); transform: skewX(-18deg);
    animation: award-light 14s ease-in-out infinite; animation-play-state: paused; pointer-events: none;
  }
  .recognition.in-view::after { animation-play-state: running; }
  .contact-heading { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, .8fr); column-gap: 2rem; }
  .contact-heading > :not(.chapter-art) { grid-column: 1; }
  .contact-heading .contact-top { grid-column: 1 / -1; }
  .contact-heading > .chapter-art { grid-column: 2; grid-row: 2 / 4; height: 100%; min-height: 300px; }
  .contact-heading h2 { font-size: clamp(3.5rem, 6.5vw, 7rem); }
  .contact-form { isolation: isolate; }
  .contact-form::before {
    display: block; content: ''; left: 12%; right: 12%; top: 0; height: 1px;
    background: linear-gradient(90deg, transparent, var(--cyan), var(--accent), transparent);
    box-shadow: 0 0 18px #74c8d977; animation: form-glow 8s ease-in-out infinite alternate; pointer-events: none;
  }
  .contact-form:focus-within::before { opacity: 1; animation-play-state: paused; }
  .signature-signoff { position: relative; isolation: isolate; overflow: hidden; }
  .signoff-atmosphere { position: absolute; inset: 0; z-index: -1; }
  footer { background: linear-gradient(180deg, #74c8d905, transparent); }
  .chapters-sleeping :is(.tool-logo, .tool-light, .signal-flow, .node-pulse, .award-visual > img),
  .chapters-sleeping :is(.publication-year, .recognition, .credential-strip > div, .ip-card)::before,
  .chapters-sleeping .recognition::after,
  .chapters-sleeping main > section::after { animation-play-state: paused !important; }

  @keyframes chapter-boundary { from { transform: translateX(-25%); opacity: .4; } to { transform: translateX(25%); opacity: .9; } }
  @keyframes credential-current { 0%,100% { background-position: 0 0; opacity: .4; } 50% { background-position: 0 100%; opacity: 1; } }
  @keyframes publication-light { 0%,15% { transform: translateX(-150%) skewX(-20deg); } 65%,100% { transform: translateX(700%) skewX(-20deg); } }
  @keyframes crystal-light { from { transform: rotate(25deg); opacity: .5; } to { transform: rotate(65deg); opacity: 1; } }
  @keyframes floating-logo { 0%,100% { transform: perspective(550px) translateY(0) rotateX(7deg) rotateY(-4deg); } 50% { transform: perspective(550px) translateY(-7px) rotateX(-3deg) rotateY(5deg); } }
  @keyframes laurel-glow { from { filter: drop-shadow(0 0 7px #dfbd7b16); } to { filter: drop-shadow(0 0 17px #dfbd7b55); } }
  @keyframes award-light { 0%,15% { left: -40%; } 65%,100% { left: 140%; } }
  @keyframes form-glow { from { opacity: .45; } to { opacity: 1; } }

  @media (max-width: 900px) {
    :is(#research, #skills, #about) > .section-heading { column-gap: 1rem; }
    #experience > .section-heading { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr); gap: 1rem; }
    #experience > .section-heading > :not(.chapter-art) { grid-column: 1; margin-top: 0; }
    #experience > .section-heading > .chapter-art { grid-column: 2; grid-row: 1 / 4; height: 100%; min-height: 260px; margin: 0; }
    .project-visual { min-height: 460px; aspect-ratio: auto; }
    .project-world { height: 280px; }
    .project-visual svg { height: 130px; }
    .project-visual .visual-label { font-size: .7rem; }
  }
  @media (max-width: 650px) {
    :is(#research, #skills, #about, #experience) > .section-heading { display: flex; flex-direction: column; align-items: stretch; gap: 0; }
    :is(#research, #skills, #about, #experience) > .section-heading h2 { margin-top: 1.3rem; }
    :is(#research, #skills, #about, #experience) > .section-heading > p { margin-top: 1.4rem; }
    :is(#research, #skills, #about, #experience) > .section-heading > .chapter-art { height: 240px; min-height: 0; margin: 1.2rem 0 -1rem; }
    .project-visual { min-height: 390px; }
    .project-world { top: 35px; height: 240px; }
    .project-visual svg { height: 110px; bottom: 8px; left: 1%; width: 98%; }
    .contact-heading { display: block; }
    .contact-heading .chapter-art { height: 200px; min-height: 0; margin-bottom: -1rem; }
    .contact-heading h2 { font-size: clamp(3rem, 11vw, 5rem); }
    .contact-layout { margin-top: 1.8rem; }
    .tool-card .tool-logo { animation-duration: 9s; }
  }
  @media (prefers-reduced-motion: reduce) {
    main > section::after, .credential-strip > div::before, .publication-year::before,
    .ip-card::before, .tool-card .tool-logo, .recognition.in-view .award-visual > img,
    .recognition::after, .contact-form::before { animation: none !important; }
    .tool-card .tool-logo { transform: none; }
    .publication-year::before, .recognition::after { display: none; }
  }
  @media (forced-colors: active) {
    .chapter-art, [data-chapter-scene], main > section::before, main > section::after { display: none; }
    .project-visual { min-height: 200px; }
  }
}
@media print {
  .chapter-art, [data-chapter-scene] { display: none !important; }
  .contact-heading { display: block; }
}
