/* Indian National Calendar — plain HTML/CSS port of the Compose UI (shared/.../App.kt and ui/). */

/* Material 3 scheme seeded from gold/saffron yellow; mirrors ui/theme/Color.kt. */
:root {
    color-scheme: light dark;
    --primary: #6D5E00;
    --on-primary: #FFFFFF;
    --primary-container: #FBE264;
    --on-primary-container: #211B00;
    --secondary-container: #EEE2BC;
    --on-secondary-container: #211B04;
    --error: #BA1A1A;
    --surface: #FFF9EC;
    --on-surface: #1E1B13;
    --surface-variant: #EAE2D0;
    --on-surface-variant: #4B4639;
    --outline: #7C7767;
    --inverse-surface: #333027;
    --inverse-on-surface: #F7F0E2;
    --surface-container-low: #FAF3E5;
    --surface-container: #F4EEDF;
    --surface-container-high: #EFE8DA;
    --surface-container-highest: #E9E2D4;
    --chakra: #000080;
    --title-saffron: #EB7100;
    --title-green: #198A3B;
    --title-shadow: drop-shadow(1px 1px 0.5px #000);
    --scrim: rgba(0, 0, 0, 0.32);
    --cell-a: 0.467;     /* Maah tint alpha on day cells (0x77) */
    --picker-tint: 16%;  /* Maah tint mixed into the date-picker surface */
    --hero-h: 104px;
    --content-max: 1100px;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Devanagari", "Nirmala UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
    :root {
        --primary: #DDC74B;
        --on-primary: #393000;
        --primary-container: #524600;
        --on-primary-container: #FBE264;
        --secondary-container: #4D472A;
        --on-secondary-container: #EEE2BC;
        --error: #FFB4AB;
        --surface: #15130B;
        --on-surface: #E9E2D4;
        --surface-variant: #4B4639;
        --on-surface-variant: #CDC6B4;
        --outline: #969080;
        --inverse-surface: #E9E2D4;
        --inverse-on-surface: #333027;
        --surface-container-low: #1E1B13;
        --surface-container: #221F17;
        --surface-container-high: #2C2A21;
        --surface-container-highest: #38352B;
        --chakra: #9FB8FF;
        --title-saffron: #FFB155;
        --title-green: #7CCB86;
        --title-shadow: drop-shadow(0 0.5px 1.5px rgba(0, 0, 0, 0.3));
        --cell-a: 0.251;
        --picker-tint: 22%;
    }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    background: var(--surface);
    color: var(--on-surface);
    font-size: 16px;
    line-height: 1.5;
    letter-spacing: 0.03em;
    -webkit-tap-highlight-color: transparent;
}
button {
    font: inherit;
    color: inherit;
    letter-spacing: inherit;
    background: none;
    border: 0;
    padding: 0;
    cursor: pointer;
}
svg { width: 24px; height: 24px; fill: currentColor; flex: none; }
[hidden] { display: none !important; }

/* ---------- Shared controls ---------- */
.icon-btn {
    width: 48px;
    height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    flex: none;
}
.icon-btn:hover, .text-btn:hover, .menu-item:hover, .dial-side:hover { background-color: color-mix(in srgb, currentColor 8%, transparent); }
.icon-btn:active, .text-btn:active { background-color: color-mix(in srgb, currentColor 12%, transparent); }
.text-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    height: 40px;
    padding: 0 12px;
    border-radius: 20px;
    color: var(--primary);
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0.01em;
}
.text-btn svg { width: 18px; height: 18px; }
.text-btn.danger { color: var(--error); }

.segmented {
    display: inline-flex;
    border-radius: 999px;
    overflow: hidden;
}
.segmented button {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 40px;
    padding: 0 12px;
    font-size: 14px;
    font-weight: 500;
}
.segmented button svg { display: none; width: 18px; height: 18px; }
.segmented button[aria-pressed="true"] {
    background: var(--secondary-container);
    color: var(--on-secondary-container);
}
.segmented button[aria-pressed="true"] svg { display: block; }
.segmented.small button { height: 32px; font-size: 12px; }

