/* Hrudayapoorvam – public pages */
:root {
  --maroon: #7a1d1d;
  --maroon-dark: #5a1212;
  --gold: #b8862b;
  --gold-soft: #e7c98a;
  --cream: #fff3df;
  --paper: #fdebcd;
  --ink: #3b2414;
  --muted: #7d6450;
  --pink: #c2185b;
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Noto Sans Malayalam", system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
  background: radial-gradient(ellipse at top, #fbe6c6 0%, #f1d6ab 60%, #e6c48f 100%) fixed;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* The artwork is split into header / repeating parchment / footer so the page can grow with the form */
.page {
  max-width: 760px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 46% 5% 34%;
  background:
    url("../img/header.jpg") top center / 100% auto no-repeat,
    url("../img/footer.jpg") bottom center / 100% auto no-repeat,
    url("../img/middle.jpg") top center / 100% auto repeat-y;
  box-shadow: 0 0 40px rgba(90, 40, 10, .25);
}
@media (min-width: 761px) { .page { padding: 348px 44px 258px; } }

.card {
  background: rgba(255, 248, 236, .82);
  backdrop-filter: blur(2px);
  border: 1px solid rgba(184, 134, 43, .45);
  border-radius: var(--radius);
  padding: 22px 20px 24px;
  box-shadow: 0 8px 24px rgba(122, 29, 29, .10);
}

.welcome { text-align: center; margin-bottom: 14px; }
.welcome h2 {
  font-family: "Noto Serif Malayalam", serif;
  color: var(--maroon);
  font-size: 1.35rem;
  margin: 0 0 2px;
  line-height: 1.5;
}
.welcome .en { margin: 0; color: var(--gold); font-weight: 600; letter-spacing: .3px; font-size: .95rem; }
.intro, .welcome .intro { text-align: center;  font-size: .9rem; color: var(--muted); margin: 10px 0 0; line-height: 1.7; }
.welcome::after {
  content: "❁";
  display: block;
  color: var(--gold);
  margin-top: 8px;
  font-size: 1.1rem;
}

.field { display: block; margin-bottom: 14px; }
.field > span, .check > span { font-weight: 600; font-size: .92rem; color: var(--maroon-dark); }
.field em, .check em { font-style: normal; font-weight: 500; color: var(--muted); font-size: .82rem; }
.field > span { display: block; margin-bottom: 5px; }

input[type=text], input[type=tel], select, textarea {
  width: 100%;
  font: inherit;
  font-size: 1rem;
  color: var(--ink);
  background: #fffaf2;
  border: 1px solid #d9b98a;
  border-radius: 10px;
  padding: 11px 12px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--maroon);
  box-shadow: 0 0 0 3px rgba(122, 29, 29, .12);
}
textarea { resize: vertical; min-height: 140px; line-height: 1.7; }
.mt { margin-top: 8px; }

.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 420px) { .row { grid-template-columns: 1fr; gap: 0; } }

.phone { display: flex; align-items: stretch; }
.phone #dialCode {
  display: flex; align-items: center;
  padding: 0 12px;
  background: var(--gold-soft);
  border: 1px solid #d9b98a; border-right: 0;
  border-radius: 10px 0 0 10px;
  font-weight: 600; color: var(--maroon-dark);
}
.phone #dialCode:empty { display: none; }
.phone #dialCode:not(:empty) + input { border-radius: 0 10px 10px 0; }

.check { display: flex; gap: 10px; align-items: flex-start; margin: 4px 0 14px; cursor: pointer; line-height: 1.55; }
.check input { width: 20px; height: 20px; margin-top: 3px; accent-color: var(--maroon); flex: none; }
.check > span { font-weight: 500; font-size: .88rem; }


