/* ==========================================================================
   P Classes – site styles
   ========================================================================== */

:root {
    --bg: #f7f8fc;
    --bg-alt: #eef0f8;
    --surface: #ffffff;
    --text: #141a2e;
    --text-muted: #5b6380;
    --border: #e1e4ef;
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-soft: #eef0ff;
    --on-primary: #ffffff;
    --accent: #f97316;
    --success: #15803d;
    --danger: #b91c1c;
    --code-bg: #0f1428;
    --shadow: 0 1px 2px rgb(20 26 46 / .06), 0 8px 24px rgb(20 26 46 / .08);
    --radius: 14px;
    --radius-sm: 8px;
    --header-h: 68px;
    --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --font-hi: "Noto Sans Devanagari", var(--font);
    --font-mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #0b1020;
        --bg-alt: #111831;
        --surface: #151d38;
        --text: #e7eaf6;
        --text-muted: #9aa3c2;
        --border: #263056;
        --primary: #818cf8;
        --primary-hover: #a5b4fc;
        --primary-soft: #1d2550;
        --on-primary: #0b1020;
        --success: #4ade80;
        --danger: #f87171;
        --code-bg: #070b18;
        --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 8px 24px rgb(0 0 0 / .35);
        color-scheme: dark;
    }
}

:root[data-theme="dark"] {
    --bg: #0b1020;
    --bg-alt: #111831;
    --surface: #151d38;
    --text: #e7eaf6;
    --text-muted: #9aa3c2;
    --border: #263056;
    --primary: #818cf8;
    --primary-hover: #a5b4fc;
    --primary-soft: #1d2550;
    --on-primary: #0b1020;
    --success: #4ade80;
    --danger: #f87171;
    --code-bg: #070b18;
    --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 8px 24px rgb(0 0 0 / .35);
    color-scheme: dark;
}

/* ---------- Base ---------- */

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

html {
    scroll-behavior: smooth;
    scroll-padding-top: calc(var(--header-h) + 12px);
    -webkit-text-size-adjust: 100%;
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after { animation: none !important; transition: none !important; }
}

body {
    margin: 0;
    font-family: var(--font);
    font-size: 1rem;
    line-height: 1.65;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; height: auto; display: block; }
a { color: var(--primary); text-underline-offset: 3px; }
a:hover { color: var(--primary-hover); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; letter-spacing: -.02em; }
p { margin: 0 0 1em; }
[lang="hi"] { font-family: var(--font-hi); }

:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; border-radius: 4px; }

.icon { width: 1.25em; height: 1.25em; flex: none; }

.container { width: min(1140px, 100% - 32px); margin-inline: auto; }
.container.narrow { width: min(860px, 100% - 32px); }

.skip-link {
    position: absolute; left: 16px; top: -100px; z-index: 100;
    padding: 8px 14px; border-radius: var(--radius-sm);
    background: var(--primary); color: var(--on-primary);
}
.skip-link:focus { top: 12px; }

.muted { color: var(--text-muted); font-size: .9rem; }

/* ---------- Buttons ---------- */

.btn {
    display: inline-flex; align-items: center; gap: .5em;
    padding: .75em 1.35em;
    font: inherit; font-weight: 600; line-height: 1.2;
    border: 1px solid transparent; border-radius: var(--btn-radius, 999px);
    text-decoration: none; cursor: pointer;
    transition: background-color .2s, color .2s, border-color .2s, transform .2s;
}
.btn:active { transform: translateY(1px); }
.btn .icon { width: 1.1em; height: 1.1em; }
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-hover); color: var(--on-primary); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); }
.btn-sm { padding: .5em 1em; font-size: .875rem; }
.btn[disabled] { opacity: .6; cursor: progress; }

.icon-btn {
    display: inline-grid; place-items: center;
    width: 40px; height: 40px; padding: 0;
    border: 1px solid var(--border); border-radius: 50%;
    background: var(--surface); color: var(--text);
    cursor: pointer; transition: border-color .2s, color .2s;
}
.icon-btn:hover { border-color: var(--primary); color: var(--primary); }
.icon-btn .icon { width: 20px; height: 20px; }
.icon-btn[aria-pressed="true"] { background: var(--primary-soft); color: var(--primary); border-color: var(--primary); }

/* ---------- Header ---------- */

.site-header {
    position: sticky; top: 0; z-index: 50;
    height: var(--header-h);
    background: color-mix(in srgb, var(--bg) 82%, transparent);
    backdrop-filter: saturate(160%) blur(12px);
    -webkit-backdrop-filter: saturate(160%) blur(12px);
    border-bottom: 1px solid transparent;
    transition: border-color .2s;
}
.site-header.is-scrolled { border-bottom-color: var(--border); }

.header-inner { height: 100%; display: flex; align-items: center; gap: 24px; }

