
@tailwind base;
@tailwind components;
@tailwind utilities;

@layer base {
  :root {
    --on-background: #1b1b1b;
    --surface-container-highest: #e2e2e2;
    --surface-container-high: #e8e8e8;
    --outline-variant: #cfc4c5;
    --surface-container: #eeeeee;
    --background: #f9f9f9;
    --primary: #000000;
    --on-primary: #ffffff;
    --secondary: #5d5e63;
    --surface: #ffffff;
    --outline: #7e7576;
    --surface-container-low: #f3f3f3;
  }

  .dark {
    --on-background: #f5f5f7;
    --surface-container-highest: #3a3a3c;
    --surface-container-high: #2c2c2e;
    --outline-variant: #38383a;
    --surface-container: #1c1c1e;
    --background: #000000;
    --primary: #ffffff;
    --on-primary: #000000;
    --secondary: #86868b;
    --surface: #000000;
    --outline: #555555;
    --surface-container-low: #1c1c1e;
  }
}

.glass-card {
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.dark .glass-card {
  background: rgba(28, 28, 30, 0.7);
}

.ios-shadow {
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
}

.dark .ios-shadow {
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.custom-scrollbar::-webkit-scrollbar {
  height: 8px;
}

.custom-scrollbar::-webkit-scrollbar-track {
  background: var(--surface-container-high);
  border-radius: 4px;
}

.custom-scrollbar::-webkit-scrollbar-thumb {
  background: var(--outline-variant);
  border-radius: 4px;
}

.custom-scrollbar::-webkit-scrollbar-thumb:hover {
  background: var(--outline);
}

/* ==========================================
   Apple-Style Segmented Control Navigation
   ========================================== */
:root {
  /* Exact iOS 17/18 Colors */
  --bg-track: rgba(118, 118, 128, 0.12);
  --pill-color: #ffffff;
  --divider-color: rgba(0, 0, 0, 0.15);
}

.dark {
  --bg-track: rgba(118, 118, 128, 0.24);
  --pill-color: rgba(255, 255, 255, 0.22);
  --divider-color: rgba(255, 255, 255, 0.15);
}

.segmented-control {
  position: relative;
  display: flex;
  align-items: center;
  width: 480px; /* Expanded width for 5 items */
  background: var(--bg-track);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  padding: 2px;
  border-radius: 9px;
  user-select: none;
  border: 0.5px solid rgba(0, 0, 0, 0.04);
  transition: all 0.3s;
  z-index: 1;
}

.dark .segmented-control {
  border-color: rgba(255, 255, 255, 0.04);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
}

/* Hide the radio dots */
.segmented-control input[type="radio"] {
  display: none !important;
}

.segmented-control label {
  position: relative;
  flex: 1;
  text-align: center;
  padding: 6px 0;
  font-size: 13px;
  font-weight: 500;
  color: #000000;
  z-index: 2;
  cursor: pointer;
  transition: color 0.2s ease, transform 0.1s ease;
}

.dark .segmented-control label {
  color: rgba(255, 255, 255, 0.7);
}

.segmented-control label:hover {
  color: #000000;
}

.dark .segmented-control label:hover {
  color: #ffffff;
}

.segmented-control label:active {
  transform: scale(0.97);
}

/* Selected text styling */
.segmented-control input:checked + label {
  font-weight: 600;
  color: #000000;
}

.dark .segmented-control input:checked + label {
  color: #ffffff;
}

/* Creating the thin dividers between items */
.segmented-control label:not(:last-of-type)::after {
  content: "";
  position: absolute;
  right: 0;
  top: 20%;
  height: 60%;
  width: 1px;
  background-color: var(--divider-color);
  transition: opacity 0.2s;
}

/* Hide divider to the right of the active tab */
#nav-home:checked + label::after,
#nav-projects:checked + label::after,
#nav-experience:checked + label::after,
#nav-resume:checked + label::after {
  opacity: 0;
}

/* Hide divider to the left of the active tab using :has() */
.segmented-control:has(#nav-projects:checked) label[for="nav-home"]::after,
.segmented-control:has(#nav-experience:checked) label[for="nav-projects"]::after,
.segmented-control:has(#nav-resume:checked) label[for="nav-experience"]::after,
.segmented-control:has(#nav-contact:checked) label[for="nav-resume"]::after {
  opacity: 0;
}

/* The sliding white pill */
.selection-pill {
  position: absolute;
  top: 2px;
  bottom: 2px;
  left: 2px;
  width: calc(20% - 4px); /* Perfect mathematical inset for 5 items */
  background: var(--pill-color);
  border-radius: 7px;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.12), 0 3px 1px rgba(0, 0, 0, 0.04);
  z-index: 1;
  /* iOS Snappy "Spring" Animation Curve */
  transition: transform 0.3s cubic-bezier(0.25, 1, 0.5, 1);
  pointer-events: none;
}

.dark .selection-pill {
  border: 0.5px solid rgba(255, 255, 255, 0.04);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

/* Animation Logic: Moving the selection-pill perfectly centered with 2px padding inset gaps */
#nav-home:checked ~ .selection-pill { transform: translateX(0); }
#nav-projects:checked ~ .selection-pill { transform: translateX(calc(100% + 4px)); }
#nav-experience:checked ~ .selection-pill { transform: translateX(calc(200% + 8px)); }
#nav-resume:checked ~ .selection-pill { transform: translateX(calc(300% + 12px)); }
#nav-contact:checked ~ .selection-pill { transform: translateX(calc(400% + 16px)); }

/* SPA Content Area Fade Transition */
#content-area {
  transition: opacity 0.2s ease-in-out;
  opacity: 1;
}
#content-area.page-exit {
  opacity: 0;
}
#content-area.page-enter {
  opacity: 0;
}

/* --- RESPONSIVE MOBILE NAVIGATION BYPASS & FORCING --- */
@media (max-width: 768px) {
  /* 1. Force hide the desktop segmented control completely on mobile */
  .segmented-control {
    display: none !important;
  }

  /* 2. Force show the mobile hamburger trigger parent wrapper and icon */
  .md\:hidden {
    display: flex !important;
  }
  
  #mobile-menu-trigger {
    display: block !important;
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 24px;
    padding: 0.5rem;
    transition: transform 0.2s ease;
  }

  /* 3. Style the mobile menu dropdown to look premium, glassy, and centered */
  #mobile-menu {
    position: absolute;
    top: 80px; /* Exact height of top navbar */
    left: 0;
    width: 100%;
    background: var(--background) !important;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--outline-variant);
    padding: 1.5rem 0;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
    z-index: 999;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    transition: all 0.3s cubic-bezier(0.25, 1, 0.5, 1);
  }

  #mobile-menu.hidden {
    display: none !important;
  }

  #mobile-menu.flex {
    display: flex !important;
  }

  #mobile-menu a {
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    color: var(--secondary) !important;
    text-decoration: none;
    transition: color 0.2s ease;
  }

  #mobile-menu a.text-on-background {
    color: var(--on-background) !important;
  }

  #mobile-menu a:hover {
    color: var(--on-background) !important;
  }
}
