/* Custom styles for ICAM Lab Public Academic SPA */

html {
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

section {
  scroll-margin-top: 4.5rem;
}

/* Pages: keep the footer at the bottom of short pages and fade each page in. */
main > section {
  min-height: 70vh;
  animation: page-in 0.25s ease-out;
}

@keyframes page-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  main > section { animation: none; }
}

h1, h2, h3, h4, .font-heading {
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  letter-spacing: -0.02em;
}

/* Navigation active tab state */
.nav-tab.active,
.nav-sub.active {
  color: #0f172a;
  background-color: #f1f5f9;
  border-bottom: 2px solid #1e40af;
  font-weight: 600;
}

html.dark .nav-tab.active,
html.dark .nav-sub.active {
  color: #ffffff;
  background-color: #1e293b;
  border-bottom: 2px solid #60a5fa;
  font-weight: 600;
}

/* Academic card subtle hover states */
.pub-card, .team-card, .grant-card, .research-card {
  transition: border-color 0.15s ease-in-out, background-color 0.15s ease-in-out;
}

.pub-card:hover, .team-card:hover, .grant-card:hover, .research-card:hover {
  border-color: #94a3b8;
}

html.dark .pub-card:hover, 
html.dark .team-card:hover, 
html.dark .grant-card:hover, 
html.dark .research-card:hover {
  border-color: #475569;
}

/* Custom Scrollbar - Light */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: #f8fafc;
}

::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Custom Scrollbar - Dark */
html.dark ::-webkit-scrollbar-track {
  background: #0f172a;
}

html.dark ::-webkit-scrollbar-thumb {
  background: #334155;
}

html.dark ::-webkit-scrollbar-thumb:hover {
  background: #475569;
}

