/* ---------- colours ---------- */
:root {
  --bg: #f6f0e6;
  --card: #fffdf9;
  --text: #2b2118;
  --muted: #7a6a5a;
  --accent: #a3402a;        /* kumkum */
  --accent-dark: #8f3522;
  --accent-soft: #f7e4d8;
  --gold: #c8962e;
  --border: #eadfce;
  --bad-bg: #fbe9e4;
  --good-bg: #e7f2e7;
  --good: #2f7d4a;
  --sandhya-bg: #fdf3dc;
  --shadow: 0 1px 2px rgba(80, 50, 20, .06), 0 4px 14px rgba(80, 50, 20, .06);
  --on-accent: #fff;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17120e;
    --card: #221b15;
    --text: #f1e8dc;
    --muted: #b3a491;
    --accent: #ec8f70;
    --accent-dark: #7c2f1f;
    --accent-soft: #35251b;
    --gold: #e0b45a;
    --border: #3a3027;
    --bad-bg: #3a221c;
    --good-bg: #1f3324;
    --good: #8fd3a3;
    --sandhya-bg: #3a2f17;
    --shadow: none;
    --on-accent: #1b120c;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Noto Sans", "Noto Sans Tamil", "Noto Sans Telugu", "Noto Sans Kannada",
    "Noto Sans Devanagari", "Nirmala UI", system-ui, sans-serif;
  line-height: 1.5;
}

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; }

