/* ==========================================================================
   Design System & Styling for Terence Tam Portfolio (Classic/Preserved)
   ========================================================================== */

/* Google Fonts Import - Matches original Open Sans + Lora style */
@import url('https://fonts.googleapis.com/css2?family=Lora:ital,wght@0,400;0,700;1,400;1,700&family=Open+Sans:ital,wght@0,300;0,400;0,600;0,700;0,800;1,300;1,400;1,600;1,700;1,800&display=swap');

/* Color Variables */
:root {
  /* Default: Light Theme (Preserving original colors) */
  --bg-primary: #ffffff;
  --bg-secondary: #f8f9fa;
  --text-primary: #333333;
  --text-secondary: #777777;
  --text-muted: #999999;
  
  /* Navbar transparent initially, transitions to white */
  --navbar-bg: rgba(255, 255, 255, 0.95);
  --navbar-text: #333333;
  
  /* Cards/Thumbnails matching traditional light aesthetic */
  --card-bg: #ffffff;
  --card-border: #dddddd;
  --card-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  
  /* Accents matching original links/buttons */
  --accent-science: #337ab7; /* Bootstrap Blue */
  --accent-science-glow: rgba(51, 122, 183, 0.08);
  --accent-art: #f0ad4e; /* Warm orange/gold */
  --accent-art-glow: rgba(240, 173, 78, 0.08);
  --accent-music: #5cb85c; /* Gentle green */
  --accent-music-glow: rgba(92, 184, 92, 0.08);
  --accent-primary: #0085a1; /* Original Clean Blog teal/blue */
  --accent-primary-glow: rgba(0, 133, 161, 0.08);
  
  --divider: #eeeeee;
  --toggle-btn-bg: #eeeeee;
}

[data-theme="dark"] {
  /* Optional Dark Theme Variables */
  --bg-primary: #121212;
  --bg-secondary: #1e1e1e;
  --text-primary: #e0e0e0;
  --text-secondary: #aaaaaa;
  --text-muted: #666666;
  --navbar-bg: rgba(18, 18, 18, 0.95);
  --navbar-text: #e0e0e0;
  
  --card-bg: #1e1e1e;
  --card-border: #333333;
  --card-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  
  --accent-science: #5bc0de;
  --accent-science-glow: rgba(91, 192, 222, 0.15);
  --accent-art: #f0ad4e;
  --accent-art-glow: rgba(240, 173, 78, 0.15);
  --accent-music: #5cb85c;
  --accent-music-glow: rgba(92, 184, 92, 0.15);
  --accent-primary: #5bc0de;
  --accent-primary-glow: rgba(91, 192, 222, 0.15);
  
  --divider: #333333;
  --toggle-btn-bg: #2d2d2d;
}

/* Base Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  padding-top: 0; /* Banner overlaps navbar at top */
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  font-weight: 800;
  line-height: 1.25;
  color: var(--text-primary);
}

h1 { font-size: 2.5rem; }
h2 { font-size: 2rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }

a {
  color: var(--accent-primary);
  text-decoration: none;
  transition: color 0.15s ease;
}

a:hover {
  color: var(--accent-science);
}

p {
  margin-bottom: 1.25rem;
  color: var(--text-primary);
}

/* Container */
.container {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* Navbar */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 60px;
  background-color: transparent;
  border-bottom: 1px solid transparent;
  z-index: 1000;
  display: flex;
  align-items: center;
  transition: transform 0.3s ease, background-color 0.25s ease, border-color 0.25s ease;
}

.navbar.navbar-scrolled {
  background-color: var(--navbar-bg);
  border-bottom: 1px solid var(--divider);
}

.navbar.navbar-hidden {
  transform: translateY(-100%);
}

.navbar .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.navbar-brand {
  font-size: 1.2rem;
  font-weight: 800;
  color: #ffffff; /* White initially */
  letter-spacing: -0.02em;
  transition: color 0.25s ease;
}

.navbar.navbar-scrolled .navbar-brand {
  color: var(--navbar-text); /* Transitions to dark/standard */
}

.navbar-brand:hover {
  color: #ffffff;
  opacity: 0.8;
}

.navbar.navbar-scrolled .navbar-brand:hover {
  color: var(--accent-primary);
  opacity: 1;
}

.navbar-nav {
  display: flex;
  list-style: none;
  align-items: center;
  gap: 1.5rem;
}

.navbar-nav a {
  font-size: 0.85rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: rgba(255, 255, 255, 0.8); /* White initially */
  padding: 0.5rem 0.25rem;
  transition: color 0.25s ease;
}

.navbar-nav a:hover,
.navbar-nav a.active {
  color: #ffffff;
}

.navbar.navbar-scrolled .navbar-nav a {
  color: var(--navbar-text); /* Transitions to dark/standard */
}

.navbar.navbar-scrolled .navbar-nav a:hover,
.navbar.navbar-scrolled .navbar-nav a.active {
  color: var(--accent-primary);
}

/* Mobile Toggle & Menu */
.navbar-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
}

