/* =============================================
   ENHANCEMENTS.CSS — Premium UI/UX Additions
   Maheshwaran D Portfolio
   ============================================= */

/* ===== LOADING SCREEN ===== */
.loader-screen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--bg-primary, #080d1a);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.6s ease, visibility 0.6s ease;
}
.loader-screen.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loader-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

.loader-logo {
  font-family: 'JetBrains Mono', monospace;
  font-size: 2.2rem;
  font-weight: 700;
  color: #f1f5f9;
  animation: loaderPulse 1.2s ease-in-out infinite alternate;
}
.loader-logo span { color: #00d4ff; }

@keyframes loaderPulse {
  from { opacity: 0.5; transform: scale(0.97); }
  to   { opacity: 1;   transform: scale(1.03); }
}

.loader-bar {
  width: 240px;
  height: 3px;
  background: rgba(255,255,255,0.07);
  border-radius: 99px;
  overflow: hidden;
}
.loader-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #00d4ff, #7c3aed);
  border-radius: 99px;
  transition: width 0.25s ease;
  box-shadow: 0 0 12px rgba(0,212,255,0.6);
}
.loader-text {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  color: #64748b;
  text-transform: uppercase;
}

/* ===== CUSTOM CURSOR ===== */
.cursor-dot,
.cursor-ring {
  position: fixed;
  top: 0; left: 0;
  pointer-events: none;
  z-index: 9998;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  mix-blend-mode: screen;
}

.cursor-dot {
  width: 8px;
  height: 8px;
  background: #00d4ff;
  box-shadow: 0 0 10px #00d4ff, 0 0 20px rgba(0,212,255,0.4);
  transition: transform 0.1s ease, opacity 0.2s ease, background 0.2s ease;
}

.cursor-ring {
  width: 36px;
  height: 36px;
  border: 1.5px solid rgba(0, 212, 255, 0.5);
  background: rgba(0, 212, 255, 0.04);
  transition: width 0.25s ease, height 0.25s ease, border-color 0.25s ease,
              background 0.25s ease, opacity 0.2s ease;
}

/* Cursor grow on hover over interactive elements */
body.cursor-grow .cursor-ring {
  width: 60px;
  height: 60px;
  border-color: rgba(124, 58, 237, 0.6);
  background: rgba(124, 58, 237, 0.06);
}
body.cursor-grow .cursor-dot {
  transform: translate(-50%, -50%) scale(0);
  opacity: 0;
}

/* Hide custom cursor on mobile */
@media (hover: none) {
  .cursor-dot, .cursor-ring { display: none; }
}

/* ===== DARK / LIGHT MODE TOGGLE ===== */
.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  color: #94a3b8;
  cursor: pointer;
  transition: all 0.3s ease;
  margin-right: 4px;
  flex-shrink: 0;
}
.theme-toggle:hover {
  background: rgba(0,212,255,0.1);
  border-color: rgba(0,212,255,0.3);
  color: #00d4ff;
  transform: rotate(15deg);
}

