/* Dharmdutt.Com / Nyay Sahayak — shared site design system.
   Palette and type nod to a court letterhead rather than a SaaS template:
   paper background, navy ink, a single restrained brass accent used sparingly. */

:root {
    --paper: #F7F4EC;
    --paper-raised: #FFFFFF;
    --ink: #1B1B18;
    --ink-soft: #59564E;
    --ink-faint: #8C8878;

    --navy: #16233D;
    --navy-deep: #0D1626;
    --navy-tint: #EEF1F6;

    --brass: #A2791C;
    --brass-soft: #C9A24A;
    --maroon: #7A2A2A;

    --rule: #E4DDC9;
    --rule-strong: #CFC5A6;

    --radius: 4px;
    --radius-lg: 8px;
    --shadow: 0 1px 2px rgba(20, 18, 10, 0.05), 0 10px 30px -16px rgba(20, 18, 10, 0.25);
    --max-width: 1180px;

    --serif: 'Newsreader', Georgia, 'Times New Roman', serif;
    --sans: 'IBM Plex Sans', 'Segoe UI', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: var(--sans);
    background: var(--paper);
    color: var(--ink);
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { font-family: var(--serif); color: var(--navy); font-weight: 500; line-height: 1.2; margin: 0 0 0.5em; }

a { color: var(--navy); text-decoration: none; }
a:hover { text-decoration: underline; }

.icon { width: 1em; height: 1em; display: inline-block; vertical-align: -0.125em; fill: none; }

.skip-link {
    position: absolute; left: -9999px; top: 0; z-index: 1000;
    background: var(--navy); color: #fff; padding: 10px 16px;
}
.skip-link:focus { left: 12px; top: 12px; }

.eyebrow {
    display: inline-flex; align-items: center; gap: 8px;
    font-size: 12.5px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase;
    color: var(--brass); margin-bottom: 14px;
}
.eyebrow::before { content: ""; width: 22px; height: 1.5px; background: var(--brass); display: inline-block; }

/* ---------- Header ---------- */
.site-header {
    background: var(--paper-raised);
    border-bottom: 1px solid var(--rule-strong);
    border-top: 3px solid var(--navy);
    position: sticky;
    top: 0;
    z-index: 100;
}
.header-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}
.site-branding {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--navy);
}
.site-branding:hover { text-decoration: none; }
.brand-mark {
    width: 30px; height: 30px;
    color: var(--navy);
    flex-shrink: 0;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-family: var(--serif); font-size: 21px; font-weight: 600; color: var(--navy); }
.brand-sub { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-faint); }

.main-nav ul {
    list-style: none;
    display: flex;
    gap: 30px;
    margin: 0;
    padding: 0;
}
.main-nav a {
    color: var(--ink-soft);
    font-weight: 500;
    font-size: 14.5px;
    padding: 6px 0;
    border-bottom: 2px solid transparent;
}
.main-nav a:hover { color: var(--navy); text-decoration: none; }
.main-nav a[aria-current="page"] { color: var(--navy); border-bottom-color: var(--brass); }

.menu-toggle {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
}
.menu-toggle span { width: 22px; height: 2px; background: var(--navy); }

@media (max-width: 760px) {
    .menu-toggle { display: flex; }
    .main-nav { display: none; width: 100%; }
    .main-nav.open { display: block; }
    .main-nav ul { flex-direction: column; gap: 4px; padding: 14px 0 4px; }
    .main-nav a { display: block; padding: 10px 0; border-bottom: 1px solid var(--rule); }
}