/* ---------- Hero top bar ---------- */
#top {
    position: fixed;
    inset: 0 0 auto 0;
    z-index: 10;
}
#hero {
    background: linear-gradient(var(--primary-container) 0%, var(--primary-container) 70%, var(--surface) 100%);
    padding-top: var(--safe-top);
}
.hero-inner {
    position: relative;
    max-width: var(--content-max);
    margin: 0 auto;
    display: flex;
    align-items: center;
    height: calc(var(--hero-h) * (1 - var(--p, 0)));
    padding: 0 8px;
    overflow: hidden;
    align-items: flex-start;
}
.hero-inner > .icon-btn { opacity: var(--actions-a, 1); }
.hero-brand { flex: 1; display: flex; justify-content: center; height: 48px; align-items: center; }
.chakra { display: block; width: 40px; height: 40px; color: var(--chakra); opacity: var(--chakra-a, 1); }
.chakra svg { width: 100%; height: 100%; }
.hero-text {
    position: absolute;
    left: 8px;
    right: 8px;
    top: 0;
    text-align: center;
    transform: translateY(calc(48px * (1 - var(--rise, 0))));
    opacity: var(--title-a, 1);
}
.hero-title {
    margin: 0;
    font-size: 22px;
    line-height: 28px;
    font-weight: 600;
    letter-spacing: 0;
    /* Tricolour fill; drop-shadow (unlike text-shadow) sits under a background-clipped fill. */
    background: linear-gradient(var(--title-saffron) 0%, #FFFFFF 42%, var(--title-green) 74%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    filter: var(--title-shadow);
}
.hero-sub {
    color: var(--primary);
    font-size: 12px;
    line-height: 16px;
    font-weight: 500;
    letter-spacing: 0.04em;
}
.wide .hero-inner { height: auto; padding: 10px 8px; align-items: center; }
.wide .hero-brand { height: auto; gap: 12px; }
.wide .hero-text { position: static; transform: none; text-align: start; left: auto; right: auto; }

/* ---------- Date header ---------- */
#dateHeader {
    max-width: var(--content-max);
    margin: 0 auto;
    padding: 8px 8px 0;
    background: var(--surface);
}
.date-row { display: flex; align-items: center; gap: 4px; }
.wide .date-row { justify-content: center; gap: 8px; }
.step { color: var(--primary); touch-action: manipulation; user-select: none; -webkit-user-select: none; }
.date-card {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 16px;
    border-radius: 16px;
    background: color-mix(in srgb, var(--maah-hue) 20%, transparent);
    border: 1px solid color-mix(in srgb, var(--maah-hue) 45%, transparent);
    text-align: center;
}
@media (prefers-color-scheme: dark) {
    .date-card { background: color-mix(in srgb, var(--maah-hue) 30%, transparent); }
}
.wide .date-card { flex: 0 1 auto; min-width: 260px; }
.date-inc { color: var(--primary); font-size: 18px; }
.deva .date-inc { font-size: 22px; }
.date-greg { color: var(--on-surface-variant); font-size: 14px; line-height: 20px; letter-spacing: 0.02em; }
.today-wrap {
    display: grid;
    grid-template-rows: 1fr;
    justify-items: center;
    transition: grid-template-rows 0.2s, opacity 0.2s;
}
.today-wrap > div { overflow: hidden; }
.today-wrap.gone { grid-template-rows: 0fr; opacity: 0; }

/* ---------- Content ---------- */
#content {
    max-width: var(--content-max);
    margin: 0 auto;
    padding-top: var(--content-top, 220px);
    padding-bottom: calc(88px + var(--safe-bottom));
}
.wide #content { padding-bottom: 16px; }
.wide .panes { display: flex; align-items: flex-start; }
.wide .pane { flex: 1; min-width: 0; display: block !important; }