.counter { display: block; text-align: right; color: var(--muted); font-size: .75rem; margin-top: 3px; }
.field-error { display: block; color: #b3261e; font-size: .8rem; margin-top: 4px; }
.alert {
  background: #fde8e6; border: 1px solid #f2b8b5; color: #8c1d18;
  border-radius: 10px; padding: 10px 12px; margin-bottom: 14px; font-size: .9rem;
}
.notice { text-align: center; padding: 18px; color: var(--maroon-dark); line-height: 1.8; }
.hp { position: absolute; left: -9999px; }

.btn {
  display: block; width: 100%;
  border: 0; border-radius: 999px;
  padding: 14px 18px;
  font: inherit; font-weight: 700; font-size: 1.05rem;
  color: #fff;
  background: linear-gradient(180deg, #932626, var(--maroon-dark));
  box-shadow: 0 6px 16px rgba(122, 29, 29, .35), inset 0 1px 0 rgba(255, 255, 255, .2);
  cursor: pointer;
  text-align: center; text-decoration: none;
  transition: transform .1s, box-shadow .1s;
}
.btn span { font-weight: 500; opacity: .85; margin-left: 6px; font-size: .9rem; }
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .7; cursor: wait; }
.btn-ghost {
  background: transparent; color: var(--maroon);
  border: 1.5px solid var(--maroon); box-shadow: none; margin-top: 16px; font-size: .95rem;
}

/* Thank-you page */
.thanks { text-align: center; }
.entry-no strong { display: block; font-size: 2.6rem; color: var(--maroon); line-height: 1.2; font-family: Georgia, serif; }
.entry-no small, .schedule small, .stats small { color: var(--muted); font-size: .8rem; display: block; }
.schedule {
  margin: 16px 0;
  padding: 16px;
  border-radius: 12px;
  background: linear-gradient(180deg, #fff6e6, #fbe3bb);
  border: 1px solid var(--gold);
}
.schedule strong { display: block; font-size: 1.3rem; color: var(--maroon-dark); margin: 4px 0; }
.schedule > span { display: inline-block; background: var(--maroon); color: #fff; border-radius: 999px; padding: 2px 12px; font-size: .78rem; }
.schedule p { font-size: .85rem; color: var(--muted); margin: 10px 0 0; line-height: 1.6; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stats > div { background: rgba(255, 255, 255, .7); border: 1px solid #ecd3a6; border-radius: 10px; padding: 10px 4px; }
.stats strong { display: block; font-size: 1.35rem; color: var(--maroon); font-family: Georgia, serif; }
.fineprint { font-size: .75rem; color: var(--muted); margin: 14px 0 0; line-height: 1.6; }

/* Language switch (Google Translate) */
.lang-switch {
  display: flex; justify-content: center; gap: 4px;
  width: fit-content; margin: -6px auto 14px;
  padding: 3px; border-radius: 999px;
  background: rgba(231, 201, 138, .35); border: 1px solid rgba(184, 134, 43, .45);
}
.lang-switch button {
  border: 0; background: transparent; cursor: pointer;
  font: inherit; font-size: .8rem; font-weight: 600; color: var(--maroon-dark);
  padding: 6px 12px; border-radius: 999px;
}
.lang-switch button.active { background: var(--maroon); color: #fff; box-shadow: 0 2px 6px rgba(122, 29, 29, .3); }

/* ===== v3: wider, more interactive form ===== */
.card { padding: 26px 28px 30px; }
@media (max-width: 520px) { .card { padding: 20px 16px 24px; } }
.intro { font-size: .92rem; color: var(--muted); line-height: 1.75; margin: 0 0 14px; }

.progress-wrap { display: flex; align-items: center; gap: 10px; margin: 0 0 18px; position: sticky; top: 0; z-index: 3;
  background: rgba(255, 248, 236, .92); padding: 8px 0; backdrop-filter: blur(4px); }
.progress-track { flex: 1; height: 8px; background: #f0dcb8; border-radius: 999px; overflow: hidden; }
.progress-track span { display: block; height: 100%; width: 0; border-radius: 999px;
  background: linear-gradient(90deg, var(--gold), var(--maroon)); transition: width .45s cubic-bezier(.2,.8,.2,1); }
.progress-wrap small { font-size: .75rem; color: var(--muted); font-weight: 600; min-width: 108px; text-align: right; }

.section { border: 0; padding: 0; margin: 0 0 22px; }
.section legend { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--maroon); font-size: 1.02rem; margin-bottom: 12px; padding: 0; }
.section legend em { font-style: normal; font-weight: 500; color: var(--muted); font-size: .85rem; }
.step { width: 28px; height: 28px; border-radius: 50%; display: inline-grid; place-items: center; font-size: .85rem;
  background: linear-gradient(180deg, #a83232, var(--maroon-dark)); color: #fff; box-shadow: 0 3px 8px rgba(122,29,29,.3); flex: none; }
.row-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 640px) { .row-3 { grid-template-columns: 1fr; } }
.hint { display: block; font-size: .74rem; color: var(--muted); margin-top: 5px; line-height: 1.5; }
.sub-label { display: block; font-weight: 600; font-size: .9rem; color: var(--maroon-dark); margin: 4px 0 8px; }
.sub-label em { font-style: normal; color: var(--muted); font-weight: 500; font-size: .82rem; }

/* Choice cards */
.choice-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.choice { position: relative; text-align: left; cursor: pointer; font: inherit; color: var(--ink);
  background: #fffaf2; border: 1.5px solid #e2c697; border-radius: 14px; padding: 14px 14px 12px;
  display: flex; flex-direction: column; gap: 2px; transition: transform .15s, box-shadow .2s, border-color .2s, background .2s; }
.choice:hover { transform: translateY(-2px); box-shadow: 0 8px 18px rgba(122,29,29,.10); }
.choice strong { font-size: .92rem; color: var(--maroon-dark); }
.choice small { font-size: .8rem; color: var(--muted); }
.choice-ico { display: block; width: 34px; height: 34px; font-size: 1.5rem; line-height: 34px; margin-bottom: 8px; transition: transform .3s; transform-origin: center; }
.choice.on { border-color: var(--maroon); background: linear-gradient(180deg, #fff, #fdeedd); box-shadow: 0 0 0 3px rgba(122,29,29,.12); }
.choice.on .choice-ico { transform: scale(1.1) rotate(-6deg); }
.choice.on::after { content: "✓"; position: absolute; top: 10px; right: 12px; width: 22px; height: 22px; border-radius: 50%;
  background: var(--maroon); color: #fff; font-size: .75rem; display: grid; place-items: center; animation: pop .25s ease-out; }
@media (max-width: 420px) { .choice-cards { grid-template-columns: 1fr; } }

/* Animated reveal */
.reveal { max-height: 0; opacity: 0; overflow: hidden; transition: max-height .45s ease, opacity .3s ease; }
.reveal.open { max-height: 1400px; opacity: 1; }
.reveal:not(.open) { pointer-events: none; }

/* District chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { cursor: pointer; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span { display: inline-block; padding: 7px 13px; border-radius: 999px; font-size: .84rem; font-weight: 500;
  background: #fffaf2; border: 1px solid #e2c697; color: var(--ink); transition: all .15s; }
.chip:hover span { border-color: var(--gold); transform: translateY(-1px); }
.chip input:checked + span { background: var(--maroon); border-color: var(--maroon); color: #fff; box-shadow: 0 4px 10px rgba(122,29,29,.25); animation: pop .2s ease-out; }
.chip input:focus-visible + span { outline: 2px solid var(--gold); outline-offset: 2px; }

/* Toggle switch */
.toggle { display: flex; align-items: center; gap: 12px; cursor: pointer; margin: 6px 0 12px; font-weight: 600; font-size: .9rem; color: var(--maroon-dark); }
.toggle em { font-style: normal; color: var(--muted); font-weight: 500; }
.toggle input { position: absolute; opacity: 0; }
.toggle .track { width: 46px; height: 26px; border-radius: 999px; background: #e0cba6; position: relative; flex: none; transition: background .2s; }
.toggle .knob { position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 2px 4px rgba(0,0,0,.2); transition: left .2s; }
.toggle input:checked + .track { background: var(--maroon); }
.toggle input:checked + .track .knob { left: 23px; }
.toggle input:focus-visible + .track { outline: 2px solid var(--gold); outline-offset: 2px; }
.roots { background: rgba(231, 201, 138, .18); border: 1px dashed var(--gold); border-radius: 12px; padding: 0 14px; }
.roots.open { padding: 14px; }
.roots-preview { margin-top: 10px; padding: 10px 12px; border-radius: 10px; background: #fff; border: 1px solid #ecd3a6; font-size: .9rem; animation: fadeUp .3s ease-out; }
.roots-preview span { color: var(--gold); margin: 0 6px; }

/* Word meter */
textarea#message { min-height: 180px; transition: height .1s; }
.word-meter { margin-top: 8px; }
.wm-track { position: relative; height: 6px; background: #f0dcb8; border-radius: 999px; overflow: visible; }
.wm-fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; border-radius: 999px; background: var(--gold); transition: width .25s ease, background .25s; }
.wm-min { position: absolute; top: -3px; width: 2px; height: 12px; background: var(--maroon); opacity: .5; }
.wm-text { display: flex; justify-content: space-between; font-size: .75rem; color: var(--muted); margin-top: 5px; }
.word-meter.ok .wm-fill { background: #2f7d53; }
.word-meter.ok #wmHint { color: #2f7d53; font-weight: 600; }
.word-meter.over .wm-fill { background: #b3261e; }
.word-meter.over #wmHint, .word-meter.low #wmHint { color: #b3261e; }
.word-meter.shake { animation: shake .4s; }

.btn.loading .btn-label { opacity: .6; }
.btn.loading::after { content: ""; display: inline-block; width: 16px; height: 16px; margin-left: 10px; vertical-align: -3px;
  border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }

@keyframes pop { 0% { transform: scale(.85); } 70% { transform: scale(1.06); } 100% { transform: scale(1); } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes shake { 0%,100% { transform: none; } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
.wa-note { margin-top: 14px; padding: 12px; border-radius: 12px; background: #e7f6ec; border: 1px solid #b9e2c6; color: #1d5c3a; font-size: .88rem; line-height: 1.6; }
.wa-note small { color: #3b7a55; }
.thanks .schedule, .thanks .stats > div, .thanks .entry-no { animation: fadeUp .5s ease-out both; }
.thanks .stats > div:nth-child(2) { animation-delay: .08s; } .thanks .stats > div:nth-child(3) { animation-delay: .16s; }
.section legend { flex-wrap: wrap; row-gap: 2px; line-height: 1.4; }
@media (max-width: 520px) { .section legend em { flex-basis: 100%; padding-left: 38px; } }

/* YouTube subscribe card (thank-you page) */
.yt-card { margin-top: 16px; padding: 16px; border-radius: 16px; text-align: left;
  background: linear-gradient(180deg, #fff, #fff4f1); border: 1px solid #f3c9c0; box-shadow: 0 6px 18px rgba(204,0,0,.08);
  animation: fadeUp .5s ease-out .25s both; }
.yt-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.yt-logo svg { width: 38px; height: 27px; display: block; }
.yt-head strong { display: block; color: var(--ink); font-size: .98rem; line-height: 1.2; }
.yt-head small { color: var(--muted); font-size: .75rem; }
.yt-q, .yt-thanks { margin: 0; font-size: .92rem; line-height: 1.7; color: var(--maroon-dark); }
.yt-q-en { margin: 4px 0 12px; font-size: .8rem; color: var(--muted); line-height: 1.5; }
.yt-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.is-thanks .yt-actions { grid-template-columns: 1fr; }
@media (max-width: 420px) { .yt-actions { grid-template-columns: 1fr; } }
.yt-btn { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; padding: 11px 10px;
  border-radius: 12px; font: inherit; font-weight: 700; font-size: .92rem; text-decoration: none; cursor: pointer; border: 0;
  transition: transform .12s, box-shadow .15s; }
.yt-btn span { font-size: .75rem; font-weight: 500; opacity: .9; }
.yt-btn:hover { transform: translateY(-2px); }
.yt-sub, .yt-watch { background: #ff0000; color: #fff; box-shadow: 0 6px 16px rgba(255,0,0,.25); }
.yt-sub { animation: ytPulse 2.2s ease-in-out 1s infinite; }
.yt-done { background: #fff; color: var(--ink); border: 1.5px solid #e6d3c2; }
.yt-back { margin-top: 10px; border: 0; background: none; color: var(--muted); font: inherit; font-size: .75rem; cursor: pointer; padding: 0; }
.yt-step { animation: fadeUp .3s ease-out; }
.yt-step[hidden], [data-msg][hidden] { display: none !important; }
@keyframes ytPulse { 0%,100% { box-shadow: 0 6px 16px rgba(255,0,0,.25); } 50% { box-shadow: 0 6px 16px rgba(255,0,0,.25), 0 0 0 7px rgba(255,0,0,.10); } }

/* ===== v7: own EN/ML switch, YouTube card, WhatsApp share ===== */
.lang-switch a {
  display: inline-block; text-decoration: none;
  font-size: .82rem; font-weight: 600; color: var(--maroon-dark);
  padding: 6px 16px; border-radius: 999px; transition: background .15s, color .15s;
}
.lang-switch a:hover { background: rgba(255,255,255,.6); }
.lang-switch a.active { background: var(--maroon); color: #fff; box-shadow: 0 2px 6px rgba(122, 29, 29, .3); }

.yt-title { margin: 0 0 4px; font-weight: 700; color: var(--maroon-dark); font-size: 1rem; line-height: 1.5; }
.yt-text { margin: 0 0 14px; font-size: .86rem; color: var(--muted); line-height: 1.65; }
.yt-card .yt-sub { flex-direction: row; gap: 8px; width: 100%; font-size: 1rem; padding: 13px; }
.yt-card .yt-sub svg { width: 20px; height: 20px; }

.share-box { margin-top: 16px; padding: 16px; border-radius: 16px; background: #effaf2; border: 1px solid #c4e8cf; animation: fadeUp .5s ease-out .35s both; }
.share-box p { margin: 0 0 12px; font-size: .9rem; color: #1d5c3a; line-height: 1.6; font-weight: 500; }
.btn-wa { display: flex; align-items: center; justify-content: center; gap: 10px;
  background: #25d366; color: #fff; box-shadow: 0 6px 16px rgba(37, 211, 102, .35); text-decoration: none; }
.btn-wa:hover { background: #1fbe5b; }
.btn-wa svg { width: 22px; height: 22px; }
.lang-ml .yt-title, .lang-ml .share-box p { font-size: .95rem; }

/* ===== v8: compact Kerala / outside switch ===== */
.seg-toggle { position: relative; display: grid; grid-template-columns: 1fr 1fr; padding: 4px; margin-bottom: 14px;
  background: #f3e3c6; border: 1px solid #e2c697; border-radius: 999px; }
.seg-thumb { position: absolute; top: 4px; bottom: 4px; left: 4px; width: calc(50% - 4px); border-radius: 999px;
  background: linear-gradient(180deg, #a83232, var(--maroon-dark)); box-shadow: 0 3px 10px rgba(122,29,29,.3);
  transition: transform .3s cubic-bezier(.2,.8,.2,1); }
.seg-toggle.is-right .seg-thumb { transform: translateX(100%); }
.seg-toggle .choice { position: relative; z-index: 1; display: flex; align-items: center; justify-content: center; gap: 6px;
  border: 0; background: transparent; box-shadow: none; padding: 10px 8px; border-radius: 999px; transform: none;
  font: inherit; font-size: .84rem; font-weight: 600; line-height: 1.3; text-align: center; color: var(--maroon-dark); cursor: pointer; transition: color .2s; }
.seg-toggle .choice:hover { transform: none; box-shadow: none; }
.seg-toggle .choice.on { color: #fff; background: transparent; box-shadow: none; }
.seg-toggle .choice.on::after { display: none; }
.seg-toggle .choice:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
@media (max-width: 420px) { .seg-toggle .choice { font-size: .76rem; padding: 9px 4px; } }
#keralaBox .field, #rootsBox .field { margin-bottom: 4px; }
.roots.open { padding: 12px 14px 8px; }
