/*
 * Main Stylesheet for Thanathorn Sukprasert's Academic Website
 * Clean, modern design for academic content
 */

/* ============================================
   CSS Variables
   ============================================ */
:root {
  /* Colors - Blue and Yellow Palette */
  --color-primary: #014e85;        /* Dark blue */
  --color-primary-dark: #052561;
  --color-secondary: #547792;       /* Medium blue */
  --color-accent: #FAB95B;          /* Yellow */

  /* Text colors */
  --color-text: #2C2C2C;
  --color-text-light: #666;
  --color-text-lighter: #999;

  /* Background colors */
  --color-bg: #FFFFFF;
  --color-bg-alt: #FFFFFF;          /* Light beige */
  --color-bg-light: #ffffff;

  /* Border colors */
  --color-border: #D0CAC0;
  --color-border-light: #E8E2DB;

  /* Typography */
  --font-main: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
  --font-mono: 'SF Mono', 'Monaco', 'Consolas', 'Courier New', monospace;

  /* Spacing */
  --spacing-xs: 0.5rem;
  --spacing-sm: 1rem;
  --spacing-md: 1.5rem;
  --spacing-lg: 2rem;
  --spacing-xl: 3rem;
  --spacing-xxl: 4rem;

  /* Layout */
  --max-width: 1200px;
  --max-width-narrow: 800px;

  /* Effects */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 20px rgba(0, 0, 0, 0.15);

  --transition: all 0.3s ease;
}

/* ============================================
   Reset & Base Styles
   ============================================ */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

body {
  font-family: var(--font-main);
  color: var(--color-text);
  line-height: 1.7;
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ============================================
   Typography
   ============================================ */
h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: var(--spacing-sm);
  color: var(--color-text);
}

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

p {
  margin-bottom: var(--spacing-sm);
}

a {
  color: var(--color-primary);
  text-decoration: none;
  transition: var(--transition);
}

a:hover {
  color: var(--color-primary-dark);
  text-decoration: underline;
}

strong {
  font-weight: 600;
}

code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--color-bg-alt);
  padding: 0.2em 0.4em;
  border-radius: 3px;
}

/* ============================================
   Layout
   ============================================ */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--spacing-md);
}

.container-narrow {
  max-width: var(--max-width-narrow);
  margin: 0 auto;
  padding: 0 var(--spacing-md);
}

/* ============================================
   Header & Navigation
   ============================================ */
header {
  background: var(--color-primary);
  color: white;
  padding: var(--spacing-md) 0;
  box-shadow: var(--shadow-md);
  position: sticky;
  top: 0;
  z-index: 1000;
}

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

.site-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: white;
  margin: 0;
}

.site-title a {
  color: white;
  text-decoration: none;
}

.site-title a:hover {
  text-decoration: none;
  opacity: 0.9;
}

nav ul {
  list-style: none;
  display: flex;
  gap: var(--spacing-lg);
  margin: 0;
  padding: 0;
}

nav li {
  margin: 0;
}

nav a {
  color: white;
  font-weight: 500;
  padding: var(--spacing-xs) 0;
  border-bottom: 2px solid transparent;
  transition: var(--transition);
}

nav a:hover,
nav a.active {
  border-bottom-color: white;
  text-decoration: none;
}

/* ============================================
   Hero Section
   ============================================ */
.hero {
  padding: var(--spacing-xxl) 0;
  background: linear-gradient(135deg, var(--color-bg-light) 0%, var(--color-bg-alt) 100%);
}

.hero-content {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: var(--spacing-xl);
  align-items: center;
}

.hero-image img {
  width: 100%;
  max-width: 300px;
  border-radius: 50%;
  box-shadow: var(--shadow-lg);
  border: 5px solid white;
}

.hero-text h1 {
  font-size: 2.8rem;
  margin-bottom: var(--spacing-xs);
}

.hero-text .subtitle {
  font-size: 1.3rem;
  color: var(--color-text-light);
  margin-bottom: var(--spacing-md);
}

.hero-text .affiliation {
  color: var(--color-text-lighter);
  margin-bottom: var(--spacing-lg);
}

