/* ============================================================
   Reset + typography
   ============================================================ */

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

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

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-sans);
    font-size: var(--fs-base);
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    overflow-wrap: break-word;
}

/* Tamil glyphs need a touch more leading and a font that actually has them */
:lang(ta), .ta, .block-content, .card-body, .reader-body {
    font-family: var(--font-sans), var(--font-tamil);
}

h1, h2, h3, h4, h5, h6 {
    margin: 0 0 var(--sp-3);
    font-weight: 700;
    line-height: 1.25;
    color: var(--text-strong);
    letter-spacing: -.011em;
}
h1 { font-size: var(--fs-2xl); }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); }
h4 { font-size: var(--fs-md); }

p { margin: 0 0 var(--sp-3); }
p:last-child { margin-bottom: 0; }

a {
    color: var(--primary);
    text-decoration: none;
    transition: color var(--t-fast);
}
a:hover { color: var(--primary-dark); }

ul, ol { margin: 0 0 var(--sp-3); padding-left: 1.35em; }
li { margin-bottom: .3em; }
li:last-child { margin-bottom: 0; }

hr {
    border: 0;
    border-top: 1px solid var(--border);
    margin: var(--sp-6) 0;
}

img, svg, video { max-width: 100%; height: auto; display: block; }

code, kbd, pre, samp { font-family: var(--font-mono); font-size: .92em; }

.md-code {
    background: var(--surface-3);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: .08em .38em;
    font-size: .88em;
    color: var(--primary-dark);
}

mark {
    background: #fff3b0;
    color: inherit;
    padding: .05em .2em;
    border-radius: 4px;
}

strong { font-weight: 700; color: var(--text-strong); }

blockquote {
    margin: 0;
    padding-left: var(--sp-4);
    border-left: 3px solid var(--border-strong);
    color: var(--muted);
}

/* ---------------------------------------------------------- forms */

input, select, textarea, button {
    font: inherit;
    color: inherit;
}

.field { margin-bottom: var(--sp-4); }

.label {
    display: block;
    font-size: var(--fs-sm);
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
}
.label .req { color: var(--primary); }

.input, .select, .textarea {
    width: 100%;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 11px 13px;
    color: var(--text);
    transition: border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
}
.input:hover, .select:hover, .textarea:hover { border-color: var(--border-strong); }
.input:focus, .select:focus, .textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-ring);
}
.input::placeholder, .textarea::placeholder { color: var(--muted-2); }
.input:disabled, .select:disabled, .textarea:disabled { background: var(--surface); color: var(--muted); cursor: not-allowed; }

.textarea { min-height: 120px; resize: vertical; line-height: 1.6; }
.textarea--code { font-family: var(--font-mono); font-size: 13.5px; }

.select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2371717a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 9 7 7 7-7'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 11px center;
    padding-right: 34px;
}

.hint { font-size: var(--fs-xs); color: var(--muted); margin-top: 5px; }
.error-text { font-size: var(--fs-xs); color: var(--danger); margin-top: 5px; display: block; }

.checkline {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: var(--fs-sm);
    cursor: pointer;
    user-select: none;
}
.checkline input[type="checkbox"], .checkline input[type="radio"] {
    width: 17px; height: 17px;
    accent-color: var(--primary);
    cursor: pointer;
    flex: none;
}

/* ---------------------------------------------------------- utilities */

.stack   { display: flex; flex-direction: column; }
.row     { display: flex; align-items: center; }
.row-gap { display: flex; align-items: center; gap: var(--sp-3); }
.wrap    { flex-wrap: wrap; }
.between { justify-content: space-between; }
.center  { justify-content: center; }
.end     { justify-content: flex-end; }
.grow    { flex: 1 1 auto; min-width: 0; }
.gap-1 { gap: var(--sp-1); } .gap-2 { gap: var(--sp-2); } .gap-3 { gap: var(--sp-3); }
.gap-4 { gap: var(--sp-4); } .gap-5 { gap: var(--sp-5); } .gap-6 { gap: var(--sp-6); }

.mt-0 { margin-top: 0; } .mt-2 { margin-top: var(--sp-2); } .mt-3 { margin-top: var(--sp-3); }
.mt-4 { margin-top: var(--sp-4); } .mt-5 { margin-top: var(--sp-5); } .mt-6 { margin-top: var(--sp-6); }
.mb-0 { margin-bottom: 0; } .mb-2 { margin-bottom: var(--sp-2); } .mb-3 { margin-bottom: var(--sp-3); }
.mb-4 { margin-bottom: var(--sp-4); } .mb-5 { margin-bottom: var(--sp-5); } .mb-6 { margin-bottom: var(--sp-6); }

.muted   { color: var(--muted); }
.small   { font-size: var(--fs-sm); }
.tiny    { font-size: var(--fs-xs); }
.bold    { font-weight: 700; }
.semi    { font-weight: 600; }
.upper   { text-transform: uppercase; letter-spacing: .07em; }
.mono    { font-family: var(--font-mono); }
.nowrap  { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.text-center { text-align: center; }
.text-right  { text-align: right; }
.hidden  { display: none !important; }
.full    { width: 100%; }

.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;
}

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

::selection { background: var(--primary-ring); }

/* scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; border: 3px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--muted-2); background-clip: content-box; }

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