// Per-engagement detail pages — one route each:
// 'mediation' · 'special-master' · 'forensic-neutral' · 'ai-disputes' · 'arbitration'
// Each is a richly-explained page with context, when-to-retain, methodology,
// representative matters, frequently asked questions, and a CTA.

const PRACTICE_DETAIL = {
  mediation: {
    n: '01',
    title: 'Mediation',
    tagline: 'Privately-administered mediation for technically complex commercial disputes.',
    hero: 'Most disputes settle when someone in the room can read the source code AND the case law. The mediator is the room.',
    schematic: 'mediation',
    whatItIs: [
      'Mediation is a confidential, voluntary, settlement-oriented process. The mediator does not decide the matter — the parties do. The mediator\u2019s job is to surface the facts, frame the structure, and translate between rooms until a settlement architecture emerges that both sides can accept.',
      'Tailored mediation differs from standard mediation in one specific way: where the dispute turns on technology — model behavior, smart-contract execution, source-code provenance, log integrity — the mediator can read the technology directly rather than relying on a translation through party experts. That fluency collapses the distance between rooms in matters that would otherwise stall.',
    ],
    whenToRetain: [
      { t: 'AI / model output liability', d: 'Disputes over hallucinated outputs in regulated workflows, training-data provenance, or vendor representations about model behavior.' },
      { t: 'Trade-secret in software, ML weights, schematics', d: 'Where the alleged misappropriation requires reading code or model artifacts to assess.' },
      { t: 'Cyber-insurance coverage', d: 'Coverage fights turning on dwell time, attribution, war exclusions, or reasonable-controls representations.' },
      { t: 'Smart-contract / cryptocurrency', d: 'On-chain disputes where remedies require parsing both the contract code and the underlying bargain.' },
      { t: 'eDiscovery / ESI disputes', d: 'Where the production fight has stalled on a sampling, search-term, or privilege-log methodology question.' },
      { t: 'Cross-border commercial', d: 'International disputes with multi-jurisdictional discovery and choice-of-law overlays.' },
    ],
    methodology: [
      { p: 'Pre-session', d: 'Position statements (confidential to mediator), key-evidence designation, technical briefings as needed. Daniel issues a session agenda 7–10 days ahead.' },
      { p: 'Joint opening', d: 'Each party presents position briefly. Daniel frames the day, sets ground rules, and identifies the technical questions the mediation will tackle.' },
      { p: 'Caucus rounds', d: 'Iterative private sessions. Daniel translates technical positions and tests assumptions in each room. Where the matter turns on a verifiable fact, a forensic component is invoked to resolve it on the spot.' },
      { p: 'Convergence', d: 'Settlement architecture drafted, including any technical remediation, audit, or escrow terms.' },
      { p: 'Documentation', d: 'Term sheet executed by all parties. Where stipulated, a written summary of agreements for inclusion in court approval orders.' },
    ],
    typicalScale: 'Half-day to multi-week. $5M to $1B+ exposure.',
    faqs: [
      { q: 'Will Daniel review source code or model weights during the mediation?', a: 'Yes, where the parties stipulate and a tiered protective order is in place. He has done this many times.' },
      { q: 'Can he co-mediate with a retired judge?', a: 'Frequently. Pairing a technical neutral with a process neutral is the right configuration for many high-stakes matters.' },
      { q: 'How quickly can a session be scheduled?', a: 'Typically 14–60 days from retention.' },
    ],
  },
  'special-master': {
    n: '02',
    title: 'Special Master',
    tagline: 'Court-appointed for ESI protocols, discovery management, and complex protective orders.',
    hero: 'When a court needs technical fluency in real-time discovery, a Special Master is the mechanism. Daniel is one of a handful of neutrals nationally who can fill that role at the highest levels of complexity.',
    schematic: 'special-master',
    whatItIs: [
      'A Special Master is appointed by the court to manage some aspect of a case that exceeds the bench\u2019s practical capacity — most commonly, technically complex discovery. The Special Master issues protocols, resolves disputes in real time, conducts fact-finding where the order authorizes it, and reports back to the appointing court.',
      'The role exists because the alternative — running every technical discovery dispute through a sitting judge — is prohibitively slow and expensive for both the parties and the bench. A competent Special Master clears six months of work in three weeks and produces a record the appointing court can rely on.',
    ],
    whenToRetain: [
      { t: 'TB-scale ESI productions', d: 'Where the volume and technical complexity of production exceed what counsel can resolve unsupervised.' },
      { t: 'TAR / CAL validation', d: 'Where a continuous-active-learning workflow is contested or where seed-set composition is disputed.' },
      { t: 'Spoliation findings', d: 'FRCP 37(e) inquiries requiring a fact-finder fluent in the underlying systems and preservation mechanics.' },
      { t: 'Privilege-log adequacy', d: 'Where privilege assertions cover hundreds of thousands of documents and require sampling and validation.' },
      { t: 'Source-code review protocols', d: 'Tiered-access frameworks for source code, model weights, and proprietary algorithms.' },
      { t: 'Cross-border ESI coordination', d: 'GDPR / Schrems II / sectoral privacy law overlays on US discovery obligations.' },
    ],
    methodology: [
      { p: 'Appointment', d: 'Order of appointment from the court, scope-of-authority defined. Daniel issues a brief acknowledgment and initial procedural framework.' },
      { p: 'Initial protocol', d: 'Draft ESI protocol distributed to parties: custodians, sources, search terms / TAR design, privilege handling, production format, claw-back terms. 10–14 day comment window.' },
      { p: 'Active management', d: 'Real-time dispute resolution. Disputes raised by letter brief; rulings within 5 business days. Technical questions get a written analysis with the ruling.' },
      { p: 'Spoliation / sanctions', d: 'Fact-finding under FRCP 37(e) standards where preservation failures are alleged. Findings issue with recommended sanctions if warranted.' },
      { p: 'Reporting', d: 'Periodic reports to the appointing court. Final report on dissolution of the appointment.' },
    ],
    typicalScale: 'Multi-month engagements. Substantial document corpus. Often class-action or multi-district matters.',
    faqs: [
      { q: 'Who pays the Special Master?', a: 'The order of appointment specifies. Typically split equally between the parties; sometimes weighted to the producing party; occasionally borne by one side as a sanction.' },
      { q: 'Does the Special Master decide the merits?', a: 'No — only what the order of appointment authorizes. Daniel\u2019s reports are reviewed by the appointing court before becoming binding.' },
      { q: 'Can a Special Master be appointed at any stage?', a: 'Yes, including post-discovery and post-judgment, though early appointment usually saves the most cost.' },
    ],
  },
  'forensic-neutral': {
    n: '03',
    title: 'Forensic Neutral',
    tagline: 'Independent third-party technical expert appointed by tribunal or counsel.',
    hero: 'A party-retained forensic expert produces evidence. A court-appointed forensic neutral produces shared understanding. The distinction often determines whether the case settles or goes to trial.',
    schematic: 'forensic',
    whatItIs: [
      'A Forensic Neutral is an independent technical investigator appointed by a tribunal or stipulated by the parties to answer a narrowly-defined technical question — did a file exist on a particular device on a particular date? Did a model produce a particular output under particular conditions? Was a transaction signed by a particular wallet?',
      'The neutral\u2019s output is not an exhibit one side will move to exclude. It is a finding the parties have, in advance, agreed to treat as authoritative on the narrow question put to it. That advance agreement is what makes the role effective: it removes a class of disputes from the litigation entirely.',
      'Daniel has served as Forensic Neutral in matters spanning trade secret, IP misappropriation, fraud, employment, bankruptcy, and international device collection coordinated with FBI, Interpol, and counterpart agencies.',
    ],
    whenToRetain: [
      { t: 'Disputed file existence or content', d: 'Did a particular file exist on a device on a date? What did it contain? Was it altered?' },
      { t: 'Authenticated electronic communications', d: 'Email, chat, messaging-app artifacts that need FRE 901 authentication for admission.' },
      { t: 'Deepfake authentication', d: 'Synthetic-media-suspected evidence requiring device-level provenance and artifact analysis.' },
      { t: 'Smart-contract / on-chain forensics', d: 'Wallet attribution, transaction tracing, contract audit, oracle feed verification.' },
      { t: 'Mobile / IoT / vehicle telematics', d: 'Smartphone exports, infotainment systems, telematics, embedded device data.' },
      { t: 'International device collection', d: 'Cross-border imaging coordinated with foreign counterparts under appropriate legal authorization.' },
    ],
    methodology: [
      { p: 'Scoping', d: 'Question put to the neutral defined precisely. Investigation protocol drafted: targets, tools, custody chain, hashing strategy, reporting format, deadlines.' },
      { p: 'Acquisition', d: 'Forensic images acquired from in-scope sources. Hashes calculated and recorded. Original media sealed under access-logged custody.' },
      { p: 'Analysis', d: 'Examination per the protocol. Technical findings recorded contemporaneously. Scope-affecting discoveries trigger party notification.' },
      { p: 'Authentication', d: 'Chain-of-custody, hash verification, and tooling provenance documented for FRE 901 admission.' },
      { p: 'Report', d: 'Written report to tribunal and parties: methodology, findings, limitations, supporting exhibits. Available for cross-examination.' },
    ],
    typicalScale: 'Days to months depending on protocol scope. From single-device forensics to TB-scale enterprise collections.',
    faqs: [
      { q: 'Is the neutral\u2019s report admissible?', a: 'Yes, where the engagement order makes it admissible by stipulation. In many matters, the parties\u2019 advance agreement to treat the report as authoritative is the entire point of the engagement.' },
      { q: 'Can the neutral be cross-examined?', a: 'Yes. Daniel is regularly cross-examined on his findings and writes reports anticipating that scrutiny.' },
      { q: 'What if the investigation surfaces something outside the original scope?', a: 'The protocol specifies how scope-changes are handled. Typically Daniel notifies the appointing tribunal and the parties, and scope is amended (or not) by order.' },
    ],
  },
  'ai-disputes': {
    n: '04',
    title: 'AI Disputes — Tribunal Services',
    tagline: 'Arbitrator and protocol architect under emerging AI dispute frameworks.',
    hero: 'AI matters are not commercial-arbitration-with-a-technical-hat. They are a different artifact requiring a different process. The arbitrator who can read the system card, the eval suite, and the inference logs resolves these matters substantially faster than one who cannot.',
    schematic: 'ai',
    whatItIs: [
      'AI disputes are a distinct category of commercial dispute with their own evidentiary character. The artifacts at issue — model weights, training data, prompts, system cards, evaluation reports, retrieval logs, inference timestamps — are not the artifacts of conventional commercial arbitration. They require a tribunal that can scope discovery to what is probative, design tiered protective orders that distinguish weights from outputs, and pose its own technical questions where the record is incomplete.',
      'Daniel arbitrates under emerging AI dispute frameworks — JAMS AI Disputes Clause and Rules where parties have incorporated them; party-stipulated frameworks where they have not. He has authored and co-authored standing protective-order templates for AI matters.',
    ],
    whenToRetain: [
      { t: 'Model output liability', d: 'Hallucinated outputs in regulated workflows, defamation, autonomous-system intervention failures.' },
      { t: 'Training data IP', d: 'Disputes over the provenance, licensing, and lawful use of training corpora.' },
      { t: 'Algorithmic bias / discrimination', d: 'Statutory and common-law claims arising from differential treatment in automated decisioning.' },
      { t: 'AI vendor / enterprise contract', d: 'Disputes over service-level guarantees, model performance representations, and use restrictions.' },
      { t: 'Generative IP', d: 'Copyright, derivative-works, and substantial-similarity disputes over generative outputs.' },
      { t: 'Embedded ML in safety-critical products', d: 'Disputes where ML behavior contributed to a physical-world harm.' },
    ],
    methodology: [
      { p: 'Framework selection', d: 'AI-specific rules where the parties\u2019 contract incorporates them. Where the contract is silent, a tailored framework can be proposed with parties\u2019 consent.' },
      { p: 'Tiered protective order', d: 'Standing template distinguishing weights, training data, prompts, inference logs, and outputs into separate access tiers. Reviewer credentialing per tier.' },
      { p: 'Discovery scoping', d: 'System cards, eval reports, RAG configurations, retrieval logs, fine-tuning datasets, inference timestamps. What is probative; what is fishing into trade secrets dressed as discovery.' },
      { p: 'Technical adjudication', d: 'Daniel may pose tribunal questions where the record is incomplete. Hearings may include live model interrogation under controlled conditions.' },
      { p: 'Award', d: 'Reasoned award addressing both technical and legal questions. Where the matter turns on machine behavior, the award sets out the model behavior actually observed and the legal consequences turning on it.' },
    ],
    typicalScale: 'Six- to eighteen-month proceedings. $5M to $1B+ exposure typical.',
    faqs: [
      { q: 'Does Daniel work under specific AI dispute rules?', a: 'Where the contract incorporates them, yes. Where it does not, the parties can stipulate to a framework — including the JAMS AI Disputes Clause and Rules — or proceed under a tailored protocol.' },
      { q: 'Will the tribunal examine the model directly?', a: 'Where the parties stipulate and the protective order permits, yes. Direct interrogation under controlled conditions is sometimes determinative.' },
      { q: 'How are model weights protected during discovery?', a: 'Through a five-tier protective order with cleanroom review for the most sensitive artifacts. Daniel has authored these for many matters and adapts them to the specifics.' },
    ],
  },
  arbitration: {
    n: '05',
    title: 'Arbitration',
    tagline: 'Sole or panel arbitrator for technically complex commercial matters.',
    hero: 'In commercial arbitration, the question is rarely whether the law was followed. It is what actually happened, technically, between the parties. The arbitrator who can read the systems is the one who can answer that.',
    schematic: 'arbitration',
    whatItIs: [
      'Arbitration is a private adjudicatory proceeding governed by the parties\u2019 contract and the rules they have selected. The tribunal hears evidence, applies the law, and issues a binding award. Where the parties have selected three arbitrators, Daniel sits as chair or wing depending on the appointment.',
      'Daniel\u2019s arbitration practice spans commercial, technology, and IP matters with technical questions at their core: SaaS service-level disputes, data-breach insurance coverage, trade-secret misappropriation, software licensing, smart-contract execution, and patent validity / infringement.',
    ],
    whenToRetain: [
      { t: 'SaaS / cloud SLA disputes', d: 'Service-level disputes where performance representations meet enterprise consumption.' },
      { t: 'Data-breach insurance coverage', d: 'Coverage fights turning on attribution, dwell time, exclusion language, and reasonable-controls representations.' },
      { t: 'Cryptocurrency / token disputes', d: 'Founder/investor disputes, token-allocation disputes, on-chain execution disputes.' },
      { t: 'Software licensing', d: 'Scope, territory, audit-clause, and breach disputes in software licensing arrangements.' },
      { t: 'Patent validity / infringement', d: 'Where the contract sends patent disputes to arbitration rather than the federal courts.' },
      { t: 'Smart-contract execution', d: 'Where on-chain behavior is alleged to depart from the off-chain bargain.' },
    ],
    methodology: [
      { p: 'Constitution of tribunal', d: 'Sole arbitrator on appointment; chair or wing on three-member panels. Conflicts disclosure under L.C.I.A., H.K.I.A.C., AAA, CPR, ICC, or party-stipulated rules.' },
      { p: 'Terms of reference', d: 'Procedural calendar, scope of pleadings, evidentiary rules, language and seat. For technical matters Daniel often expands the standard order to address source-code review and expert-evidence framework.' },
      { p: 'Evidentiary phase', d: 'Documentary production per agreed scope. Witness statements and expert reports. Hearings either in-person at the seat or virtual / hybrid.' },
      { p: 'Hearing', d: 'Oral testimony, cross-examination, expert hot-tubbing where useful. Tribunal questions on technical points where the record is silent.' },
      { p: 'Award', d: 'Reasoned award addressing all submitted issues. Daniel routinely issues awards within 60–90 days of close of hearings.' },
    ],
    typicalScale: 'Six- to eighteen-month proceedings. Sole or three-member panel.',
    faqs: [
      { q: 'What rules does Daniel arbitrate under?', a: 'Whatever the parties\u2019 contract specifies — L.C.I.A., H.K.I.A.C., AAA, CPR, ICC commonly; ad-hoc or party-stipulated frameworks where the contract is silent or open.' },
      { q: 'Where are hearings seated?', a: 'Wherever the contract specifies; Daniel hears matters in-person across more than ten venues globally and conducts virtual or hybrid hearings as the seat allows.' },
      { q: 'How long until an award issues?', a: 'Within 60–90 days of the close of hearings is the standard cadence Daniel maintains.' },
    ],
  },
};

