/* =====================================================================
   Enhancements: motion, interaction and the extra sections.
   Loaded after app.css and relies on its design tokens.
   ===================================================================== */

/* ---------- Scroll progress ---------- */
.progress { position: fixed; inset: 0 0 auto 0; height: 3px; z-index: 50; pointer-events: none; }
#progress-bar { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transform-origin: 0 50%; transform: scaleX(0); }

/* ---------- Header: quick-nav button ---------- */
.kbd-btn { border: 1px solid var(--border); background: var(--surface); color: var(--muted); height: 2.3rem; padding: 0 .7rem; border-radius: 10px; cursor: pointer; font-family: var(--mono); font-size: .78rem; display: inline-flex; align-items: center; gap: .5rem; }
.kbd-btn:hover { border-color: var(--accent); color: var(--text); }
kbd { font-family: var(--mono); font-size: .72rem; border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 6px; padding: .05rem .4rem; background: var(--surface-2); color: var(--muted); }
@media (max-width: 719px) {
  .kbd-btn { order: 2; margin-left: auto; }
  .kbd-btn kbd { display: none; }
}

/* ---------- Command palette ---------- */
.palette { border: 1px solid var(--border); border-radius: 16px; background: var(--surface); color: var(--text); padding: 0; width: min(34rem, calc(100vw - 2rem)); margin: 12vh auto auto; box-shadow: 0 24px 64px rgb(0 0 0 / .45); }
.palette::backdrop { background: rgb(2 6 12 / .6); backdrop-filter: blur(4px); }
.palette-box { display: grid; }
.palette input { width: 100%; border: 0; border-bottom: 1px solid var(--border); background: transparent; color: var(--text); font: inherit; font-size: 1.05rem; padding: 1rem 1.1rem; outline: none; }
.palette ul { list-style: none; margin: 0; padding: .4rem; max-height: 50vh; overflow: auto; }
.palette li[hidden] { display: none; }
.palette li a { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .6rem .8rem; border-radius: 10px; color: var(--text); text-decoration: none; }
.palette li.active a, .palette li a:hover { background: var(--accent-soft); }
.palette-hint { padding: .6rem 1rem; border-top: 1px solid var(--border); text-transform: none; letter-spacing: .04em; }

/* ---------- Hero extras ---------- */
@property --ang { syntax: "<angle>"; inherits: false; initial-value: 0deg; }
.photo-ring { display: inline-block; padding: 3px; border-radius: 50%; margin-bottom: 1.5rem; background: conic-gradient(from var(--ang), var(--accent), var(--accent-2), transparent 55%, var(--accent)); animation: spin 8s linear infinite; }
.photo-ring .hero-photo { display: block; margin: 0; padding: 0; border: 3px solid var(--bg); }
@keyframes spin { to { --ang: 360deg; } }
.hero::after { content: ""; position: absolute; z-index: -1; pointer-events: none; right: 0; top: 0; width: min(40rem, 100%); aspect-ratio: 1; background: radial-gradient(circle, var(--accent-soft), transparent 65%); filter: blur(30px); opacity: .9; }

/* ---------- Now strip ---------- */
.now { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; padding: .85rem 1.1rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); margin-bottom: 1.25rem; }
.now-tag { display: inline-flex; align-items: center; gap: .5rem; }
.now ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .25rem 1.5rem; color: var(--muted); font-size: .92rem; }
.pulse { width: .55rem; height: .55rem; border-radius: 50%; background: var(--accent); animation: pulse 2s ease-out infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgb(45 212 191 / .55); } 100% { box-shadow: 0 0 0 .7rem rgb(45 212 191 / 0); } }

/* ---------- Tech ticker ---------- */
.ticker { overflow: hidden; border-block: 1px solid var(--border); margin-bottom: 1rem; -webkit-mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent); mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent); }
.ticker-track { display: flex; width: max-content; animation: marquee 70s linear infinite; }
.ticker:hover .ticker-track { animation-play-state: paused; }
.ticker ul { list-style: none; display: flex; margin: 0; padding: .7rem 0; }
.ticker li { font-family: var(--mono); font-size: .8rem; color: var(--muted); padding-inline: 1.1rem; white-space: nowrap; }
.ticker li::after { content: "/"; margin-left: 2.2rem; color: var(--accent); opacity: .6; }
@keyframes marquee { to { transform: translateX(-50%); } }

/* ---------- Spotlight cards ---------- */
.spot { position: relative; overflow: hidden; }
.spot::after { content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity .25s ease; background: radial-gradient(240px circle at var(--mx, 50%) var(--my, 50%), var(--accent-soft), transparent 70%); }
.spot:hover::after { opacity: 1; }
.stretch { display: flex; }
.stretch > .card { flex: 1; }

