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

:root {
  --gold: #C49A28;
  --gold-dark: #a8831e;
  --bg: #f0eeea;
  --surface: #ffffff;
  --text: #1f1e1c;
  --text-muted: #6b6860;
  --text-light: #9b968c;
  --border: #e5e1d8;
  --serif: 'Lora', Georgia, 'Times New Roman', serif;
  --display: 'Playfair Display', Georgia, serif;
  --sans: 'Inter', system-ui, -apple-system, sans-serif;
}

body {
  font-family: var(--serif);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* === Header === */
header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--gold);
  display: flex;
  align-items: center;
  height: 58px;
  padding: 0 0.75rem;
}

.hamburger, .speaker-btn {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background 0.15s;
  flex-shrink: 0;
}
.hamburger { font-size: 1.3rem; letter-spacing: -1px; }
.speaker-btn { font-size: 1.2rem; }
.hamburger:hover, .speaker-btn:hover { background: rgba(255,255,255,0.18); }

.site-name {
  flex: 1;
  text-align: center;
  font-family: var(--sans);
  font-weight: 700;
  font-size: 0.8rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: white;
}

/* === Sidebar === */
.sidebar {
  position: fixed;
  top: 0;
  left: -290px;
  width: 290px;
  height: 100dvh;
  background: var(--surface);
  z-index: 300;
  transition: left 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  box-shadow: 4px 0 24px rgba(0,0,0,0.12);
}
.sidebar.open { left: 0; }

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.38);
  z-index: 299;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s;
}
.sidebar-backdrop.open { opacity: 1; pointer-events: all; }

.sidebar-head {
  background: var(--gold);
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem 0 1.25rem;
}
.sidebar-head-title {
  font-family: var(--sans);
  font-weight: 700;
  font-size: 0.75rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: white;
}
.sidebar-close {
  background: none;
  border: none;
  color: white;
  font-size: 1.1rem;
  cursor: pointer;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background 0.15s;
}
.sidebar-close:hover { background: rgba(255,255,255,0.18); }

.sidebar-body { flex: 1; overflow-y: auto; padding: 1.25rem 0; }

.sidebar-search-wrap {
  display: flex;
  align-items: center;
  margin: 0 1.25rem 1rem;
  background: #f8f7f4;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 0.5rem 0.75rem;
  transition: border-color 0.18s;
}
.sidebar-search-wrap:focus-within {
  border-color: var(--gold);
  background: #fff;
}
.sidebar-search-icon {
  color: var(--text-dim);
  flex-shrink: 0;
  margin-right: 0.5rem;
}
.sidebar-search-input {
  flex: 1;
  border: none;
  background: transparent;
  font-family: var(--sans);
  font-size: 0.88rem;
  color: var(--text);
  outline: none;
  min-width: 0;
  -webkit-appearance: none;
}
.sidebar-search-input::placeholder { color: var(--text-dim); }
.sidebar-search-input::-webkit-search-cancel-button { display: none; }
.sidebar-search-clear {
  display: none;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 0.75rem;
  padding: 0 0 0 0.35rem;
  flex-shrink: 0;
}
.sidebar-search-clear:hover { color: var(--text); }

.sidebar-label {
  font-family: var(--sans);
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-light);
  padding: 0 1.25rem;
  margin-bottom: 0.35rem;
  margin-top: 1rem;
}
.sidebar-label:first-child { margin-top: 0; }

.sidebar-nav { list-style: none; }
.sidebar-nav li button {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  border-left: 3px solid transparent;
  padding: 0.6rem 1.25rem;
  font-family: var(--sans);
  font-size: 0.88rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}
.sidebar-nav li button:hover { background: #faf8f4; color: var(--gold); border-left-color: var(--gold); }
.sidebar-nav li button.active { color: var(--gold); font-weight: 700; border-left-color: var(--gold); background: #fef9ee; }

.sidebar-divider { height: 1px; background: var(--border); margin: 1rem 1.25rem; }

.sidebar-write {
  display: block;
  margin: 0.75rem 1.25rem 0;
  padding: 0.65rem 1rem;
  background: var(--gold);
  color: white;
  border-radius: 4px;
  font-family: var(--sans);
  font-size: 0.84rem;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  transition: background 0.15s;
}
.sidebar-write:hover { background: var(--gold-dark); opacity: 1; }

/* === Main Feed === */
main { max-width: 680px; margin: 0 auto; padding: 1.75rem 0 6rem; }
body.player-active main { padding-bottom: 5.5rem; }

.post-card {
  background: var(--surface);
  padding: 2rem 2.5rem;
  margin-bottom: 1rem;
  cursor: pointer;
  transition: box-shadow 0.18s;
  -webkit-tap-highlight-color: transparent;
}
.post-card:hover { box-shadow: 0 3px 16px rgba(0,0,0,0.09); }
.post-card--pinned { border-left: 3px solid var(--gold); }

.post-cat-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.5rem;
}
.post-cat-row .post-cat { margin-bottom: 0; }

.post-pin-badge {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--gold);
  opacity: 0.75;
}

