/*! HTML5 Boilerplate v9.0.1 | MIT License | https://html5boilerplate.com/ */

/* main.css 3.0.0 | MIT License | https://github.com/h5bp/main.css#readme */
/*
 * What follows is the result of much research on cross-browser styling.
 * Credit left inline and big thanks to Nicolas Gallagher, Jonathan Neal,
 * Kroc Camen, and the H5BP dev community and team.
 */

/* ==========================================================================
   Base styles: opinionated defaults
   ========================================================================== */

:root {
  --bg-primary: #060913;         /* Deeper space navy-black background */
  --bg-secondary: #0e1626;       /* Dark slate gray */
  --bg-card: rgba(22, 28, 45, 0.75); /* Opaque slate card */
  --border-color: rgba(255, 255, 255, 0.08);
  --border-highlight: rgba(56, 189, 248, 0.2);
  --accent-color: #38bdf8;       /* Tech cyan/sky blue */
  --accent-hover: #0ea5e9;       /* Darker sky blue */
  --text-primary: #f3f4f6;       /* White/slate gray light */
  --text-secondary: #cbd5e1;     /* Slate 300 */
  --text-muted: #94a3b8;         /* Slate 400 */
  
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.5);
  --shadow-accent: 0 4px 15px rgba(56, 189, 248, 0.25);
  
  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  
  --header-bg: rgba(6, 9, 19, 0.85); /* transulcent dark header matching new background */
  --button-secondary-hover: rgba(56, 189, 248, 0.1);
  --bg-nametag: rgba(30, 41, 59, 0.4);
  --bg-toggle: rgba(30, 41, 59, 0.6);
  --border-toggle: rgba(56, 189, 248, 0.25);
  --color-toggle: #38bdf8;
  --bg-toggle-hover: rgba(56, 189, 248, 0.15);
}

[data-theme="light"] {
  --bg-primary: #cbd5e1;         /* Slate 300 backdrop for high distinction */
  --bg-secondary: #e2e8f0;       /* Slate 200 top gradient */
  --bg-card: rgba(255, 255, 255, 0.96); /* Opaque white cards */
  --border-color: rgba(15, 23, 42, 0.12);
  --border-highlight: rgba(37, 99, 235, 0.2);
  --accent-color: #2563eb;       /* Rich royal blue accent */
  --accent-hover: #1d4ed8;       /* Darker royal blue */
  --text-primary: #0f172a;       /* Dark slate primary text */
  --text-secondary: #334155;     /* Dark slate secondary text */
  --text-muted: #475569;         /* Slate 600 muted text */
  
  --shadow-sm: 0 2px 5px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 4px 15px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 10px 30px rgba(15, 23, 42, 0.12);
  --shadow-accent: 0 4px 18px rgba(37, 99, 235, 0.15);
  
  --header-bg: rgba(226, 232, 240, 0.92); /* Slate 200 glassmorphism */
  --button-secondary-hover: rgba(37, 99, 235, 0.08);
  --bg-nametag: rgba(37, 99, 235, 0.08); /* Soft blue wash for nametag */
  --bg-toggle: rgba(255, 255, 255, 0.95);
  --border-toggle: rgba(37, 99, 235, 0.25);
  --color-toggle: #2563eb;
  --bg-toggle-hover: rgba(37, 99, 235, 0.1);
}

/* Smooth theme transition styling */
body.theme-transitioning,
body.theme-transitioning *,
body.theme-transitioning *::before,
body.theme-transitioning *::after {
  transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease, box-shadow 0.3s ease !important;
}

html {
  box-sizing: border-box;
  min-height: 100%;
  height: 100%;
  background-color: var(--bg-primary);
  background-image: radial-gradient(circle at top right, var(--bg-secondary) 0%, var(--bg-primary) 100%);
  background-attachment: fixed;
  scroll-behavior: smooth;
}

*, *:before, *:after {
  box-sizing: inherit;
}

body {
  width: 100%;
  margin: 0;
  padding: 0 2% 50px 2%;
  font-family: "Orbitron", sans-serif;
  color: var(--text-secondary);
  overflow-x: hidden;
  margin-top: 130px; /* Offset for the fixed header on desktop */
}

@media (max-width: 768px) {
  body {
    margin-top: 240px; /* Extra height for stacked header on mobile */
  }
}

.orbitron-orbfont {
  font-family: "Orbitron", sans-serif;
  font-optical-sizing: auto;
  font-weight: 500;
  font-style: normal;
}

/* ==========================================================================
   Header and Navigation Layout (Desktop and Mobile)
   ========================================================================== */

.header-bg-box {
  display: flex;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  gap: 2rem;
  padding: 15px 10%;
  background-color: var(--header-bg); /* Sleek translucent glassmorphism */
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  box-shadow: var(--shadow-md);
  z-index: 100;
  transition: var(--transition-smooth);
}

