/*
=================================================================
  New Professional Stylesheet for Rittik Paul's Portfolio
  Author: Gemini
  Version: 2.7 (Advanced Share Feature)
  Description: A complete rewrite focusing on modern design,
               theming (light/dark), and maintainability.
=================================================================
*/

/* ===== 1. THEME & DESIGN TOKENS (VARIABLES) ===== */
:root {
  /* Fonts */
  --font-body: "Inter", system-ui, -apple-system, Segoe UI, Roboto, "Helvetica Neue", Arial, sans-serif;
  
  /* Typography Scale */
  --text-base: 1rem;       /* 16px */
  --text-lg: 1.125rem;    /* 18px */
  --text-xl: 1.25rem;     /* 20px */
  --text-2xl: 1.5rem;     /* 24px */
  --text-3xl: 2rem;       /* 32px */
  --text-4xl: 2.5rem;     /* 40px */
  
  /* Spacing Scale */
  --space-1: 0.25rem; /* 4px */
  --space-2: 0.5rem;  /* 8px */
  --space-3: 0.75rem; /* 12px */
  --space-4: 1rem;    /* 16px */
  --space-5: 1.25rem; /* 20px */
  --space-6: 1.5rem;  /* 24px */
  --space-8: 2rem;    /* 32px */
  --space-12: 3rem;   /* 48px */
  --space-16: 4rem;   /* 64px */

  /* Border Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  /* Transitions */
  --transition-fast: all 0.2s ease-in-out;
  --transition-smooth: all 0.3s ease-in-out;
  
  /* ------------------- DARK THEME (DEFAULT) ------------------- */
  --bg: #0D1117;
  --panel: #161B22;
  --text-primary: #e6edf3;
  --text-secondary: #a1aab5;
  --text-muted: #7d8590;
  --accent: #58A6FF;
  --accent-faded: rgba(88, 166, 255, 0.15);
  --border: rgba(255, 255, 255, 0.1);
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  --nav-bg: rgba(13, 17, 23, 0.7);
}

/* ------------------- LIGHT THEME ------------------- */
html[data-theme='light'] {
  --bg: #f6f8fa;
  --panel: #ffffff;
  --text-primary: #24292f;
  --text-secondary: #4e5661;
  --text-muted: #6e7781;
  --accent: #0969DA;
  --accent-faded: rgba(9, 105, 218, 0.1);
  --border: rgba(0, 0, 0, 0.1);
  --shadow: 0 8px 24px rgba(9, 105, 218, 0.1);
  --nav-bg: rgba(246, 248, 250, 0.7);
}

/* ===== 2. GLOBAL RESETS & BASE STYLES ===== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  background-color: var(--bg);
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color 0.3s ease, color 0.3s ease;
}

h1, h2, h3, h4, h5, h6 {
  color: var(--text-primary);
  line-height: 1.3;
  font-weight: 600;
}

h1 { font-size: var(--text-4xl); }
h2 { font-size: var(--text-3xl); }
h3 { font-size: var(--text-xl); }

p { margin-bottom: var(--space-4); }
p:last-child { margin-bottom: 0; }

a {
  color: var(--accent);
  text-decoration: none;
  transition: var(--transition-fast);
}
a:hover { text-decoration: underline; }

img {
  max-width: 100%;
  display: block;
}

/* ===== 3. LAYOUT & CONTAINER ===== */
.container {
  width: 100%;
  max-width: 1100px;
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--space-5);
  padding-right: var(--space-5);
}

/* ===== 4. COMPONENT: NAVIGATION BAR ===== */
.navbar {
  position: sticky;
  top: 0;
  z-index: 1000;
  background-color: var(--nav-bg);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.nav-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 70px;
}

.nav-logo {
  font-weight: 700;
  font-size: var(--text-xl);
  color: var(--text-primary);
}
.nav-logo:hover { text-decoration: none; }

.nav-links-wrapper {
  display: flex;
  align-items: center;
  gap: var(--space-6);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  list-style: none;
}

.nav-links a {
  position: relative;
  padding: var(--space-2) var(--space-3);
  color: var(--text-secondary);
  font-weight: 500;
  border-radius: var(--radius-sm);
  transition: color 0.2s ease;
}

.nav-links a::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 0;
  height: 2px;
  background-color: var(--accent);
  transition: all 0.3s ease;
}

.nav-links a:hover {
  color: var(--text-primary);
  text-decoration: none;
}

.nav-links a:hover::after,
.nav-links a.active::after {
  width: 100%;
  left: 0;
}

.nav-links a.active {
  color: var(--text-primary);
  font-weight: 600;
}

.nav-actions {
  display: flex;
  align-items: center;
}

