/* ===========================
   CSS Custom Properties
   =========================== */
:root {
  --gold: #CFB53B;
  --black: #1a1a1a;
  --red: #CC2200;
  --blue: #0057A8;
  --white: #f5f5f5;
  --text-light: #1a1a1a;
  --bg-light: #f5f5f5;
  --text-dark: #f5f5f5;
  --bg-dark: #1a1a1a;
}

/* ===========================
   Light Theme (default)
   =========================== */
body {
  background-color: var(--bg-light);
  color: var(--text-light);
  font-family: Georgia, serif;
  font-size: clamp(1rem, 2.5vw, 1.2rem);
  line-height: 1.7;
  margin: 0;
  padding: 0;
}

/* ===========================
   Dark Theme
   =========================== */
body.dark {
  background-color: var(--bg-dark);
  color: var(--text-dark);
}

@media (prefers-color-scheme: dark) {
  body:not(.light) .gallery-caption {
    color: var(--text-dark);
  }
  body:not(.light) .gallery-date {
    color: var(--text-dark);
  }
  body:not(.light) {
    background-color: var(--bg-dark);
    color: var(--text-dark);
  }
}

/* ===========================
   Header & Navigation
   =========================== */
header {
  background-color: var(--black);
  border-bottom: 3px solid var(--gold);
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

header h1 {
  color: var(--gold);
  font-size: clamp(1.2rem, 3vw, 1.8rem);
  margin: 0;
}

nav {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
}

nav a {
  color: var(--white);
  text-decoration: none;
  font-size: 1rem;
  transition: color 0.2s;
}

nav a:hover {
  color: var(--gold);
}

/* ===========================
   Main Content
   =========================== */
main {
  max-width: 860px;
  margin: 2rem auto;
  padding: 0 1.5rem;
}

h1, h2, h3 {
  color: var(--gold);
}

body.dark h1,
body.dark h2,
body.dark h3 {
  color: var(--gold);
}

/* ===========================
   Links & Buttons
   =========================== */
a {
  color: var(--red);
  text-decoration: underline;
}

a:hover {
  color: var(--blue);
}

.button {
  display: inline-block;
  background-color: var(--red);
  color: var(--white);
  padding: 0.6rem 1.4rem;
  border-radius: 4px;
  text-decoration: none;
  font-size: 1rem;
  transition: background-color 0.2s;
}

.button:hover {
  background-color: var(--blue);
  color: var(--white);
}

/* ===========================
   Theme Toggle Button
   =========================== */
#theme-toggle {
  background: none;
  border: 2px solid var(--gold);
  color: var(--gold);
  padding: 0.4rem 0.8rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s;
}

#theme-toggle:hover {
  background-color: var(--gold);
  color: var(--black);
}

/* ===========================
   Footer
   =========================== */
footer {
  background-color: var(--black);
  border-top: 3px solid var(--gold);
  color: var(--white);
  text-align: center;
  padding: 1.5rem;
  font-size: 0.9rem;
  margin-top: 3rem;
}

/* ===========================
   Responsive
   =========================== */
@media (max-width: 600px) {
  header {
    flex-direction: column;
    align-items: flex-start;
  }

  nav {
    gap: 1rem;
  }
}

/* ===========================
   Dark Theme Overrides
   =========================== */
body.dark {
  background-color: #1a1a1a !important;
  color: #f5f5f5 !important;
}

body.dark main {
  background-color: #1a1a1a !important;
  color: #f5f5f5 !important;
}

body.dark header {
  background-color: #000000 !important;
}

body.dark footer {
  background-color: #000000 !important;
}

/* ===========================
   Images
   =========================== */
img {
  max-width: 75%;
  height: auto;
  display: block;
  margin: 1.5rem auto;
}

/* War Diary Chapter Navigation */
.chapter-nav {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid #ccc;
}

.chapter-nav-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.chapter-nav-prev,
.chapter-nav-next,
.chapter-nav-index {
  text-decoration: none;
  color: #5a3e2b;
  font-family: Georgia, serif;
  font-size: 0.95rem;
}

.chapter-nav-prev:hover,
.chapter-nav-next:hover,
.chapter-nav-index:hover {
  text-decoration: underline;
}

.chapter-nav-index {
  font-style: italic;
  opacity: 0.8;
}

.chapter-nav-placeholder {
  display: inline-block;
  width: 1rem;
}

body.dark .chapter-nav {
  border-top-color: #555 !important;
}

body.dark .chapter-nav-prev,
body.dark .chapter-nav-next,
body.dark .chapter-nav-index {
  color: #d4b896 !important;
}

/* ─── Gallery ─────────────────────────────────────────────── */

.gallery-intro {
  max-width: 640px;
  margin: 0 auto 3rem;
  font-style: italic;
  color: var(--color-text-secondary, #555);
  text-align: center;
}

.gallery-flowing {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3.5rem;
  margin: 0 auto;
  max-width: 720px;
}

.gallery-item {
  margin: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.gallery-item img {
  max-width: 75%;
  height: auto;
  display: block;
  margin: 0 auto;
  border: 1px solid #ddd;
}

.gallery-item figcaption {
  margin-top: 0.75rem;
  text-align: center;
  max-width: 75%;
}

.gallery-caption {
  display: block;
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--color-text-primary, #222);
}

.gallery-date {
  display: block;
  font-size: 0.85rem;
  color: var(--color-text-secondary, #666);
  margin-top: 0.25rem;
  font-style: italic;
}

/* Dark mode */
body.dark .gallery-item img {
  border-color: #444;
}

body.dark .gallery-intro {
  color: #aaa;
}

/* Responsive */
@media (max-width: 600px) {
  .gallery-item img,
  .gallery-item figcaption {
    max-width: 100%;
  }
}

body.dark .gallery-caption {
  color: #e0e0e0;
}

body.dark .gallery-date {
  color: #aaa;
}

body.dark .gallery-caption {
  color: #e0e0e0 !important;
}

body.dark .gallery-date {
  color: #aaa !important;
}