/* Section permalinks: a "#" that appears next to a heading on hover or keyboard focus. */
.anchor-link {
  margin-left: 0.5rem;
  color: #94a3b8;
  text-decoration: none;
  font-weight: 400;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s;
}
[data-anchor]:hover > .anchor-link,
.anchor-link:focus { opacity: 1; }
.anchor-link:hover { color: #1e40af; }
.dark .anchor-link:hover { color: #60a5fa; }
@media (hover: none) { .anchor-link { opacity: 0.6; } }

/* Tooltip shown before clicking a permalink. */
.anchor-link { position: relative; }
.anchor-link::after {
  content: attr(data-tip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 6px);
  transform: translateX(-50%);
  padding: 0.25rem 0.5rem;
  border-radius: 0.375rem;
  background: #1e293b;
  color: #f8fafc;
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.2;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 40;
}
.anchor-link:hover::after,
.anchor-link:focus-visible::after { opacity: 1; }
.dark .anchor-link::after { background: #e2e8f0; color: #0f172a; }
@media (hover: none) { .anchor-link::after { display: none; } }

/* Confirmation toast (e.g. after copying a section link). */
#toast {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  transform: translate(-50%, 0.5rem);
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  background: #1e293b;
  color: #f8fafc;
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 100;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
.dark #toast { background: #e2e8f0; color: #0f172a; }

/* Selected filter pills keep their own colours on hover (the unselected pills' hover text colour
   would otherwise land on the dark/light selected background with no contrast). */
.pub-filter-btn.active,
.pub-filter-btn.active:hover,
.team-filter-btn.active,
.team-filter-btn.active:hover {
  background-color: #0f172a !important;
  color: #ffffff !important;
}
html.dark .pub-filter-btn.active,
html.dark .pub-filter-btn.active:hover,
html.dark .team-filter-btn.active,
html.dark .team-filter-btn.active:hover {
  background-color: #f1f5f9 !important;
  color: #0f172a !important;
}

/* Blog post body (sanitized Blogger HTML rendered natively) */
.blog-post { font-size: 1rem; line-height: 1.75; overflow-wrap: anywhere; }
.blog-post p, .blog-post ul, .blog-post ol, .blog-post blockquote, .blog-post pre, .blog-post table, .blog-post figure { margin: 0 0 1rem; }
.blog-post h1, .blog-post h2, .blog-post h3, .blog-post h4 { font-weight: 700; margin: 1.75rem 0 0.75rem; line-height: 1.3; }
.blog-post h3 { font-size: 1.25rem; }
.blog-post h4 { font-size: 1.1rem; }
.blog-post ul { list-style: disc; padding-left: 1.5rem; }
.blog-post ol { list-style: decimal; padding-left: 1.5rem; }
.blog-post li { margin: 0.25rem 0; }
.blog-post a { color: #1e40af; text-decoration: underline; }
.blog-post img { max-width: 100%; height: auto; border-radius: 0.375rem; margin: 0.5rem 0; }
.blog-post iframe { display: block; width: 100%; max-width: 100%; aspect-ratio: 16 / 9; height: auto; border: 0; border-radius: 0.375rem; margin: 1rem 0; }
.blog-post blockquote { border-left: 3px solid #cbd5e1; padding-left: 1rem; color: #475569; }
.blog-post pre, .blog-post code, .blog-post tt { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.875em; }
.blog-post pre { background: #f1f5f9; padding: 0.75rem 1rem; border-radius: 0.375rem; overflow-x: auto; }
.blog-post table { border-collapse: collapse; display: block; overflow-x: auto; }
.blog-post td, .blog-post th { border: 1px solid #cbd5e1; padding: 0.4rem 0.6rem; }
html.dark .blog-post a { color: #60a5fa; }
html.dark .blog-post blockquote { border-left-color: #475569; color: #94a3b8; }
html.dark .blog-post pre { background: #1e293b; }
html.dark .blog-post td, html.dark .blog-post th { border-color: #475569; }

/* Home page: one divided strip of headline numbers. */
.home-stats { display: grid; grid-template-columns: repeat(2, 1fr); border: 1px solid #e2e8f0; border-radius: 0.5rem; overflow: hidden; }
@media (min-width: 640px) { .home-stats { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1024px) { .home-stats { grid-template-columns: repeat(5, 1fr); } }
.home-stat { display: block; text-align: center; padding: 0.75rem 0.5rem; margin: -0.5px; border: 0.5px solid #e2e8f0; transition: background-color 0.15s; }
.home-stat:hover { background: #f1f5f9; }
html.dark .home-stats, html.dark .home-stat { border-color: #1e293b; }
html.dark .home-stat:hover { background: #1e293b; }

/* Home hero: the headline's middle phrase cycles through application domains in a moving gradient.
   Timed for 4 words plus the repeated first word (each holds ~2.1s, then slides up). */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.hl-rotate { display: block; height: 1.2em; line-height: 1.2em; overflow: hidden; margin: 0.02em 0; }
.hl-track { display: block; animation: hl-cycle 10s cubic-bezier(.7,0,.3,1) infinite; }
.hl-word { display: block; height: 1.2em; white-space: nowrap; width: max-content; max-width: 100%;
  background: linear-gradient(90deg, #1d4ed8, #0891b2 45%, #059669 90%); background-size: 200% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: hl-shimmer 5s ease-in-out infinite alternate; }
html.dark .hl-word { background-image: linear-gradient(90deg, #60a5fa, #22d3ee 45%, #34d399 90%); }
@keyframes hl-cycle {
  0%, 21% { transform: translateY(0); }
  25%, 46% { transform: translateY(-1.2em); }
  50%, 71% { transform: translateY(-2.4em); }
  75%, 96% { transform: translateY(-3.6em); }
  100% { transform: translateY(-4.8em); }
}
@keyframes hl-shimmer { to { background-position: 100% 0; } }
@media (prefers-reduced-motion: reduce) { .hl-track, .hl-word { animation: none; } }

/* Home hero: animated remaining-useful-life forecast. Plays once on load; the "now" dot keeps pulsing. */
.rul-figure { margin: 0.25rem 0 0; }
.rul { display: block; width: 100%; height: auto; overflow: visible; }
.anim-armed:not(.anim-play) * { animation-play-state: paused; }
.rul-axis { stroke: #cbd5e1; stroke-width: 1; }
.rul-threshold { stroke: #94a3b8; stroke-width: 1; stroke-dasharray: 2 4; }
.rul-label { font: 600 11px/1 ui-sans-serif, system-ui, sans-serif; fill: #64748b; letter-spacing: 0.02em; }
.rul-measured { fill: none; stroke: #1e40af; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 1; stroke-dashoffset: 1; animation: rul-draw 1.6s ease-out 0.2s forwards; }
.rul-samples circle { fill: #1e40af; opacity: 0; animation: rul-fade 0.3s ease-out forwards; animation-delay: calc(0.25s + var(--i) * 0.15s); }
.rul-cone { fill: #3b82f6; opacity: 0; animation: rul-cone 0.8s ease-out 1.8s forwards; }
.rul-forecast { fill: none; stroke: #1e40af; stroke-width: 2; stroke-dasharray: 5 5; opacity: 0;
  animation: rul-fade 0.6s ease-out 1.8s forwards, rul-march 1.2s linear 1.8s infinite; }
.rul-now { fill: #1e40af; stroke: #fff; stroke-width: 2; opacity: 0; animation: rul-fade 0.3s ease-out 1.7s forwards; }
.rul-now-pulse { fill: #3b82f6; opacity: 0; transform-box: fill-box; transform-origin: center; animation: rul-pulse 2s ease-out 2s infinite; }
.rul-now-label { fill: #1e40af; opacity: 0; animation: rul-fade 0.3s ease-out 1.8s forwards; }
.rul-service { opacity: 0; transform: translateY(-6px); animation: rul-drop 0.5s ease-out 2.6s forwards; }
.rul-service line { stroke: #059669; stroke-width: 1.5; stroke-dasharray: 3 3; }
.rul-service circle { fill: #059669; }
.rul-service path { fill: none; stroke: #fff; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.rul-service-label { fill: #047857; }
.rul-bracket path { fill: none; stroke: #1e40af; stroke-width: 1.5; transform-box: fill-box; transform-origin: left center; transform: scaleX(0);
  animation: rul-grow 0.7s ease-out 3s forwards; }
.rul-bracket-label { fill: #1e40af; opacity: 0; animation: rul-fade 0.4s ease-out 3.5s forwards; }
@media (max-width: 640px) { .rul-label { font-size: 17px; } }
html.dark .rul-axis { stroke: #334155; }
html.dark .rul-threshold { stroke: #64748b; }
html.dark .rul-label { fill: #94a3b8; }
html.dark .rul-measured, html.dark .rul-forecast, html.dark .rul-bracket path { stroke: #60a5fa; }
html.dark .rul-samples circle, html.dark .rul-now { fill: #60a5fa; }
html.dark .rul-now { stroke: #0f172a; }
html.dark .rul-now-label, html.dark .rul-bracket-label { fill: #60a5fa; }
html.dark .rul-service line { stroke: #34d399; }
html.dark .rul-service circle { fill: #10b981; }
html.dark .rul-service-label { fill: #34d399; }
@keyframes rul-draw { to { stroke-dashoffset: 0; } }
@keyframes rul-fade { to { opacity: 1; } }
@keyframes rul-cone { to { opacity: 0.14; } }
@keyframes rul-march { to { stroke-dashoffset: -10; } }
@keyframes rul-pulse { 0% { opacity: 0.45; transform: scale(1); } 100% { opacity: 0; transform: scale(3.2); } }
@keyframes rul-drop { to { opacity: 1; transform: none; } }
@keyframes rul-grow { to { transform: scaleX(1); } }
@media (prefers-reduced-motion: reduce) {
  .rul *, .rul g { animation: none !important; }
  .rul-measured { stroke-dashoffset: 0; }
  .rul-samples circle, .rul-forecast, .rul-now, .rul-now-label, .rul-service, .rul-bracket-label { opacity: 1; transform: none; }
  .rul-cone { opacity: 0.14; }
  .rul-bracket path { transform: none; }
}

/* Method art (art.js): small animated illustrations for prognosis, diagnosis, signal processing,
   computer vision, and control & estimation. Delays come from an inline --d; --t overrides draw time. */
.art { display: block; width: 100%; height: auto; overflow: visible; }
.art .a-axis { stroke: #cbd5e1; stroke-width: 1; }
.art .a-thr { fill: none; stroke: #94a3b8; stroke-width: 1; stroke-dasharray: 2 4; }
.art .a-label { font: 600 11px/1 ui-sans-serif, system-ui, sans-serif; fill: #64748b; letter-spacing: 0.02em; }
.art .a-tag { font: 700 10px/1 ui-sans-serif, system-ui, sans-serif; fill: #fff; }
.art .a-ink, .art .a-box, .art .a-arrow { fill: none; stroke: #1e40af; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.art .a-thick { stroke-width: 2.5; }
.art .a-dashed { stroke-width: 2; stroke-dasharray: 5 5; }
.art .a-arrow { stroke: #94a3b8; }
.art .a-ink-fill { fill: #1e40af; }
.art .a-ink-text { fill: #1e40af; }
.art .a-soft { fill: #93c5fd; }
.art .a-muted-fill { fill: #94a3b8; }
.art .a-dot { stroke: #fff; stroke-width: 2; }
.art .a-cone { fill: #3b82f6; }
.art .a-cone.a-fade { animation-name: art-cone; }
.art .a-band { fill: #3b82f6; opacity: 0.07; }
.art .a-ok { fill: none; stroke: #059669; stroke-width: 1.5; }
.art .a-dashed-thin { stroke-dasharray: 3 3; }
.art .a-ok-fill { fill: #059669; }
.art .a-ok-text { fill: #047857; }
.art .a-warn { fill: none; stroke: #d97706; stroke-width: 1.5; }
.art .a-warn-fill { fill: #d97706; }
.art .a-warn-text { fill: #b45309; }
.art .a-check { fill: none; stroke: #fff; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.art .a-box { stroke-width: 2; }
.art .a-box.a-ok { stroke: #059669; } .art .a-box.a-warn { stroke: #d97706; }
.art .a-frame { fill: none; stroke: #94a3b8; stroke-width: 2; }
.art .a-figure { fill: #e2e8f0; }
.art .a-limb { fill: none; stroke: #e2e8f0; stroke-width: 9; stroke-linecap: round; }
.art .a-helmet { fill: #facc15; }
.art .a-vest { fill: none; stroke: #f97316; stroke-width: 4; }
.art .a-part { fill: #e2e8f0; stroke: #cbd5e1; }
.art .a-crack { fill: none; stroke: #475569; stroke-width: 1.5; stroke-linejoin: round; }
.art .a-scan { stroke: #3b82f6; stroke-width: 2; opacity: 0; animation: art-scan 3.2s ease-in-out var(--d, 0s) infinite; }

.art .a-draw { stroke-dasharray: 1; stroke-dashoffset: 1; animation: art-draw var(--t, 1.4s) ease-out var(--d, 0s) forwards; }
.art .a-fade { opacity: 0; animation: art-fade 0.45s ease-out var(--d, 0s) forwards; }
.art .a-pop { opacity: 0; transform: scale(0.6); transform-box: fill-box; transform-origin: center; animation: art-pop 0.4s cubic-bezier(.3,1.5,.6,1) var(--d, 0s) forwards; }
.art .a-grow-x { transform: scaleX(0); transform-box: fill-box; transform-origin: left center; animation: art-grow 0.6s ease-out var(--d, 0s) forwards; }
.art .a-grow-y { transform: scaleY(0); transform-box: fill-box; transform-origin: center bottom; animation: art-grow 0.5s ease-out var(--d, 0s) forwards; }
.art .a-pulse { opacity: 0; transform-box: fill-box; transform-origin: center; animation: art-pulse 2s ease-out var(--d, 0s) infinite; }
@keyframes art-draw { to { stroke-dashoffset: 0; } }
@keyframes art-fade { to { opacity: 1; } }
@keyframes art-cone { to { opacity: 0.14; } }
@keyframes art-pop { to { opacity: 1; transform: none; } }
@keyframes art-grow { to { transform: none; } }
@keyframes art-pulse { 0% { opacity: 0.45; transform: scale(1); } 100% { opacity: 0; transform: scale(3.2); } }
@keyframes art-scan { 0% { opacity: 0; transform: translateX(0); } 10%, 85% { opacity: 0.45; } 100% { opacity: 0; transform: translateX(272px); } }

html.dark .art .a-axis { stroke: #334155; }
html.dark .art .a-thr, html.dark .art .a-frame, html.dark .art .a-arrow { stroke: #64748b; }
html.dark .art .a-label { fill: #94a3b8; }
html.dark .art .a-ink, html.dark .art .a-box { stroke: #60a5fa; }
html.dark .art .a-ink-fill, html.dark .art .a-ink-text { fill: #60a5fa; }
html.dark .art .a-soft { fill: #1e3a8a; }
html.dark .art .a-muted-fill { fill: #64748b; }
html.dark .art .a-dot { stroke: #0f172a; }
html.dark .art .a-ok, html.dark .art .a-box.a-ok { stroke: #34d399; }
html.dark .art .a-ok-fill { fill: #10b981; }
html.dark .art .a-ok-text { fill: #34d399; }
html.dark .art .a-warn, html.dark .art .a-box.a-warn { stroke: #fbbf24; }
html.dark .art .a-warn-fill { fill: #f59e0b; }
html.dark .art .a-warn-text { fill: #fbbf24; }
html.dark .art .a-figure, html.dark .art .a-part { fill: #334155; }
html.dark .art .a-limb { stroke: #334155; }
html.dark .art .a-part { stroke: #475569; }
html.dark .art .a-crack { stroke: #cbd5e1; }
html.dark .art .a-band { fill: #60a5fa; }
@media (prefers-reduced-motion: reduce) {
  .art * { animation: none !important; }
  .art .a-draw { stroke-dashoffset: 0; }
  .art .a-fade, .art .a-pop { opacity: 1; transform: none; }
  .art .a-cone { opacity: 0.14; }
  .art .a-grow-x, .art .a-grow-y { transform: none; }
  .art .a-pulse, .art .a-scan { display: none; }
}

/* Blog list: a cropped thumbnail above the card text (posts without images just have no thumbnail). */
.blog-thumb { aspect-ratio: 16 / 9; background: #0f172a; overflow: hidden; }
.blog-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }

/* Social wall: Pinterest-style masonry using CSS columns. */
.wall { display: flex; align-items: flex-start; gap: 1rem; }
.wall-col { flex: 1 1 0; min-width: 0; }
.wall-card { margin-bottom: 1rem; display: block; overflow: hidden; }
.wall-spinner { width: 1.25rem; height: 1.25rem; border-radius: 9999px; border: 2px solid #cbd5e1; border-top-color: #1e40af; animation: wall-spin 0.8s linear infinite; }
html.dark .wall-spinner { border-color: #475569; border-top-color: #60a5fa; }
@keyframes wall-spin { to { transform: rotate(360deg); } }
.wall-media { position: relative; display: block; width: 100%; background: #0f172a; }
.wall-media img { display: block; width: 100%; height: auto; }
.wall-media iframe { display: block; width: 100%; aspect-ratio: 16 / 9; border: 0; }
.wall-media.is-short iframe { aspect-ratio: 9 / 16; max-height: 70vh; }
.wall-play {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(15, 23, 42, 0.25); color: #fff; font-size: 2.5rem; border: 0; cursor: pointer; width: 100%;
}
.wall-play:hover { background: rgba(15, 23, 42, 0.45); }

/* Active page inside a dropdown: an accent bar on the left instead of the tab underline. */
.nav-sub.active { border-bottom: 0; box-shadow: inset 3px 0 0 #1e40af; }
html.dark .nav-sub.active { box-shadow: inset 3px 0 0 #60a5fa; }