const PracticeDetailPage = ({ id, onNav }) => {
  const d = PRACTICE_DETAIL[id];
  if (!d) return null;
  const Schematic =
    d.schematic === 'mediation' ? window.MediationSchematic :
    d.schematic === 'special-master' ? window.SpecialMasterSchematic :
    d.schematic === 'forensic' ? window.ForensicSchematic :
    d.schematic === 'ai' ? window.AISchematic :
    d.schematic === 'arbitration' ? window.ArbitrationSchematic : null;

  return (
    <div className="page-fade">
      {/* Hero */}
      <section style={{ background: 'var(--ink)', color: 'var(--paper)', padding: '120px 0 80px', position: 'relative', overflow: 'hidden' }}>
        <div className="dotgrid-dark" style={{ position: 'absolute', inset: 0, opacity: 0.3 }}/>
        <div className="container" style={{ position: 'relative' }}>
          <button onClick={() => onNav('services')} className="mono" style={{
            fontSize: 11, color: 'var(--gold)', letterSpacing: '0.2em', marginBottom: 32, display: 'block',
          }}>← ALL ENGAGEMENTS</button>
          <div style={{ display: 'grid', gridTemplateColumns: '1fr 2fr', gap: 64, alignItems: 'baseline' }}>
            <div>
              <div className="display" style={{ fontSize: 120, color: 'var(--gold)', fontWeight: 300, lineHeight: 0.9 }}>
                {d.n}
              </div>
              <div className="mono" style={{ fontSize: 11, letterSpacing: '0.2em', color: 'var(--gold)', marginTop: 14 }}>
                ENGAGEMENT
              </div>
            </div>
            <div>
              <h1 className="display" style={{ fontSize: 'clamp(48px, 7vw, 96px)', color: 'var(--paper)', lineHeight: 1.02 }}>
                {d.title}
              </h1>
              <p className="serif" style={{ fontSize: 22, color: 'var(--slate-300)', marginTop: 24, fontStyle: 'italic', lineHeight: 1.45, maxWidth: 760 }}>
                {d.tagline}
              </p>
              <p style={{ marginTop: 32, fontSize: 19, color: 'var(--paper)', lineHeight: 1.6, maxWidth: 720, opacity: 0.92 }}>
                {d.hero}
              </p>
            </div>
          </div>
        </div>
      </section>

      {/* What this is */}
      <section className="section">
        <div className="container">
          <div style={{ display: 'grid', gridTemplateColumns: '1fr 2fr', gap: 80 }}>
            <div>
              <div className="eyebrow">§ 01 · What this is</div>
            </div>
            <div>
              {d.whatItIs.map((p, i) => (
                <p key={i} className={i === 0 ? 'serif' : ''} style={{
                  fontSize: i === 0 ? 22 : 18, lineHeight: i === 0 ? 1.55 : 1.7,
                  color: i === 0 ? 'var(--ink)' : 'var(--slate-900)',
                  marginBottom: 24,
                }}>
                  {p}
                </p>
              ))}
              {Schematic && (
                <div style={{ marginTop: 32, padding: 24, border: '1px solid var(--line-soft)', background: 'var(--paper-2)' }}>
                  <Schematic/>
                </div>
              )}
            </div>
          </div>
        </div>
      </section>

      {/* When to retain */}
      <section className="section" style={{ background: 'var(--paper-2)' }}>
        <div className="container">
          <div className="eyebrow" style={{ marginBottom: 16 }}>§ 02 · When to retain</div>
          <h2 className="display" style={{ fontSize: 'clamp(34px, 4vw, 56px)', lineHeight: 1.05, marginBottom: 56 }}>
            Indicators that <em style={{ color: 'var(--gold-deep)', fontStyle: 'italic' }}>this is the right role</em> for the matter.
          </h2>
          <div style={{ display: 'grid', gridTemplateColumns: 'repeat(2, 1fr)', gap: 32 }}>
            {d.whenToRetain.map((w, i) => (
              <div key={i} style={{
                padding: 28, background: 'var(--paper)', border: '1px solid var(--line-soft)',
              }}>
                <div className="mono" style={{ fontSize: 11, color: 'var(--gold-deep)', letterSpacing: '0.18em' }}>
                  {String(i + 1).padStart(2, '0')}
                </div>
                <h3 className="serif" style={{ fontSize: 22, marginTop: 8, fontWeight: 500, lineHeight: 1.2 }}>{w.t}</h3>
                <p style={{ marginTop: 12, fontSize: 15, color: 'var(--slate-700)', lineHeight: 1.6 }}>{w.d}</p>
              </div>
            ))}
          </div>
        </div>
      </section>

      {/* Methodology */}
      <section className="section">
        <div className="container">
          <div className="eyebrow" style={{ marginBottom: 16 }}>§ 03 · Methodology</div>
          <h2 className="display" style={{ fontSize: 'clamp(34px, 4vw, 56px)', lineHeight: 1.05, marginBottom: 16 }}>
            How an engagement runs.
          </h2>
          <p className="serif" style={{ fontSize: 18, color: 'var(--slate-700)', fontStyle: 'italic', marginBottom: 48, maxWidth: 720 }}>
            Typical scale: {d.typicalScale}
          </p>
          <ol style={{ listStyle: 'none', counterReset: 'phase' }}>
            {d.methodology.map((m, i) => (
              <li key={i} style={{
                paddingBottom: 28, marginBottom: 28,
                borderBottom: i < d.methodology.length - 1 ? '1px solid var(--line-soft)' : 'none',
                display: 'grid', gridTemplateColumns: '70px 1fr', gap: 32,
              }}>
                <div className="display" style={{ fontSize: 36, color: 'var(--gold-deep)', fontWeight: 300, lineHeight: 1 }}>
                  {String(i + 1).padStart(2, '0')}
                </div>
                <div>
                  <h4 className="serif" style={{ fontSize: 24, lineHeight: 1.2, fontWeight: 500 }}>{m.p}</h4>
                  <p style={{ fontSize: 16, color: 'var(--slate-900)', lineHeight: 1.65, marginTop: 8 }}>{m.d}</p>
                </div>
              </li>
            ))}
          </ol>
        </div>
      </section>

      {/* Quick FAQ */}
      <section className="section" style={{ background: 'var(--paper-2)' }}>
        <div className="container">
          <div className="eyebrow" style={{ marginBottom: 16 }}>§ 04 · Frequently asked</div>
          <h2 className="display" style={{ fontSize: 'clamp(28px, 3.4vw, 42px)', lineHeight: 1.1, marginBottom: 40 }}>
            About this role.
          </h2>
          <div style={{ borderTop: '1px solid var(--line-soft)' }}>
            {d.faqs.map((f, i) => (
              <div key={i} style={{ padding: '24px 0', borderBottom: '1px solid var(--line-soft)' }}>
                <h4 className="serif" style={{ fontSize: 20, fontWeight: 500, lineHeight: 1.3, color: 'var(--ink)' }}>
                  {f.q}
                </h4>
                <p style={{ fontSize: 16, color: 'var(--slate-900)', lineHeight: 1.65, marginTop: 10, maxWidth: 760 }}>
                  {f.a}
                </p>
              </div>
            ))}
          </div>
          <button onClick={() => onNav('faq')} className="mono" style={{
            marginTop: 32, fontSize: 11, letterSpacing: '0.2em', color: 'var(--gold-deep)',
            borderBottom: '1px solid currentColor', paddingBottom: 2, cursor: 'pointer',
          }}>
            Full FAQ →
          </button>
        </div>
      </section>

      {/* CTA */}
      <section className="section" style={{ background: 'var(--ink)', color: 'var(--paper)' }}>
        <div className="container center">
          <div className="eyebrow on-dark">Begin a {d.title.toLowerCase()} matter</div>
          <h2 className="display" style={{ fontSize: 'clamp(40px, 5vw, 68px)', marginTop: 16, color: 'var(--paper)' }}>
            Eight questions. <em style={{ color: 'var(--gold)', fontStyle: 'italic', fontWeight: 300 }}>One considered match.</em>
          </h2>
          <button className="btn btn-gold" style={{ marginTop: 40 }} onClick={() => onNav('intake')}>
            Open match intake <span className="arrow">→</span>
          </button>
        </div>
      </section>
    </div>
  );
};

window.PracticeDetailPage = PracticeDetailPage;
window.PRACTICE_DETAIL = PRACTICE_DETAIL;
