@font-face {
  font-family: "Iosevka Term";
  src: url(../font/SGr-IosevkaTerm-Regular.ttc) format("truetype-collection");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

/* ===================== VARIABLES ===================== */
:root {
  --accent: #5588ff;
  --bg: #000;
  --fg: #fff;
  --muted: #888;
  --border: #222;
  --error: #ff6b6b;
  --error-bg: #1a0a0a;
  --transition: 0.2s ease;
  color-scheme: dark;
}

[data-theme="light"] {
  --accent: #2255cc;
  --bg: #fff;
  --fg: #000;
  --muted: #666;
  --border: #ddd;
  --error: #cc3333;
  --error-bg: #fff5f5;
  color-scheme: light;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --accent: #2255cc;
    --bg: #fff;
    --fg: #000;
    --muted: #666;
    --border: #ddd;
    --error: #cc3333;
    --error-bg: #fff5f5;
    color-scheme: light;
  }
}

/* ===================== RESET & BASE ===================== */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.7 "Iosevka Term", ui-monospace, monospace;
  margin: 0;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ===================== LAYOUT ===================== */
.site-container {
  max-width: 800px;
  margin: 0 auto;
  padding: 60px 24px;
}

/* ===================== TYPOGRAPHY ===================== */
h1 {
  font: 400 20px/1.4 inherit;
  margin: 0 0 40px;
}

h2 {
  font: 400 14px/1.4 inherit;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin: 48px 0 16px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

p { margin: 0 0 16px; }

a {
  color: var(--fg);
  text-decoration: none;
  border-bottom: 1px solid var(--border);
  transition: color var(--transition), border-color var(--transition);
}

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

ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

li {
  margin-bottom: 8px;
  padding-left: 16px;
  position: relative;
}

li::before {
  content: "–";
  position: absolute;
  left: 0;
  color: var(--muted);
}

/* ===================== HEADER ===================== */
.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 40px;
}

.site-header h1 {
  margin: 0;
  font-size: 18px;
}

.site-header h1 a { border-bottom: none; }
.site-header .page-title { color: var(--muted); }

.resume-link {
  font-size: 12px;
  color: var(--muted);
  padding: 4px 8px;
}

.resume-link:hover { color: var(--accent); }

/* ===================== NAVIGATION ===================== */
.top-nav {
  display: flex;
  align-items: center;
  gap: 24px;
}

.top-nav a {
  font-size: 14px;
  color: var(--muted);
  border-bottom: none;
  transition: color var(--transition);
}

.top-nav a:hover { color: var(--accent); }

#theme-toggle {
  background: none;
  border: none;
  padding: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

#theme-toggle img {
  width: 16px;
  height: 16px;
  filter: brightness(0) invert(1);
  transition: filter var(--transition);
}

/* Dark theme: show sun, hide moon */
#theme-toggle .icon-sun { display: block; }
#theme-toggle .icon-moon { display: none; }

/* Light theme: show moon, hide sun */
[data-theme="light"] #theme-toggle .icon-sun { display: none; }
[data-theme="light"] #theme-toggle .icon-moon { display: block; }
[data-theme="light"] #theme-toggle img { filter: brightness(0); }

#theme-toggle:hover img {
  filter: brightness(0) saturate(100%) invert(45%) sepia(98%) saturate(1500%) hue-rotate(200deg);
}

/* ===================== PROFILE ===================== */
.profile-img {
  width: 120px;
  height: 120px;
  margin: 10px 10px 0 0;
  object-fit: cover;
  float: left;
  filter: grayscale(1);
  transition: filter 0.3s;
}

.profile-img:hover { filter: grayscale(0); }

/* ===================== PROJECTS ===================== */
.project-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.project-list li {
  border: 1px solid var(--border);
  padding: 12px 16px;
  margin: 0;
  transition: border-color var(--transition);
}

.project-list li::before { display: none; }
.project-list li:hover { border-color: var(--accent); }

.project-link {
  color: var(--fg) !important;
  border-bottom: none !important;
}

.project-link:hover { color: var(--accent) !important; }

/* ===================== SOCIAL ===================== */
.social-links { line-height: 2; }

.social-links .icon {
  width: 18px;
  height: 18px;
  margin-right: 8px;
  color: var(--muted);
  vertical-align: middle;
}

/* ===================== RECOMMENDATIONS ===================== */
.rec-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rec-item {
  display: flex;
  gap: 12px;
  padding: 8px 0;
  border-bottom: none;
}