.contact-links {
  display: flex;
  gap: var(--spacing-md);
  flex-wrap: wrap;
}

.contact-links a {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: var(--spacing-xs) var(--spacing-md);
  background: var(--color-primary);
  color: white;
  border-radius: 5px;
  font-weight: 500;
  transition: var(--transition);
}

.contact-links a:hover {
  background: var(--color-primary-dark);
  text-decoration: none;
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

/* ============================================
   Main Content
   ============================================ */
main {
  padding: var(--spacing-xxl) 0;
  min-height: calc(100vh - 300px);
}

section {
  margin-bottom: var(--spacing-xxl);
}

section:last-child {
  margin-bottom: 0;
}

.section-title {
  font-size: 2rem;
  margin-bottom: var(--spacing-lg);
  padding-bottom: var(--spacing-sm);
  border-bottom: 3px solid var(--color-primary);
  display: inline-block;
}

/* ============================================
   Publications
   ============================================ */
.publication {
  background: var(--color-bg-alt);
  padding: var(--spacing-lg);
  margin-bottom: var(--spacing-lg);
  border-left: 4px solid var(--color-primary);
  border-radius: 5px;
  transition: var(--transition);
}

.publication:hover {
  box-shadow: var(--shadow-md);
  transform: translateX(5px);
}

.pub-title {
  font-size: 1.3rem;
  margin-bottom: var(--spacing-xs);
  color: var(--color-text);
}

.pub-authors {
  color: var(--color-text-light);
  margin-bottom: var(--spacing-xs);
  font-size: 0.95rem;
}

.pub-authors strong {
  color: var(--color-text);
}

.pub-venue {
  color: var(--color-text-lighter);
  font-style: italic;
  margin-bottom: var(--spacing-md);
  font-size: 0.9rem;
}

.pub-links {
  display: flex;
  gap: var(--spacing-sm);
  flex-wrap: wrap;
}

.pub-links a {
  padding: 0.4rem 1rem;
  background: var(--color-primary);
  color: white;
  border-radius: 4px;
  font-size: 0.9rem;
  font-weight: 500;
  transition: var(--transition);
}

.pub-links a:hover {
  background: var(--color-primary-dark);
  text-decoration: none;
  transform: translateY(-2px);
}

/* ============================================
   PDF Viewer
   ============================================ */
.pdf-container {
  background: var(--color-bg-alt);
  padding: var(--spacing-md);
  border-radius: 8px;
  box-shadow: var(--shadow-md);
}

.pdf-controls {
  display: flex;
  gap: var(--spacing-sm);
  margin-bottom: var(--spacing-md);
  flex-wrap: wrap;
}

.pdf-viewer {
  width: 100%;
  height: 80vh;
  min-height: 600px;
  border: 1px solid var(--color-border);
  border-radius: 5px;
  background: white;
}

/* Fullpage PDF Viewer for CV */
.cv-fullpage {
  padding: 0;
  margin: 0;
  width: 100%;
  height: calc(100vh - 60px); /* Subtract header height */
}

.pdf-fullpage-container {
  width: 100%;
  height: 100%;
}

.pdf-viewer-fullpage {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

/* ============================================
   Running Map (Strava)
   ============================================ */
#running-map {
  height: 600px;
  width: 100%;
  border-radius: 8px;
  box-shadow: var(--shadow-md);
  margin-bottom: var(--spacing-lg);
}

.map-controls {
  background: var(--color-bg-alt);
  padding: var(--spacing-md);
  border-radius: 8px;
  margin-bottom: var(--spacing-lg);
  display: flex;
  gap: var(--spacing-md);
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
}

.stats-panel {
  background: var(--color-bg-alt);
  padding: var(--spacing-lg);
  border-radius: 8px;
  margin-bottom: var(--spacing-lg);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--spacing-lg);
}

.stat-item {
  text-align: center;
  padding: var(--spacing-md);
  background: white;
  border-radius: 5px;
  box-shadow: var(--shadow-sm);
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--color-primary);
  display: block;
}