.post-cat {
  font-family: var(--sans);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--gold);
}

.post-title {
  font-family: var(--display);
  font-size: 1.55rem;
  font-weight: 700;
  line-height: 1.25;
  color: var(--text);
  margin-bottom: 0.35rem;
}

.post-date {
  font-family: var(--sans);
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.post-hr { border: none; border-top: 1px solid var(--border); margin-bottom: 1rem; }

.post-body {
  font-size: 0.985rem;
  line-height: 1.82;
  color: var(--text);
  text-align: justify;
  margin-bottom: 1.25rem;
}
.post-body p { margin-bottom: 1.1rem; }
.post-body p:last-child { margin-bottom: 0; }

.post-footer {
  display: flex;
  align-items: center;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.post-listen-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: none;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 0.35rem 0.85rem;
  font-family: var(--sans);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}
.post-listen-btn:hover { border-color: var(--gold); color: var(--gold); background: rgba(196,154,40,0.06); }

/* === Listen Dialog === */
.dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 400;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.dialog-overlay.open { opacity: 1; pointer-events: all; }

.listen-dialog {
  background: var(--surface);
  border-radius: 12px;
  padding: 2.5rem 2rem 2rem;
  max-width: 360px;
  width: 100%;
  text-align: center;
  transform: translateY(16px) scale(0.97);
  transition: transform 0.22s cubic-bezier(0.34, 1.2, 0.64, 1);
  box-shadow: 0 24px 64px rgba(0,0,0,0.22);
  max-height: calc(100dvh - 4rem);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.dialog-overlay.open .listen-dialog { transform: translateY(0) scale(1); }

.dialog-icon { font-size: 2.25rem; display: block; margin-bottom: 0.75rem; }

.listen-dialog h2 {
  font-family: var(--display);
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.35rem;
}
.listen-dialog > p {
  font-family: var(--sans);
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 1.75rem;
}

.time-opts { display: flex; gap: 0.5rem; margin-bottom: 1.5rem; }

.time-opt {
  flex: 1;
  padding: 0.8rem 0.5rem;
  border: 2px solid var(--border);
  border-radius: 8px;
  background: none;
  font-family: var(--sans);
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.18s;
}
.time-opt:hover { border-color: var(--gold); color: var(--gold); }
.time-opt.active { border-color: var(--gold); background: var(--gold); color: white; }

.btn-start {
  display: block;
  width: 100%;
  padding: 0.9rem;
  background: var(--gold);
  color: white;
  border: none;
  border-radius: 8px;
  font-family: var(--sans);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  margin-bottom: 0.85rem;
  transition: background 0.15s, transform 0.12s;
}
.btn-start:hover { background: var(--gold-dark); transform: translateY(-1px); }
.btn-start:active { transform: translateY(0); }

.btn-cancel {
  background: none;
  border: none;
  font-family: var(--sans);
  font-size: 0.85rem;
  color: var(--text-light);
  cursor: pointer;
  padding: 0.4rem;
  transition: color 0.15s;
}
.btn-cancel:hover { color: var(--text-muted); }

/* === Mini Player === */
.mini-player {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #1f1e1c;
  z-index: 200;
  padding: 0.7rem 1.25rem;
  display: none;
  align-items: center;
  gap: 1rem;
  border-top: 2px solid var(--gold);
}
.mini-player.active { display: flex; }

.mp-info { flex: 1; min-width: 0; }

.mp-label {
  font-family: var(--sans);
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--gold);
  font-weight: 700;
  display: block;
  margin-bottom: 0.18rem;
}
.mp-title {
  font-family: var(--serif);
  font-size: 0.85rem;
  color: white;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mp-progress {
  height: 2px;
  background: rgba(255,255,255,0.12);
  border-radius: 1px;
  margin-top: 0.4rem;
  overflow: hidden;
}
.mp-bar {
  height: 100%;
  background: var(--gold);
  width: 0%;
  transition: width 0.5s linear;
}

.mp-controls { display: flex; align-items: center; gap: 0.4rem; flex-shrink: 0; }

.mp-btn {
  background: none;
  border: 1px solid rgba(255,255,255,0.2);
  color: rgba(255,255,255,0.8);
  border-radius: 6px;
  padding: 0.38rem 0.65rem;
  font-family: var(--sans);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.mp-btn:hover { background: rgba(255,255,255,0.08); border-color: rgba(255,255,255,0.4); color: white; }

.mp-skip { border-color: rgba(196,154,40,0.6); color: var(--gold); }
.mp-skip:hover { background: rgba(196,154,40,0.12); border-color: var(--gold); }

/* === Article Modal === */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 3rem 1rem 2rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s;
  overflow-y: auto;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }

.modal {
  background: var(--surface);
  max-width: 680px;
  width: 100%;
  position: relative;
  transform: translateY(20px);
  transition: transform 0.22s cubic-bezier(0.34, 1.2, 0.64, 1);
  box-shadow: 0 24px 64px rgba(0,0,0,0.22);
}
.modal-overlay.open .modal { transform: translateY(0); }

.modal-gold-bar { background: var(--gold); height: 4px; }

.modal-inner { padding: 2.25rem 2.5rem; }

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: rgba(196,154,40,0.1);
  border: none;
  color: var(--gold);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--sans);
  font-weight: 700;
  transition: background 0.15s;
}
.modal-close:hover { background: rgba(196,154,40,0.2); }

