/* ═══════════════════════════════════════════
   Typography — Google Fonts
   ═══════════════════════════════════════════ */
@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;0,600;0,700;0,800;1,400;1,600;1,700&family=Lora:ital,wght@0,400;0,500;0,600;1,400;1,500&family=Inter:wght@300;400;500;600&display=swap');

:root {
  --font-display: 'Playfair Display', Georgia, serif;
  --font-body: 'Lora', 'Georgia', serif;
  --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;

  /* Light theme (warm paper) */
  --bg-primary: #faf8f4;
  --bg-secondary: #f3efe8;
  --bg-card: #ffffff;
  --text-primary: #2c2417;
  --text-secondary: #6b5d4e;
  --text-muted: #9a8b7a;
  --accent: #8b5e3c;
  --accent-light: #c49a6c;
  --border: #e8e0d4;
  --shadow-sm: 0 1px 3px rgba(44, 36, 23, 0.06);
  --shadow-md: 0 4px 16px rgba(44, 36, 23, 0.08);
  --shadow-lg: 0 8px 32px rgba(44, 36, 23, 0.10);
  --gradient-hero: radial-gradient(ellipse at 30% 0%, #f5edd8 0%, transparent 60%),
                   radial-gradient(ellipse at 70% 100%, #ede5d3 0%, transparent 50%),
                   var(--bg-primary);
}

/* Dark theme */
[data-theme="dark"] {
  --bg-primary: #1a1612;
  --bg-secondary: #231f1a;
  --bg-card: #2a2520;
  --text-primary: #e8ddd0;
  --text-secondary: #a89a88;
  --text-muted: #7a6e60;
  --accent: #c49a6c;
  --accent-light: #8b5e3c;
  --border: #3d3630;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.35);
  --gradient-hero: radial-gradient(ellipse at 30% 0%, #2a2218 0%, transparent 60%),
                   radial-gradient(ellipse at 70% 100%, #231f1a 0%, transparent 50%),
                   var(--bg-primary);
}

html {
  font-size: 16px;
}

@media (min-width: 1200px) {
  html {
    font-size: 17px;
  }
}

body {
  margin-bottom: 60px;
  background: var(--gradient-hero);
  font-family: var(--font-body);
  color: var(--text-primary);
  transition: background 0.4s ease, color 0.3s ease;
  min-height: 100vh;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  color: var(--text-primary);
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

html {
  position: relative;
  min-height: 100%;
}

/* ═══════════════════════════════════════════
   Navbar — Frosted Glass
   ═══════════════════════════════════════════ */
.navbar {
  background: rgba(250, 248, 244, 0.85) !important;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  transition: background 0.4s ease, box-shadow 0.3s ease;
  padding: 0.6rem 0;
}

[data-theme="dark"] .navbar {
  background: rgba(26, 22, 18, 0.88) !important;
}

.navbar.scrolled {
  box-shadow: var(--shadow-sm);
}

.navbar-brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.35rem;
  color: var(--text-primary) !important;
  letter-spacing: -0.02em;
}

.nav-link {
  font-family: var(--font-ui);
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--text-secondary) !important;
  transition: color 0.2s ease;
  padding: 0.5rem 1rem !important;
}

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

/* ═══════════════════════════════════════════
   Theme Toggle
   ═══════════════════════════════════════════ */
.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.3s ease;
}

.theme-toggle:hover {
  background: var(--bg-secondary);
  color: var(--accent);
  border-color: var(--accent-light);
}

/* ═══════════════════════════════════════════
   Reading Progress Bar
   ═══════════════════════════════════════════ */
#reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  width: 0%;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent-light));
  z-index: 9999;
  transition: width 0.1s linear;
}

/* ═══════════════════════════════════════════
   Hero Section
   ═══════════════════════════════════════════ */
.hero-panel {
  max-width: 900px;
  margin: 4rem auto 3rem;
  padding: 3rem 2.5rem;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: var(--shadow-lg);
  text-align: center;
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}

.hero-panel::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle at 30% 20%, rgba(196, 154, 108, 0.08) 0%, transparent 50%),
              radial-gradient(circle at 70% 80%, rgba(139, 94, 60, 0.06) 0%, transparent 50%);
  animation: heroFloat 20s ease-in-out infinite;
  pointer-events: none;
}