/* ---------- Reveal on scroll (only when JS is running) ---------- */
.reveal-ready [data-reveal] { opacity: 0; transform: translateY(18px); transition: opacity .6s ease, transform .6s ease; }
.reveal-ready [data-reveal].in { opacity: 1; transform: none; }
.grid > [data-reveal]:nth-child(3n+2), .impact > [data-reveal]:nth-child(3n+2) { transition-delay: .08s; }
.grid > [data-reveal]:nth-child(3n+3), .impact > [data-reveal]:nth-child(3n+3) { transition-delay: .16s; }

/* ---------- Life of a request ---------- */
.flow { max-width: none; }
.flow-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: .6rem; }
.flow-step { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); transition: border-color .25s ease, background .25s ease; }
.flow-head { width: 100%; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: .9rem; padding: .85rem 1rem; background: none; border: 0; color: inherit; font: inherit; text-align: left; cursor: default; }
.flow-js .flow-head { cursor: pointer; }
.flow-num { display: grid; place-items: center; width: 2rem; height: 2rem; border-radius: 50%; border: 1px solid var(--border); font-family: var(--mono); font-size: .78rem; color: var(--muted); transition: all .25s ease; }
.flow-title { font-weight: 650; }
.flow-body { margin: 0; padding: 0 1rem 1.1rem 3.9rem; color: var(--muted); max-width: 70rem; }
.flow-js .flow-step:not(.is-active) .flow-body { display: none; }
.flow-step.is-active { border-color: var(--accent); background: linear-gradient(var(--accent-soft), var(--accent-soft)), var(--surface); }
.flow-step.is-active .flow-num { border-color: var(--accent); color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.flow-step.is-done .flow-num { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }
@media (max-width: 560px) {
  .flow-head { grid-template-columns: auto 1fr; }
  .flow-layer { display: none; }
  .flow-body { padding-left: 1rem; }
}

/* ---------- Technology matrix ---------- */
/* position: relative so the absolutely-positioned .sr-only labels inside cells are clipped by this scroller */
.matrix-wrap { position: relative; overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.matrix { width: 100%; min-width: 30rem; border-collapse: collapse; }
.matrix th, .matrix td { padding: .75rem 1rem; border-bottom: 1px solid var(--border); text-align: center; }
.matrix tbody tr:last-child th, .matrix tbody tr:last-child td { border-bottom: 0; }
.matrix tbody th { text-align: left; font-weight: 600; }
.matrix thead th { color: var(--muted); }
.matrix td .dot { display: inline-block; width: .8rem; height: .8rem; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.matrix td.off::before { content: ""; display: inline-block; width: .8rem; height: 2px; background: var(--border); vertical-align: middle; }
.matrix tbody tr:hover { background: var(--accent-soft); }

/* ---------- Case study pages ---------- */
.crumb { padding-top: 2rem; margin: 0; }
.case-head { padding-block: 1rem .5rem; }
.case-head h1 { margin: .35rem 0 .5rem; }
.case section { margin-top: 2.5rem; }
.pipeline { list-style: none; counter-reset: p; margin: 1.5rem 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: .6rem 1.4rem; }
.pipeline li { counter-increment: p; position: relative; border: 1px solid var(--border); background: var(--surface); border-radius: 10px; padding: .45rem .8rem; font-family: var(--mono); font-size: .8rem; }
.pipeline li::before { content: counter(p, decimal-leading-zero); color: var(--accent); margin-right: .5rem; }
.pipeline li:not(:last-child)::after { content: "→"; position: absolute; right: -1.15rem; top: 50%; transform: translateY(-50%); color: var(--accent); }
.case-nav { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); margin-top: 3rem; }
.case-nav a { display: flex; flex-direction: column; gap: .25rem; }
.case-nav .next { text-align: right; }

/* ---------- Reduced motion and print: show everything, move nothing ---------- */
@media (prefers-reduced-motion: reduce) {
  .reveal-ready [data-reveal] { opacity: 1; transform: none; transition: none; }
  .photo-ring, .pulse { animation: none; }
  .ticker-track { animation: none; width: auto; flex-wrap: wrap; }
  .ticker ul + ul { display: none; }
  .ticker ul { flex-wrap: wrap; }
  .flow-step, .flow-num { transition: none; }
}
@media print {
  .progress, .palette, .kbd-btn, .ticker, .now, .hero::after { display: none !important; }
  .reveal-ready [data-reveal] { opacity: 1; transform: none; }
}
