/* Special School Sasthrolsavam – public site styles (mobile first) */
:root {
    --brand: #0f4c75;
    --brand-dark: #0a3655;
    --brand-light: #e8f1f8;
    --accent: #f2a541;
    --accent-dark: #d98a1f;
    --ok: #1e8e5a;
    --danger: #c0392b;
    --danger-bg: #fdecea;
    --text: #1f2933;
    --muted: #5f6b7a;
    --line: #e2e8f0;
    --bg: #f4f7fb;
    --card: #ffffff;
    --gold: #d4a017;
    --silver: #9aa5b1;
    --bronze: #b0703c;
    --radius: 14px;
    --shadow: 0 6px 24px rgba(15, 76, 117, .08);
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: "Poppins", "Noto Sans Malayalam", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    font-size: 15px;
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
}

img { max-width: 100%; height: auto; }
a { color: var(--brand); }
a:hover { color: var(--brand-dark); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.container { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 16px; }

.skip-link {
    position: absolute; left: -999px; top: 0; background: var(--accent); color: #000;
    padding: 8px 14px; z-index: 100; font-weight: 600;
}
.skip-link:focus { left: 8px; top: 8px; }

/* ---------- Header ---------- */
.site-banner { background: #fff; line-height: 0; }
/* HEADER.jpg (2172x724) has white bands above/below the artwork; crop them. Remove if the image is re-cropped. */
.site-banner img { width: 100%; display: block; aspect-ratio: 2172 / 288; object-fit: cover; object-position: center 49%; }

.site-nav {
    position: sticky; top: 0; z-index: 50;
    background: var(--brand);
    box-shadow: 0 2px 10px rgba(0, 0, 0, .15);
}
.site-nav .container { display: flex; align-items: center; justify-content: space-between; min-height: 56px; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-weight: 600; }
.brand:hover { color: #fff; }
.brand img { width: 36px; height: 36px; border-radius: 50%; background: #fff; padding: 2px; }
.brand span { font-size: 15px; line-height: 1.2; }

.nav-toggle {
    background: transparent; border: 1px solid rgba(255, 255, 255, .4); color: #fff;
    border-radius: 8px; width: 44px; height: 40px; cursor: pointer; display: inline-flex;
    align-items: center; justify-content: center; font-size: 20px;
}

.nav-links {
    display: none; list-style: none; margin: 0; padding: 8px 0 12px;
    position: absolute; left: 0; right: 0; top: 100%; background: var(--brand-dark);
}
.nav-links.open { display: block; }
.nav-links a {
    display: block; padding: 12px 20px; color: #fff; text-decoration: none; font-weight: 500;
}
.nav-links a:hover, .nav-links a.active { background: rgba(255, 255, 255, .12); color: #fff; }
.nav-links a.active { box-shadow: inset 4px 0 0 var(--accent); }

@media (min-width: 900px) {
    .nav-toggle { display: none; }
    .nav-links { display: flex !important; position: static; background: none; padding: 0; gap: 4px; }
    .nav-links a { padding: 8px 14px; border-radius: 8px; }
    .nav-links a.active { box-shadow: inset 0 -3px 0 var(--accent); }
}

/* ---------- Layout ---------- */
main { padding: 20px 0 40px; }

.page-head { margin: 4px 0 18px; }
.page-head h1 { font-size: 22px; line-height: 1.3; margin: 0 0 4px; color: var(--brand-dark); }
.page-head p { margin: 0; color: var(--muted); }
.page-head .actions { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 8px; }

@media (min-width: 768px) {
    .page-head h1 { font-size: 28px; }
}

.card {
    background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
    border: 1px solid var(--line); overflow: hidden; margin-bottom: 18px;
}
.card-head {
    padding: 14px 18px; border-bottom: 1px solid var(--line); background: var(--brand-light);
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px;
}
.card-head h2, .card-head h3 { margin: 0; font-size: 17px; color: var(--brand-dark); line-height: 1.35; }
.card-head .meta { font-size: 13px; color: var(--muted); }
.card-body { padding: 18px; }

.grid { display: grid; gap: 18px; }
@media (min-width: 768px) {
    .grid-2 { grid-template-columns: 1fr 1fr; }
    .grid-3 { grid-template-columns: repeat(3, 1fr); }
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 44px; padding: 10px 18px; border-radius: 10px; border: 1px solid transparent;
    font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; transition: background .15s;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); color: #fff; }
.btn-accent { background: var(--accent); color: #2b1a00; }
.btn-accent:hover { background: var(--accent-dark); color: #2b1a00; }
.btn-outline { background: #fff; color: var(--brand); border-color: var(--brand); }
.btn-outline:hover { background: var(--brand-light); }
.btn-block { width: 100%; }
.btn-sm { min-height: 36px; padding: 6px 12px; font-size: 14px; }

/* ---------- Hero / Home ---------- */
.hero {
    background: linear-gradient(135deg, var(--brand) 0%, #1b6ca8 60%, #3282b8 100%);
    color: #fff; padding: 28px 0 32px;
}
.hero-grid { display: grid; gap: 24px; align-items: start; }
@media (min-width: 900px) {
    .hero { padding: 44px 0 48px; }
    .hero-grid { grid-template-columns: 1.35fr 1fr; gap: 40px; }
}
.hero-title { display: flex; gap: 14px; align-items: center; margin-bottom: 14px; }
.hero-title img { width: 64px; height: 64px; border-radius: 50%; background: #fff; padding: 4px; flex: none; }
.hero h1 { font-size: 22px; line-height: 1.3; margin: 0; }
.hero .tag { display: inline-block; background: var(--accent); color: #2b1a00; font-weight: 600; font-size: 13px; padding: 3px 10px; border-radius: 999px; margin-bottom: 6px; }
.hero .intro { font-size: 15px; line-height: 1.85; opacity: .95; text-align: justify; }
.hero .intro p { margin: 0 0 12px; }
.hero .intro.collapsed { max-height: 9.5em; overflow: hidden; position: relative; }
.hero .intro.collapsed::after {
    content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3em;
    background: linear-gradient(transparent, #1b6ca8);
}
.link-btn { background: none; border: 0; color: #fff; text-decoration: underline; font: inherit; font-weight: 600; cursor: pointer; padding: 6px 0; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.hero-actions .btn-outline { background: transparent; color: #fff; border-color: rgba(255, 255, 255, .7); }
.hero-actions .btn-outline:hover { background: rgba(255, 255, 255, .12); }
@media (min-width: 768px) {
    .hero h1 { font-size: 28px; }
}

/* ---------- Login card ---------- */
.login-card { background: #fff; color: var(--text); border-radius: 18px; box-shadow: 0 16px 40px rgba(0, 0, 0, .2); padding: 22px; }
.login-card h2 { margin: 0 0 4px; font-size: 20px; color: var(--brand-dark); }
.login-card .sub { margin: 0 0 16px; color: var(--muted); font-size: 14px; }

.field { margin-bottom: 14px; }
.field label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.input-wrap { position: relative; display: flex; }
.input-wrap .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.input {
    width: 100%; min-height: 46px; padding: 10px 12px 10px 38px; font: inherit; font-size: 16px;
    border: 1.5px solid var(--line); border-radius: 10px; background: #fff; color: var(--text);
}
.input:focus { border-color: var(--brand); outline: none; box-shadow: 0 0 0 3px rgba(15, 76, 117, .15); }
.input.no-icon { padding-left: 12px; }
.input-wrap .toggle-pw {
    position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
    background: none; border: 0; color: var(--muted); cursor: pointer; padding: 8px 10px; font-size: 16px;
}

.captcha-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.captcha-img { border: 1.5px solid var(--line); border-radius: 10px; height: 56px; width: 180px; max-width: 70%; background: #f6f8fc; }
.icon-btn {
    width: 44px; height: 44px; border-radius: 10px; border: 1.5px solid var(--line); background: #fff;
    color: var(--brand); cursor: pointer; font-size: 18px; display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: var(--brand-light); }
.captcha-input { text-transform: uppercase; letter-spacing: 4px; font-weight: 600; }
.hint { font-size: 12.5px; color: var(--muted); margin-top: 4px; }

.alert { padding: 12px 14px; border-radius: 10px; margin-bottom: 14px; font-size: 14px; }
.alert-danger { background: var(--danger-bg); color: var(--danger); border: 1px solid #f5c6c0; }
.alert-info { background: var(--brand-light); color: var(--brand-dark); border: 1px solid #c9dcec; }

/* ---------- Section titles ---------- */
.section { padding: 28px 0 8px; }
.section-title { display: flex; align-items: center; gap: 10px; margin: 0 0 16px; font-size: 20px; color: var(--brand-dark); }
.section-title::before { content: ""; width: 6px; height: 24px; border-radius: 3px; background: var(--accent); }

/* ---------- Leaderboard ---------- */
.leader-list { list-style: none; margin: 0; padding: 0; }
.leader-list li { display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--line); }
.leader-list li:last-child { border-bottom: 0; }
.rank-badge {
    flex: none; width: 36px; height: 36px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
    font-weight: 700; background: var(--brand-light); color: var(--brand-dark);
}
.rank-1 .rank-badge { background: var(--gold); color: #fff; }
.rank-2 .rank-badge { background: var(--silver); color: #fff; }
.rank-3 .rank-badge { background: var(--bronze); color: #fff; }
.leader-info { flex: 1; min-width: 0; }
.leader-info strong { display: block; font-size: 14.5px; line-height: 1.35; }
.leader-info small { color: var(--muted); font-size: 12.5px; }
.leader-score { font-weight: 700; color: var(--brand); font-size: 17px; white-space: nowrap; }
.card-foot { padding: 12px 18px; border-top: 1px solid var(--line); text-align: right; }

.empty {
    text-align: center; color: var(--muted); padding: 32px 18px;
}
.empty .big { font-size: 34px; display: block; margin-bottom: 6px; }

/* ---------- Festival result cards ---------- */
.fest-card .card-body { display: grid; gap: 10px; }
@media (min-width: 560px) {
    .fest-card .card-body { grid-template-columns: repeat(3, 1fr); }
}

/* ---------- Tables (become cards on phones) ---------- */
.table-wrap { width: 100%; overflow-x: auto; }
.rtable { width: 100%; border-collapse: collapse; font-size: 14px; }
.rtable th, .rtable td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.rtable thead th { background: #f8fafc; font-size: 12.5px; text-transform: uppercase; letter-spacing: .3px; color: var(--muted); white-space: nowrap; }
.rtable tbody tr:nth-child(even) { background: #fbfcfe; }
.rtable tbody tr:hover { background: var(--brand-light); }
.rtable .num { text-align: center; }
.rtable .total { font-weight: 700; color: var(--brand); }
.rtable tr.rank-1 td:first-child, .rtable tr.rank-2 td:first-child, .rtable tr.rank-3 td:first-child { font-weight: 700; }

.pill { display: inline-block; min-width: 28px; padding: 2px 8px; border-radius: 999px; font-weight: 700; font-size: 13px; text-align: center; background: var(--brand-light); color: var(--brand-dark); }
.pill.r1 { background: var(--gold); color: #fff; }
.pill.r2 { background: var(--silver); color: #fff; }
.pill.r3 { background: var(--bronze); color: #fff; }
.pill.grade { background: #e7f6ee; color: var(--ok); }

@media (max-width: 700px) {
    .rtable thead { display: none; }
    .rtable, .rtable tbody, .rtable tr, .rtable td { display: block; width: 100%; }
    .rtable tr { padding: 10px 14px; border-bottom: 1px solid var(--line); }
    .rtable tbody tr:nth-child(even) { background: #fff; }
    .rtable td { border: 0; padding: 4px 0; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
    .rtable td > .cell-val { text-align: right; }
    .rtable td::before { content: attr(data-label); font-weight: 600; color: var(--muted); text-align: left; flex: none; max-width: 45%; }
    .rtable td.num { text-align: right; }
    .rtable td.cell-main { display: block; text-align: left; font-weight: 600; font-size: 15px; padding-bottom: 6px; }
    .rtable td.cell-main::before { display: none; }
}

/* ---------- Search / toolbar ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; align-items: center; }
.toolbar .search { flex: 1 1 260px; position: relative; }
.toolbar .search .input { padding-left: 38px; }
.toolbar .search .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }

.item-jump { width: 100%; min-height: 46px; padding: 8px 12px; border-radius: 10px; border: 1.5px solid var(--line); font: inherit; background: #fff; }

/* ---------- Simple list ---------- */
.link-list { list-style: none; padding: 0; margin: 0; }
.link-list li { border-bottom: 1px solid var(--line); }
.link-list li:last-child { border-bottom: 0; }
.link-list a { display: flex; align-items: center; gap: 12px; padding: 14px 18px; text-decoration: none; color: var(--text); font-weight: 500; }
.link-list a:hover { background: var(--brand-light); }
.link-list .fa { color: var(--brand); width: 20px; text-align: center; }

/* ---------- Footer ---------- */
.site-footer { background: var(--brand-dark); color: rgba(255, 255, 255, .85); padding: 22px 0; font-size: 13.5px; text-align: center; }
.site-footer a { color: var(--accent); }

.back-top {
    position: fixed; right: 16px; bottom: 16px; width: 46px; height: 46px; border-radius: 50%;
    background: var(--accent); color: #2b1a00; border: 0; box-shadow: var(--shadow); cursor: pointer;
    font-size: 18px; display: none; z-index: 40;
}
.back-top.show { display: inline-flex; align-items: center; justify-content: center; }

.text-muted { color: var(--muted); }
.mt-0 { margin-top: 0; }

/* ---------- Print ---------- */
@media print {
    .site-nav, .site-footer, .toolbar, .back-top, .no-print, .page-head .actions { display: none !important; }
    body { background: #fff; font-size: 12px; }
    .card { box-shadow: none; border: 1px solid #999; break-inside: avoid; }
    .rtable thead { display: table-header-group !important; }
    .rtable { display: table !important; width: 100%; }
    .rtable tbody { display: table-row-group !important; }
    .rtable tr { display: table-row !important; }
    .rtable td { display: table-cell !important; text-align: left !important; }
    .rtable td::before { display: none !important; }
}

.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.result-item, #login { scroll-margin-top: 72px; }

/* ---------- Nav login button ---------- */
.nav-links a.nav-login { background: var(--accent); color: #2b1a00; font-weight: 600; margin: 8px 16px 0; border-radius: 10px; text-align: center; }
.nav-links a.nav-login:hover { background: var(--accent-dark); color: #2b1a00; }
@media (min-width: 900px) {
    .nav-links a.nav-login { margin: 0 0 0 6px; }
}

/* ---------- Compact hero ---------- */
.hero.compact { padding: 20px 0 22px; }
.hero.compact .hero-title { margin-bottom: 0; }
.hero.compact .hero-inner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; }
.hero.compact .hero-actions { margin-top: 0; }
.hero.compact .hero-title img { width: 54px; height: 54px; }
.hero.compact h1 { font-size: 19px; }
@media (min-width: 768px) {
    .hero.compact { padding: 26px 0; }
    .hero.compact h1 { font-size: 26px; }
}

.about .intro { line-height: 1.9; text-align: justify; }
.about .intro p { margin: 0 0 12px; }
.about .intro.collapsed { max-height: 7.6em; overflow: hidden; position: relative; }
.about .intro.collapsed::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3em; background: linear-gradient(rgba(255,255,255,0), #fff); }
.about .link-btn { color: var(--brand); }

/* ---------- Login modal ---------- */
.modal {
    position: fixed; inset: 0; z-index: 200; display: none; align-items: center; justify-content: center;
    padding: 16px; background: rgba(10, 30, 50, .6); backdrop-filter: blur(2px);
}
.modal.open { display: flex; }
.modal .login-card { width: 100%; max-width: 400px; max-height: calc(100vh - 32px); overflow-y: auto; position: relative; animation: pop .18s ease-out; }
.modal-close {
    position: absolute; top: 10px; right: 10px; width: 40px; height: 40px; border-radius: 50%;
    border: 0; background: var(--bg); color: var(--muted); font-size: 18px; cursor: pointer;
}
.modal-close:hover { background: var(--line); color: var(--text); }
body.modal-open { overflow: hidden; }
@keyframes pop { from { transform: translateY(12px) scale(.98); } to { transform: none; } }
@media (min-width: 900px) {
    .hero .hero-login { display: none; } /* nav bar has its own Login button on desktop */
}

/* ---------- Mobile nav login ---------- */
.nav-right { display: flex; align-items: center; gap: 8px; }
.nav-links a.nav-login { display: none; }
@media (min-width: 900px) {
    .nav-login-mobile { display: none; }
    .nav-links a.nav-login { display: block; }
}

/* ---------- Find Results form ---------- */
.finder .card-head { background: linear-gradient(135deg, var(--brand) 0%, #1b6ca8 100%); border-bottom: 0; }
.finder .card-head h2 { color: #fff; }
.finder .card-head .meta { color: rgba(255, 255, 255, .85); }
.finder-form { display: grid; gap: 4px 16px; }
.finder-form .field { margin-bottom: 10px; }
.finder-form .field label { font-size: 13.5px; }
@media (min-width: 600px) {
    .finder-form { grid-template-columns: 1fr 1fr; align-items: end; }
}
@media (min-width: 1080px) {
    .finder-form { grid-template-columns: 1fr 1.4fr 1.2fr auto; }
    .finder-form .field { margin-bottom: 0; }
}
.finder-submit .btn { min-height: 46px; white-space: nowrap; }
.finder-links { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 18px 16px; }
.finder-links a {
    display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 999px;
    background: var(--brand-light); color: var(--brand-dark); text-decoration: none; font-size: 13.5px; font-weight: 500;
}
.finder-links a:hover { background: #d6e6f3; }

/* ---------- KITE footer ---------- */
.site-footer { background: #1f2329; text-align: left; padding: 24px 0; }
.footer-inner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px 24px; }
.kite-credit { display: flex; align-items: center; gap: 16px; text-decoration: none; color: inherit; }
.kite-credit:hover { color: inherit; }
.kite-logo { flex: none; background: #fff; border-radius: 10px; padding: 6px 10px; line-height: 0; }
.kite-logo img { width: 92px; height: auto; }
.kite-text { display: flex; flex-direction: column; line-height: 1.5; }
.kite-text strong { color: #fff; font-size: 15.5px; }
.kite-text span { color: #9aa4b2; font-size: 13.5px; }
.footer-copy { margin: 0; color: #7d8794; font-size: 12.5px; }

/* ---------- Small phones ---------- */
@media (max-width: 599px) {
    .hero .intro, .about .intro { text-align: left; } /* justified Malayalam leaves big gaps on narrow screens */
    .card-body { padding: 14px; }
    .card-head { padding: 12px 14px; }
    .leader-list li { padding: 12px 14px; gap: 10px; }
    .finder-links { padding: 0 14px 14px; }
    .footer-inner { flex-direction: column; align-items: flex-start; }
}
@media (max-width: 400px) {
    .site-nav .container { gap: 8px; }
    .brand span { font-size: 13px; }
    .brand img { width: 32px; height: 32px; }
    .nav-login-mobile { padding: 6px 10px; }
    .leader-score { font-size: 15px; }
    .rank-badge { width: 30px; height: 30px; font-size: 14px; }
    .kite-credit { gap: 12px; }
    .kite-logo img { width: 72px; }
    .kite-text strong { font-size: 14px; }
}
@media (max-width: 340px) {
    .brand span { display: none; } /* logo only on very small phones so Login + menu fit */
}

/* ---------- Pre-results home (no data yet) ---------- */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (min-width: 900px) { .tiles { grid-template-columns: repeat(4, 1fr); gap: 18px; } }
.tile {
    display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 18px 16px;
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
    text-decoration: none; color: var(--text); transition: transform .15s, box-shadow .15s;
}
.tile:hover { transform: translateY(-2px); box-shadow: 0 10px 28px rgba(15, 76, 117, .14); color: var(--text); }
.tile .fa { font-size: 22px; color: var(--brand); background: var(--brand-light); width: 46px; height: 46px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; margin-bottom: 8px; }
.tile strong { font-size: 15px; }
.tile span { font-size: 13px; color: var(--muted); }
.tile-accent .fa { background: var(--accent); color: #2b1a00; }