/* ---------- Layout ---------- */
.site-content {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 40px 24px 70px;
    min-height: 60vh;
}
.section { padding: 56px 0; }
.section-head { max-width: 640px; margin-bottom: 36px; }
.section-head p { color: var(--ink-soft); font-size: 15.5px; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 22px;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
    border: 1.5px solid transparent;
    font-family: var(--sans);
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-deep); }
.btn-outline { background: transparent; border-color: var(--navy); color: var(--navy); }
.btn-outline:hover { background: var(--navy); color: #fff; }
.btn-text { color: var(--navy); font-weight: 600; border-bottom: 1.5px solid var(--brass); border-radius: 0; padding: 2px 0; }

/* ---------- Hero (home page) ---------- */
.hero {
    display: grid;
    grid-template-columns: 1.05fr 0.95fr;
    gap: 56px;
    align-items: center;
    padding: 56px 0 64px;
}
.hero h1 { font-size: clamp(32px, 4.2vw, 48px); }
.hero .lede { font-size: 17.5px; color: var(--ink-soft); max-width: 46ch; margin-bottom: 28px; }
.hero-cta { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; margin-bottom: 40px; }

.stat-row { display: flex; gap: 32px; flex-wrap: wrap; border-top: 1px solid var(--rule-strong); padding-top: 22px; }
.stat-row .stat-num { font-family: var(--serif); font-size: 26px; color: var(--navy); font-weight: 600; display: block; }
.stat-row .stat-label { font-size: 12.5px; color: var(--ink-faint); text-transform: uppercase; letter-spacing: 0.06em; }

/* Hero document mockup — a stylised order-sheet, not a stock illustration */
.doc-mock {
    background: var(--paper-raised);
    border: 1px solid var(--rule-strong);
    box-shadow: var(--shadow);
    padding: 34px 30px;
    position: relative;
    max-width: 380px;
    margin: 0 auto;
    transform: rotate(-0.6deg);
}
.doc-mock::before {
    content: "";
    position: absolute; inset: 10px;
    border: 1px solid var(--rule);
    pointer-events: none;
}
.doc-mock .doc-head {
    text-align: center;
    font-family: var(--serif);
    font-size: 13.5px;
    line-height: 1.5;
    color: var(--navy);
    border-bottom: 1px solid var(--rule-strong);
    padding-bottom: 14px;
    margin-bottom: 16px;
}
.doc-mock .doc-line { height: 8px; background: var(--rule); border-radius: 2px; margin-bottom: 10px; }
.doc-mock .doc-line.short { width: 55%; }
.doc-mock .doc-line.tiny { height: 6px; width: 40%; }
.doc-mock .doc-seal {
    position: absolute;
    bottom: -18px; right: -14px;
    width: 76px; height: 76px;
    border: 2px solid var(--maroon);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: var(--maroon);
    font-family: var(--serif);
    font-size: 10px;
    letter-spacing: 0.08em;
    text-align: center;
    line-height: 1.3;
    transform: rotate(-14deg);
    background: rgba(122, 42, 42, 0.03);
}

/* ---------- Tool / feature grids ---------- */
.tool-grid, .feature-grid, .legal-grid-wrapper {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1px;
    background: var(--rule-strong);
    border: 1px solid var(--rule-strong);
}
.tool-card, .feature-card, .legal-card {
    background: var(--paper-raised);
    padding: 26px 24px;
    display: block;
    text-decoration: none;
    color: inherit;
    position: relative;
    transition: background 0.15s ease;
}
.tool-card:hover, .legal-card:hover { background: var(--navy-tint); text-decoration: none; }
.tool-card .card-icon, .legal-icon {
    width: 38px; height: 38px;
    display: flex; align-items: center; justify-content: center;
    color: var(--brass);
    margin-bottom: 14px;
}
.tool-card .card-icon .icon, .legal-icon .icon { width: 24px; height: 24px; }
.card-title, .tool-card .card-title, .legal-card h3 {
    font-family: var(--serif); font-size: 18px; color: var(--navy); font-weight: 600;
    display: block; margin-bottom: 6px;
}
.card-desc, .tool-card .card-desc, .legal-card p {
    font-size: 14px; color: var(--ink-soft); display: block; margin: 0;
}
.launch-btn {
    margin-top: 16px; display: inline-flex; align-items: center; gap: 6px;
    font-size: 13px; font-weight: 600; color: var(--navy);
}
.legal-btn {
    display: inline-flex; align-items: center; gap: 6px; margin-top: 14px;
    color: var(--navy); font-weight: 600; font-size: 14px;
    border-bottom: 1.5px solid var(--brass); padding-bottom: 1px;
}

/* ---------- Numbered "how it works" ---------- */
.step-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 36px; }
.step { position: relative; padding-left: 0; }
.step .step-num {
    font-family: var(--serif); font-size: 15px; color: var(--brass);
    display: block; margin-bottom: 10px; font-weight: 600;
}
.step h3 { font-size: 18px; margin-bottom: 8px; }
.step p { color: var(--ink-soft); font-size: 14.5px; margin: 0; }

@media (max-width: 860px) {
    .hero { grid-template-columns: 1fr; padding-top: 32px; }
    .doc-mock { order: -1; max-width: 320px; }
}

/* ---------- Legacy component styles kept for tool-widget pages ---------- */
.legal-search-box { text-align: center; padding: 20px; background: var(--navy-tint); border-radius: var(--radius); }