/* ---------- top bar ---------- */
.topbar {
  background: linear-gradient(120deg, #7c2f1f, #a3402a 60%, #b8632f);
  color: #fff;
  box-shadow: 0 2px 10px rgba(80, 30, 10, .25);
  border-bottom: 3px solid #e0b45a; /* thin gold line under the header */
}
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 60px; }
.topbar-inner { padding-top: 16px; padding-bottom: 16px; }
.brand { display: flex; align-items: center; gap: 16px; min-width: 0; }
.brand-img {
  width: 68px; height: 68px; flex-shrink: 0; border-radius: 50%;
  object-fit: cover; object-position: 60% 15%; border: 2px solid rgba(255, 255, 255, .7); background: #fff;
}
.topbar h1 { margin: 0; display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.brand-org { font-size: 1.15rem; font-weight: 600; opacity: .92; letter-spacing: .2px; }
.brand-title { font-size: 2.1rem; letter-spacing: .3px; }
.topbar select {
  background: rgba(255, 255, 255, .15); color: #fff; border: 1px solid rgba(255, 255, 255, .35);
  min-height: 38px; padding: 4px 8px;
}
.topbar select option { color: #2b2118; }
.topbar-tools { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.size-btn {
  min-height: 38px; min-width: 40px; padding: 2px 8px; font-weight: 700; font-size: .9rem;
  background: rgba(255, 255, 255, .15); color: #fff; border: 1px solid rgba(255, 255, 255, .35);
}
.size-btn--big { font-size: 1.15rem; }
.size-btn:disabled { opacity: .45; cursor: default; }

/* Coming up */
.coming { list-style: none; margin: 0; padding: 0; }
.coming li {
  display: grid; grid-template-columns: 1fr auto; gap: 0 10px; padding: 8px 0;
  border-top: 1px solid var(--border);
}
.coming li:first-child { border-top: none; }
.coming .coming-date { color: var(--muted); font-size: .9em; grid-column: 1; }
.coming .coming-when {
  grid-column: 2; grid-row: 1 / span 2; align-self: center; font-size: .85em; font-weight: 600;
  color: var(--accent); background: var(--accent-soft); padding: 2px 10px; border-radius: 999px; white-space: nowrap;
}
.coming li.festival .linkish { color: #b45309; }
.coming .linkish { text-align: left; }

/* ---------- form controls ---------- */
select, input, button {
  font: inherit; font-size: 1rem; color: var(--text);
  background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  padding: 8px 10px; min-height: 42px;
}
button { background: var(--accent); color: var(--on-accent); border-color: var(--accent); cursor: pointer; }
button:hover { filter: brightness(1.07); }
.btn-ghost {
  background: transparent; color: var(--accent); border-color: var(--accent);
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}

.toolbar {
  display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: flex-end; justify-content: space-between;
  margin-top: 16px; padding: 12px 14px;
  background: var(--card); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow);
}
.field { display: flex; flex-direction: column; gap: 2px; font-size: .8rem; color: var(--muted); }
.place-group, .date-group { display: flex; align-items: flex-end; gap: 8px; }
.place-group { flex: 1 1 340px; }
.place-group .field { flex: 1; min-width: 0; }
#city { width: 100%; }
.date-nav { display: inline-flex; gap: 6px; }
.arrow { width: 42px; padding: 0; font-size: 1.5rem; line-height: 1; }

#status { color: var(--muted); min-height: 1.2em; margin: 6px 2px; font-size: .9rem; }
#status:empty { margin: 0; min-height: 0; }

/* ---------- search ---------- */
.search { margin: 12px 0 16px; }
.search-box {
  display: flex; align-items: center; gap: 8px; padding: 0 14px;
  background: var(--card); border: 1px solid var(--border); border-radius: 999px; box-shadow: var(--shadow);
  color: var(--muted);
}
.search-box:focus-within { border-color: var(--accent); }
.search-box input { flex: 1; border: none; background: transparent; min-height: 48px; padding: 0; outline: none; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chips:empty { display: none; }
.chip {
  min-height: 34px; padding: 4px 12px; border-radius: 999px; font-size: .9rem;
  background: var(--card); color: var(--text); border-color: var(--border);
}
.chip.on { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
#searchOut:not(:empty) {
  margin-top: 10px; padding: 12px 16px;
  background: var(--card); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow);
}
#searchOut p { margin: 0; }
.result-head { margin-bottom: 6px !important; }
.year-list { margin: 6px 0 0; padding-left: 28px; columns: 3 230px; column-gap: 28px; }
.year-list li { padding: 4px 0; break-inside: avoid; }
.year-list li span { margin-left: 8px; }
.linkish {
  background: none; border: none; min-height: 0; padding: 0; color: var(--accent);
  font-weight: 600; text-decoration: underline; text-underline-offset: 3px; cursor: pointer;
}

/* ---------- day summary ---------- */
.hero {
  padding: 18px 20px; border-radius: 16px; border: 1px solid var(--border);
  background: linear-gradient(135deg, var(--accent-soft), var(--card) 70%);
  box-shadow: var(--shadow); margin-bottom: 16px;
}
.hero-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; margin-bottom: 14px; }
.hero-head h2 { margin: 0; font-size: 1.9rem; line-height: 1.2; }
.hero-head p { margin: 0; color: var(--muted); }
.hero-paksha {
  margin-left: auto !important; padding: 2px 12px; border-radius: 999px;
  background: var(--card); border: 1px solid var(--border); color: var(--accent) !important; font-weight: 600;
}
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.tiles--two { grid-template-columns: repeat(2, minmax(0, 260px)); }
.tile:has(.tile-icon) { flex-direction: row; align-items: center; gap: 12px; }
.tile-icon { display: flex; flex-shrink: 0; }
.tile-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tile {
  display: flex; flex-direction: column; gap: 2px; padding: 12px 14px;
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
}
.tile-label { font-size: .8rem; color: var(--muted); }
.tile-value { font-size: 1.3rem; font-weight: 700; line-height: 1.25; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tile.sun .tile-value { color: var(--accent); }
.tile-sub { font-size: .85rem; color: var(--muted); }

/* ---------- special-day banners ---------- */
.banners { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px; margin-bottom: 16px; }
.card.banner {
  display: flex; align-items: center; gap: 14px; margin: 0;
  background: var(--card); border-color: var(--border); border-left: 5px solid var(--gold);
}
.banner p { margin: 0; }
.banner-title { font-weight: 700; }
.banner-sub { color: var(--muted); font-size: .9em; }

/* Big festivals: full width, larger, in their own colours */
.card.banner--festival {
  grid-column: 1 / -1; padding: 18px 22px; gap: 18px; border-width: 2px; color: #fff;
  box-shadow: 0 6px 22px rgba(60, 30, 10, .25); position: relative; overflow: hidden;
}
.card.banner--festival { padding-top: 56px; }
.banner--festival > * { position: relative; z-index: 1; }
/* Marigold thoranam across the top: flowers on a green string, mango leaves at each joint */
.banner--festival::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 44px; pointer-events: none;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='64' height='34' viewBox='0 0 64 34'%3E%3Cpath d='M0 3 Q32 24 64 3' fill='none' stroke='%232e7d32' stroke-width='1.6'/%3E%3Cpath d='M0 2 C-5 9 -4 17 0 24 C4 17 5 9 0 2Z M64 2 C59 9 60 17 64 24 C68 17 69 9 64 2Z' fill='%233f9142'/%3E%3Cpath d='M0 4 L0 22 M64 4 L64 22' stroke='%23215c24' stroke-width='.8'/%3E%3Cg%3E%3Ccircle cx='9' cy='9' r='4.6' fill='%23f59e0b'/%3E%3Ccircle cx='9' cy='9' r='1.7' fill='%23c2410c'/%3E%3Ccircle cx='20.5' cy='12.6' r='4.6' fill='%23facc15'/%3E%3Ccircle cx='20.5' cy='12.6' r='1.7' fill='%23ea580c'/%3E%3Ccircle cx='32' cy='13.8' r='4.6' fill='%23f97316'/%3E%3Ccircle cx='32' cy='13.8' r='1.7' fill='%239a3412'/%3E%3Ccircle cx='43.5' cy='12.6' r='4.6' fill='%23facc15'/%3E%3Ccircle cx='43.5' cy='12.6' r='1.7' fill='%23ea580c'/%3E%3Ccircle cx='55' cy='9' r='4.6' fill='%23f59e0b'/%3E%3Ccircle cx='55' cy='9' r='1.7' fill='%23c2410c'/%3E%3C/g%3E%3Ccircle cx='32' cy='21' r='2.2' fill='%23fde68a'/%3E%3Ccircle cx='32' cy='25.5' r='1.6' fill='%23fb923c'/%3E%3C/svg%3E") repeat-x 0 0 / 83px 44px;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .25));
}
/* Kolam-style mandala glowing on the right */
.banner--festival::after {
  content: ""; position: absolute; right: -40px; top: 50%; transform: translateY(-45%);
  width: 230px; height: 230px; pointer-events: none; opacity: .22;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' fill='none' stroke='white' stroke-width='1.3'%3E%3Ccircle cx='50' cy='50' r='8'/%3E%3Ccircle cx='50' cy='50' r='20'/%3E%3Ccircle cx='50' cy='50' r='47' stroke-dasharray='2 3'/%3E%3Cg id='p'%3E%3Cellipse cx='50' cy='28' rx='5' ry='12'/%3E%3Cellipse cx='50' cy='10' rx='3' ry='6'/%3E%3C/g%3E%3Cuse href='%23p' transform='rotate(30 50 50)'/%3E%3Cuse href='%23p' transform='rotate(60 50 50)'/%3E%3Cuse href='%23p' transform='rotate(90 50 50)'/%3E%3Cuse href='%23p' transform='rotate(120 50 50)'/%3E%3Cuse href='%23p' transform='rotate(150 50 50)'/%3E%3Cuse href='%23p' transform='rotate(180 50 50)'/%3E%3Cuse href='%23p' transform='rotate(210 50 50)'/%3E%3Cuse href='%23p' transform='rotate(240 50 50)'/%3E%3Cuse href='%23p' transform='rotate(270 50 50)'/%3E%3Cuse href='%23p' transform='rotate(300 50 50)'/%3E%3Cuse href='%23p' transform='rotate(330 50 50)'/%3E%3C/svg%3E") center / contain no-repeat;
}
.banner--festival .portrait { width: 92px; height: 92px; border-width: 3px; border-color: #f3d58a; }
.banner--festival .banner-title { font-size: 1.6rem; line-height: 1.25; letter-spacing: .3px; }
.banner--festival .banner-sub { color: rgba(255, 255, 255, .88); font-size: 1rem; margin-top: 2px; }
.card.banner--vishnu { background: linear-gradient(120deg, #1d3277, #2c4fae 60%, #b8862b); border-color: #e0b45a; }
.card.banner--shiva { background: linear-gradient(120deg, #1f2430, #3b4252 55%, #6b7385); border-color: #a9b1c2; }
.card.banner--periyava { background: linear-gradient(120deg, #7c2d12, #c2410c 50%, #e0a43a); border-color: #fcd34d; } /* kavi */
.card.banner--murugan { background: linear-gradient(120deg, #7f1d1d, #b91c1c 55%, #ea9a2a); border-color: #fcd34d; }
.card.banner--deepam { background: linear-gradient(120deg, #3b0d0c, #7c2d12 55%, #d97706); border-color: #fcd34d; }
.portrait--icon { background: #fff7e6; }
.portrait--icon img { object-fit: contain; padding: 5px; }
.card.banner--harvest { background: linear-gradient(120deg, #3f6212, #65a30d 50%, #d97706); border-color: #fcd34d; }
.portrait--pongal { background: #fff7e6; }
.portrait--pongal img { object-fit: contain; padding: 4px; }
.card.banner--ganesha { background: linear-gradient(120deg, #8a2f0f, #c2410c 55%, #e0a43a); border-color: #f3c46b; }
.portrait {
  width: 64px; height: 64px; flex-shrink: 0; overflow: hidden;
  border-radius: 50%; border: 2px solid var(--gold); background: #fff;
}
.portrait img { width: 100%; height: 100%; display: block; object-fit: cover; }
.portrait--periyava img { transform: scale(1.9); transform-origin: 60% 22%; } /* zoom in on the face */
.portrait--shiva img { transform: scale(1.35); transform-origin: 50% 25%; }
.portrait--namam img { object-fit: contain; padding: 5px; }
.portrait--ganapathi img { object-fit: contain; padding: 6px; }
.portrait--amavasya img { object-fit: contain; padding: 8px; }
.portrait--moon { background: #1d2a4d; }
.portrait--moon img { object-fit: contain; padding: 4px; }

/* ---------- cards and main grid ---------- */
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: 14px;
  padding: 12px 16px; box-shadow: var(--shadow);
}
.card h3 {
  margin: 0 0 10px; font-size: 1.02rem; font-weight: 700; color: var(--accent);
  display: flex; align-items: center; gap: 8px;
}
.card h3::before { /* small accent bar before each card title */
  content: ""; width: 4px; height: 1.05em; border-radius: 2px; background: linear-gradient(var(--accent), var(--gold));
}
.grid {
  display: grid; grid-template-columns: 1.3fr 1fr; gap: 14px; align-items: start;
  /* panchanga and the timing cards side by side; Coming up full width below */
  grid-template-areas: "panchanga times" "coming coming";
}
.area-panchanga { grid-area: panchanga; }
.area-times { grid-area: times; }
.area-coming { grid-area: coming; align-self: start; }
.stack { display: flex; flex-direction: column; gap: 14px; }

dl { margin: 0; }
.row {
  display: grid; grid-template-columns: minmax(100px, 32%) 1fr; gap: 12px;
  padding: 7px 0; border-top: 1px solid var(--border);
}
.row:first-child { border-top: none; }
dt { color: var(--muted); }
dd { margin: 0; }
.name { font-weight: 600; }
.muted { color: var(--muted); font-size: .9em; }

.periods { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.period {
  display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 7px 12px; border-radius: 9px; border: 1px solid transparent;
}
.periods.bad .period { background: var(--bad-bg); }
.periods.good .period { background: var(--good-bg); }
.periods.sandhya .period { background: var(--sandhya-bg); }
.period-name { font-weight: 600; }
.period-time { font-variant-numeric: tabular-nums; }
.period.live { border-color: var(--accent); }
.period em {
  font-style: normal; font-size: .75rem; font-weight: 700; margin-left: 6px; padding: 1px 8px;
  border-radius: 999px; background: var(--accent); color: var(--on-accent); vertical-align: 2px;
}
.periods.good .period.live { border-color: var(--good); }
.periods.good .period em { background: var(--good); }

/* ---------- help ---------- */
#helpBox { margin-top: 16px; }
.fold summary { cursor: pointer; font-weight: 600; color: var(--accent); }
.help h4 { margin: 14px 0 4px; }
.help ul { margin: 0; padding-left: 20px; }
.help li { margin: 4px 0; }
.table-wrap { overflow-x: auto; margin: 10px 0; }
.rule-table { border-collapse: collapse; width: 100%; font-size: .9rem; min-width: 460px; }
.rule-table caption { text-align: left; font-weight: 700; color: var(--accent); padding: 4px 0; }
.rule-table th, .rule-table td { border: 1px solid var(--border); padding: 6px 8px; text-align: left; vertical-align: top; }
.rule-table th { background: var(--accent-soft); font-weight: 600; }
.rule-table th small { font-weight: 400; color: var(--muted); }
.source { margin: 4px 0 0; font-size: .8rem; }

.note { color: var(--muted); font-size: .8rem; text-align: center; margin: 16px 0 8px; }
.site-footer {
  border-top: 1px solid var(--border); margin-top: 12px; padding: 14px 0 22px;
  color: var(--muted); font-size: .85rem; text-align: center;
}
.site-footer .wrap { display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; }
.site-footer img { border-radius: 50%; }
.error { color: var(--accent); }

/* ---------- tablets and phones ---------- */
@media (max-width: 820px) {
  .grid { grid-template-columns: 1fr; grid-template-areas: "panchanga" "times" "coming"; grid-template-rows: auto; }
  .tiles { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
  .brand-img { width: 54px; height: 54px; }
  .brand-org { font-size: .74rem; line-height: 1.25; }
  .brand-img { width: 46px !important; height: 46px !important; }
  .topbar-tools { gap: 4px; }
  .size-btn { min-width: 32px; min-height: 34px; padding: 0 5px; font-size: .8rem; }
  .size-btn--big { font-size: 1rem; }
  .topbar select { min-height: 34px; padding: 2px 4px; font-size: .85rem; max-width: 84px; }
  .brand { gap: 12px; }
  .topbar-inner { padding-top: 12px; padding-bottom: 12px; }
  .brand-title { font-size: 1.6rem; }
  .toolbar { padding: 10px; gap: 10px; }
  .place-group, .date-group { flex: 1 1 100%; }
  .date-group { min-width: 0; }
  .date-group .field { flex: 1; min-width: 0; }
  .date-nav { display: flex; min-width: 0; gap: 4px; }
  .date-nav input { flex: 1; min-width: 0; width: 100%; padding: 8px 6px; }
  .arrow { width: 38px; flex-shrink: 0; }
  #today { flex-shrink: 0; padding: 8px 10px; }
  .hero { padding: 14px; }
  .hero-head h2 { font-size: 1.5rem; }
  .hero-paksha { margin-left: 0 !important; }
  .tile { padding: 10px; }
  .tile:has(.tile-icon) { gap: 8px; }
  .tile-icon svg { width: 34px; height: 28px; }
  .tile-value { font-size: 1.1rem; }
  .tile-label { font-size: .75rem; }
  .card { padding: 12px 14px; }
  .row { grid-template-columns: 96px 1fr; }
  .banner--festival { padding: 14px 16px; gap: 14px; }
  .banner--festival .portrait { width: 72px; height: 72px; }
  .banner--festival .banner-title { font-size: 1.3rem; }
}
@media (max-width: 400px) {
  #locate span { display: none; } /* icon only on very small phones */
}

/* Festival banners keep an even border (the gold left edge is for regular banners) */
.card.banner.banner--festival { border-left-width: 2px; border-left-color: inherit; }

/* Coming up: several columns when it spans the full width on wide screens */
@media (min-width: 821px) {
  .coming { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); column-gap: 28px; }
  .coming li { border-top: none; border-bottom: 1px solid var(--border); }
}
.coming li { padding: 6px 0; }

/* Small picture at the right end of a card title (e.g. arghyam on Sandhyavandanam) */
.card h3 .card-icon { width: 58px; height: 44px; margin: -12px 0 -12px auto; border-radius: 8px; object-fit: cover; }