.navbar-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  background-color: #ffffff; /* White initially */
  margin: 4px 0;
  transition: 0.3s;
}

.navbar.navbar-scrolled .navbar-toggle span {
  background-color: var(--navbar-text);
}
}

/* Theme Toggle Button */
.theme-toggle-btn {
  background-color: var(--toggle-btn-bg);
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--navbar-text);
  transition: transform 0.2s ease;
}

.theme-toggle-btn:hover {
  transform: scale(1.05);
}

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

/* Hero/Intro Header */
.intro-header {
  position: relative;
  background-size: cover;
  background-position: center;
  padding: 8rem 0;
  color: #ffffff;
  text-align: center;
  margin-bottom: 3rem;
  background-color: #808080;
}

.intro-header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 1;
}

.intro-header .container {
  position: relative;
  z-index: 2;
}

.site-heading h1 {
  font-size: 3.5rem;
  font-weight: 800;
  color: #ffffff;
  margin-bottom: 1rem;
}

.site-heading hr.small {
  width: 80px;
  height: 4px;
  background-color: #ffffff;
  border: none;
  margin: 1.5rem auto;
  border-radius: 2px;
}

.site-heading .subheading {
  font-size: 1.25rem;
  font-weight: 300;
  color: #ffffff;
  display: block;
}

/* Projects Section */
.page-header {
  font-size: 1.8rem;
  font-weight: 800;
  margin-bottom: 2rem;
  border-bottom: 1px solid var(--divider);
  padding-bottom: 0.75rem;
  position: relative;
}

.project-note {
  font-size: 0.95rem;
  color: var(--text-secondary);
  margin-top: -1.5rem;
  margin-bottom: 2.5rem;
  font-style: italic;
}

/* Grid Layout */
.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 2rem;
  margin-bottom: 4rem;
}

/* Preserved Thumbnail Design */
.project-card {
  background-color: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 4px;
  overflow: hidden;
  padding: 4px; /* Matches traditional thumbnail padding */
  box-shadow: var(--card-shadow);
  display: flex;
  flex-direction: column;
  height: 100%;
  transition: opacity 0.15s ease;
}

.project-card:hover {
  border-color: var(--accent-primary);
}

.project-card-image-wrapper {
  position: relative;
  width: 100%;
  padding-bottom: 75%; /* 4:3 aspect ratio */
  overflow: hidden;
  background-color: var(--bg-secondary);
}