.brand {
    display: inline-flex; align-items: center; gap: 10px;
    color: var(--text); text-decoration: none; font-weight: 800; font-size: 1.15rem;
}
.brand img { width: 40px; height: 40px; object-fit: contain; }

.site-nav { margin-left: auto; }
.site-nav ul { display: flex; gap: 4px; margin: 0; padding: 0; list-style: none; }
.site-nav a {
    display: block; padding: 8px 14px; border-radius: 999px;
    color: var(--text-muted); font-weight: 500; text-decoration: none;
}
.site-nav a:hover, .site-nav a[aria-current="page"] { color: var(--text); background: var(--primary-soft); }

.header-actions { display: flex; gap: 8px; }
.nav-toggle { display: none; }
.icon-close, .icon-sun { display: none; }
.nav-toggle[aria-expanded="true"] .icon-open { display: none; }
.nav-toggle[aria-expanded="true"] .icon-close { display: block; }

:root[data-theme="dark"] .icon-moon { display: none; }
:root[data-theme="dark"] .icon-sun { display: block; }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .icon-moon { display: none; }
    :root:not([data-theme="light"]) .icon-sun { display: block; }
}

@media (max-width: 820px) {
    .nav-toggle { display: inline-grid; }
    .header-actions { margin-left: auto; }
    .site-nav {
        position: absolute; inset: var(--header-h) 0 auto 0;
        margin: 0; padding: 12px 16px 20px;
        background: var(--surface); border-bottom: 1px solid var(--border);
        box-shadow: var(--shadow);
        display: none;
    }
    .site-nav.is-open { display: block; }
    .site-nav ul { flex-direction: column; }
    .site-nav a { padding: 12px 14px; border-radius: var(--radius-sm); }
}

/* ---------- Hero ---------- */

.hero {
    position: relative; overflow: hidden;
    padding: clamp(48px, 9vw, 112px) 0 clamp(56px, 9vw, 120px);
}
.hero::before {
    content: ""; position: absolute; inset: -40% -10% auto auto;
    width: 720px; height: 720px; border-radius: 50%;
    background: radial-gradient(closest-side, color-mix(in srgb, var(--primary) 22%, transparent), transparent);
    pointer-events: none;
}

.hero-grid {
    position: relative;
    display: grid; grid-template-columns: 1.1fr .9fr; gap: 56px; align-items: center;
}

.eyebrow {
    display: inline-block; margin-bottom: 18px; padding: 6px 14px;
    border-radius: 999px; background: var(--primary-soft); color: var(--primary);
    font-size: .85rem; font-weight: 600;
}
.hero h1 { font-size: clamp(2.25rem, 5.5vw, 3.75rem); font-weight: 800; }
.grad {
    background: linear-gradient(90deg, var(--primary), var(--accent));
    -webkit-background-clip: text; background-clip: text; color: transparent;
}
.lead { font-size: 1.15rem; color: var(--text-muted); max-width: 56ch; }
.lead-hi { font-size: 1.05rem; }
.hero-cta { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 28px; }

