/* ═══════════════════════════════════════════════════
   HINDU PANCHANGAM CALENDAR  –  style.css
   Traditional saffron & vermillion aesthetic
   ═══════════════════════════════════════════════════ */

:root {
  --cream:        #FFF8E7;
  --cream-mid:    #F5E8C8;
  --cream-dark:   #EDD9A3;
  --saffron:      #FF9933;
  --saffron-lt:   #FFB347;
  --saffron-dim:  #FFE0A8;
  --red:          #8B1A1A;
  --red-mid:      #A52020;
  --red-lt:       #C0392B;
  --gold:         #C8A84B;
  --gold-lt:      #E2C47A;
  --maroon:       #5C0A0A;
  --ink:          #1E0A00;
  --ink-mid:      #3D1C0C;
  --ink-lt:       #7A4030;
  --festival-bg:  #FFF0E0;
  --major-color:  #8B1A1A;
  --minor-color:  #B35400;
  --special-color:#006080;
  --today-ring:   #FF6B00;
  --selected-bg:  #FFF0CC;
  --header-h:     64px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Palatino Linotype','Book Antiqua', Palatino, Georgia, serif;
  background: var(--cream);
  color: var(--ink);
  min-height: 100vh;
  font-size: 14px;
}

/* ── Top Bar ─────────────────────────────────────── */
.topbar {
  background: var(--red);
  color: var(--cream);
  padding: 0 20px;
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 3px solid var(--gold);
  position: sticky;
  top: 0;
  z-index: 100;
  gap: 16px;
}
.topbar-title {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.topbar-title .om {
  font-size: 28px;
  color: var(--gold-lt);
  line-height: 1;
}
.topbar-title h1 {
  font-size: 18px;
  font-weight: normal;
  letter-spacing: 0.04em;
  color: var(--cream);
}
.topbar-title h1 span {
  display: block;
  font-size: 11px;
  color: var(--gold-lt);
  font-style: italic;
  letter-spacing: 0.08em;
}
.topbar-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}
.location-select {
  background: var(--maroon);
  color: var(--cream);
  border: 1px solid var(--gold);
  border-radius: 4px;
  padding: 5px 10px;
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  outline: none;
}
.location-select:hover { background: var(--red-mid); }

/* ── Month Navigation Bar ───────────────────────── */
.monthbar {
  background: var(--cream-mid);
  border-bottom: 2px solid var(--gold);
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.month-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}
.nav-btn {
  background: var(--red);
  color: var(--cream);
  border: none;
  width: 30px; height: 30px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
  flex-shrink: 0;
}
.nav-btn:hover { background: var(--red-lt); }
.month-label {
  font-size: 20px;
  font-weight: bold;
  color: var(--red);
  min-width: 160px;
  text-align: center;
}
.month-label .greg {
  font-size: 12px;
  color: var(--ink-lt);
  font-weight: normal;
  margin-left: 6px;
}
.month-meta {
  font-size: 12px;
  color: var(--ink-mid);
  text-align: right;
  line-height: 1.5;
}
.month-meta strong { color: var(--red); }

/* ── Main Layout ─────────────────────────────────── */
.main {
  display: grid;
  grid-template-columns: 1fr 310px;
  gap: 0;
  min-height: calc(100vh - var(--header-h) - 58px);
}

/* ── Calendar Grid ───────────────────────────────── */
.calendar-wrap {
  padding: 16px;
  overflow: hidden;
}
.weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-bottom: 4px;
}
.weekday-hdr {
  text-align: center;
  font-size: 11px;
  font-weight: bold;
  letter-spacing: 0.06em;
  color: var(--ink-lt);
  text-transform: uppercase;
  padding: 4px 0;
}
.weekday-hdr:first-child { color: var(--red-lt); }
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.day-cell {
  background: #fff;
  border: 1px solid var(--cream-dark);
  border-radius: 4px;
  padding: 6px 7px 7px;
  min-height: 90px;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s, box-shadow 0.12s;
  position: relative;
  overflow: hidden;
}
.day-cell:hover {
  border-color: var(--saffron);
  background: #FFFAF0;
  box-shadow: 0 2px 8px rgba(139,26,26,0.10);
  z-index: 2;
}
.day-cell.selected {
  background: var(--selected-bg);
  border-color: var(--red);
  box-shadow: 0 2px 10px rgba(139,26,26,0.18);
}
.day-cell.today {
  border-color: var(--today-ring);
  border-width: 2px;
}
.day-cell.today .day-num { color: var(--today-ring); }
.day-cell.empty {
  background: transparent;
  border-color: transparent;
  cursor: default;
  pointer-events: none;
}
.day-cell.other-month { opacity: 0.35; }