.project-card-image {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.project-card-content {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  flex-grow: 1;
}

.project-card-tag {
  font-size: 0.75rem;
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.05em;
  margin-bottom: 0.35rem;
  color: var(--text-muted);
}

.project-card-title {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

.project-card-title a {
  color: var(--text-primary);
}

.project-card-title a:hover {
  color: var(--accent-primary);
}

.project-card-desc {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 1.25rem;
  flex-grow: 1;
}

.project-card-link {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--accent-primary);
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin-top: auto;
  align-self: flex-start;
}

/* Blog Section */
.blog-section {
  padding: 3rem 0;
  border-top: 1px solid var(--divider);
}

.blog-grid {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  margin-bottom: 3rem;
  max-width: 800px;
  margin-left: auto;
  margin-right: auto;
}

/* Clean Clean-Blog Style List Items */
.blog-card {
  display: flex;
  border-bottom: 1px solid var(--divider);
  padding-bottom: 1.5rem;
  gap: 1.5rem;
}

.blog-card:last-child {
  border-bottom: none;
}

.blog-card-thumbnail {
  width: 70px;
  height: 70px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
  border: 1px solid var(--card-border);
}

.blog-card-content {
  display: flex;
  flex-direction: column;
  justify-content: center;
  flex-grow: 1;
}

.blog-card-title {
  font-size: 1.35rem;
  font-family: 'Lora', 'Times New Roman', serif;
  margin-bottom: 0.25rem;
  font-weight: 700;
}

.blog-card-title a {
  color: var(--text-primary);
}

.blog-card-title a:hover {
  color: var(--accent-primary);
}

.blog-card-desc {
  font-size: 1rem;
  font-family: 'Lora', 'Times New Roman', serif;
  font-style: italic;
  margin-bottom: 0.5rem;
  color: var(--text-secondary);
}

.blog-card-meta {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.pager-container {
  display: flex;
  justify-content: flex-end;
  max-width: 800px;
  margin-left: auto;
  margin-right: auto;
}

.btn-pager {
  display: inline-flex;
  align-items: center;
  padding: 0.5rem 1.25rem;
  background-color: var(--accent-primary);
  border: 1px solid var(--accent-primary);
  border-radius: 0; /* original button style is flat square */
  color: #ffffff !important;
  font-weight: 800;
  text-transform: uppercase;
  font-size: 0.85rem;
  letter-spacing: 1px;
}

.btn-pager:hover {
  background-color: #006b82;
  border-color: #006b82;
}

/* Detail Pages Grid/Layouts */
.content-wrapper {
  padding: 3rem 0 5rem;
}

.detail-layout {
  max-width: 800px;
  margin: 0 auto;
}

.rich-text {
  font-size: 1.1rem;
  line-height: 1.7;
}

.rich-text p {
  margin-bottom: 1.5rem;
  color: var(--text-primary);
}

.rich-text img {
  border-radius: 4px;
  margin: 1.5rem 0;
  border: 1px solid var(--card-border);
  padding: 4px;
  max-width: 100%;
}

/* Custom styled blockquote - Preserving classic feel */
blockquote {
  font-family: 'Lora', 'Times New Roman', serif;
  font-size: 1.2rem;
  font-style: italic;
  border-left: 5px solid var(--text-muted);
  padding: 0.5rem 1.5rem;
  margin: 2rem 0;
  color: var(--text-secondary);
}

/* Artwork Masonry & Lightbox */
.art-gallery {
  column-count: 3;
  column-gap: 1.5rem;
  margin: 2rem 0 4rem;
}

@media (max-width: 900px) {
  .art-gallery { column-count: 2; }
}

@media (max-width: 600px) {
  .art-gallery { column-count: 1; }
}

.gallery-item {
  display: inline-block;
  width: 100%;
  margin-bottom: 1.5rem;
  background-color: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 4px;
  padding: 4px;
  box-shadow: var(--card-shadow);
  cursor: pointer;
}

.gallery-item:hover {
  border-color: var(--accent-primary);
}

.gallery-img {
  width: 100%;
  height: auto;
  display: block;
}

.gallery-info {
  padding: 0.75rem 0.5rem 0.25rem;
  text-align: center;
}

.gallery-title {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 0.15rem;
  color: var(--text-primary);
}

.gallery-type {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 700;
}

/* Lightbox Modal */
.lightbox-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.9);
  z-index: 2000;
  justify-content: center;
  align-items: center;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.lightbox-modal.active {
  display: flex;
  opacity: 1;
}

.lightbox-content-wrapper {
  max-width: 90%;
  max-height: 85%;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.lightbox-img {
  max-width: 100%;
  max-height: 75vh;
  object-fit: contain;
  border-radius: 2px;
  border: 4px solid #ffffff;
  box-shadow: 0 10px 25px rgba(0,0,0,0.5);
}

.lightbox-caption {
  color: #ffffff;
  margin-top: 1rem;
  text-align: center;
}

.lightbox-caption h4 {
  color: #ffffff;
  font-size: 1.1rem;
  margin-bottom: 0.15rem;
}

.lightbox-caption p {
  color: #cccccc;
  font-size: 0.85rem;
}

.lightbox-close {
  position: absolute;
  top: -40px;
  right: 0;
  background: none;
  border: none;
  color: #ffffff;
  font-size: 2rem;
  cursor: pointer;
  opacity: 0.7;
}

.lightbox-close:hover {
  opacity: 1;
}

/* Music Download Cards */
.music-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
  gap: 2rem;
  margin: 2rem 0;
}

@media (max-width: 600px) {
  .music-grid {
    grid-template-columns: 1fr;
  }
}

.music-card {
  background-color: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 4px;
  padding: 1.5rem;
  box-shadow: var(--card-shadow);
  display: flex;
  gap: 1.5rem;
  align-items: center;
}

.music-card:hover {
  border-color: var(--accent-primary);
}

.music-icon {
  width: 48px;
  height: 48px;
  background-color: var(--bg-secondary);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-primary);
  flex-shrink: 0;
}

.music-icon svg {
  width: 24px;
  height: 24px;
}

.music-details {
  flex-grow: 1;
}

.music-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 0.15rem;
}

.music-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  display: block;
}

.btn-download {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.85rem;
  background-color: var(--accent-primary);
  color: #ffffff !important;
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
  transition: opacity 0.15s;
}

.btn-download:hover {
  background-color: #006b82;
}

.btn-download svg {
  width: 12px;
  height: 12px;
}

/* Footer Section */
footer {
  margin-top: auto;
  padding: 3rem 0;
  border-top: 1px solid var(--divider);
  text-align: center;
}

.footer-socials {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
  list-style: none;
}

.footer-socials a {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--card-border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
  background-color: var(--bg-primary);
  box-shadow: 0 1px 2px rgba(0,0,0,0.02);
  transition: background-color 0.15s, color 0.15s;
}

.footer-socials a:hover {
  background-color: var(--accent-primary);
  border-color: var(--accent-primary);
  color: #ffffff;
}

.footer-socials svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

.copyright {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Responsive Overrides */
@media (max-width: 768px) {
  h1 { font-size: 2rem; }
  .site-heading h1 { font-size: 2.5rem; }
  body { padding-top: 0; }
  
  .navbar-toggle {
    display: block;
  }
  
  .navbar-nav {
    display: none;
    position: fixed;
    top: 60px;
    left: 0;
    right: 0;
    background-color: var(--bg-primary);
    border-bottom: 1px solid var(--divider);
    flex-direction: column;
    padding: 1.5rem;
    gap: 1rem;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
  }
  
  .navbar-nav.active {
    display: flex;
  }
  
  .blog-card {
    flex-direction: row;
  }
}