.modal-cat {
  font-family: var(--sans);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--gold);
  margin-bottom: 0.5rem;
}
.modal-title {
  font-family: var(--display);
  font-size: 1.8rem;
  font-weight: 700;
  line-height: 1.25;
  margin-bottom: 0.5rem;
  padding-right: 3rem;
}
.modal-byline {
  font-family: var(--sans);
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 0.85rem;
}
.modal-listen-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.9rem;
  background: rgba(196,154,40,0.1);
  border: 1px solid rgba(196,154,40,0.35);
  color: var(--gold);
  border-radius: 4px;
  font-family: var(--sans);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  margin-bottom: 1.5rem;
}
.modal-listen-btn:hover { background: rgba(196,154,40,0.18); }

.modal-divider { border: none; border-top: 1px solid var(--border); margin-bottom: 1.75rem; }

.modal-body {
  font-size: 1rem;
  line-height: 1.85;
  color: var(--text);
  text-align: justify;
}
.modal-body p { margin-bottom: 1.25rem; }
.modal-body p:last-child { margin-bottom: 0; }

/* === Feed sentinel (infinite scroll trigger) === */
#feedSentinel { height: 1px; }

/* === Footer === */
footer {
  text-align: center;
  padding: 1.75rem 1.25rem;
  font-family: var(--sans);
  font-size: 0.78rem;
  color: var(--text-light);
  border-top: 1px solid var(--border);
  margin-bottom: 3.5rem;
  max-width: 680px;
  margin-left: auto;
  margin-right: auto;
}
footer a { color: var(--gold); font-weight: 600; text-decoration: none; }
footer a:hover { color: var(--gold-dark); }


/* === Calendar === */
.calendar-widget {
  max-width: 680px;
  margin: 0.5rem auto 0;
  background: var(--surface);
}

.cal-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0.55rem 1.5rem;
  background: none;
  border: none;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  font-family: var(--sans);
  color: var(--text-muted);
  transition: background 0.15s;
}
.cal-toggle:hover { background: #faf8f4; }

.cal-toggle-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
  font-weight: 600;
}

.cal-chevron {
  font-size: 0.55rem;
  color: var(--text-light);
}

.cal-body {
  padding: 0.75rem 1.5rem 0.85rem;
}

.cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.cal-month-label {
  font-family: var(--sans);
  font-weight: 700;
  font-size: 0.82rem;
  color: var(--text);
}

.cal-nav {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: 26px;
  height: 26px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.cal-nav:hover { border-color: var(--gold); color: var(--gold); }

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
}

.cal-day-label {
  font-family: var(--sans);
  font-size: 0.58rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-light);
  text-align: center;
  padding: 0.15rem 0 0.3rem;
}

.cal-cell {
  height: 26px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  font-family: var(--sans);
  font-size: 0.72rem;
  color: var(--text-light);
  gap: 1px;
}