.user-info {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  background-color: var(--panel);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

#userEmail {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
  max-width: 150px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-auth-logout {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-weight: 600;
  padding: 0;
}
.btn-auth-logout:hover {
  text-decoration: underline;
}

.menu-toggle { display: none; }

/* ===== 5. COMPONENT: INTRO/HEADER ===== */
.intro-section {
  padding: var(--space-16) 0;
  text-align: center;
  border-bottom: 1px solid var(--border);
}

.profile-pic {
  width: 160px;
  height: 160px;
  border-radius: 50%;
  border: 4px solid var(--panel);
  box-shadow: 0 0 0 2px var(--border), var(--shadow);
  margin: 0 auto var(--space-6);
  transition: var(--transition-smooth);
}
.profile-pic:hover {
  transform: scale(1.05);
  box-shadow: 0 0 0 2px var(--accent), var(--shadow);
}

.intro-section h1 {
  margin-bottom: var(--space-2);
}

.designation {
  font-size: var(--text-lg);
  color: var(--text-primary);
  font-weight: 500;
}

.side-role {
  color: var(--text-muted);
}

/* ===== 6. COMPONENT: SECTIONS ===== */
section {
  padding: var(--space-16) 0;
  border-bottom: 1px solid var(--border);
}
section:last-of-type {
  border-bottom: none;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-8);
}

/* ===== 7. COMPONENT: CARDS (Skills & Insights) ===== */
.skills-grid, .insights-grid {
  display: grid;
  gap: var(--space-6);
}

.skills-grid { grid-template-columns: repeat(2, 1fr); }
.insights-grid { grid-template-columns: repeat(3, 1fr); }

.skill-card, .insight-card {
  background-color: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-6);
  transition: var(--transition-smooth);
}

.skill-card h3, .insight-card h3 {
  margin-bottom: var(--space-3);
}

.skill-card ul {
  padding-left: var(--space-5);
  color: var(--text-secondary);
}

.insight-card {
  padding: var(--space-4);
  text-align: left;
}
.insight-card:hover {
  transform: translateY(-5px);
  border-color: var(--accent);
  box-shadow: var(--shadow);
}

.insight-card .thumb {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: var(--space-4);
  background-color: var(--bg);
}

.insight-card .thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.insight-card .date {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: var(--space-3);
}

.insight-card .excerpt {
  margin-bottom: var(--space-4);
}

.insight-card .read-more {
  font-weight: 600;
}

/* ===== 8. COMPONENT: BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
  border: 1px solid transparent;
}
.btn-outline {
  color: var(--accent);
  border-color: var(--accent);
  background: transparent;
}
.btn-outline:hover {
  background-color: var(--accent-faded);
  text-decoration: none;
}

/* ===== 9. COMPONENT: CONTACT INFO ===== */
.contact-info ul {
  list-style: none;
  margin-top: var(--space-6);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-4);
}

.contact-info li {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.contact-info a {
  color: var(--text-secondary);
  font-weight: 500;
}

.contact-info a:hover {
  color: var(--accent);
  text-decoration: none;
}

/* ===== 10. COMPONENT: MODALS ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(3, 6, 10, 0.6);
  backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: var(--space-5);
  z-index: 1200;
}
html[data-theme='light'] .modal-overlay {
  background: rgba(246, 248, 250, 0.6);
}

.modal-content {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  max-width: 760px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  padding: var(--space-8);
}

.close-btn {
  position: absolute;
  top: var(--space-4);
  right: var(--space-4);
  font-size: 2rem;
  cursor: pointer;
  color: var(--text-muted);
}
.close-btn:hover { color: var(--text-primary); }

/* ===== 11. COMPONENT: BLOG POSTS ===== */
.blog-list-section {
  padding-top: var(--space-12);
}
.post-full-content {
  position: relative; /* Needed for floating share button positioning */
  max-width: 75ch; /* Optimal for reading */
  margin: var(--space-12) auto;
}
.post-title { margin-bottom: var(--space-3); }
.post-meta {
  color: var(--text-muted);
  margin-bottom: var(--space-8);
}
.post-featured-image {
  border-radius: var(--radius-md);
  margin-bottom: var(--space-8);
}
.post-body h2, .post-body h3 { margin: var(--space-8) 0 var(--space-4); }
.post-body p {
  font-size: var(--text-lg);
  text-align: justify;
}
.post-body blockquote {
  border-left: 3px solid var(--accent);
  margin: var(--space-6) 0;
  padding-left: var(--space-5);
  font-style: italic;
  color: var(--text-primary);
}
.post-body pre {
  background-color: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-4);
  overflow-x: auto;
  font-size: 0.9em;
}

/* ===== 12. UTILITIES & HELPERS ===== */
.back-to-top {
  position: fixed;
  right: var(--space-5);
  bottom: var(--space-5);
  width: 50px;
  height: 50px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background-color: var(--panel);
  color: var(--text-secondary);
  display: grid;
  place-items: center;
  cursor: pointer;
  z-index: 1100;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: var(--transition-smooth);
}
.back-to-top.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.back-to-top:hover {
  background-color: var(--bg);
  color: var(--accent);
}