.stat-label {
  color: var(--color-text-light);
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.auth-prompt {
  background: var(--color-bg-light);
  padding: var(--spacing-xxl);
  text-align: center;
  border-radius: 8px;
  border: 2px dashed var(--color-border);
}

.auth-prompt h3 {
  margin-bottom: var(--spacing-md);
  color: var(--color-text-light);
}

/* ============================================
   Buttons
   ============================================ */
.btn {
  display: inline-block;
  padding: 0.7rem 1.5rem;
  background: var(--color-primary);
  color: white;
  border: none;
  border-radius: 5px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  text-align: center;
}

.btn:hover {
  background: var(--color-primary-dark);
  text-decoration: none;
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.btn-secondary {
  background: var(--color-secondary);
}

.btn-secondary:hover {
  background: #002D45;
}

.btn-accent {
  background: var(--color-accent);
}

.btn-accent:hover {
  background: #E64302;
}

.btn-outline {
  background: transparent;
  border: 2px solid var(--color-primary);
  color: var(--color-primary);
}

.btn-outline:hover {
  background: var(--color-primary);
  color: white;
}

/* ============================================
   Footer
   ============================================ */
footer {
  background: var(--color-bg-alt);
  padding: var(--spacing-xl) 0;
  margin-top: var(--spacing-xxl);
  border-top: 1px solid var(--color-border);
}

footer .container {
  text-align: center;
  color: var(--color-text-light);
}

footer p {
  margin: 0;
}

footer a {
  color: var(--color-primary);
}

/* ============================================
   Utility Classes
   ============================================ */
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-lg { margin-top: var(--spacing-lg); }
.mb-lg { margin-bottom: var(--spacing-lg); }
.hidden { display: none; }

/* Loading spinner */
.spinner {
  border: 3px solid var(--color-bg-alt);
  border-top: 3px solid var(--color-primary);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 1s linear infinite;
  margin: 0 auto;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* ============================================
   Leaflet Custom Styles
   ============================================ */
.leaflet-popup-content-wrapper {
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  max-height: 500px;
}

.leaflet-popup-content {
  max-height: 450px;
  overflow-y: auto;
  margin: 13px 19px;
}

.activity-popup h4 {
  color: var(--color-primary);
  margin-bottom: var(--spacing-xs);
}

.activity-popup p {
  margin-bottom: 0.3rem;
  font-size: 0.9rem;
}

.activity-popup a {
  display: inline-block;
  margin-top: var(--spacing-sm);
  color: var(--color-accent);
  font-weight: 500;
}

/* ============================================
   City Marker Custom Styles
   ============================================ */
.city-marker {
  font-size: 0.8rem;
  font-weight: 600;
  text-align: center;
}

.marker-pin {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background-color: var(--color-primary);
  border: 3px solid white;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  margin: 0 auto;
}

.marker-label {
  margin-top: 2px;
  color: var(--color-text);
  font-size: 0.75rem;
  text-shadow:
    -1px -1px 0 white,
    1px -1px 0 white,
    -1px 1px 0 white,
    1px 1px 0 white;
  white-space: nowrap;
}

.city-popup {
  min-width: 250px;
  max-width: 350px;
  font-family: var(--font-stack);
}

.city-popup h4 {
  font-size: 1.2rem;
  margin-bottom: 0.8rem;
  margin-top: 0;
  color: var(--color-primary);
  position: sticky;
  top: 0;
  background: white;
  z-index: 1;
  padding-bottom: 0.5rem;
}

.city-popup p {
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
  line-height: 1.5;
}

.notes-section {
  margin-top: 0.5rem;
}

.notes-section h5 {
  font-size: 1rem;
  color: var(--color-primary);
  margin-bottom: 0.8rem;
  position: sticky;
  top: 2.5rem;
  background: white;
  z-index: 1;
  padding-bottom: 0.3rem;
}

.note-item {
  font-size: 0.9rem;
  line-height: 1.6;
  margin-bottom: 0.8rem;
}

.note-item strong {
  color: var(--color-primary);
  font-size: 0.95rem;
}

.note-item p {
  margin-top: 0.3rem;
  margin-bottom: 0;
  color: var(--color-text);
}