.code-card {
    border-radius: var(--radius); overflow: hidden;
    background: var(--code-bg); color: #d7dcf5;
    box-shadow: 0 30px 60px -20px rgb(20 26 46 / .45);
    font-family: var(--font-mono); font-size: .9rem;
    transform: rotate(1.5deg);
}
.code-card-bar { display: flex; align-items: center; gap: 7px; padding: 12px 16px; background: rgb(255 255 255 / .05); }
.code-card-bar span { width: 11px; height: 11px; border-radius: 50%; background: #ff5f57; }
.code-card-bar span:nth-child(2) { background: #febc2e; }
.code-card-bar span:nth-child(3) { background: #28c840; }
.code-card-bar em { margin-left: 10px; font-style: normal; color: #8b93b8; font-size: .8rem; }
.code-card pre { margin: 0; padding: 20px; overflow-x: auto; line-height: 1.7; }
.code-card .k { color: #c792ea; }
.code-card .t { color: #82aaff; }
.code-card .f { color: #ffcb6b; }
.code-card .s { color: #c3e88d; }
.code-card-out { padding: 12px 20px 18px; border-top: 1px solid rgb(255 255 255 / .08); color: #28c840; }

@media (max-width: 900px) {
    .hero-grid { grid-template-columns: 1fr; gap: 40px; }
    .code-card { transform: none; }
}

/* ---------- Sections ---------- */

.section { padding: clamp(56px, 8vw, 96px) 0; }
.section-alt { background: var(--bg-alt); }
.section-title { font-size: clamp(1.75rem, 3.5vw, 2.4rem); font-weight: 800; }
.section-sub { color: var(--text-muted); font-size: 1.1rem; margin-bottom: 40px; }
.center { text-align: center; }

.about-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 56px; align-items: center; }
.about-img { border-radius: var(--radius); }
@media (max-width: 820px) { .about-grid { grid-template-columns: 1fr; } }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 24px 0 0; padding: 0; list-style: none; }
.chips li {
    padding: 6px 14px; border: 1px solid var(--border); border-radius: 999px;
    background: var(--surface); font-family: var(--font-mono); font-size: .85rem;
}

/* ---------- Cards ---------- */

.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; }

.card {
    display: block; padding: 28px;
    background: var(--surface); color: var(--text);
    border: 1px solid var(--border); border-radius: var(--radius);
    text-decoration: none;
    transition: transform .2s, box-shadow .2s, border-color .2s;
}
.card:hover { color: var(--text); transform: translateY(-4px); box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--primary) 40%, var(--border)); }
.card h3 { font-size: 1.2rem; margin-top: 18px; }
.card p { color: var(--text-muted); margin: 0; }
.card-icon {
    display: inline-grid; place-items: center; width: 52px; height: 52px;
    border-radius: 12px; background: var(--primary-soft); color: var(--primary);
}
.card-icon .icon { width: 26px; height: 26px; }

/* ---------- Contact form ---------- */

.contact-form {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px;
    padding: clamp(20px, 4vw, 36px);
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.field-wide { grid-column: 1 / -1; }
@media (max-width: 720px) { .contact-form { grid-template-columns: 1fr; } }

.field label { display: block; margin-bottom: 6px; font-weight: 600; font-size: .9rem; }
.field input, .field textarea {
    width: 100%; padding: 12px 14px;
    font: inherit; color: var(--text);
    background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm);
    transition: border-color .2s, box-shadow .2s;
}
.field textarea { resize: vertical; min-height: 140px; }
.field input:focus, .field textarea:focus {
    outline: none; border-color: var(--primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 25%, transparent);
}
.field.has-error input, .field.has-error textarea { border-color: var(--danger); }
.field-error { margin: 6px 0 0; color: var(--danger); font-size: .85rem; }

.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; }
.form-status { margin: 0; font-weight: 500; }
.form-status.is-success { color: var(--success); }
.form-status.is-error { color: var(--danger); }

.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* ---------- Test papers ---------- */

.papers { display: grid; gap: 16px; margin: 0; padding: 0; list-style: none; }

.paper {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    overflow: hidden;
}
.paper summary {
    display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
    padding: 18px 20px; cursor: pointer; list-style: none;
}
.paper summary::-webkit-details-marker { display: none; }
.paper summary:hover .paper-toggle { color: var(--primary); }
.paper-title { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.1rem; }
.paper-title .icon { color: var(--primary); }
.paper-toggle { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; color: var(--text-muted); font-size: .9rem; }
.paper details[open] .paper-toggle { color: var(--primary); }
.paper details img { border-top: 1px solid var(--border); background: #fff; width: 100%; }

.badge {
    padding: 2px 10px; border-radius: 999px;
    background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent);
    font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
}

.paper-actions {
    display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
    padding: 14px 20px; border-top: 1px solid var(--border); background: var(--bg-alt);
}

.answer-dialog {
    width: min(960px, 100% - 32px); height: min(90vh, 900px);
    padding: 0; border: 1px solid var(--border); border-radius: var(--radius);
    background: var(--surface); color: var(--text);
    box-shadow: 0 30px 80px rgb(0 0 0 / .4);
}
.answer-dialog[open] { display: flex; flex-direction: column; }
.answer-dialog::backdrop { background: rgb(8 10 20 / .6); backdrop-filter: blur(3px); }
.dialog-head { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.dialog-head h2 { font-size: 1.05rem; margin: 0 auto 0 0; }
.answer-dialog iframe { flex: 1; width: 100%; border: 0; background: #fff; }

/* ---------- Footer ---------- */

.site-footer { padding: 28px 0; border-top: 1px solid var(--border); color: var(--text-muted); font-size: .9rem; }
.footer-inner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; }
.footer-inner p { margin: 0; }
.socials { display: flex; gap: 8px; margin: 0; padding: 0; list-style: none; }
.socials a { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; color: var(--text-muted); border: 1px solid var(--border); }
.socials a:hover { color: var(--primary); border-color: var(--primary); }
.socials .icon { width: 18px; height: 18px; }

.to-top {
    position: fixed; right: 20px; bottom: 20px; z-index: 40;
    display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%;
    background: var(--primary); color: var(--on-primary); box-shadow: var(--shadow);
    opacity: 0; visibility: hidden; transform: translateY(10px);
    transition: opacity .2s, transform .2s, visibility .2s;
}
.to-top.is-visible { opacity: 1; visibility: visible; transform: none; }
.to-top:hover { color: var(--on-primary); background: var(--primary-hover); }

/* ---------- Reveal on scroll ---------- */

.reveal { opacity: 0; transform: translateY(16px); transition: opacity .6s ease, transform .6s ease; }
.reveal.is-visible { opacity: 1; transform: none; }