.myDiv {
  border-left: 4px solid var(--accent-color);
  background-color: var(--bg-nametag);
  border-top: 1px solid var(--border-color);
  border-right: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
  padding: 12px 24px;
  border-radius: 0 8px 8px 0;
  max-width: 500px;
  text-align: left;
  z-index: 100;
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.05);
}

.myDiv h1 {
  font-size: 1.6rem;
  font-weight: 700;
  margin: 0;
  letter-spacing: 0.05em;
  color: var(--text-primary);
}

.myDiv h3 {
  font-size: 0.85rem;
  font-weight: 500;
  margin: 4px 0 0 0;
  color: var(--accent-color);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.header-nav {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 2rem;
  opacity: 0;
  transform: translateY(-10px);
  pointer-events: none;
  transition: var(--transition-smooth);
}

.header-bg-box.scrolled .header-nav {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.nav-link {
  position: relative;
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 6px 0;
  transition: color 0.2s ease;
}

.nav-link:hover,
.nav-link.active {
  color: var(--accent-color);
}

.nav-link::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background-color: var(--accent-color);
  transform: scaleX(0);
  transform-origin: right;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-link:hover::after,
.nav-link.active::after {
  transform: scaleX(1);
  transform-origin: left;
}

@media (max-width: 1024px) {
  .header-nav {
    display: none !important;
  }
}

.theme-toggle-btn {
  background-color: var(--bg-toggle);
  border: 1px solid var(--border-toggle);
  color: var(--color-toggle);
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition-smooth);
}

.theme-toggle-btn:hover {
  background-color: var(--bg-toggle-hover);
  border-color: var(--accent-color);
  color: var(--accent-color);
  transform: scale(1.05);
  box-shadow: var(--shadow-md), var(--shadow-accent);
}

.theme-toggle-btn svg {
  width: 20px;
  height: 20px;
}

/* Toggle sun/moon based on active theme */
[data-theme="light"] .sun-icon {
  display: none;
}
[data-theme="light"] .moon-icon {
  display: block;
}

[data-theme="dark"] .sun-icon {
  display: block;
}
[data-theme="dark"] .moon-icon {
  display: none;
}

/* Also adjust flashlight visibility in light mode for a cleaner look */
[data-theme="light"] #flashlight {
  opacity: 0.05;
  background-blend-mode: soft-light;
}

.button-group {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 1rem;
}

.cv_container {
  display: inline-block;
  text-align: center;
  padding: 10px 24px;
  text-decoration: none;
  border-radius: 8px;
  font-weight: 600;
  font-size: 1rem;
  transition: var(--transition-smooth);
  cursor: pointer;
}

/* Primary Button: View CV */
.cv_container.btn-primary {
  background-color: var(--accent-color);
  color: var(--bg-primary);
  border: 2px solid var(--accent-color);
}

.cv_container.btn-primary:hover {
  background-color: var(--accent-hover);
  border-color: var(--accent-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-accent);
}

/* Secondary Button: Mail Me! */
.cv_container.btn-secondary {
  background-color: transparent;
  color: var(--accent-color);
  border: 2px solid var(--accent-color);
}

.cv_container.btn-secondary:hover {
  background-color: var(--button-secondary-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-accent);
}

@media (max-width: 768px) {
  .header-bg-box {
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 15px 20px;
    text-align: center;
  }

  .myDiv {
    border-left: none;
    border-top: 4px solid var(--accent-color);
    border-radius: 0 0 8px 8px;
    text-align: center;
    width: 100%;
    max-width: 100%;
  }

  .button-group {
    justify-content: center;
    width: 100%;
  }

  .cv_container {
    flex: 1;
    font-size: 0.95rem;
    padding: 8px 16px;
  }
}

/* Mobile Landscape Optimization */
@media (max-width: 900px) and (orientation: landscape), (max-height: 480px) and (orientation: landscape) {
  body {
    margin-top: 90px;
  }

  .header-bg-box {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    padding: 8px 5%;
    gap: 1rem;
  }

  .myDiv {
    border-right: none;
    border-top: none;
    border-left: 4px solid var(--accent-color);
    border-radius: 0 8px 8px 0;
    text-align: left;
    padding: 6px 12px;
    max-width: 50%;
    width: auto;
  }

  .myDiv h1 {
    font-size: 1.1rem;
  }

  .myDiv h3 {
    font-size: 0.7rem;
    margin-top: 2px;
  }

  .button-group {
    justify-content: flex-end;
    width: auto;
    gap: 0.5rem;
  }

  .cv_container {
    flex: none;
    padding: 6px 12px;
    font-size: 0.8rem;
  }

  .theme-toggle-btn {
    width: 32px;
    height: 32px;
    padding: 6px;
  }

  .theme-toggle-btn svg {
    width: 16px;
    height: 16px;
  }

  .work-section {
    scroll-margin-top: 100px;
  }
}