/* ---------- Recent-documents history panel ---------- */
.history-box {
    background: var(--navy-tint);
    border: 1px solid var(--rule-strong);
    border-radius: var(--radius);
    padding: 16px 20px;
    margin-top: 20px;
    max-width: 800px;
    position: relative;
}
.history-title { font-weight: 600; color: var(--navy); margin-bottom: 10px; font-family: var(--serif); }
.history-clear {
    position: absolute; top: 14px; right: 18px;
    font-size: 12px; color: var(--ink-faint); cursor: pointer; text-decoration: underline;
}
.history-list { display: flex; flex-direction: column; gap: 6px; }
.history-item {
    background: var(--paper-raised); border: 1px solid var(--rule-strong); border-radius: var(--radius);
    padding: 8px 12px; cursor: pointer; display: flex; gap: 12px; align-items: baseline; font-size: 13px;
}
.history-item:hover { border-color: var(--navy); }
.history-item .h-tool { font-weight: 600; color: var(--navy); }
.history-item .h-ref { color: var(--ink-soft); }
.history-item .h-date { margin-left: auto; color: var(--ink-faint); }
.history-item .h-del {
    color: var(--maroon); font-weight: 700; font-size: 15px; line-height: 1; padding: 0 2px;
}
.history-item .h-del:hover { text-decoration: underline; }
.history-box.no-print { margin-top: 0; margin-bottom: 20px; max-width: none; }

/* ---------- Feedback / generic forms ---------- */
.feedback-form, .ni-form {
    background: var(--paper-raised); border: 1px solid var(--rule-strong); border-radius: var(--radius-lg);
    padding: 28px; max-width: 560px; margin: 0 auto;
}
.feedback-form label, .ni-form label { display: block; font-weight: 600; margin: 14px 0 6px; color: var(--navy); font-size: 14px; }
.feedback-form input[type="text"], .feedback-form input[type="email"], .feedback-form select, .feedback-form textarea,
.ni-form input[type="date"] {
    width: 100%; padding: 10px; font-size: 15px; border: 1px solid var(--rule-strong); border-radius: var(--radius); font-family: inherit;
}
.feedback-form textarea { min-height: 140px; }
.feedback-form button { margin-top: 18px; }
.honeypot { position: absolute; left: -9999px; }
.notice { max-width: 560px; margin: 0 auto 18px; padding: 14px 18px; border-radius: var(--radius); }
.notice.success { background: #E6F1E6; border: 1px solid #A9CBA9; color: #2B5C2B; }
.notice.error { background: #F6E4E1; border: 1px solid #E0AFA6; color: var(--maroon); }

/* ---------- Footer ---------- */
.site-footer {
    border-top: 1px solid var(--rule-strong);
    background: var(--paper-raised);
    margin-top: 40px;
}
.footer-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 40px 24px 24px;
    display: flex;
    justify-content: space-between;
    gap: 40px;
    flex-wrap: wrap;
}
.footer-brand { display: flex; gap: 14px; max-width: 380px; }
.footer-brand .icon { width: 26px; height: 26px; color: var(--navy); flex-shrink: 0; margin-top: 2px; }
.footer-brand .brand-name { font-family: var(--serif); font-size: 17px; color: var(--navy); font-weight: 600; }
.footer-brand p { margin: 4px 0 0; font-size: 13.5px; color: var(--ink-soft); }
.footer-links { display: flex; gap: 24px; align-items: flex-start; }
.footer-links a { font-size: 14px; color: var(--ink-soft); font-weight: 500; }
.footer-links a:hover { color: var(--navy); }
.footer-bar {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 16px 24px;
    border-top: 1px solid var(--rule);
    text-align: center;
    font-size: 12.5px;
    color: var(--ink-faint);
}

/* ==========================================================================
   Shared print-document system — used by every order/notice/letter generator
   (Cognizance, Mediation Letter, Death Report, Release Order, etc.) so they
   all share one styling + font/paper-size mechanism instead of each page
   re-implementing it. Pair with initPrintFormatting() in site.js.
   ========================================================================== */
.gen-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 30px; align-items: start; }
@media (max-width: 900px) { .gen-layout { grid-template-columns: 1fr; } }

/* Shared tab bar for the multi-part order-sheet generators (Cognizance /
   First Order Sheet / Bail Order / Chargesheet), each its own page. */
