/* ─── RESET ──────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ─── THEMES ─────────────────────────────────────────────────────── */
:root,
[data-theme="dark"] {
  --bg:           #000;
  --bg-subtle:    #111;
  --border:       #222;
  --text:         #ededed;
  --text-2:       #888;
  --text-3:       #555;
  --link:         #ededed;
  --link-hover:   #fff;
  --tag-bg:       #1a1a1a;
  --tag-text:     #666;
  --nav-bg:       rgba(0,0,0,0.8);
  --btn-bg:       #1a1a1a;
  --btn-hover:    #222;
}

[data-theme="grey"] {
  --bg:           #1c1c1e;
  --bg-subtle:    #2c2c2e;
  --border:       #3a3a3c;
  --text:         #e5e5ea;
  --text-2:       #8e8e93;
  --text-3:       #636366;
  --link:         #e5e5ea;
  --link-hover:   #fff;
  --tag-bg:       #2c2c2e;
  --tag-text:     #8e8e93;
  --nav-bg:       rgba(28,28,30,0.85);
  --btn-bg:       #2c2c2e;
  --btn-hover:    #3a3a3c;
}

[data-theme="light"] {
  --bg:           #fafafa;
  --bg-subtle:    #f2f2f2;
  --border:       #e5e5e5;
  --text:         #111;
  --text-2:       #666;
  --text-3:       #999;
  --link:         #111;
  --link-hover:   #000;
  --tag-bg:       #efefef;
  --tag-text:     #777;
  --nav-bg:       rgba(250,250,250,0.85);
  --btn-bg:       #efefef;
  --btn-hover:    #e5e5e5;
}

/* ─── BASE ───────────────────────────────────────────────────────── */
html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background 0.25s, color 0.25s;
}

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

/* ─── LAYOUT ─────────────────────────────────────────────────────── */
.header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--nav-bg);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  border-bottom: 1px solid var(--border);
}

.nav {
  max-width: 680px;
  margin: 0 auto;
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.nav-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.2px;
  flex-shrink: 0;
}
.nav-name:hover { color: var(--link-hover); }

.nav-right {
  display: flex;
  align-items: center;
  gap: 2px;
}

.nav-link {
  font-size: 13px;
  color: var(--text-2);
  padding: 5px 9px;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}
.nav-link:hover { color: var(--text); background: var(--btn-bg); }

.nav-icons {
  display: flex;
  align-items: center;
  gap: 1px;
  margin-left: 4px;
  padding-left: 8px;
  border-left: 1px solid var(--border);
}

/* ─── ICON LINKS ─────────────────────────────────────────────────── */
.icon-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  border-radius: 6px;
  color: var(--text-2);
  transition: color 0.15s, background 0.15s;
}
.icon-link:hover { color: var(--text); background: var(--btn-bg); }

/* ─── THEME TOGGLE ───────────────────────────────────────────────── */
.theme-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  border-radius: 6px;
  border: none;
  background: none;
  color: var(--text-2);
  cursor: pointer;
  font-family: inherit;
  transition: color 0.15s, background 0.15s;
  margin-left: 2px;
}
.theme-btn:hover { color: var(--text); background: var(--btn-bg); }

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

/* ─── MAIN ───────────────────────────────────────────────────────── */
.main {
  max-width: 680px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ─── PAGE SWITCHING ─────────────────────────────────────────────── */
#home,
#projects,
#writing,
#about {
  display: none;
}

#home.active,
#projects.active,
#writing.active,
#about.active {
  display: block;
  animation: pageFadeIn 0.22s ease forwards;
}

@keyframes pageFadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ─── INTRO ──────────────────────────────────────────────────────── */
.intro {
  padding: 56px 0 48px;
  border-bottom: 1px solid var(--border);
}

.intro-text {
  font-size: 16px;
  color: var(--text-2);
  line-height: 1.75;
  margin-bottom: 18px;
}
.intro-text:last-child { margin-bottom: 0; }

.intro-text a {
  color: var(--text);
  border-bottom: 1px solid var(--border);
  transition: border-color 0.15s;
}
.intro-text a:hover { border-color: var(--text-2); }

/* ─── SECTIONS ───────────────────────────────────────────────────── */
.section {
  padding: 48px 0;
  border-bottom: 1px solid var(--border);
}

.section-title {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 32px;
}

/* ─── ENTRIES ────────────────────────────────────────────────────── */
.entry-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.entry {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 20px;
  padding: 24px 0;
  border-top: 1px solid var(--border);
}
.entry:first-child { border-top: none; }

.entry-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-top: 2px;
}

.entry-year {
  font-size: 13px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.2px;
}

.entry-tag,
.entry-read {
  font-size: 11px;
  color: var(--text-3);
  background: var(--tag-bg);
  padding: 2px 7px;
  border-radius: 4px;
  width: fit-content;
}

.entry-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.entry-title {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.4;
  letter-spacing: -0.2px;
  color: var(--text);
}
.entry-title a {
  color: var(--text);
  transition: color 0.15s;
}
.entry-title a:hover { color: var(--link-hover); }

.entry-desc {
  font-size: 14px;
  color: var(--text-2);
  line-height: 1.7;
}

.entry-stack {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 4px;
}
.entry-stack span {
  font-size: 11px;
  color: var(--tag-text);
  background: var(--tag-bg);
  padding: 2px 8px;
  border-radius: 4px;
}

/* ─── ABOUT ──────────────────────────────────────────────────────── */
.about-text {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.about-text p {
  font-size: 15px;
  color: var(--text-2);
  line-height: 1.75;
}

.about-text a {
  color: var(--text);
  border-bottom: 1px solid var(--border);
  transition: border-color 0.15s;
}
.about-text a:hover { border-color: var(--text-2); }

.about-now {
  margin-top: 8px;
  padding: 20px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.about-now-title {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 14px;
}

.now-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.now-list li {
  font-size: 14px;
  color: var(--text-2);
  line-height: 1.6;
  padding-left: 14px;
  position: relative;
}
.now-list li::before {
  content: "–";
  position: absolute;
  left: 0;
  color: var(--text-3);
}
.now-list em { font-style: italic; color: var(--text-2); }

/* ─── FOOTER ─────────────────────────────────────────────────────── */
.footer {
  max-width: 680px;
  margin: 0 auto;
  padding: 28px 24px 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.footer-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.footer-social {
  display: flex;
  align-items: center;
  gap: 1px;
}

.footer-copy {
  font-size: 12px;
  color: var(--text-3);
  padding-left: 10px;
  border-left: 1px solid var(--border);
}

.footer-source {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--text-3);
  padding: 5px 9px;
  border: 1px solid var(--border);
  border-radius: 6px;
  transition: color 0.15s, border-color 0.15s;
}
.footer-source:hover { color: var(--text-2); border-color: var(--text-3); }

/* ─── RESPONSIVE ─────────────────────────────────────────────────── */
@media (max-width: 560px) {
  .nav-link { display: none; }

  .nav-icons {
    padding-left: 6px;
    margin-left: 2px;
  }

  .entry {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .entry-meta {
    flex-direction: row;
    align-items: center;
    gap: 8px;
  }

  .footer {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  .footer-left {
    flex-wrap: wrap;
    gap: 10px;
  }
}

/* ─── REDUCED MOTION ─────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; }
  html { scroll-behavior: auto; }
}
