/* ===== Themes ===== */
:root {
  --bg: #f4ede3;
  --bg-subtle: #ebe1d3;
  --text: #3b3228;
  --text-secondary: #6e6055;
  --text-muted: #9a8e82;
  --accent: #5c5047;
  --link: #b0603a;
  --link-hover: #8a4520;
  --border: #d8cabb;
  --nav-bg: rgba(244, 237, 227, 0.94);
  --tag-bg: #e6dac8;
  --tag-text: #6e6055;
  --date-accent: #d49362;
  --photo-ring: rgba(176, 96, 58, 0.12);
}

[data-theme="dark"] {
  --bg: #111;
  --bg-subtle: #191919;
  --text: #d8d8d8;
  --text-secondary: #aaa;
  --text-muted: #666;
  --accent: #ccc;
  --link: #7eaadf;
  --link-hover: #a8c8f0;
  --border: #2a2a2a;
  --nav-bg: rgba(17, 17, 17, 0.92);
  --tag-bg: #222;
  --tag-text: #aaa;
  --date-accent: #e3a16e;
  --photo-ring: rgba(227, 161, 110, 0.12);
}

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

html { scroll-behavior: smooth; }

body {
  font-family: 'Source Serif 4', Georgia, 'Times New Roman', serif;
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.75;
  min-height: 100vh;
  transition: background-color 0.25s, color 0.25s;
}

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

/* ===== Layout ===== */
.container {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* ===== Header ===== */
.site-header {
  padding: 2.5rem 0 0;
  margin-bottom: 1rem;
}

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

.site-name {
  font-family: 'Caveat', 'Brush Script MT', cursive;
  font-size: 1.55rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.01em;
  line-height: 1;
  text-decoration: none;
}
.site-name:hover {
  color: var(--text);
  text-decoration: none;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.header-nav {
  display: flex;
  gap: 1.25rem;
  list-style: none;
  font-size: 0.9rem;
}

.header-nav a {
  color: var(--text-secondary);
  text-decoration: none;
  font-family: 'Inter', sans-serif;
}
.header-nav a:hover,
.header-nav a.active {
  color: var(--text);
}

.icon-links {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.icon-links a {
  color: var(--text-muted);
  display: flex;
  transition: color 0.2s, transform 0.2s;
}
.icon-links a:hover {
  color: var(--text);
  text-decoration: none;
  transform: translateY(-1px);
}

.icon-links svg {
  width: 16px;
  height: 16px;
}

/* Theme toggle */
.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-family: 'Inter', sans-serif;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: color 0.2s, border-color 0.2s;
}
.theme-toggle:hover {
  color: var(--text);
  border-color: var(--text-muted);
}
.theme-toggle svg {
  width: 13px;
  height: 13px;
}

/* ===== Divider ===== */
.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1rem 0 2rem;
}

/* ===== Page content ===== */
.page-content {
  padding-bottom: 4rem;
  min-height: 70vh;
}

/* ===== Home: intro ===== */
.intro {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 1rem;
  margin-bottom: 3rem;
}

.intro-photo-wrap {
  position: relative;
  display: inline-block;
  border-radius: 50%;
  overflow: hidden;
  line-height: 0;
}

.intro-photo {
  width: clamp(200px, 46vw,50px);
  height: clamp(200px, 46vw, 50px);
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  display: block;
  box-shadow: none;
  opacity: 0;
  transform: translateY(12px) scale(0.97);
  transition: opacity 0.8s ease, transform 0.8s ease;
}

.intro-photo.is-loaded {
  opacity: 1;
  transform: none;
}

.intro-photo-link {
  position: absolute;
  right: 0.85rem;
  bottom: 0.85rem;
  z-index: 1;
  padding: 0.34rem 0.6rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  background: rgba(17, 17, 17, 0.42);
  color: #fff;
  font-family: 'Inter', sans-serif;
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: lowercase;
  line-height: 1;
  text-decoration: none;
  backdrop-filter: blur(10px);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.18);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.35s ease, transform 0.35s ease, background-color 0.2s ease, border-color 0.2s ease;
}

.intro-photo.is-loaded + .intro-photo-link {
  opacity: 1;
  transform: none;
}

.intro-photo-link:hover {
  color: #fff;
  text-decoration: none;
  background: rgba(17, 17, 17, 0.58);
  border-color: rgba(255, 255, 255, 0.34);
}

.intro-text {
  max-width: 34rem;
}

.intro-text p {
  color: var(--text-secondary);
  font-size: 1rem;
  margin-bottom: 0.45rem;
}

.intro-text p:first-child {
  color: var(--text);
}