.os-tabs { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 26px; }
.os-tab-btn {
    padding: 10px 20px; border-radius: 30px; border: 1px solid var(--rule-strong);
    background: var(--paper-raised); color: var(--ink-soft); font-weight: 600; cursor: pointer; font-size: 14px;
}
.os-tab-btn.active { background: var(--navy); color: #fff; border-color: var(--navy); }
.os-tab-btn[disabled] { opacity: 0.5; cursor: default; }

.gen-box {
    background: var(--paper-raised); border: 1px solid var(--rule-strong); border-radius: var(--radius-lg);
    padding: 22px; margin-bottom: 20px;
}
.gen-box h3 { margin-top: 0; font-size: 16px; }
.gen-field { margin-bottom: 14px; }
.gen-field label { display: block; font-weight: 600; font-size: 13px; color: var(--navy); margin-bottom: 5px; }
.gen-field input, .gen-field select, .gen-field textarea {
    width: 100%; padding: 9px 10px; border: 1px solid var(--rule-strong); border-radius: var(--radius); font-family: inherit; font-size: 14px;
}
.gen-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.gen-court-summary { font-size: 13px; color: var(--ink-soft); background: var(--navy-tint); border-radius: var(--radius); padding: 10px 12px; margin-top: 8px; white-space: pre-line; }

.preview-wrap { position: sticky; top: 90px; }
.format-bar {
    display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; padding: 12px 14px;
    background: var(--navy-tint); border: 1px solid var(--rule-strong); border-radius: var(--radius);
}
.format-bar > div { flex: 1; min-width: 150px; }
.format-bar label { display: block; font-size: 12px; font-weight: 600; color: var(--navy); margin-bottom: 4px; }
.format-bar select { width: 100%; padding: 7px 8px; border: 1px solid var(--rule-strong); border-radius: var(--radius); font-size: 13px; }
.preview-actions { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.review-flag {
    background: #FFF6E0; border: 1px solid #E8C766; color: #7A5B00; border-radius: var(--radius); padding: 10px 14px; font-size: 13px; margin-bottom: 14px; display: none;
}
.review-flag.show { display: block; }

.print-sheet {
    background: #fff; border: 2px solid #000; color: #000; line-height: 2; font-size: 18px;
    /* 18% left margin, matching Indian court order-sheet convention */
    padding: 60px 6% 40px 18%;
}
.print-sheet .doc-head { text-align: center; font-weight: bold; font-size: 17px; line-height: 1.5; margin-bottom: 18px; }
.print-sheet .doc-title { text-align: center; font-weight: bold; font-size: 17px; line-height: 1.5; margin-bottom: 18px; text-decoration: underline; }
.print-sheet .doc-caseno { text-align: right; margin-bottom: 16px; }
.print-sheet .doc-date { font-weight: bold; margin-bottom: 14px; }
.print-sheet p { text-align: justify; text-indent: 2em; }
/* Signature sits at the right of the page, each line centered relative to
   the block's own (content-sized) width rather than the full page. */
.print-sheet .doc-sign {
    margin-top: 40px; margin-left: auto; width: fit-content; max-width: 100%;
    text-align: center; font-weight: bold; white-space: pre-line; line-height: 1.3;
}
.print-sheet .doc-footer-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 30px; text-indent: 0; }

/* Compact variant: for documents that print two copies on one A4 page
   (e.g. Death Report) — tighter type so both halves fit comfortably. */
.print-sheet.compact { font-size: 14px; line-height: 1.5; padding: 24px 5% 24px 15%; }
.print-sheet.compact p { text-indent: 1.5em; }
.gen-copy { margin-bottom: 20px; }
.cut-line { border-top: 1px dashed #000; width: 100%; position: relative; height: 22px; margin: 6px 0; text-indent: 0; }
.cut-line::after {
    content: "✂ Cut Here"; position: absolute; left: 50%; top: -10px; transform: translateX(-50%);
    background: #fff; padding: 0 10px; font-size: 9px; color: #444;
}
@media print {
    /* .preview-wrap is "position: sticky" for on-screen scrolling — during print
       that becomes the positioning context .print-sheet's "absolute" resolves
       against, trapping it wherever the sticky box naturally sits in the still
       layout-occupying (only visibility-hidden, not removed) page instead of
       the true page top. Neutralizing it here is what makes the print start on
       page 1 instead of several blank pages in. */
    .preview-wrap { position: static !important; }
    body * { visibility: hidden; }
    .print-sheet, .print-sheet * { visibility: visible; }
    .print-sheet { position: absolute; top: 0; left: 0; width: 100%; border: none; }
    .no-print { display: none !important; }

    /* visibility: hidden above hides these visually but does NOT remove them
       from the page's layout flow — they still occupy their full on-screen
       height, so the print engine still paginates for that whole height and
       produces blank trailing pages after the print-sheet's own content ends.
       display: none actually collapses their height to zero. */
    .site-header, .site-footer, .section-head, .os-tabs,
    .gen-layout > div:first-child, .os-layout > div:first-child {
        display: none !important;
    }
}