@keyframes heroFloat {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  33% { transform: translate(2%, -1%) rotate(1deg); }
  66% { transform: translate(-1%, 1%) rotate(-0.5deg); }
}

.hero-panel > * {
  position: relative;
  z-index: 1;
}

.eyebrow {
  letter-spacing: 0.2rem;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 600;
  font-family: var(--font-ui);
  font-size: 0.75rem;
  margin-bottom: 0.75rem;
}

/* ═══════════════════════════════════════════
   Featured Poem (Poem of the Day)
   ═══════════════════════════════════════════ */
.featured-poem {
  max-width: 900px;
  margin: 2rem auto 3rem;
  padding: 2rem 2.5rem;
  border-radius: 16px;
  background: var(--bg-card);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
  transition: box-shadow 0.3s ease;
}

.featured-poem:hover {
  box-shadow: var(--shadow-lg);
}

.featured-poem::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: linear-gradient(to bottom, var(--accent), var(--accent-light));
}

.featured-label {
  font-family: var(--font-ui);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.15rem;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.5rem;
}

.featured-title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.75rem;
}

.featured-snippet {
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.8;
  color: var(--text-secondary);
  white-space: pre-wrap;
  max-height: 120px;
  overflow: hidden;
  position: relative;
}

.featured-snippet::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: linear-gradient(to bottom, transparent, var(--bg-card));
}

.featured-author {
  font-family: var(--font-ui);
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 1rem;
}

.featured-link {
  font-family: var(--font-ui);
  font-size: 0.85rem;
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s ease;
}

.featured-link:hover {
  color: var(--accent-light);
  text-decoration: underline;
}

/* ═══════════════════════════════════════════
   Poem Cards — Editorial Grid
   ═══════════════════════════════════════════ */
.poem-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
}

.poem-card {
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg-card);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.poem-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--accent-light);
}

