/*-----------------------------------*\
  #animations.css
  Premium animation layer — zero extra dependencies
\*-----------------------------------*/


/* ============================================================
   0. REDUCED-MOTION SAFETY NET
   ============================================================ */
@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;
  }
}


/* ============================================================
   1. CSS CUSTOM PROPERTIES — animation tokens
   ============================================================ */
:root {
  --ease-out-expo:    cubic-bezier(0.16, 1, 0.3, 1);
  --ease-out-back:    cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-in-out-soft: cubic-bezier(0.45, 0, 0.55, 1);
  --ease-spring:      cubic-bezier(0.175, 0.885, 0.32, 1.275);

  --dur-fast:   200ms;
  --dur-base:   350ms;
  --dur-slow:   600ms;
  --dur-xslow:  900ms;

  --stagger-1: 60ms;
  --stagger-2: 120ms;
  --stagger-3: 180ms;
}


/* ============================================================
   2. PAGE / ARTICLE TRANSITION
      Replace the simple opacity fade with a lifted card effect
   ============================================================ */
@keyframes articleEnter {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

article.active {
  animation: articleEnter var(--dur-base) var(--ease-out-expo) backwards;
}


/* ============================================================
   3. INITIAL PAGE LOAD — sidebar entrance
      Mobile (<1250px): subtle vertical fade to prevent horizontal scroll glitch
      Desktop (>=1250px): slide in from the left
   ============================================================ */
@keyframes sidebarFadeInMobile {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes sidebarSlideInDesktop {
  from {
    opacity: 0;
    transform: translateX(-24px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.sidebar {
  animation: sidebarFadeInMobile var(--dur-slow) var(--ease-out-expo) 80ms backwards;
}

@media (min-width: 1250px) {
  .sidebar {
    animation: sidebarSlideInDesktop var(--dur-slow) var(--ease-out-expo) 80ms backwards;
  }
}


/* ============================================================
   4. HERO / SIDEBAR CARD — staggered children entrance
   ============================================================ */
@keyframes heroFadeUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes btnCornerFadeIn {
  from {
    opacity: 0;
    transform: scale(0.94);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.avatar-box {
  animation: heroFadeUp var(--dur-slow) var(--ease-out-expo) 160ms backwards;
}

.info-content .name {
  animation: heroFadeUp var(--dur-slow) var(--ease-out-expo) 240ms backwards;
}

.info-content .title {
  animation: heroFadeUp var(--dur-slow) var(--ease-out-expo) 310ms backwards;
}

/* Anchor details button cleanly in corner: pinned to top-right with no positional jitter */
.info_more-btn {
  transform-origin: top right;
  animation: btnCornerFadeIn var(--dur-base) var(--ease-out-expo) 140ms backwards;
  transition:
    transform var(--dur-fast) var(--ease-out-expo),
    background var(--dur-base) ease,
    border-color var(--dur-base) ease,
    box-shadow var(--dur-base) ease,
    color var(--dur-fast) ease;
}


/* ============================================================
   5. AVATAR — subtle pulse ring on load + hover lift
   ============================================================ */
@keyframes avatarRing {
  0%   { box-shadow: 0 0 0 0 var(--accent-glow); }
  60%  { box-shadow: 0 0 0 10px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

.avatar-box {
  animation: heroFadeUp var(--dur-slow) var(--ease-out-expo) 160ms backwards,
             avatarRing 1.6s ease-out 900ms;
}

/* hover lift only for devices supporting hover to prevent sticky mobile states */
.avatar-box {
  transition: transform var(--dur-base) var(--ease-out-back),
              box-shadow var(--dur-base) ease;
}

@media (hover: hover) {
  .avatar-box:hover {
    transform: scale(1.05) translateY(-3px);
    box-shadow: 0 16px 40px rgba(47, 191, 113, 0.25);
  }
}


/* ============================================================
   6. NAVBAR ENTRANCE
   ============================================================ */
@keyframes navbarSlideUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.navbar {
  animation: navbarSlideUp var(--dur-slow) var(--ease-out-expo) 200ms backwards;
}

/* nav link active indicator — animated underline */
.navbar-link {
  position: relative;
  transition: color var(--dur-fast) ease;
}

.navbar-link::after {
  content: '';
  position: absolute;
  bottom: 14px;
  left: 50%;
  width: 0;
  height: 2px;
  background: var(--accent-highlight);
  border-radius: 2px;
  transform: translateX(-50%);
  transition: width var(--dur-base) var(--ease-out-expo);
}

.navbar-link.active::after {
  width: 20px;
}

@media (hover: hover) {
  .navbar-link:hover::after {
    width: 20px;
  }
}


/* ============================================================
   7. SCROLL-REVEAL — base state (JS adds .revealed)
   ============================================================ */
.reveal {
  opacity: 0;
  transform: translateY(28px);
  transition:
    opacity  var(--dur-slow) var(--ease-out-expo),
    transform var(--dur-slow) var(--ease-out-expo);
}

.reveal.revealed {
  opacity: 1;
  transform: translateY(0);
}

/* stagger variants for list children */
.reveal-stagger > * {
  opacity: 0;
  transform: translateY(22px);
  transition:
    opacity  var(--dur-slow) var(--ease-out-expo),
    transform var(--dur-slow) var(--ease-out-expo);
}

.reveal-stagger.revealed > *:nth-child(1)  { transition-delay: 0ms;   opacity: 1; transform: none; }
.reveal-stagger.revealed > *:nth-child(2)  { transition-delay: 80ms;  opacity: 1; transform: none; }
.reveal-stagger.revealed > *:nth-child(3)  { transition-delay: 160ms; opacity: 1; transform: none; }
.reveal-stagger.revealed > *:nth-child(4)  { transition-delay: 240ms; opacity: 1; transform: none; }
.reveal-stagger.revealed > *:nth-child(5)  { transition-delay: 320ms; opacity: 1; transform: none; }
.reveal-stagger.revealed > *:nth-child(6)  { transition-delay: 400ms; opacity: 1; transform: none; }
.reveal-stagger.revealed > *:nth-child(7)  { transition-delay: 480ms; opacity: 1; transform: none; }
.reveal-stagger.revealed > *:nth-child(8)  { transition-delay: 560ms; opacity: 1; transform: none; }

/* slide-in from left variant */
.reveal-left {
  opacity: 0;
  transform: translateX(-30px);
  transition:
    opacity  var(--dur-slow) var(--ease-out-expo),
    transform var(--dur-slow) var(--ease-out-expo);
}

.reveal-left.revealed {
  opacity: 1;
  transform: translateX(0);
}

/* scale-up variant (for cards) */
.reveal-scale {
  opacity: 0;
  transform: scale(0.93);
  transition:
    opacity  var(--dur-slow) var(--ease-out-expo),
    transform var(--dur-slow) var(--ease-out-expo);
}

.reveal-scale.revealed {
  opacity: 1;
  transform: scale(1);
}


/* ============================================================
   8. ARTICLE HEADER — title underline grows on reveal
   ============================================================ */
.article-title::after {
  transition: width var(--dur-slow) var(--ease-out-expo) var(--dur-base),
              height var(--dur-slow) var(--ease-out-expo) var(--dur-base);
}

/* When article becomes active, trigger via JS class .title-animated */
.article-title.title-animated::after {
  width: 40px; /* match existing responsive size */
}


/* ============================================================
   9. SERVICE / EXPERTISE CARDS — hover lift
   ============================================================ */
.service-item {
  transition:
    transform  var(--dur-base) var(--ease-out-back),
    box-shadow var(--dur-base) ease,
    border-color var(--dur-base) ease;
}

@media (hover: hover) {
  .service-item:hover {
    transform: translateY(-5px) scale(1.01);
    box-shadow: 0 20px 48px rgba(0, 0, 0, 0.35),
                0 0 0 1px rgba(47, 191, 113, 0.2);
    border-color: rgba(47, 191, 113, 0.3);
  }
}


/* ============================================================
   10. PROJECT / CASE STUDY CARDS
   ============================================================ */
/*
  Flicker-free entrance: project items are display:none → block, so
  CSS `animation` fires the moment `display` is applied. A pure
  opacity + subtle translateY (no scale) is the smoothest approach.
*/
@keyframes projectCardIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.project-item.active {
  animation: projectCardIn 320ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

/* card hover — border glow + image lift */
.project-item > a {
  display: block;
  border-radius: 16px;
  transition:
    transform var(--dur-base) var(--ease-out-back),
    box-shadow var(--dur-base) ease;
}

@media (hover: hover) {
  .project-item > a:hover {
    transform: translateY(-6px);
    box-shadow: 0 24px 56px rgba(0, 0, 0, 0.4),
                0 0 0 1px rgba(47, 191, 113, 0.25);
  }

  .project-item > a:hover img {
    transform: scale(1.08);
  }

  .project-item > a:hover .project-item-icon-box {
    --scale: 1;
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

/* tactile feedback on mobile tap */
.project-item > a:active {
  transform: scale(0.98);
}

/* image zoom — already handled via img:hover transform, smoothed */
.project-img img {
  transition: transform var(--dur-slow) var(--ease-out-expo),
              filter var(--dur-base) ease;
}

/* eye icon — spring scale in */
.project-item-icon-box {
  transition:
    opacity   var(--dur-base) ease,
    transform var(--dur-base) var(--ease-out-back);
}


/* ============================================================
   11. TIMELINE DOTS — pulse on scroll-reveal
   ============================================================ */
@keyframes dotPop {
  0%   { transform: scale(0); opacity: 0; box-shadow: 0 0 0 0 var(--accent-glow); }
  60%  { transform: scale(1.4); }
  80%  { box-shadow: 0 0 0 8px transparent; }
  100% { transform: scale(1); opacity: 1; box-shadow: 0 0 0 0 transparent; }
}

.timeline-item.revealed::after {
  animation: dotPop 0.55s var(--ease-out-back) forwards;
}

.timeline-item::after {
  opacity: 0;
}

/* timeline line — grows downward */
@keyframes lineGrow {
  from { transform: scaleY(0); transform-origin: top; }
  to   { transform: scaleY(1); transform-origin: top; }
}

.timeline-list.revealed::before {
  animation: lineGrow var(--dur-xslow) var(--ease-out-expo) 150ms both;
}

.timeline-list::before {
  transform-origin: top;
}


/* ============================================================
   12. CONTACT ITEMS IN SIDEBAR — staggered slide on mobile open
   ============================================================ */
@media (max-width: 1249px) {
  .sidebar-info_more .contact-item,
  .sidebar-info_more .social-item {
    opacity: 0;
    transform: translateY(10px);
    transition:
      opacity var(--dur-base) var(--ease-out-expo),
      transform var(--dur-base) var(--ease-out-expo);
  }

  .sidebar.active .sidebar-info_more .contact-item,
  .sidebar.active .sidebar-info_more .social-item {
    opacity: 1;
    transform: translateY(0);
  }

  .sidebar.active .sidebar-info_more .contact-item:nth-child(1) { transition-delay: 80ms; }
  .sidebar.active .sidebar-info_more .contact-item:nth-child(2) { transition-delay: 140ms; }
  .sidebar.active .sidebar-info_more .contact-item:nth-child(3) { transition-delay: 200ms; }
  .sidebar.active .sidebar-info_more .contact-item:nth-child(4) { transition-delay: 260ms; }
  .sidebar.active .sidebar-info_more .social-item:nth-child(1)  { transition-delay: 300ms; }
  .sidebar.active .sidebar-info_more .social-item:nth-child(2)  { transition-delay: 340ms; }
  .sidebar.active .sidebar-info_more .social-item:nth-child(3)  { transition-delay: 380ms; }
  .sidebar.active .sidebar-info_more .social-item:nth-child(4)  { transition-delay: 420ms; }
}

@media (min-width: 1250px) {
  .sidebar-info_more .contact-item,
  .sidebar-info_more .social-item {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }
}

/* icon-box micro bounce */
.icon-box {
  transition:
    transform  var(--dur-base) var(--ease-out-back),
    background var(--dur-fast) ease,
    color      var(--dur-fast) ease;
}

/* Animate only when hovering directly on or near the icon box on hover-capable devices */
@media (hover: hover) {
  .contact-item:hover .icon-box,
  .timeline .icon-box:hover {
    transform: scale(1.15) rotate(-5deg);
    background: var(--accent-soft-bg);
    color: var(--text-primary);
  }
}

.timeline .icon-box {
  cursor: pointer;
}

.contact-item .icon-box:active,
.timeline .icon-box:active {
  transform: scale(0.95);
}


/* ============================================================
   13. SOCIAL LINKS — spring hover + mobile active
   ============================================================ */
.social-item .social-link {
  transition:
    color            var(--dur-fast) ease,
    background-color var(--dur-fast) ease,
    border-color     var(--dur-fast) ease,
    box-shadow       var(--dur-base) ease,
    transform        var(--dur-base) var(--ease-out-back);
}

@media (hover: hover) {
  .social-item .social-link:hover {
    color: var(--accent-highlight);
    background: var(--bg-card-elevated);
    border-color: rgba(47, 191, 113, 0.4);
    transform: translateY(-3px);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  }
}

.social-item .social-link:active {
  transform: scale(0.92);
  background: var(--bg-hover);
}


/* ============================================================
   14. FORM — input focus ripple + button press
   ============================================================ */
.form-input {
  transition:
    border-color var(--dur-fast) ease,
    box-shadow   var(--dur-base) ease,
    transform    var(--dur-fast) ease;
}

.form-input:focus {
  border-color: var(--input-focus-border);
  box-shadow: 0 0 0 3px var(--input-focus-glow);
  transform: translateY(-1px);
}

.form-btn {
  transition:
    background  var(--dur-fast) ease,
    transform   var(--dur-fast) var(--ease-out-back),
    box-shadow  var(--dur-base) ease;
  will-change: transform;
}

@media (hover: hover) {
  .form-btn:not(:disabled):hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(47, 191, 113, 0.35);
  }
}

.form-btn:not(:disabled):active {
  transform: scale(0.97) translateY(0);
  box-shadow: none;
}


/* ============================================================
   15. FILTER BUTTONS — active indicator slide
   ============================================================ */
.filter-item button {
  position: relative;
  transition: color var(--dur-fast) ease;
  overflow: hidden;
}

.filter-item button::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 100%;
  height: 2px;
  background: var(--accent-highlight);
  border-radius: 2px;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform var(--dur-base) var(--ease-out-expo);
}

.filter-item button.active::after {
  transform: scaleX(1);
}

@media (hover: hover) {
  .filter-item button:hover::after {
    transform: scaleX(1);
  }
}


/* ============================================================
   16. DETAILS (INFO MORE) BUTTON — mobile interactions & chevron rotation
   ============================================================ */

/* Hover state only on devices that truly support hover (prevents sticky green on mobile tap) */
@media (hover: hover) {
  .info_more-btn:hover {
    background: var(--accent-hover);
    color: var(--text-primary);
  }
}

/* Reset mobile tap focus so button doesn't stay stuck green */
.info_more-btn:focus:not(:focus-visible) {
  background: var(--bg-card-elevated);
  color: var(--accent-highlight);
}

/* Smooth, corner-anchored press feedback on touch (clean, no glow) */
.info_more-btn:active {
  transform: scale(0.95);
  transform-origin: top right;
  background: var(--bg-hover);
}

/* When sidebar drawer is expanded — clean, no glow */
.sidebar.active .info_more-btn {
  border-color: var(--border-primary);
  box-shadow: var(--shadow-2);
}

/* Chevron arrow: butter-smooth rotation perfectly paced with the drawer expansion */
.info_more-btn ion-icon {
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transform-origin: 50% 50%;
  transition: transform 0.45s var(--ease-out-expo);
  will-change: transform;
}

.sidebar.active .info_more-btn ion-icon {
  transform: rotate(180deg);
}


/* ============================================================
   17. ARTICLE TITLE UNDERLINE — animated on page enter
   ============================================================ */
@keyframes underlineGrow {
  from { width: 0; }
  to   { width: 30px; }
}

article.active .article-title::after {
  animation: underlineGrow 0.5s var(--ease-out-expo) 300ms both;
}

@media (min-width: 580px) {
  @keyframes underlineGrow {
    from { width: 0; }
    to   { width: 40px; }
  }
}


/* ============================================================
   18. SEPARATOR — fade in
   ============================================================ */
@keyframes separatorFade {
  from { opacity: 0; transform: scaleX(0.3); }
  to   { opacity: 1; transform: scaleX(1); }
}

@media (max-width: 1249px) {
  .sidebar.active .separator {
    animation: separatorFade var(--dur-slow) var(--ease-out-expo) 60ms both;
    transform-origin: left;
  }
}


/* ============================================================
   19. NAVBAR ACTIVE LINK — smooth color transition
   ============================================================ */
.navbar-link {
  transition:
    color      var(--dur-fast) ease,
    transform  var(--dur-fast) ease;
}

.navbar-link:active {
  transform: scale(0.92);
}


/* ============================================================
   20. CERTIFICATION / BLOG ITEMS — same reveal as project cards
   ============================================================ */
.blog .project-item.active {
  animation: projectCardIn 320ms cubic-bezier(0.16, 1, 0.3, 1) both;
}


/* ============================================================
   21. SCROLL-TO-TOP FADE (body scroll indicator)
   ============================================================ */
html {
  scroll-behavior: smooth;
}


/* ============================================================
   22. SELECTION HIGHLIGHT — accent branded
   ============================================================ */
::selection {
  background: var(--accent-highlight);
  color: #000;
}


/* ============================================================
   23. PROJECT IMAGE PLACEHOLDER
   ============================================================ */
.project-img {
  background-color: var(--bg-card-elevated);
}


/* ============================================================
   24. ABOUT TEXT — graceful entrance on page activation
       (Visible by default to prevent blank screen on mobile load)
   ============================================================ */
@keyframes aboutTextIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

article.active .about-text p {
  animation: aboutTextIn var(--dur-slow) var(--ease-out-expo) backwards;
}

article.active .about-text p:nth-child(1) { animation-delay: 80ms; }
article.active .about-text p:nth-child(2) { animation-delay: 160ms; }
article.active .about-text p:nth-child(3) { animation-delay: 240ms; }


/* ============================================================
   25. CONTACT ITEM LINK — colour shift on hover
       (No ::after underline — incompatible with overflow:hidden+ellipsis)
   ============================================================ */
.contact-link {
  transition: color var(--dur-fast) ease;
}

@media (hover: hover) {
  .contact-link:hover {
    color: var(--accent-highlight);
  }
}


/* ============================================================
   26. MOBILE FILTER SELECT DROPDOWN — smooth pop-down
   ============================================================ */
.select-list {
  transform: translateY(-8px) scale(0.98);
  transform-origin: top center;
  transition:
    opacity    var(--dur-base) var(--ease-out-expo),
    transform  var(--dur-base) var(--ease-out-expo),
    visibility var(--dur-base);
}

.filter-select.active + .select-list {
  transform: translateY(0) scale(1);
}

.select-item button:active {
  color: var(--accent-highlight);
  transform: translateX(4px);
  transition: transform var(--dur-fast) ease, color var(--dur-fast) ease;
}