.day-num {
  font-size: 20px;
  font-weight: bold;
  color: var(--ink);
  line-height: 1;
  text-align: right;
  margin-bottom: 3px;
}
.day-tithi {
  font-size: 10.5px;
  color: var(--red-mid);
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 1px;
}
.day-nakshatra {
  font-size: 10px;
  color: var(--ink-lt);
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-style: italic;
}
.day-festivals {
  margin-top: 4px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.fest-tag {
  font-size: 10px;
  line-height: 1.25;
  font-weight: bold;
  padding: 1px 4px;
  border-radius: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fest-tag.major {
  background: #FFF0E0;
  color: var(--major-color);
  border-left: 2px solid var(--saffron);
}
.fest-tag.minor {
  background: #F0F8FF;
  color: var(--special-color);
}
.fest-tag.monthly {
  background: transparent;
  color: var(--minor-color);
  font-weight: normal;
  font-style: italic;
}

/* ── Panchangam Side Panel ───────────────────────── */
.panel {
  background: var(--cream);
  border-left: 2px solid var(--gold);
  position: sticky;
  top: calc(var(--header-h) + 58px);
  height: calc(100vh - var(--header-h) - 58px);
  overflow-y: auto;
  padding: 20px 18px;
}
.panel-header {
  border-bottom: 1px solid var(--gold);
  padding-bottom: 12px;
  margin-bottom: 16px;
}
.panel-date {
  font-size: 17px;
  font-weight: bold;
  color: var(--red);
  margin-bottom: 2px;
}
.panel-vara {
  font-size: 13px;
  color: var(--ink-mid);
  font-style: italic;
}
.panel-masa {
  font-size: 12px;
  color: var(--ink-lt);
  margin-top: 4px;
}
.panel-section {
  margin-bottom: 18px;
}
.panel-section-title {
  font-size: 10px;
  font-weight: bold;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
  border-bottom: 1px solid var(--cream-dark);
  padding-bottom: 4px;
  margin-bottom: 10px;
}
.panchang-row {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 4px 8px;
  margin-bottom: 8px;
  align-items: start;
}
.panchang-label {
  font-size: 11px;
  color: var(--ink-lt);
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding-top: 1px;
}
.panchang-value {
  font-size: 13px;
  color: var(--ink);
  line-height: 1.4;
}
.panchang-value .end-time {
  font-size: 11px;
  color: var(--ink-lt);
  display: block;
  font-style: italic;
}
.panchang-value .end-time::before { content: 'ends '; }

.sun-row {
  display: flex;
  justify-content: space-between;
  background: var(--cream-mid);
  border-radius: 6px;
  padding: 10px 14px;
  margin-bottom: 14px;
}
.sun-item { text-align: center; }
.sun-item .sun-icon { font-size: 20px; display: block; }
.sun-item .sun-label { font-size: 10px; color: var(--ink-lt); text-transform: uppercase; letter-spacing: 0.06em; }
.sun-item .sun-time { font-size: 16px; font-weight: bold; color: var(--red); }

.panel-festivals {
  margin-top: 16px;
}
.panel-fest-item {
  padding: 8px 10px;
  border-radius: 4px;
  margin-bottom: 6px;
  border-left: 3px solid var(--saffron);
  background: var(--festival-bg);
  font-size: 13px;
  color: var(--major-color);
  font-weight: bold;
}
.panel-fest-item.minor {
  border-left-color: var(--gold-lt);
  background: var(--cream-mid);
  color: var(--ink-mid);
  font-weight: normal;
  font-size: 12px;
}
.panel-empty {
  color: var(--ink-lt);
  font-style: italic;
  font-size: 13px;
  padding: 20px 0;
  text-align: center;
}

/* ── Decorative border on panel ─────────────────── */
.panel::before {
  content: '';
  display: block;
  height: 4px;
  background: repeating-linear-gradient(
    90deg, var(--red) 0, var(--red) 8px,
    var(--gold) 8px, var(--gold) 12px,
    var(--saffron) 12px, var(--saffron) 20px,
    var(--gold) 20px, var(--gold) 24px
  );
  margin: -20px -18px 20px;
}

/* ── Loading overlay ─────────────────────────────── */
.loading {
  position: fixed; inset: 0;
  background: rgba(255,248,231,0.85);
  display: flex; align-items: center; justify-content: center;
  z-index: 999;
  font-size: 20px;
  color: var(--red);
  letter-spacing: 0.08em;
}

/* ── Responsive ─────────────────────────────────── */
@media (max-width: 900px) {
  .main { grid-template-columns: 1fr; }
  .panel {
    position: static;
    height: auto;
    border-left: none;
    border-top: 2px solid var(--gold);
  }
  .panel::before { margin: -20px -18px 20px; }
}
@media (max-width: 600px) {
  .topbar { padding: 0 12px; }
  .topbar-title h1 { font-size: 14px; }
  .topbar-title .om { font-size: 22px; }
  .calendar-wrap { padding: 8px; }
  .day-cell { min-height: 70px; padding: 4px 5px; }
  .day-num { font-size: 16px; }
  .day-tithi, .day-nakshatra { font-size: 9px; }
  .fest-tag { font-size: 9px; }
  .month-label { font-size: 16px; min-width: 120px; }
}

/* ── Print ──────────────────────────────────────── */
@media print {
  .topbar, .monthbar, .panel { display: none; }
  .main { grid-template-columns: 1fr; }
  .day-cell { break-inside: avoid; }
  body { background: white; }
}