.rec-item:hover { border-bottom: none; }

.rec-type {
  color: var(--muted);
  font-size: 13px;
  min-width: 50px;
}

.rec-title {
  color: var(--fg);
  transition: color var(--transition);
}

.rec-item:hover .rec-title { color: var(--accent); }

/* ===================== BLOG ===================== */
.category-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0;
}

.category-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  font: 12px inherit;
  padding: 4px 12px;
  cursor: pointer;
  transition: all var(--transition);
}

.category-btn:hover {
  color: var(--fg);
  border-color: var(--muted);
}

.category-btn.active {
  background: var(--fg);
  color: var(--bg);
  border-color: var(--fg);
}

.quote {
  margin-top: 40px;
  padding-left: 16px;
  border-left: 2px solid var(--border);
  font-style: italic;
  font-size: 14px;
  color: var(--muted);
}

.blog-post a {
  color: var(--fg);
  text-decoration: underline;
  text-underline-offset: 3px;
  border-bottom: none;
}

.blog-post a:hover { color: var(--accent); }

/* ===================== GALLERY ===================== */
.gallery-grid {
  columns: 4;
  column-gap: 20px;
  margin-top: 20px;
}

.gallery-item {
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  box-shadow: 0 4px 6px rgba(0,0,0,.3);
  cursor: pointer;
  break-inside: avoid;
  margin-bottom: 20px;
  background: var(--border);
  transition: transform 0.3s, box-shadow 0.3s;
}

.gallery-item:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 15px rgba(0,0,0,.5);
}

.gallery-item img {
  width: 100%;
  height: auto;
  display: block;
  transition: transform 0.3s;
}

.gallery-item:hover img { transform: scale(1.05); }

.gallery-item-overlay {
  position: absolute;
  inset: auto 0 0;
  background: linear-gradient(transparent, rgba(0,0,0,.8));
  color: #fff;
  padding: 15px;
  opacity: 0;
  transition: opacity 0.3s;
}

.gallery-item:hover .gallery-item-overlay { opacity: 1; }

.gallery-item-title {
  font-size: 0.9rem;
  font-weight: 700;
  margin: 0;
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  inset: 0;
  background: rgba(0,0,0,.9);
  cursor: pointer;
  backdrop-filter: blur(4px);
}

.modal.active {
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-content {
  max-width: 90%;
  max-height: 90%;
  object-fit: contain;
  border-radius: 8px;
}

.modal-close {
  position: absolute;
  top: 20px;
  right: 40px;
  color: #fff;
  font-size: 40px;
  cursor: pointer;
  background: rgba(0,0,0,.5);
  border-radius: 50%;
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.3s;
}

.modal-close:hover { color: var(--error); }

/* ===================== FOOTER ===================== */
.site-footer {
  margin-top: 64px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 13px;
}

/* ===================== BACK BUTTON ===================== */
#end-button-container {
  display: none;
  margin-top: 48px;
  text-align: center;
}

#back-to-top-btn {
  background: none;
  border: none;
  color: var(--muted);
  font: 13px inherit;
  padding: 0;
  cursor: pointer;
  transition: color var(--transition);
}

#back-to-top-btn:hover { color: var(--accent); }

/* ===================== UTILITIES ===================== */
.htmx-indicator {
  opacity: 0.6;
  font-style: italic;
  color: var(--muted);
}

.error {
  color: var(--error);
  font-style: italic;
  padding: 10px;
  background: var(--error-bg);
  border-left: 3px solid var(--error);
  border-radius: 4px;
}

/* ===================== RESPONSIVE ===================== */
@media (max-width: 768px) {
  .site-container { padding: 40px 16px 60px; }
  .profile-img { width: 100px; height: 100px; }
  .top-nav { gap: 16px; }
  .gallery-grid { columns: 2; column-gap: 12px; }
  .gallery-item { margin-bottom: 12px; border-radius: 6px; }
  .modal-close { top: 15px; right: 25px; font-size: 32px; }
}

@media (max-width: 480px) {
  .gallery-grid { column-gap: 8px; }
  .gallery-item { margin-bottom: 8px; border-radius: 4px; }
  .modal-content { max-width: 95%; max-height: 85%; }
}

@media (hover: none) {
  .gallery-item:hover {
    transform: none;
    box-shadow: 0 4px 6px rgba(0,0,0,.3);
  }
  .gallery-item:hover img { transform: none; }
  .gallery-item-overlay { opacity: 1; }
}