/* ===== Section titles ===== */
.section-title {
  font-family: 'Inter', sans-serif;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

/* ===== Blog list ===== */
.post-list {
  list-style: none;
  margin-bottom: 3rem;
}

.post-item {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  padding: 0.45rem 0;
}

.post-date {
  font-family: 'JetBrains Mono', 'SF Mono', monospace;
  font-size: 0.8rem;
  color: var(--date-accent);
  flex-shrink: 0;
  min-width: 5.5rem;
}

.post-title {
  font-size: 0.95rem;
}

.post-title a {
  color: var(--text);
}
.post-title a:hover {
  color: var(--link);
}

.post-tags {
  display: inline;
  margin-left: 0.5rem;
}

.tag {
  font-family: 'Inter', sans-serif;
  font-size: 0.7rem;
  color: var(--tag-text);
  background: var(--tag-bg);
  padding: 0.1rem 0.45rem;
  border-radius: 3px;
  margin-left: 0.25rem;
}

.view-all {
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
}

.feed-status {
  color: var(--text-muted);
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  margin-bottom: 1.5rem;
}

.post-item-placeholder {
  color: var(--text-secondary);
  font-family: 'Inter', sans-serif;
}

/* ===== About ===== */
.about-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.about-page h1 {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 0;
  letter-spacing: -0.01em;
}

.about-page p {
  color: var(--text-secondary);
  margin-bottom: 1rem;
  font-size: 0.95rem;
}

.about-links {
  flex-shrink: 0;
}

/* ===== Blog page ===== */
.blog-page h1 {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  letter-spacing: -0.01em;
}

.blog-archive .post-list:last-child {
  margin-bottom: 0;
}

/* ===== Gallery ===== */
.gallery-page h1 {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  letter-spacing: -0.01em;
}

.gallery-page .page-desc {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-bottom: 2rem;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}

.gallery-item {
  overflow: hidden;
  border-radius: 4px;
  cursor: pointer;
  aspect-ratio: 1;
}

.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: opacity 0.2s;
}

.gallery-item:hover img {
  opacity: 0.85;
}

/* Caption row */
.gallery-caption {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin-top: 0.25rem;
  margin-bottom: 1.5rem;
}

.gallery-caption span {
  font-family: 'Inter', sans-serif;
  font-size: 0.72rem;
  color: var(--text-muted);
  text-align: center;
}

/* Lightbox */
.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.92);
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
}

.lightbox.active {
  display: flex;
}

.lightbox img {
  max-width: 90vw;
  max-height: 90vh;
  object-fit: contain;
}

.lightbox-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: rgba(255,255,255,0.1);
  color: #fff;
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lightbox-close:hover {
  background: rgba(255,255,255,0.2);
}

/* ===== Blog post single ===== */
.post-page .post-header {
  margin-bottom: 2rem;
}

.post-page .post-back {
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  margin-bottom: 1.5rem;
}

.post-page .post-header h1 {
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.02em;
  margin-bottom: 0.5rem;
}

.post-page .post-meta {
  font-family: 'Inter', sans-serif;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.post-page .post-meta .post-tags {
  margin-left: 0.4rem;
}

.post-page .post-body p {
  color: var(--text-secondary);
  margin-bottom: 1.25rem;
  font-size: 0.98rem;
}

.post-page .post-body h2 {
  font-size: 1.15rem;
  margin-top: 2rem;
  margin-bottom: 0.75rem;
}

.post-page .post-body blockquote {
  border-left: 2px solid var(--border);
  padding-left: 1rem;
  color: var(--text-muted);
  font-style: italic;
  margin: 1.5rem 0;
}

.post-page .post-body code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  background: var(--bg-subtle);
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
}

.post-page .post-body pre {
  overflow-x: auto;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 6px;
  margin: 1.5rem 0;
  padding: 1rem;
}

.post-page .post-body pre code {
  background: transparent;
  padding: 0;
  border-radius: 0;
}

.post-page .post-body ul {
  margin: 0 0 1.25rem 1.25rem;
  color: var(--text-secondary);
}

.post-page .post-body li {
  margin-bottom: 0.45rem;
}

/* ===== Mobile ===== */
@media (max-width: 600px) {
  .site-header .container {
    flex-wrap: wrap;
    gap: 0.75rem;
  }

  .header-right {
    gap: 0.75rem;
  }

  .header-nav {
    gap: 0.9rem;
  }

  .about-header {
    flex-wrap: wrap;
    align-items: center;
  }

  .post-item {
    flex-direction: column;
    gap: 0.1rem;
    padding: 0.6rem 0;
  }

  .gallery-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .gallery-caption {
    grid-template-columns: repeat(2, 1fr);
  }

}

@media (prefers-reduced-motion: reduce) {
  .intro-photo {
    opacity: 1;
    transform: none;
    transition: none;
  }

  .intro-photo-link {
    opacity: 1;
    transform: none;
    transition: background-color 0.2s ease, border-color 0.2s ease;
  }
}