.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: 40px;
  height: 40px;
  padding: 8px;
  border-radius: 50%;
  cursor: pointer;
  transition: var(--transition-fast);
}
.theme-toggle:hover {
  color: var(--text-primary);
  border-color: var(--accent);
}
.theme-toggle svg { width: 100%; height: 100%; }
.theme-toggle .moon { display: block; }
.theme-toggle .sun { display: none; }
html[data-theme='light'] .theme-toggle .moon { display: none; }
html[data-theme='light'] .theme-toggle .sun { display: block; }

/* ===== 13. RESPONSIVE MEDIA QUERIES ===== */
@media (max-width: 980px) {
  .insights-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 820px) {
  .menu-toggle {
    display: block;
    cursor: pointer;
    z-index: 1001; /* Above nav links */
  }
  .nav-links-wrapper {
    position: absolute;
    top: 70px;
    right: var(--space-5);
    width: min(280px, calc(100% - var(--space-5) * 2));
    padding: var(--space-4);
    background-color: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow);
    display: none; /* Toggled by JS */
  }
  .nav-links-wrapper.show { display: block; }
  .nav-links { flex-direction: column; align-items: stretch; }
  .nav-links li { width: 100%; }
  .nav-links a { display: block; width: 100%; }
  .theme-toggle {
    margin-top: var(--space-2);
    width: 100%;
    border-radius: var(--radius-sm);
  }
}

@media (max-width: 720px) {
  h1 { font-size: var(--text-3xl); }
  h2 { font-size: var(--text-2xl); }
  section { padding: var(--space-12) 0; }
  .skills-grid { grid-template-columns: 1fr; }
  .insights-grid { grid-template-columns: 1fr; }
  .share-buttons-floating { display: none; } /* Hide floating share on small screens */
}

/* =================================
   14. Mobile Menu Icon Animation
   ================================= */
.menu-toggle svg {
  transition: transform 0.3s ease;
}

.menu-toggle.active svg {
  transform: rotate(180deg);
}

/* This creates the 'X' shape */
.menu-toggle .hamburger-icon { display: block; }
.menu-toggle .close-icon { display: none; }

.menu-toggle.active .hamburger-icon { display: none; }
.menu-toggle.active .close-icon { display: block; }

/* =================================
   15. Homepage Text Alignment
   ================================= */
/* Center align text content for specified sections on the homepage */
#about .container,
#philosophy .container,
#contact .container,
#skills .container {
  text-align: center;
}

/* Add spacing below section headings to improve separation */
#about h2,
#philosophy h2,
#skills h2,
#contact h2 {
    margin-bottom: var(--space-8);
}

/* Justify and constrain width of long text blocks for readability */
#about p,
#philosophy p {
    max-width: 75ch; /* Optimal characters per line for reading */
    margin-left: auto;
    margin-right: auto;
    text-align: justify;
}

/* Reset text-align for child elements that should remain left-aligned */
#contact .contact-info ul,
#skills .skill-card {
  text-align: left;
}

/* Use inline-grid for the contact list to allow the grid itself to be centered. */
#contact .contact-info ul {
  display: inline-grid;
}

/* =================================
   16. Component: Bottom Share Buttons
   ================================= */
.share-buttons-bottom {
  margin-top: var(--space-12);
  padding-top: var(--space-8);
  border-top: 1px solid var(--border);
  text-align: center;
}

.share-title {
  font-size: var(--text-lg);
  color: var(--text-secondary);
  margin-bottom: var(--space-4);
  font-weight: 500;
}

.share-buttons-bottom .share-links {
  display: flex;
  justify-content: center;
  gap: var(--space-4);
}

.share-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--text-secondary);
  transition: var(--transition-fast);
  background-color: transparent;
  cursor: pointer;
  padding: 0;
}

.share-link:hover {
  color: var(--text-primary);
  border-color: var(--accent);
  transform: translateY(-2px);
  text-decoration: none;
}

.share-link svg {
  width: 20px;
  height: 20px;
}

/* =================================
   17. Component: Floating Share Buttons
   ================================= */
.share-buttons-floating {
  position: absolute;
  top: 0;
  right: calc(-1 * var(--space-16)); /* Position it outside the main content area */
  z-index: 10;
}

.main-share-btn {
  background-color: var(--panel);
}

.floating-dropdown {
  position: absolute;
  top: calc(100% + var(--space-3));
  left: 50%;
  transform: translateX(-50%);
  background-color: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-2);
  
  /* Hidden by default */
  opacity: 0;
  visibility: hidden;
  transform: translate(-50%, 10px);
  transition: opacity 0.2s ease, visibility 0.2s ease, transform 0.2s ease;
}

.floating-dropdown.show {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%);
}

.floating-dropdown .share-link {
  border: none;
  width: 40px;
  height: 40px;
}