/* ===== LIGHT MODE OVERRIDES ===== */
body.light-mode {
  --bg-primary: #f0f4ff;
  --bg-secondary: #e8eeff;
  --bg-card: #ffffff;
  --bg-card-hover: #f5f8ff;
  --bg-glass: rgba(0,0,0,0.03);
  --bg-glass-border: rgba(0,0,0,0.09);
  --text-primary: #0f172a;
  --text-secondary: #334155;
  --text-muted: #64748b;
}
body.light-mode .navbar.scrolled {
  background: rgba(240, 244, 255, 0.88);
}
body.light-mode .hero {
  background: linear-gradient(135deg, #eef2ff 0%, #f0f4ff 60%, #e8eeff 100%);
}
body.light-mode .grid-overlay {
  background-image:
    linear-gradient(rgba(124,58,237,0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(124,58,237,0.06) 1px, transparent 1px);
}
body.light-mode .hero-orb { opacity: 0.2; }
body.light-mode .nav-links { background: rgba(240,244,255,0.97); }
body.light-mode .loader-screen { background: #f0f4ff; }
body.light-mode .loader-logo  { color: #0f172a; }
body.light-mode ::-webkit-scrollbar-track { background: #e8eeff; }
body.light-mode .skill-bar-bg { background: rgba(0,0,0,0.08); }

/* Light mode smooth transition on everything */
body, body * {
  transition: background-color 0.35s ease, border-color 0.35s ease,
              color 0.25s ease, box-shadow 0.35s ease;
}
/* But keep motion-sensitive properties un-transitioned */
body.cursor-dot, body.cursor-ring { transition: none; }

/* ===== SCROLL PROGRESS BAR ===== */
#scrollProgress {
  position: fixed;
  top: 0; left: 0;
  height: 2px;
  width: 0%;
  background: linear-gradient(90deg, #00d4ff, #7c3aed);
  z-index: 10001;
  transition: width 0.05s linear;
  box-shadow: 0 0 8px rgba(0,212,255,0.6);
}

/* ===== SECTION REVEAL ANIMATIONS ===== */
.reveal-section {
  opacity: 0;
  transform: translateY(40px);
  transition: opacity 0.75s cubic-bezier(0.4,0,0.2,1),
              transform 0.75s cubic-bezier(0.4,0,0.2,1);
}
.reveal-section.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Staggered children */
.reveal-children > * {
  opacity: 0;
  transform: translateY(28px);
  transition: opacity 0.55s ease, transform 0.55s ease;
}
.reveal-children.visible > *:nth-child(1)  { transition-delay: 0.05s; }
.reveal-children.visible > *:nth-child(2)  { transition-delay: 0.12s; }
.reveal-children.visible > *:nth-child(3)  { transition-delay: 0.19s; }
.reveal-children.visible > *:nth-child(4)  { transition-delay: 0.26s; }
.reveal-children.visible > *:nth-child(5)  { transition-delay: 0.33s; }
.reveal-children.visible > *:nth-child(6)  { transition-delay: 0.40s; }
.reveal-children.visible > * {
  opacity: 1;
  transform: translateY(0);
}

/* ===== PARTICLE CANVAS ===== */
#particleCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  opacity: 0.5;
}

/* ===== SKILL PROGRESS BARS ===== */
.skill-progress-wrap {
  margin-top: 10px;
}
.skill-bar-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  font-size: 0.78rem;
  color: #94a3b8;
  font-family: 'JetBrains Mono', monospace;
}
.skill-bar-bg {
  height: 4px;
  background: rgba(255,255,255,0.07);
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 10px;
}
.skill-bar-fill {
  height: 100%;
  width: 0%;
  border-radius: 99px;
  background: linear-gradient(90deg, #00d4ff, #7c3aed);
  box-shadow: 0 0 8px rgba(0,212,255,0.4);
  transition: width 1.2s cubic-bezier(0.4,0,0.2,1);
}

/* ===== PROJECT CARD ENHANCED HOVER ===== */
.project-card {
  transition: transform 0.35s cubic-bezier(0.4,0,0.2,1),
              box-shadow 0.35s ease,
              border-color 0.35s ease !important;
  will-change: transform;
}
.project-card:hover {
  transform: translateY(-8px) !important;
  box-shadow: 0 16px 50px rgba(0,0,0,0.5),
              0 0 0 1px rgba(0,212,255,0.18),
              0 0 30px rgba(0,212,255,0.1) !important;
}
.project-card:hover .pv-icon {
  animation: floatFast 1.4s ease-in-out infinite !important;
}
@keyframes floatFast {
  0%,100% { transform: translateY(0) scale(1.05); }
  50%      { transform: translateY(-12px) scale(1.12); }
}

/* Tech chip hover glow */
.tech-chip {
  transition: background 0.25s ease, color 0.25s ease, border-color 0.25s ease !important;
  cursor: default;
}
.tech-chip:hover {
  background: rgba(0,212,255,0.1) !important;
  color: #00d4ff !important;
  border-color: rgba(0,212,255,0.3) !important;
}

/* ===== BUTTON RIPPLE ===== */
.btn {
  overflow: hidden;
  position: relative;
}
.ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  transform: scale(0);
  animation: rippleAnim 0.6s linear;
  pointer-events: none;
}
@keyframes rippleAnim {
  to { transform: scale(4); opacity: 0; }
}

/* ===== SKILL PILL MICRO-ANIMATIONS ===== */
.skill-pill {
  transition: transform 0.2s ease, box-shadow 0.2s ease !important;
}
.skill-pill:hover {
  transform: translateY(-2px) scale(1.04) !important;
  box-shadow: 0 4px 16px rgba(0,212,255,0.15) !important;
}

/* ===== SKILL CATEGORY REVEAL ===== */
.skill-category {
  opacity: 0;
  transform: translateY(24px) scale(0.97);
  transition: opacity 0.55s ease, transform 0.55s ease !important;
}
.skill-category.in-view {
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* ===== TIMELINE CARD REVEAL ===== */
.timeline-item {
  opacity: 0;
  transform: translateX(-20px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}
.timeline-item.in-view {
  opacity: 1;
  transform: translateX(0);
}

/* ===== CONTACT ITEM REVEAL ===== */
.contact-item {
  opacity: 0;
  transform: translateX(-16px);
  transition: opacity 0.5s ease, transform 0.5s ease,
              border-color 0.3s ease, background 0.3s ease !important;
}
.contact-item.in-view {
  opacity: 1;
  transform: translateX(0);
}

/* ===== NAV LINK UNDERLINE SLIDE ===== */
.nav-link {
  position: relative;
}
.nav-link::after {
  content: '';
  position: absolute;
  bottom: 2px; left: 50%;
  width: 0; height: 2px;
  background: linear-gradient(90deg, #00d4ff, #7c3aed);
  border-radius: 99px;
  transition: width 0.3s ease, left 0.3s ease;
}
.nav-link:hover::after,
.nav-link.active::after {
  width: 60%;
  left: 20%;
}

/* ===== HERO TITLE CURSOR ===== */
.typed-cursor {
  display: inline-block;
  width: 3px;
  background: #00d4ff;
  border-radius: 2px;
  margin-left: 3px;
  animation: blinkCursor 0.8s step-end infinite;
  vertical-align: middle;
}
@keyframes blinkCursor {
  0%,100% { opacity: 1; }
  50%      { opacity: 0; }
}

/* ===== SECTION HEADER ANIMATED TAG ===== */
.section-tag {
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.section-tag:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0,212,255,0.2);
}

/* ===== CERT ITEM HOVER ===== */
.cert-item {
  transition: transform 0.25s ease, border-color 0.25s ease,
              background 0.25s ease !important;
}
.cert-item:hover {
  transform: translateX(6px);
  border-color: rgba(0,212,255,0.2) !important;
  background: rgba(0,212,255,0.04) !important;
}

/* ===== BACK-TO-TOP BUTTON ===== */
#backToTop {
  position: fixed;
  bottom: 32px;
  right: 32px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, #00d4ff, #7c3aed);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.4s ease, transform 0.4s ease, box-shadow 0.3s ease;
  z-index: 888;
  box-shadow: 0 4px 20px rgba(0,212,255,0.3);
}
#backToTop.visible {
  opacity: 1;
  transform: translateY(0);
}
#backToTop:hover {
  box-shadow: 0 8px 28px rgba(0,212,255,0.5);
  transform: translateY(-3px);
}

/* ===== RESPONSIVE ADJUSTMENTS ===== */
@media (max-width: 768px) {
  .cursor-dot, .cursor-ring { display: none; }
  #backToTop { bottom: 20px; right: 20px; width: 40px; height: 40px; }
  .theme-toggle { width: 34px; height: 34px; }
}

/* =============================================
   CONTACT FORM ENHANCEMENTS
   ============================================= */

/* Required asterisk */
.field-required {
  color: #f87171;
  margin-left: 2px;
  font-size: 0.85em;
}

/* Inline field error text */
.field-error {
  display: block;
  font-size: 0.8rem;
  color: #f87171;
  margin-top: 4px;
  min-height: 0;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 0.25s ease, opacity 0.25s ease;
}
.field-error.visible {
  max-height: 40px;
  opacity: 1;
}

/* Input error border */
.form-group input.input-error,
.form-group textarea.input-error {
  border-color: #f87171 !important;
  background: rgba(248, 113, 113, 0.04) !important;
  animation: fieldShake 0.4s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}
@keyframes fieldShake {
  0%,100% { transform: translateX(0); }
  20%      { transform: translateX(-6px); }
  40%      { transform: translateX(6px); }
  60%      { transform: translateX(-4px); }
  80%      { transform: translateX(4px); }
}

/* Button spinner */
.btn-spinner {
  display: none;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ===== TOAST NOTIFICATION ===== */
.toast-notification {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  z-index: 9999;
  display: flex;
  align-items: center;
  gap: 14px;
  background: #1a2540;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 14px;
  padding: 16px 20px;
  min-width: 300px;
  max-width: 90vw;
  box-shadow: 0 8px 40px rgba(0,0,0,0.5);
  opacity: 0;
  transition: transform 0.4s cubic-bezier(0.34,1.56,0.64,1),
              opacity 0.35s ease;
  pointer-events: none;
}
.toast-notification.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}
.toast-notification.toast-success {
  border-color: rgba(16,185,129,0.35);
  box-shadow: 0 8px 40px rgba(0,0,0,0.5), 0 0 0 1px rgba(16,185,129,0.15);
}
.toast-notification.toast-error {
  border-color: rgba(248,113,113,0.35);
  box-shadow: 0 8px 40px rgba(0,0,0,0.5), 0 0 0 1px rgba(248,113,113,0.15);
}

.toast-icon { font-size: 1.4rem; flex-shrink: 0; }

.toast-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}
.toast-body strong {
  font-size: 0.92rem;
  color: #f1f5f9;
  font-weight: 700;
}
.toast-body span {
  font-size: 0.82rem;
  color: #94a3b8;
  line-height: 1.4;
}

.toast-close {
  background: none;
  border: none;
  color: #64748b;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  transition: color 0.2s ease;
  flex-shrink: 0;
}
.toast-close:hover { color: #f1f5f9; }

/* Light mode toast */
body.light-mode .toast-notification {
  background: #ffffff;
  border-color: rgba(0,0,0,0.1);
}
body.light-mode .toast-body strong { color: #0f172a; }
body.light-mode .toast-body span   { color: #475569; }
body.light-mode .toast-close       { color: #94a3b8; }

/* Toast on mobile — full‑width bottom */
@media (max-width: 480px) {
  .toast-notification {
    bottom: 0;
    left: 0;
    right: 0;
    transform: translateY(100%);
    border-radius: 14px 14px 0 0;
    max-width: 100%;
    min-width: unset;
  }
  .toast-notification.show {
    transform: translateY(0);
  }
}

