/* ============================================================
   Lịch Âm Dương – stylesheet
   Palette: cream / wood-brown / warm orange
   Font: Noto Serif
   ============================================================ */

/* ── Reset / Base ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --cream:        #faf6f0;
  --cream-dark:   #f0e8da;
  --cream-border: #e2d2be;
  --brown-light:  #c8a882;
  --brown:        #8b5e3c;
  --brown-dark:   #5a3620;
  --text:         #3d2b1f;
  --text-muted:   #8a6a55;
  --today-bg:     #d4762c;
  --today-text:   #fff;
  --saturday:     #7a3b00;
  --sunday:       #b02020;
  --tiet-khi:     #2e6e3e;
  --panel-bg:     #fffdf8;
  --shadow:       0 4px 24px rgba(90, 54, 32, 0.14);
  --radius:       10px;
  --transition:   0.22s ease;
}

html { font-size: 16px; }

body {
  background: var(--cream);
  color: var(--text);
  font-family: 'Noto Serif', 'Palatino Linotype', Georgia, serif;
  min-height: 100vh;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

/* ── App shell ─────────────────────────────────────────────── */
.app {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 12px 40px;
}

/* ── Header ────────────────────────────────────────────────── */
.app-header {
  padding: 24px 0 16px;
  border-bottom: 2px solid var(--cream-border);
  margin-bottom: 16px;
}

.app-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}

.app-title__icon { font-size: 1.5rem; }

.app-title__text {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--brown-dark);
  letter-spacing: 0.02em;
}

/* ── Nav bar ───────────────────────────────────────────────── */
.nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav__btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 1.8rem;
  line-height: 1;
  color: var(--brown);
  transition: background var(--transition);
  flex-shrink: 0;
}
.nav__btn:hover { background: var(--cream-border); }

.nav__center {
  flex: 1;
  text-align: center;
}

.nav__month-year {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--brown-dark);
}

.nav__can-chi {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.nav__today-btn {
  padding: 7px 16px;
  border-radius: 20px;
  background: var(--brown);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  transition: background var(--transition);
  flex-shrink: 0;
}
.nav__today-btn:hover { background: var(--brown-dark); }

/* ── Calendar grid ─────────────────────────────────────────── */
.calendar-wrap { overflow: hidden; }

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

/* Weekday headers */
.weekday-header {
  text-align: center;
  padding: 8px 0;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.weekday-header--sat { color: var(--saturday); }
.weekday-header--sun { color: var(--sunday); }

/* Day cells */
.day-cell {
  position: relative;
  min-height: 76px;
  padding: 6px 6px 4px;
  border-radius: var(--radius);
  background: var(--cream-dark);
  border: 1px solid var(--cream-border);
  cursor: pointer;
  transition: background var(--transition), box-shadow var(--transition);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  overflow: hidden;
}
.day-cell:hover {
  background: #e8d9c6;
  box-shadow: 0 2px 10px rgba(139, 94, 60, 0.15);
  z-index: 1;
}

.day-cell--empty {
  background: transparent;
  border-color: transparent;
  cursor: default;
  pointer-events: none;
}
.day-cell--empty:hover { background: transparent; box-shadow: none; }

/* Today */
.day-cell--today {
  background: var(--today-bg);
  border-color: var(--today-bg);
}
.day-cell--today .day-solar { color: var(--today-text); }
.day-cell--today .day-lunar { color: rgba(255,255,255,0.85); }
.day-cell--today .day-tietKhi { color: rgba(255,255,255,0.9); }
.day-cell--today:hover { background: #c0681e; }

/* Saturday */
.day-cell--saturday .day-solar { color: var(--saturday); }

/* Sunday */
.day-cell--sunday .day-solar { color: var(--sunday); }

/* Solar number */
.day-solar {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.1;
}

/* Lunar date */
.day-lunar {
  font-size: 0.72rem;
  color: var(--brown);
  line-height: 1.2;
}

/* Tiết khí */
.day-tietKhi {
  font-size: 0.62rem;
  color: var(--tiet-khi);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* Moon phase icon */
.day-moon {
  position: absolute;
  top: 5px;
  right: 5px;
  font-size: 0.8rem;
  line-height: 1;
}

/* ── Detail panel ──────────────────────────────────────────── */
.detail-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: min(360px, 100vw);
  height: 100%;
  background: var(--panel-bg);
  box-shadow: -6px 0 30px rgba(90, 54, 32, 0.18);
  transform: translateX(110%);
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 200;
  overflow-y: auto;
  padding: 24px 24px 40px;
  border-left: 2px solid var(--cream-border);
}

.detail-panel.is-open {
  transform: translateX(0);
}

.detail-panel__close {
  position: absolute;
  top: 14px;
  right: 16px;
  font-size: 1.6rem;
  color: var(--text-muted);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition);
}
.detail-panel__close:hover { background: var(--cream-border); }

/* Detail content */
.detail-date-heading {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 8px 0 20px;
}

.detail-solar-big {
  font-size: 3.2rem;
  font-weight: 700;
  color: var(--brown-dark);
  line-height: 1;
}

.detail-solar-meta {
  font-size: 1rem;
  color: var(--text-muted);
}

.detail-section {
  margin-bottom: 20px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--cream-border);
}
.detail-section:last-child { border-bottom: none; }

.detail-section h3 {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--brown-light);
  margin-bottom: 10px;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 5px 0;
  border-bottom: 1px dotted var(--cream-border);
}
.detail-row:last-child { border-bottom: none; }

.detail-label {
  font-size: 0.82rem;
  color: var(--text-muted);
  min-width: 90px;
}

.detail-value {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
  text-align: right;
}

.detail-value--tietKhi { color: var(--tiet-khi); }

.loading, .error {
  text-align: center;
  padding: 40px 0;
  color: var(--text-muted);
  font-style: italic;
}

/* ── Overlay ───────────────────────────────────────────────── */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(61, 43, 31, 0.35);
  z-index: 150;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.overlay.is-visible {
  opacity: 1;
  pointer-events: auto;
}

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 640px) {
  .app-title__text { font-size: 1.1rem; }
  .nav__month-year { font-size: 1rem; }

  .day-cell {
    min-height: 60px;
    padding: 4px 4px 3px;
  }

  .day-solar { font-size: 1.05rem; }
  .day-lunar { font-size: 0.62rem; }
  .day-tietKhi { font-size: 0.55rem; }
  .day-moon { font-size: 0.68rem; }

  .detail-panel { width: 100vw; }
}

@media (max-width: 420px) {
  .calendar-grid { gap: 2px; }

  .day-cell { min-height: 52px; border-radius: 6px; }

  .weekday-header { font-size: 0.7rem; padding: 6px 0; }
}