/* ==========================================================================
   Page Content Styling
   ========================================================================== */

.mainDiv {
  text-align: center;
  margin: 60px auto 40px auto;
  max-width: 800px;
  padding: 0 20px;
}

.mainDiv h1 {
  font-size: 2.2rem;
  font-weight: 700;
  margin-bottom: 15px;
  color: var(--text-primary);
}

.mainDiv p {
  color: var(--text-muted);
  font-size: 1.1rem;
  line-height: 1.5;
}

/* Tile Grid Container */
.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  max-width: 80%;
  margin: 0 auto 80px auto;
}

/* Individual Tile Styling */
.tile {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 35px 20px;
  text-align: center;
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 1.25rem;
  font-weight: bold;
  box-shadow: var(--shadow-sm);
  transition: var(--transition-smooth);
}

/* Hover effects for interactive tiles */
.tile:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-lg), var(--shadow-accent);
  border-color: var(--accent-color);
}

[data-theme="light"] .tile {
  background-color: var(--bg-card);
  border-color: rgba(37, 99, 235, 0.18);
  color: var(--text-secondary);
}

[data-theme="light"] .tile:hover {
  background-color: #ffffff;
  border-color: var(--accent-color);
  color: var(--accent-color);
}

/* Portfolio Work Sections */
.work-section {
  scroll-margin-top: 140px; /* Match offset of the fixed header */
  max-width: 80%;
  margin: 60px auto;
  padding: 40px;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  box-shadow: var(--shadow-md);
  transition: var(--transition-smooth);
}

@media (max-width: 768px) {
  .work-section {
    scroll-margin-top: 250px;
    max-width: 95%;
    padding: 24px 16px;
  }
}

.work-section h1 {
  font-size: 2rem;
  font-weight: 700;
  border-bottom: 2px solid var(--border-color);
  padding-bottom: 12px;
  margin-bottom: 24px;
  color: var(--text-primary);
}

.work-section h2 {
  font-size: 1.6rem;
  color: var(--text-primary);
  margin-top: 30px;
}

.work-section h3 {
  color: var(--accent-color);
  font-size: 1.3rem;
  margin-top: 24px;
  margin-bottom: 12px;
  font-weight: 600;
}

