How Senior Advocates Draft a Complaint: Step-by-Step Legal Drafting Guide With Examples | EduLaw
EduLaw EditorialAdvocate PlaybookA practical drafting workshop on how senior advocates draft a complaint from scratch. Learn the 7-step playbook, offence ingredients, timeline method, and pre-filing checklist with real-style examples. For law students and junior advocates.
E EduLaw Legal Intelligence 🔍 Home › Advocate Playbooks › How Senior Advocates Draft a Complaint Advocate Playbook · Legal Drafting Workshop How Senior Advocates Draft a Complaint: Step-by-Step Legal Drafting Guide With Examples Not theory. A practical drafting workshop showing the exact method seniors use to turn a messy client story into a complaint that proves an offence — quietly, precisely, and without a single wasted word. ⏱ 18 min read Law Students Junior Advocates Interns First-Generation Litigators Updated for BNS & BNSS, 2023 ⬇ Download Complaint Drafting Checklist See Example Draft On this page Quick Summary The 7-Step Roadmap 1 · What Is a Complaint? 2 · The Biggest Mistake 3 · Step 1 — Identify the Offence 4 · Step 2 — Build the Timeline 5 · Step 3 — Draft Like a Witness 6 · Step 4 — Match Ingredients 7 · Step 5 — Cut the Clutter 8 · Step 6 — Complaint Structure 9 · Step 7 — Pre-Filing Checklist Worked Examples Document Strength Matrix FAQ The Senior Advocate Rule 📑 Table of contents Quick Summary The 7-Step Roadmap 1 · What Is a Complaint? 2 · The Biggest Mistake 3 · Step 1 — Identify the Offence 4 · Step 2 — Build the Timeline 5 · Step 3 — Draft Like a Witness 6 · Step 4 — Match Ingredients 7 · Step 5 — Cut the Clutter 8 · Step 6 — Complaint Structure 9 · Step 7 — Pre-Filing Checklist Worked Examples FAQ The Senior Advocate Rule A client walks in angry. The story comes out in pieces — money, broken promises, sleepless nights. A junior writes down the anger. A senior writes down the offence. This is the difference, and it is learnable. Most young lawyers are never taught complaint drafting as a craft. They are handed a format, told to "fill in the facts," and left to improvise. The result is predictable: long, emotional, repetitive complaints that a Magistrate sets aside in minutes. This playbook reverse-engineers what senior advocates actually do — the order in which they think, the questions they ask, and the discipline they apply before a single line is filed. 📋 Quick Summary Card Topic How senior advocates draft a complaint from scratch using a repeatable 7-step method. Who should read this Law students, interns, junior advocates, and first-generation litigators who draft or assist in drafting complaints. Main learning A complaint is built by matching facts to the ingredients of an offence — not by describing the client's emotions. Key rule Every sentence must answer one question: "Will this help establish the offence?" Best use case Drafting a police complaint or a private complaint before a Magistrate where facts and documents already exist. Common mistake Using labels like "fraud" and "cheating" without facts that satisfy each statutory ingredient. Final takeaway Great complaints don't accuse loudly. They prove quietly. The Interactive 7-Step Drafting Roadmap Tap any card to see how a senior advocate handles that stage. The steps are sequential — seniors almost never skip ahead, because each step decides what goes into the next. 1 Identify the offence Before writing anything, decide which offence the facts actually disclose. The offence governs which facts matter. 2 Build the timeline Lay out every date, event and supporting document in order. The timeline becomes the skeleton of your facts. 3 Draft facts like a witness Write neutral, dated, specific facts as a witness would testify — no adjectives, no conclusions, no drama. 4 Match facts to ingredients Place each statutory ingredient beside the fact and document that proves it. Gaps become visible immediately. 5 Remove unnecessary material Delete emotion, family history, reputation attacks and repetition. Keep only what proves the offence. 6 Follow the structure Pour the cleaned facts into the standard complaint structure: parties, jurisdiction, facts, offence, prayer, verification. 7 Verify before filing Run the pre-filing checklist: names, dates, amounts, jurisdiction, annexures, limitation, and internal consistency. 1 · What Is a Complaint, Really? The word "complaint" is used loosely in everyday speech, but in litigation it has a precise meaning that depends on where it is filed. Senior advocates fix this in their mind before drafting, because the destination changes the form. A complaint to the police is information given to a police officer about an offence. If it discloses a cognizable offence, the officer is required to register a First Information Report (FIR) under Section 173 of the Bharatiya Nagarik Suraksha Sanhita, 2023 (BNSS), which replaced Section 154 of the old CrPC. The Supreme Court in Lalita Kumari v. Government of U.P. held that registration of an FIR is mandatory when the information discloses a cognizable offence. A private complaint before a Magistrate is an allegation made directly to a Magistrate — orally or in writing — that some person has committed an offence, under Section 223 BNSS (earlier Section 200 CrPC). The Magistrate examines the complainant on oath and may then order inquiry, investigation, or issue process. A notable change under Section 223 BNSS is a proviso requiring, in certain situations, that the accused be given an opportunity of being heard before cognizance is taken. Knowing the family of documents helps you avoid drafting the wrong instrument entirely: Document Purpose Filed before When used Common mistake Complaint (police) Set criminal machinery in motion for an offence Police (SHO) When a cognizable offence has occurred Writing it like a grievance letter, not disclosing the offence FIR First recorded report of a cognizable offence Police (registered by them) Triggered by the complaint/information Confusing the FIR (police-written) with your complaint (your words) Private Complaint Allege an offence directly to the court Magistrate (S.223 BNSS) When police don't act or the offence is non-cognizable Filing without proof when sworn examination will follow Legal Notice Demand / warn before litigation Sent to the opposite party Pre-litigation, often before a complaint or suit Treating it as the remedy itself rather than a step Representation Request action from an authority Government / statutory body Administrative grievances Using it where a criminal complaint is needed Plaint Initiate a civil suit for a civil remedy Civil court Recovery, declaration, injunction, damages Filing a criminal complaint for a purely civil dispute Simple example. If your client lent money under a written agreement and it wasn't repaid, that is usually a civil dispute needing a plaint — unless there was dishonest intention from the very start , which can convert it into cheating . Identifying which one applies is Step 1, not an afterthought. 2 · The Biggest Mistake Young Lawyers Make The single most common error is this: junior lawyers write the client's emotions instead of legal facts . The client is hurt, and the draft reads like the client speaking. Three patterns repeat: First, they pour in feelings — betrayal, ruin, sleepless nights — none of which a court can act on. Second, they fire off conclusory labels like "fraud", "cheating" and "harassment" without pleading the facts that satisfy each statutory ingredient. A label is not proof. Third, they write everything — every conversation, every relative, every grievance — instead of the relevant facts that disclose the offence. ✖ Weak Draft "The accused cheated me and ruined my life. He is a fraud and a dishonest person who has caused me immense mental agony and financial destruction." Why it fails: pure conclusion. No date, no amount, no representation, no document. Nothing here a Magistrate can test against the ingredients of cheating. ✓ Senior Advocate Version "On 15 February 2025, the accused received ₹5,00,000 from the complainant after representing that the goods would be delivered within 30 days. Despite repeated demands and a legal notice dated 05 April 2025, no delivery was made and no amount was refunded." Why it works: dated, specific amount, a clear representation, an inducement, a failure, and a documented demand. Every ingredient of cheating is now testable. The Discipline Don't describe how the client feels about the offence. Describe the facts from which the offence can be inferred. Let the court reach the conclusion. 3 · Step 1 — Identify the Offence First Seniors never start by writing facts. They start by asking: what offence, if any, do these facts disclose? The chosen offence acts as a filter — it tells you which facts are relevant and which are noise. Common offences a litigator meets, with their current BNS, 2023 sections, include: Cheating (Section 318 BNS) — deception that dishonestly induces a person to deliver property or do something they otherwise wouldn't. Criminal breach of trust (Section 316 BNS) — property entrusted to a person and then dishonestly misappropriated. Forgery (Section 336 BNS) — making a false document or electronic record with intent to cause damage or fraud. Criminal intimidation (Section 351 BNS) — threatening another with injury to person, reputation or property. Defamation (Section 356 BNS). Assault / use of criminal force (Sections 130–131 BNS). A domestic violence complaint is usually filed under the Protection of Women from Domestic Violence Act, 2005, which is civil-protective in nature. A consumer grievance (deficiency in service / defective goods) goes to a Consumer Commission, not a criminal court — a distinction young lawyers frequently miss. Offence Key ingredients Facts needed Documents that help Weak phrase Strong phrase Cheating (S.318 BNS) Deception · dishonest inducement · delivery of property · resulting loss · intent at the outset What was represented, when, the amount, the failure Agreement, receipts, bank entries, chats, notice "He cheated me." "On 15.02.2025 he represented delivery in 30 days and took ₹5,00,000; no delivery followed." Criminal breach of trust (S.316 BNS) Entrustment of property · dishonest misappropriation / conversion How property was entrusted; how it was diverted Trust deed, partnership deed, handover proof, accounts "He stole the firm's money." "₹8,00,000 entrusted for vendor payment on 10.03.2025 was transferred to his personal account on 12.03.2025." Forgery (S.336 BNS) False document / record · intent to cause damage or fraud Which document, what was altered, by whom Original vs. disputed document, expert opinion "The documents are fake." "The sale deed dated 02.01.2025 bears a signature the complainant never executed, as shown in Annexure C-3." Criminal intimidation (S.351 BNS) Threat of injury to person/reputation/property · intent to cause alarm Exact words, date, medium, who heard it Recordings, messages, witness statements "He threatened me." "On 20.04.2025 at 8 pm, he stated by phone, 'Withdraw the case or face consequences,' as recorded in Annexure C-4." Section numbers reflect the Bharatiya Nyaya Sanhita, 2023 (BNS), which replaced the Indian Penal Code, 1860. Always verify the applicable section, the punishment, and whether the offence is cognizable/non-cognizable before drafting. 4 · Step 2 — Build the Timeline (Date · Event · Document) Once the offence is fixed, seniors reconstruct the events as a strict chronology. The method is simple and powerful: for every line, capture three things — the date , the event , and the supporting document . A fourth column, legal relevance , links each event to an ingredient. If an event has no legal relevance, it usually doesn't belong in the complaint. 10 Jan 2025 Supply agreement signed for delivery of goods 📎 Agreement (Annexure C-1) — establishes the representation 15 Feb 2025 Complainant pays ₹5,00,000 to the accused 📎 Bank transfer + receipt (Annexure C-2) — establishes delivery of property & inducement 17 Mar 2025 Promised delivery date passes; no goods delivered 📎 Delivery schedule clause — establishes failure 25 Mar 2025 WhatsApp reminders sent; vague replies, then silence 📎 Chat screenshots (Annexure C-3) — establishes evasion & dishonest intent 05 Apr 2025 Legal notice issued demanding delivery or refund 📎 Notice + dispatch proof (Annexure C-4) — establishes formal demand 20 Apr 2025 No response; no delivery; no refund 📎 Tracking / non-reply record — establishes continuing loss 📥 Timeline-builder checklist (use before drafting facts) ✓ I have a date for every material event ✓ Each event names a document or witness ✓ Events are in strict chronological order ✓ Each row links to a legal ingredient ✓ Amounts and figures are exact, not approximate ✓ Gaps in the timeline are explained or removed 5 · Step 3 — Draft Facts Like a Witness The fact section should read as if a careful witness were giving evidence: neutral tone, specific dates, specific amounts, specific statements, specific documents, and zero exaggeration. A witness who editorialises loses credibility; so does a complaint that does the same. ✍️ Interactive: "Rewrite This Paragraph" + ✖ As the client said it "This man completely destroyed my business. He is a habitual cheat, everyone in the market knows it, and he has done this to many people. He has no shame and deserves the harshest punishment." Reputation attack, hearsay ("everyone knows"), opinion, and a sentencing demand. None of it proves the offence. ✓ As a senior would draft it "On 15.02.2025, relying on the accused's representation dated 10.01.2025 (Annexure C-1) that the goods would be delivered within 30 days, the complainant transferred ₹5,00,000 (Annexure C-2). The goods were never delivered and, despite the legal notice dated 05.04.2025 (Annexure C-4), no refund was made." Why it is stronger: it is dated, sourced to documents, neutral in tone, and every clause maps to an ingredient of cheating. The court can verify each statement. The six tests every fact paragraph must pass Before keeping a sentence, seniors silently run it through six filters: is the tone neutral ; is there a specific date ; is there a specific amount where money is involved; is the statement quoted rather than characterised; is a document or witness named; and is the sentence free of exaggeration . A sentence that fails any of these is rewritten or removed. 6 · Step 4 — Match Facts With Legal Ingredients This is the step that separates a strong complaint from a loud one. A complaint is not strong because the allegations are dramatic. It is strong because each legal ingredient is supported by a fact, and each fact is supported by a document. Seniors literally lay the offence's ingredients in one column and answer each with a fact, a document, and a paragraph reference. Representation → Inducement → Delivery of property → Dishonest intent → Loss Fact Legal ingredient (cheating) Document Para no. Risk if missing Accused promised delivery in 30 days Deception / false representation Agreement (C-1) ¶3 No deception ⇒ no cheating, only civil breach Complainant paid ₹5,00,000 on the strength of it Dishonest inducement Bank record (C-2) ¶4 Cannot show the lie caused the payment ₹5,00,000 actually transferred Delivery of property Receipt (C-2) ¶4 No property parted with ⇒ ingredient fails No delivery, evasive replies, no refund Dishonest intention at the outset Chats (C-3), Notice (C-4) ¶5–6 Looks like mere failure, not crime ₹5,00,000 lost and unrecovered Wrongful loss Non-reply record ¶7 No demonstrable loss weakens the case When the table is complete with no blank cells, the complaint is ready. Where a cell is blank, you have found your weakness before the opposing counsel does. 7 · Step 5 — Remove Everything Unnecessary Now comes the part juniors resist most: deletion. Senior advocates cut emotional paragraphs, irrelevant family history, reputation attacks, repeated allegations, and personal opinions. The complaint gets shorter and, paradoxically, far stronger — because what remains is pure proof. Original complaint line Senior advocate version Why edited "My family has suffered greatly because of this man's evil nature." (deleted) Emotion + character attack; proves nothing "I have known the accused since college and trusted him blindly." (deleted unless entrustment is the offence) Irrelevant history for a cheating case "He is a known cheat in the market." (deleted) Hearsay and reputation attack; risks defamation counter "He cheated me, he deceived me, he defrauded me." (×3) "The accused dishonestly induced the payment as set out in ¶3–4." Removes repetition; states it once, precisely "I believe he should be jailed immediately." (deleted) Opinion on sentence; not for the complainant to assert The One Test Every sentence must answer: "Will this help establish the offence?" If the honest answer is no, the sentence goes. 8 · Step 6 — The Final Complaint Structure With clean, ingredient-matched facts in hand, the draft is poured into a standard structure. Following the same blueprint every time means nothing is forgotten and the Magistrate's office finds everything where it expects to. Heading Court / authority, complaint title, and case category. Parties Full name, parentage, age, occupation and address of complainant and accused. Jurisdiction Where the cause of action arose and why this court can hear it. Facts Numbered, chronological, neutral, document-referenced paragraphs. Offence disclosed The offence(s) and section(s) the facts make out. Supporting documents A list of annexures, each tied to a paragraph. Prayer The specific relief sought from the court or police. Verification Signed declaration that the contents are true to knowledge/belief. Annexures The documents themselves, paginated and indexed. 📄 Expandable: educational sample skeleton + This is a teaching skeleton only — it deliberately omits operative legal content. Real facts, sections and prayers must be drafted and verified by a qualified advocate. To, The Learned Judicial Magistrate / Station House Officer, [Court / Police Station], [District] Complaint under Section _____ of the Bharatiya Nyaya Sanhita, 2023 read with Section 223 BNSS, 2023 1. PARTIES Complainant: [Name, age, address] Accused: [Name, address] 2. JURISDICTION The cause of action arose at [place] within the jurisdiction of this Hon'ble Court / Police Station. 3. FACTS (numbered, dated, document-referenced) 3.1 On [date], ................... (Annexure C-1) 3.2 On [date], ................... (Annexure C-2) 4. OFFENCE DISCLOSED The above facts disclose the offence of ______ punishable under Section ______ BNS, 2023. 5. SUPPORTING DOCUMENTS C-1 ..... C-2 ..... C-3 ..... 6. PRAYER It is prayed that this Hon'ble Court / Officer may be pleased to ............................................ VERIFICATION Verified at [place] on [date] that the contents of paragraphs ___ are true to my knowledge and belief. (Signature of Complainant) Through Counsel: [Advocate] ⚠ Educational skeleton only. This is intentionally non-operative to prevent misuse. A complaint must be built on verified facts, the correct applicable sections, the proper forum, and professional legal review before filing. 9 · Step 7 — The Pre-Filing Checklist Before anything is signed, seniors run a final verification pass. Tick each item below — your progress saves as you go, and you can copy or print the list. 0 of 13 verified 📋 Copy checklist 🖨 Print checklist ↺ Reset ✓ Correct names of all parties (spelling, parentage) ✓ Correct, complete addresses ✓ Correct dates throughout the facts ✓ Correct amounts and figures ✓ Correct jurisdiction established ✓ Correct supporting documents identified ✓ Correct annexures attached & indexed ✓ Correct offences and sections cited ✓ Correct, specific prayer ✓ Correct signature & verification ✓ No contradiction with the documents ✓ No unsupported allegations ✓ No limitation issue ignored (see S.514 BNSS) Note on limitation: Section 514 BNSS prescribes graded limitation periods for taking cognizance of certain offences (broadly six months to three years depending on punishment). Always check whether your offence is time-barred before filing. Worked Examples (Realistic Hypotheticals) The following four scenarios are realistic hypothetical examples created for teaching. They are not real cases and should not be cited as authority. Each shows the senior advocate's thinking from facts to a strong drafting line. EXAMPLE 1 Money taken, goods never delivered Facts Buyer pays ₹5,00,000 on a written promise of delivery in 30 days; nothing is delivered; replies turn evasive; refund refused after notice. Possible offence Cheating, Section 318 BNS (if dishonest intent existed at the outset); otherwise a civil breach of contract. Documents needed Agreement, bank transfer/receipt, chat reminders, legal notice with dispatch proof. Weak line "He cheated me and ran away with my money." Strong line "On 15.02.2025, induced by the accused's written representation of delivery within 30 days (C-1), the complainant paid ₹5,00,000 (C-2); no delivery or refund followed despite notice dated 05.04.2025 (C-4)." Drafting risk If intent at the outset isn't shown, a court may treat it as purely civil and decline criminal cognizance. EXAMPLE 2 Property document forgery Facts A sale deed surfaces bearing the complainant's signature, which the complainant says they never executed; the property is transferred on its strength. Possible offence Forgery, Section 336 BNS (with related sections for using a forged document as genuine). Documents needed The disputed deed, genuine signature specimens, prior title documents, and (often) handwriting expert opinion. Weak line "The documents are all fake and fraudulent." Strong line "The sale deed dated 02.01.2025 (C-3) purports to bear the complainant's signature; the complainant never executed it, as is evident on comparison with admitted signatures (C-5)." Drafting risk Alleging forgery without producing the document or any basis for comparison invites early dismissal. EXAMPLE 3 Threat and intimidation Facts The accused phones the complainant and threatens harm unless a pending case is withdrawn; the call is recorded and a witness overhears it. Possible offence Criminal intimidation, Section 351 BNS. Documents needed Call recording/transcript, call records, witness particulars, any follow-up messages. Weak line "He keeps threatening me all the time and I am scared." Strong line "On 20.04.2025 at about 8:00 pm, the accused stated by telephone, 'Withdraw the case or face consequences,' overheard by [witness] and recorded at Annexure C-4." Drafting risk Vague "he threatened me" without exact words, date and medium makes the threat unprovable. EXAMPLE 4 Business partner misappropriation Facts A partner entrusted with firm funds for vendor payments transfers part of those funds to a personal account and conceals it in the accounts. Possible offence Criminal breach of trust, Section 316 BNS. Documents needed Partnership deed, bank statements showing the diversion, ledger/accounts, vendor confirmations. Weak line "My partner is a thief who looted the company." Strong line "₹8,00,000 entrusted to the accused on 10.03.2025 for vendor payment (C-1) was transferred to his personal account on 12.03.2025 (C-2) and not applied to any vendor." Drafting risk Without proof of entrustment for a specific purpose, the matter may be read as a civil accounts dispute between partners. Visual Tools: Mistakes Heatmap & Document Strength Matrix Common-mistakes heatmap How damaging each common drafting error tends to be: Drafting mistake Impact on the complaint Labels offence but pleads no ingredients Critical Ignores limitation period Critical Allegations contradict the annexures Critical No dates / vague amounts High Wrong forum (criminal vs civil) Critical Emotional / reputation language High Repetition of the same allegation Moderate Annexures not indexed to paragraphs Moderate Document strength matrix Not all evidence carries the same weight. Seniors lean on the strongest documents available: Document type Probative strength Why Registered deed / signed agreement Strong Authenticated, hard to deny, fixes the representation Bank statement / verified transfer Strong Independent record of money moving Legal notice with dispatch proof Strong Shows demand and the accused's awareness WhatsApp / email (with metadata) Medium Useful for intent; needs proper certification Audio/video recording Medium Powerful but authenticity is often contested Oral assurance, no record Weak Deniable; hard to prove without corroboration "Everyone knows" / market reputation Weak Hearsay; generally inadmissible and risky Frequently Asked Questions What is the difference between a complaint and an FIR? An FIR is the first written record made by the police about a cognizable offence (Section 173 BNSS, earlier S.154 CrPC). A complaint is an allegation made to a Magistrate that someone has committed an offence (Section 223 BNSS, earlier S.200 CrPC). An FIR launches police investigation; a private complaint launches a Magistrate's inquiry. Can a complaint be filed without documents? Yes, but it is far weaker. Documents corroborate facts and help the authority see that the offence is disclosed. Where documents exist, failing to annex them is a serious drafting weakness. Should legal sections be mentioned in a complaint? It is good practice to indicate the offence and section, but a complaint's strength comes from facts that satisfy each ingredient — not from merely citing sections. A court can apply the correct section even if the complainant cites the wrong one, provided the facts disclose an offence. How long should a complaint be? As long as necessary to disclose the offence — no longer. A focused two-to-four page complaint that proves every ingredient beats a ten-page emotional narrative. Every paragraph should answer: does this help establish the offence? Can emotional facts be included? Minimise them. Courts decide on facts and law, not feelings. Replace conclusions like "he ruined my life" with provable facts: dates, amounts, representations, documents. What is a private complaint? A complaint filed directly before a Magistrate under Section 223 BNSS instead of to the police. The Magistrate examines the complainant on oath and may order inquiry, investigation, or issue process. A new proviso under S.223 BNSS can require hearing the accused before cognizance in certain cases. What if the police refuse to register an FIR? For a cognizable offence, send the information in writing to the Superintendent of Police under Section 173(4) BNSS. If that fails, approach the Magistrate under Section 175(3) BNSS, who may direct investigation. The Supreme Court in Lalita Kumari held registration is mandatory where a cognizable offence is disclosed. What should be attached with a complaint? Every document that proves an alleged fact: agreements, receipts, bank statements, invoices, messages, the legal notice and its dispatch proof, replies, and a list of witnesses — each annexure referenced by paragraph. How do advocates decide the offences? They work backwards from facts to offence. List the proven facts, then check which offence's ingredients they satisfy — e.g., a false promise inducing payment with dishonest intent points to cheating (S.318 BNS); entrusted property later misappropriated points to criminal breach of trust (S.316 BNS). What makes a complaint weak? Being loud but unproven: labels without ingredient-facts, missing dates and amounts, irrelevant history and reputation attacks, internal contradiction with the documents, ignoring limitation, or failing to annex proving documents. This FAQ touches on criminal procedure and offences. It is general legal education, not advice on any specific matter. The Senior Advocate Rule A complaint should not tell a long story. A complaint should prove an offence. Great complaints do not accuse loudly. They prove quietly. Want to learn legal drafting like a senior advocate? Explore EduLaw Legal Intelligence — case briefs, drafting guides, ingredient maps, and advocate playbooks built for the next generation of litigators. Subscribe Now Read More Advocate Playbooks Legal caution. This blog is for legal education only and is not legal advice. Statutory references reflect the Bharatiya Nyaya Sanhita, 2023 and the Bharatiya Nagarik Suraksha Sanhita, 2023, which may be amended and may be interpreted differently across jurisdictions. Complaint drafting must be based on verified facts, the applicable law, and professional legal review by a qualified advocate. ⬇ Checklist Example Draft © EduLaw Legal Intelligence · Advocate Playbooks · For educational use only. (function(){ "use strict"; document.getElementById('yr').textContent = new Date().getFullYear(); /* Reading progress */ var bar = document.getElementById('progress'); function updateProgress(){ var h = document.documentElement; var scrolled = h.scrollTop; var max = h.scrollHeight - h.clientHeight; bar.style.width = (max>0 ? (scrolled/max*100) : 0) + '%'; } window.addEventListener('scroll', updateProgress, {passive:true}); updateProgress(); /* Roadmap clickable cards */ document.querySelectorAll('#roadmapGrid .step-card').forEach(function(c){ function toggle(){ c.classList.toggle('open'); } c.addEventListener('click', toggle); c.addEventListener('keydown', function(e){ if(e.key==='Enter'||e.key===' '){ e.preventDefault(); toggle(); }}); }); /* Accordions */ document.querySelectorAll('.acc .acc-head').forEach(function(h){ h.addEventListener('click', function(){ h.parentElement.classList.toggle('open'); }); }); /* Checklists (all) with progress + persistence */ function setupList(ul){ var key = 'edulaw_' + (ul.dataset.list||'list'); var saved = {}; try { saved = JSON.parse(localStorage.getItem(key)||'{}'); } catch(e){} var items = ul.querySelectorAll('li'); items.forEach(function(li,i){ if(saved[i]) li.classList.add('done'); li.addEventListener('click', function(){ li.classList.toggle('done'); saved[i] = li.classList.contains('done'); try { localStorage.setItem(key, JSON.stringify(saved)); } catch(e){} updateCount(); }); }); function updateCount(){ var prog = document.getElementById('clProgress'); if(prog && ul.id==='preFileList'){ var done = ul.querySelectorAll('li.done').length; prog.textContent = done + ' of ' + items.length + ' verified'; } } updateCount(); return {ul:ul, items:items, key:key, saved:saved, updateCount:updateCount}; } var lists = {}; document.querySelectorAll('.checklist').forEach(function(ul){ var L = setupList(ul); if(ul.id) lists[ul.id] = L; }); /* Checklist actions */ var copyBtn = document.getElementById('copyChecklist'); if(copyBtn){ copyBtn.addEventListener('click', function(){ var lines = ['PRE-FILING COMPLAINT CHECKLIST — EduLaw']; document.querySelectorAll('#preFileList li').forEach(function(li){ lines.push((li.classList.contains('done')?'[x] ':'[ ] ') + li.textContent.trim().replace(/^✓\s*/,'')); }); var text = lines.join('\n'); function done(){ var t=copyBtn.textContent; copyBtn.textContent='✓ Copied'; setTimeout(function(){copyBtn.textContent=t;},1500); } if(navigator.clipboard && navigator.clipboard.writeText){ navigator.clipboard.writeText(text).then(done, function(){ fallback(text); done(); }); } else { fallback(text); done(); } function fallback(t){ var ta=document.createElement('textarea'); ta.value=t; document.body.appendChild(ta); ta.select(); try{document.execCommand('copy');}catch(e){} document.body.removeChild(ta); } }); } var printBtn = document.getElementById('printChecklist'); if(printBtn){ printBtn.addEventListener('click', function(){ window.print(); }); } var resetBtn = document.getElementById('resetChecklist'); if(resetBtn){ resetBtn.addEventListener('click', function(){ var L = lists['preFileList']; if(!L) return; L.items.forEach(function(li){ li.classList.remove('done'); }); L.saved = {}; try{ localStorage.setItem(L.key,'{}'); }catch(e){} L.updateCount(); }); } /* TOC scroll-spy */ var tocLinks = Array.prototype.slice.call(document.querySelectorAll('.toc.desktop a')); var sections = tocLinks.map(function(a){ return document.querySelector(a.getAttribute('href')); }).filter(Boolean); if('IntersectionObserver' in window && sections.length){ var io = new IntersectionObserver(function(entries){ entries.forEach(function(en){ if(en.isIntersecting){ tocLinks.forEach(function(a){ a.classList.remove('active'); }); var link = document.querySelector('.toc.desktop a[href="#'+en.target.id+'"]'); if(link) link.classList.add('active'); } }); }, {rootMargin:'-20% 0px -70% 0px'}); sections.forEach(function(s){ io.observe(s); }); } /* In-page search with highlight */ var search = document.getElementById('pageSearch'); var article = document.querySelector('.article'); function clearMarks(){ article.querySelectorAll('mark.hl').forEach(function(m){ var p = m.parentNode; p.replaceChild(document.createTextNode(m.textContent), m); p.normalize(); }); } function doSearch(q){ clearMarks(); if(!q || q.length '+m+' '; }); node.parentNode.replaceChild(span, node); while(span.firstChild) span.parentNode.insertBefore(span.firstChild, span); span.parentNode.removeChild(span); }); first = article.querySelector('mark.hl'); if(first) first.scrollIntoView({behavior:'smooth', block:'center'}); } if(search){ var t; search.addEventListener('input', function(){ clearTimeout(t); t=setTimeout(function(){ doSearch(search.value.trim()); }, 250); }); } })();