/* ---------- Calendar pane ---------- */
.dial { display: flex; align-items: baseline; padding: 0 8px; }
.dial-side {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: baseline;
    gap: 4px;
    padding: 12px 0;
    color: var(--on-surface-variant);
    font-size: 12px;
    font-weight: 500;
    line-height: 16px;
    border-radius: 8px;
}
.dial-label { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; }
.fade-start { text-align: start; -webkit-mask-image: linear-gradient(to right, transparent, #000 30%); mask-image: linear-gradient(to right, transparent, #000 30%); }
.fade-end { text-align: end; -webkit-mask-image: linear-gradient(to right, #000 70%, transparent); mask-image: linear-gradient(to right, #000 70%, transparent); }
.dial-current {
    padding: 12px;
    font-size: 18px;
    font-weight: 500;
    text-align: center;
    color: var(--on-surface);
}
.national .dial-current { color: var(--primary); }
.deva .dial-current { font-size: 22px; }
.cal-toolbar { display: flex; align-items: center; justify-content: space-between; padding: 0 8px; }

.weekdays, .grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.weekdays div {
    margin: 1px;
    border-radius: 4px;
    background: var(--surface-variant);
    text-align: center;
    font-size: 12px;
    font-weight: 500;
}
.deva .weekdays div { font-size: 14px; }
.grid { touch-action: pan-y; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.cell {
    position: relative;
    margin: 1px;
    aspect-ratio: 0.75;
    border-radius: 4px;
    container-type: inline-size;
    cursor: pointer;
}
.cell.out { cursor: default; }
.cell.sel { border: 2px solid var(--primary); border-radius: 8px; background: none !important; }
/* Text scales with the cell: phone-sized cells (~56px) keep base sizes, wider ones grow up to 2x. */
.cell .g {
    position: absolute;
    top: 4px;
    right: 6px;
    line-height: 1;
    text-align: right;
    white-space: nowrap;
    font-size: clamp(12px, 21.43cqw, 24px);
}
.gregorian .cell .g { font-size: clamp(14px, 25cqw, 28px); }
.cell .i {
    position: absolute;
    left: 4px;
    bottom: 4px;
    line-height: 1.2;
    color: var(--primary);
    font-size: clamp(16px, 28.57cqw, 32px);
}
.gregorian .cell .i { font-size: clamp(12px, 21.43cqw, 24px); }
.cell .i small { display: block; font-size: clamp(8px, 14.29cqw, 16px); }
.deva .cell .i small { font-size: inherit; }
.cell .bm {
    position: absolute;
    right: 0;
    bottom: 0;
    color: var(--primary);
    width: clamp(13px, 23.21cqw, 26px);
    height: clamp(13px, 23.21cqw, 26px);
}
.sel .bm { right: -2px; bottom: -2px; }

/* ---------- Info pane ---------- */
.info-cards { display: flex; justify-content: space-evenly; padding: 8px; }
.info-card {
    margin: 2px;
    padding: 6px;
    border-radius: 12px;
    background: var(--surface-container-low);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 1px 3px 1px rgba(0, 0, 0, 0.15);
    text-align: center;
}
.info-card span { display: block; font-size: 12px; font-weight: 300; }
.info-card b { color: var(--primary); }
#orbit { display: block; width: 100%; aspect-ratio: 1 / 0.9; margin-top: 8px; cursor: pointer; }

/* ---------- Bottom navigation (portrait) ---------- */
#bottomBar {
    position: fixed;
    inset: auto 0 0 0;
    z-index: 10;
    display: flex;
    justify-content: center;
    gap: 8px;
    height: calc(80px + var(--safe-bottom));
    padding-bottom: var(--safe-bottom);
    background: var(--surface-container);
}
.wide #bottomBar { display: none; }
#bottomBar button {
    flex: 1;
    max-width: 200px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    color: var(--on-surface-variant);
    font-size: 12px;
    font-weight: 500;
    line-height: 16px;
}
.nav-pill { width: 64px; height: 32px; border-radius: 16px; display: flex; align-items: center; justify-content: center; }
#bottomBar button[aria-selected="true"] { color: var(--on-surface); }
#bottomBar button[aria-selected="true"] .nav-pill { background: var(--secondary-container); color: var(--on-secondary-container); }

/* ---------- Menu, snackbar ---------- */
.menu {
    position: fixed;
    z-index: 20;
    inset: auto;
    margin: 0;
    padding: 8px 0;
    min-width: 180px;
    border: 0;
    border-radius: 4px;
    background: var(--surface-container);
    color: var(--on-surface);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 2px 6px 2px rgba(0, 0, 0, 0.15);
}
.menu-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    width: 100%;
    height: 48px;
    padding: 0 12px;
    font-size: 14px;
    font-weight: 500;
    text-align: start;
    cursor: pointer;
}
.menu-item input { width: 18px; height: 18px; margin: 0 3px; accent-color: var(--primary); }
#snackbar {
    position: fixed;
    inset: auto 12px calc(96px + var(--safe-bottom)) 12px;
    margin: 0 auto;
    max-width: 600px;
    padding: 14px 16px;
    border: 0;
    border-radius: 4px;
    background: var(--inverse-surface);
    color: var(--inverse-on-surface);
    font-size: 14px;
    line-height: 20px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}
.wide #snackbar { bottom: 16px; }

/* ---------- Dialogs and bottom sheet ---------- */
dialog {
    border: 0;
    padding: 0;
    color: var(--on-surface);
    max-height: calc(100dvh - 48px);
}
dialog::backdrop { background: var(--scrim); }
.alert {
    width: min(560px, calc(100vw - 48px));
    min-width: 280px;
    border-radius: 28px;
    background: var(--dlg-bg, var(--surface-container-high));
}
.alert[open] { display: flex; flex-direction: column; }
.alert h2 { margin: 0; padding: 24px 24px 16px; font-size: 24px; line-height: 32px; font-weight: 400; letter-spacing: 0; }
.alert .dlg-body {
    padding: 0 24px;
    overflow-y: auto;
    color: var(--on-surface-variant);
    font-size: 14px;
    line-height: 20px;
    white-space: pre-line;
}
.alert .dlg-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 24px; }
.picker-head { display: flex; flex-direction: column; align-items: center; text-align: center; }
.picker-head .segmented { width: 100%; margin-bottom: 12px; }
.picker-inc { color: var(--primary); font-size: 16px; line-height: 24px; }
.deva .picker-inc { font-size: 18px; }
.picker-greg { color: var(--on-surface-variant); font-size: 14px; line-height: 20px; }