p {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.work-section p {
  line-height: 1.7;
  color: var(--text-secondary);
  font-size: 1.05rem;
  margin-bottom: 20px;
}

.project-item {
  display: flex;
  flex-direction: row;
  align-items: center; /* Centered vertically for a clean, balanced look */
  gap: 40px;
  margin: 40px 0;
}

.project-item .image-style {
  flex: 0 0 45%;
  width: 45%;
  max-width: 500px;
  margin: 0;
  display: block;
  height: auto;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  transition: var(--transition-smooth);
}

.project-item .image-style:hover {
  transform: scale(1.02);
  box-shadow: var(--shadow-lg);
  border-color: var(--border-highlight);
}

.project-item .project-details {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.project-item .project-details h3 {
  margin-top: 0;
  margin-bottom: 12px;
}

.project-item .project-details p:last-child {
  margin-bottom: 0;
}

.project-divider {
  border: 0;
  border-top: 1px solid var(--border-color);
  margin: 40px 0;
}

@media (max-width: 768px) {
  .project-item {
    flex-direction: column;
    align-items: stretch;
    gap: 20px;
    margin: 30px 0;
  }

  .project-item .image-style {
    flex: 0 0 100%;
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
  }
}

.image-style {
  display: block;
  width: 100%;
  max-width: 500px;
  height: auto;
  margin: 24px auto;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  transition: var(--transition-smooth);
}

.image-style:hover {
  transform: scale(1.02);
  box-shadow: var(--shadow-lg);
  border-color: var(--border-highlight);
}

/* Flashlight element (keep original definition layout in case of dynamic injection) */
#flashlight {
  z-index: -10;
  position: fixed;
  width: 100%;
  min-height: 100vh;
  --Xpos: 50vw;
  --Ypos: 50vh;
  background-image:
    radial-gradient(circle 9em at var(--Xpos) var(--Ypos), rgba(255,255,255,1) 100%, rgba(0,0,0,0.5) 0%),
    url('Images/traces.png'); /* Switched to white traces to match slate tone, fallbacks handled gracefully */
  background-size: auto, cover;
  background-position: center;
  background-attachment: fixed;
  background-blend-mode: multiply;
  opacity: 0.15; /* Subtled to make the dark mode professional */
}

/* ==========================================================================
   Boilerplate Helper Classes
   ========================================================================== */

::-moz-selection {
  background: var(--accent-hover);
  color: var(--bg-primary);
  text-shadow: none;
}

::selection {
  background: var(--accent-hover);
  color: var(--bg-primary);
  text-shadow: none;
}

hr {
  display: block;
  height: 1px;
  border: 0;
  border-top: 1px solid var(--border-color);
  margin: 2em 0;
  padding: 0;
}

audio,
canvas,
iframe,
img,
svg,
video {
  vertical-align: middle;
}

fieldset {
  border: 0;
  margin: 0;
  padding: 0;
}

textarea {
  resize: vertical;
}

.hidden,
[hidden] {
  display: none !important;
}

.visually-hidden {
  border: 0;
  clip: rect(0, 0, 0, 0);
  height: 1px;
  margin: -1px;
  overflow: hidden;
  padding: 0;
  position: absolute;
  white-space: nowrap;
  width: 1px;
}

.visually-hidden.focusable:active,
.visually-hidden.focusable:focus {
  clip: auto;
  height: auto;
  margin: 0;
  overflow: visible;
  position: static;
  white-space: inherit;
  width: auto;
}

.invisible {
  visibility: hidden;
}

.clearfix::before,
.clearfix::after {
  content: "";
  display: table;
}

.clearfix::after {
  clear: both;
}

/* ==========================================================================
   Print styles
   ========================================================================== */

@media print {
  *,
  *::before,
  *::after {
    background: #fff !important;
    color: #000 !important;
    box-shadow: none !important;
    text-shadow: none !important;
  }

  a,
  a:visited {
    text-decoration: underline;
  }

  a[href]::after {
    content: " (" attr(href) ")";
  }

  abbr[title]::after {
    content: " (" attr(title) ")";
  }

  a[href^="#"]::after,
  a[href^="javascript:"]::after {
    content: "";
  }

  pre {
    white-space: pre-wrap !important;
  }

  pre,
  blockquote {
    border: 1px solid #999;
    page-break-inside: avoid;
  }

  tr,
  img {
    page-break-inside: avoid;
  }

  p,
  h2,
  h3 {
    orphans: 3;
    widows: 3;
  }

  h2,
  h3 {
    page-break-after: avoid;
  }
}

/* ==========================================================================
   Interactive UI & Enhancements
   ========================================================================== */

/* Clickable images hint */
.project-item .image-style {
  cursor: pointer;
}

/* Social Icon Link Styling */
.social-icon-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border-toggle);
  background-color: var(--bg-toggle);
  color: var(--color-toggle);
  text-decoration: none;
  box-shadow: var(--shadow-sm);
  transition: var(--transition-smooth);
}

.social-icon-link:hover {
  background-color: var(--bg-toggle-hover);
  border-color: var(--accent-color);
  color: var(--accent-color);
  transform: scale(1.05);
  box-shadow: var(--shadow-md), var(--shadow-accent);
}

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

/* Scroll-to-Top Button */
.scroll-top-btn {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1px solid var(--border-toggle);
  background-color: var(--bg-toggle);
  color: var(--color-toggle);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-md);
  z-index: 99;
  opacity: 0;
  pointer-events: none;
  transform: translateY(15px);
  transition: var(--transition-smooth);
}

.scroll-top-btn.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.scroll-top-btn:hover {
  background-color: var(--bg-toggle-hover);
  border-color: var(--accent-color);
  color: var(--accent-color);
  transform: scale(1.05);
  box-shadow: var(--shadow-lg), var(--shadow-accent);
}

.scroll-top-btn svg {
  width: 20px;
  height: 20px;
}

/* Prevent page scroll when lightbox is active */
body.lightbox-open {
  overflow: hidden;
}

/* Image Lightbox Modal Overlay */
.lightbox-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(6, 9, 19, 0.9);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  padding: 40px;
}

.lightbox-overlay[aria-hidden="false"] {
  opacity: 1;
  pointer-events: auto;
}

.lightbox-image {
  max-width: 90vw;
  max-height: 75vh;
  border-radius: 8px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.1);
  transform: translate(0px, 0px) scale(0.95);
  transition: transform 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
  object-fit: contain;
  cursor: zoom-in;
  user-select: none;
  -webkit-user-drag: none;
}

.lightbox-image.dragging {
  transition: none !important;
}

.lightbox-overlay[aria-hidden="false"] .lightbox-image {
  transform: translate(0px, 0px) scale(1);
}

.lightbox-caption {
  margin-top: 20px;
  color: var(--text-primary);
  font-size: 1.1rem;
  font-weight: 500;
  text-align: center;
}

.lightbox-close {
  position: absolute;
  top: 20px;
  right: 25px;
  background: transparent;
  border: none;
  color: #ffffff;
  font-size: 2.5rem;
  font-weight: 300;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.lightbox-close:hover {
  color: var(--accent-color);
  transform: scale(1.1);
}