.cal-cell.has-article {
  cursor: pointer;
  color: var(--text);
  font-weight: 600;
}
.cal-cell.has-article:hover { background: rgba(196,154,40,0.1); color: var(--gold); }
.cal-cell.selected { background: var(--gold); color: white; border-radius: 4px; }
.cal-cell.selected:hover { background: var(--gold-dark); }
.cal-cell.today:not(.selected) { outline: 1.5px solid var(--gold); outline-offset: -1px; border-radius: 4px; }

.cal-dot {
  width: 3px;
  height: 3px;
  background: var(--gold);
  border-radius: 50%;
  flex-shrink: 0;
}
.cal-cell.selected .cal-dot { background: rgba(255,255,255,0.7); }

.cal-clear {
  display: block;
  width: 100%;
  margin-top: 0.5rem;
  padding: 0.35rem;
  background: none;
  border: 1px dashed rgba(196,154,40,0.4);
  border-radius: 5px;
  font-family: var(--sans);
  font-size: 0.75rem;
  color: var(--gold);
  cursor: pointer;
  text-align: center;
  transition: background 0.15s;
}
.cal-clear:hover { background: rgba(196,154,40,0.08); }

/* Year carousel */
.cal-year-carousel {
  display: flex;
  gap: 0.3rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
  padding: 0.55rem 1.5rem 0.1rem;
  margin: 0.5rem -1.5rem 0;
  border-top: 1px solid var(--border-subtle);
  scrollbar-width: none;
  cursor: grab;
}
.cal-year-carousel:active { cursor: grabbing; }
.cal-year-carousel::-webkit-scrollbar { display: none; }
.cal-year-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.28rem 0.65rem;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: none;
  font-family: var(--sans);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.cal-year-btn:hover { border-color: var(--gold); color: var(--gold-dark); background: rgba(196,154,40,0.07); }
.cal-year-btn.active { background: var(--gold); color: #fff; border-color: var(--gold); }
.cal-year-count {
  font-size: 0.65rem;
  font-weight: 700;
  opacity: 0.75;
}
.cal-year-clear {
  border-style: dashed;
  color: var(--text-light);
}

/* === Category chips (listen dialog) === */
.cat-filter-label {
  font-family: var(--sans);
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-light);
  text-align: left;
  margin-bottom: 0.5rem;
}

.cat-filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  justify-content: center;
  margin-bottom: 1.25rem;
}

.cat-chip {
  padding: 0.32rem 0.7rem;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  background: none;
  font-family: var(--sans);
  font-size: 0.76rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}
.cat-chip:hover:not(.active) { border-color: var(--gold); color: var(--gold); }
.cat-chip.active { border-color: var(--gold); background: var(--gold); color: white; }

/* === Scrollbar === */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* === Mobile === */
@media (max-width: 600px) {
  main { padding: 0.75rem 0 6rem; }
  body.player-active main { padding-bottom: 11rem; }

  .post-card { padding: 1.5rem 1.25rem; margin-bottom: 0.6rem; }
  .post-title { font-size: 1.25rem; }
  .post-body { font-size: 0.93rem; line-height: 1.75; }

  /* Listen dialog: centered, clears header + mini player */
  .dialog-overlay {
    align-items: center;
    padding: 1rem;
  }
  .listen-dialog {
    max-width: 100%;
    max-height: calc(100dvh - 9rem);
    border-radius: 12px;
    padding: 1.5rem 1.25rem 1.5rem;
    transform: translateY(16px) scale(0.97);
  }
  .dialog-overlay.open .listen-dialog { transform: translateY(0) scale(1); }
  .time-opt { font-size: 0.85rem; padding: 0.7rem 0.4rem; }

  /* Mini player: stack vertically so title never overlaps controls */
  .mini-player {
    flex-direction: column;
    align-items: stretch;
    gap: 0.25rem;
    padding: 0.6rem 1rem;
  }
  .mp-info { flex: none; }
  .mp-title {
    white-space: normal;
    font-size: 0.82rem;
    line-height: 1.35;
  }
  .mp-controls {
    display: flex;
    gap: 0.4rem;
    margin-top: 0.25rem;
  }
  .mp-btn {
    flex: 1;
    text-align: center;
    padding: 0.42rem 0.4rem;
    font-size: 0.76rem;
  }


  footer { margin-bottom: 4rem; }
}