.field { position: relative; display: block; margin-top: 8px; }
.field select, .field input {
    width: 100%;
    height: 56px;
    padding: 0 16px;
    border: 1px solid var(--outline);
    border-radius: 4px;
    background: transparent;
    color: var(--on-surface);
    font: inherit;
    font-size: 16px;
    appearance: none;
    -webkit-appearance: none;
}
.field select {
    padding-right: 40px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%237C7767' d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 24px;
}
.field select:focus, .field input:focus { outline: none; border: 2px solid var(--primary); padding-left: 15px; }
.field > span {
    position: absolute;
    left: 12px;
    top: -8px;
    padding: 0 4px;
    font-size: 12px;
    line-height: 16px;
    color: var(--on-surface-variant);
    background: var(--dlg-bg, var(--surface-container-high));
}
.field:focus-within > span { color: var(--primary); }
.field select option { background: var(--surface-container-high); color: var(--on-surface); }

.card-filled, .card-elevated { padding: 12px; border-radius: 12px; }
.card-filled { background: var(--surface-variant); }
.card-elevated { margin-top: 12px; background: var(--surface-container-highest); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 2px 6px 2px rgba(0, 0, 0, 0.15); }
.card-filled small, .card-elevated small { display: block; font-size: 12px; line-height: 16px; color: var(--on-surface); }
.big-inc { color: var(--primary); font-size: 22px; line-height: 28px; }
.big-greg { color: var(--on-surface); font-size: 16px; line-height: 24px; font-weight: 500; }
.radio-row { display: flex; align-items: center; gap: 16px; padding: 8px 0; color: var(--on-surface); font-size: 16px; cursor: pointer; }
.radio-row input { width: 20px; height: 20px; margin: 10px; accent-color: var(--primary); }

.sheet {
    width: 100%;
    max-width: 640px;
    margin: auto auto 0;
    border-radius: 28px 28px 0 0;
    background: var(--surface-container-low);
    padding: 0 24px calc(32px + var(--safe-bottom));
    overflow-y: auto;
}
.sheet[open] { animation: sheet-up 0.25s ease-out; }
@keyframes sheet-up { from { transform: translateY(100%); } }
.sheet .handle { width: 32px; height: 4px; margin: 22px auto; border-radius: 2px; background: color-mix(in srgb, var(--on-surface-variant) 40%, transparent); }
.sheet-head { display: flex; flex-direction: column; align-items: center; text-align: center; margin-bottom: 20px; }
.sheet-disc { width: 72px; height: 72px; border-radius: 50%; background: var(--primary-container); display: flex; align-items: center; justify-content: center; margin-bottom: 12px; }
.sheet-disc .chakra { width: 46px; height: 46px; }
.sheet-head h2 { margin: 0; font-size: 24px; line-height: 32px; font-weight: 600; letter-spacing: 0; }
.sheet-head div { color: var(--primary); font-size: 14px; line-height: 20px; font-weight: 500; }
.fact { display: flex; gap: 14px; padding: 7px 0; color: var(--on-surface-variant); font-size: 14px; line-height: 20px; }
.fact b {
    flex: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--primary-container);
    color: var(--on-primary-container);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}