.poem-card-body {
  padding: 1.5rem;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.poem-card-body h2 {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.35;
}

.poem-card-body h2 a {
  color: var(--text-primary);
  transition: color 0.2s ease;
}

.poem-card-body h2 a:hover {
  color: var(--accent);
}

.poem-card-date {
  font-family: var(--font-ui);
  font-size: 0.8rem;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

/* ═══════════════════════════════════════════
   Poem Reader — Immersive View
   ═══════════════════════════════════════════ */
.poem-article {
  max-width: 740px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

.poem-article header h1 {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 2.5rem;
  line-height: 1.2;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.poem-article header .poem-meta {
  font-family: var(--font-ui);
  font-size: 0.85rem;
  color: var(--text-muted);
  letter-spacing: 0.03em;
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.poem-body {
  font-family: var(--font-body);
  font-size: 1.15rem;
  line-height: 1.9;
  word-wrap: break-word;
  color: var(--text-primary);
}
.poem-body p {
  margin-bottom: 1.25rem;
}

.poem-body h1, .poem-body h2, .poem-body h3, .poem-body h4, .poem-body h5, .poem-body h6 {
  font-family: var(--font-display);
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
  color: var(--text-primary);
}

.poem-body ul, .poem-body ol {
  margin-bottom: 1.25rem;
  padding-left: 1.5rem;
}

.poem-body li {
  margin-bottom: 0.4rem;
}

.poem-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2rem 0;
}

.poem-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.95rem;
}

.poem-body th, .poem-body td {
  border: 1px solid var(--border);
  padding: 0.6rem 0.9rem;
  text-align: left;
}

.poem-body thead th {
  font-family: var(--font-ui);
  font-weight: 600;
  background: var(--bg-secondary);
}

.poem-body blockquote {
  border-left: 3px solid var(--accent-light);
  padding-left: 1.25rem;
  margin: 1.5rem 0;
  font-style: italic;
  color: var(--text-secondary);
}

.poem-body a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: var(--accent-light);
  text-underline-offset: 3px;
}

.poem-body a:hover {
  color: var(--accent-light);
}

.poem-body img {
  max-width: 100%;
  height: auto;
  border-radius: 10px;
  margin: 1.5rem 0;
}

.poem-body img.float-left {
  float: left;
  margin: 0 1.5rem 1rem 0;
  width: min(42%, 340px);
}

.poem-body img.float-right {
  float: right;
  margin: 0 0 1rem 1.5rem;
  width: min(42%, 340px);
}

.poem-body::after {
  content: "";
  display: table;
  clear: both;
}

.poem-feed-item + .poem-feed-item {
  margin-top: 3.5rem;
  padding-top: 3rem;
  border-top: 1px solid var(--border);
}

.poem-feed-sentinel {
  font-family: var(--font-ui);
  font-size: 0.85rem;
  min-height: 2.5rem;
}

@media (max-width: 768px) {
  .poem-article header h1 {
    font-size: 1.8rem;
  }
  .poem-body img.float-left,
  .poem-body img.float-right {
    float: none;
    display: block;
    margin: 1.5rem auto;
    width: 100%;
  }
  .poem-body table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }
}

/* ═══════════════════════════════════════════
   Scroll Reveal Animations
   ═══════════════════════════════════════════ */
.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.7s cubic-bezier(0.25, 0.46, 0.45, 0.94),
              transform 0.7s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

.reveal-delay-1 { transition-delay: 0.1s; }
.reveal-delay-2 { transition-delay: 0.2s; }
.reveal-delay-3 { transition-delay: 0.3s; }

/* ═══════════════════════════════════════════
   Footer
   ═══════════════════════════════════════════ */
footer.footer {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  font-family: var(--font-ui);
  font-size: 0.85rem;
  color: var(--text-muted);
  padding: 1.25rem 0;
  transition: background 0.4s ease, border-color 0.4s ease;
}

/* ═══════════════════════════════════════════
   Cards & Alerts
   ═══════════════════════════════════════════ */
.alert {
  font-family: var(--font-ui);
  border-radius: 10px;
  border: 1px solid var(--border);
}

/* ═══════════════════════════════════════════
   Studio Table
   ═══════════════════════════════════════════ */
.table {
  --bs-table-bg: transparent;
  --bs-table-border-color: var(--border);
}

.table thead th {
  font-family: var(--font-ui);
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  border-bottom-width: 2px;
}

/* ═══════════════════════════════════════════
   EasyMDE / CodeMirror tweaks
   ═══════════════════════════════════════════ */
.editor-toolbar, .editor-toolbar + .CodeMirror, .CodeMirror, .EasyMDEContainer {
  max-width: 100%;
}
.CodeMirror {
  min-height: 280px;
}
.editor-toolbar {
  border-radius: 6px 6px 0 0;
}
.editor-toolbar .fa {
  font-size: 14px;
}

/* ═══════════════════════════════════════════
   Dark mode overrides
   ═══════════════════════════════════════════ */
[data-theme="dark"] .poem-card {
  background: var(--bg-card);
}

[data-theme="dark"] .poem-card-body h2 a {
  color: var(--text-primary);
}

[data-theme="dark"] .hero-panel {
  background: rgba(42, 37, 32, 0.6);
  border-color: var(--border);
}

[data-theme="dark"] .featured-poem {
  background: var(--bg-card);
}

/* ═══════════════════════════════════════════
   Responsive tweaks
   ═══════════════════════════════════════════ */
@media (max-width: 767.98px) {
  .hero-panel {
    margin: 2rem 1rem;
    padding: 2rem 1.5rem;
  }
  .featured-poem {
    margin: 1.5rem 1rem;
    padding: 1.5rem;
  }
  .poem-article {
    padding: 1.5rem 0.75rem;
  }
  .poem-article header h1 {
    font-size: 1.6rem;
  }
  .poem-body {
    font-size: 1.05rem;
  }
}