﻿/* ═══════════════════════════════════════════
       0. Custom Properties
       ═══════════════════════════════════════════ */
    :root {
      --accent:       #f59e0b;
      --accent-light: #fef3c7;
      --accent-dark:  #b45309;
      --accent-text:  #78350f;
      --text:         #1e293b;
      --text-mid:     #475569;
      --text-light:   #64748b;
      --bg:           #ffffff;
      --bg-page:      #f8fafc;
      --bg-alt:       #f1f5f9;
      --border:       #e2e8f0;
      --border-light: #f1f5f9;
      --radius:       12px;
      --radius-sm:    8px;
      --shadow-sm:    0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
      --shadow-md:    0 4px 16px rgba(0,0,0,0.06), 0 2px 4px rgba(0,0,0,0.04);
      --shadow-lg:    0 8px 30px rgba(0,0,0,0.08);
      --focus-ring:   0 0 0 3px rgba(245,158,11,0.45);
      --transition:   0.2s ease;
      --toc-width:    260px;
      --content-max:  760px;
    }

    /* ═══════════════════════════════════════════
       1. Reset & Base
       ═══════════════════════════════════════════ */
    *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

    html {
      scroll-behavior: smooth;
      scroll-padding-top: 24px;
    }

    body {
      background: var(--bg-page);
      color: var(--text);
      font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
      font-size: clamp(15px, 1vw + 12px, 17px);
      line-height: 1.75;
      -webkit-font-smoothing: antialiased;
      -moz-osx-font-smoothing: grayscale;
      text-rendering: optimizeLegibility;
    }

    /* ═══════════════════════════════════════════
       2. Skip Link (WCAG 2.4.1)
       ═══════════════════════════════════════════ */
    .skip-link {
      position: absolute;
      top: -100%;
      left: 16px;
      z-index: 9999;
      padding: 12px 24px;
      background: var(--text);
      color: #fff;
      border-radius: var(--radius-sm);
      font-weight: 600;
      font-size: 0.9rem;
      text-decoration: none;
      transition: top var(--transition);
    }
    .skip-link:focus {
      top: 16px;
    }

    /* ═══════════════════════════════════════════
       3. Reading Progress Bar
       ═══════════════════════════════════════════ */
    .progress-bar {
      position: fixed;
      top: 0;
      left: 0;
      width: 0%;
      height: 3px;
      background: linear-gradient(90deg, var(--accent), var(--accent-dark));
      z-index: 1000;
      transition: width 60ms linear;
      border-radius: 0 2px 2px 0;
    }

    /* ═══════════════════════════════════════════
       4. Layout: ToC Sidebar + Main
       ═══════════════════════════════════════════ */
    .bf-layout {
      display: grid;
      grid-template-columns: var(--toc-width) 1fr;
      gap: 0;
      max-width: calc(var(--toc-width) + var(--content-max) + 80px);
      margin: 0 auto;
    }

    /* ═══════════════════════════════════════════
       5. Table of Contents – Sticky Sidebar
       ═══════════════════════════════════════════ */
    .toc {
      position: sticky;
      top: 12px;
      align-self: start;
      height: calc(100dvh - 24px);
      padding: 24px 16px 24px 20px;
      border-right: 1px solid var(--border);
      background: var(--bg);
      scrollbar-width: thin;
      scrollbar-color: var(--border) transparent;
    }
    .toc::-webkit-scrollbar { width: 4px; }
    .toc::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

    .toc-title {
      font-size: 0.7rem;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: 0.1em;
      color: var(--text-light);
      margin-bottom: 16px;
      padding-bottom: 8px;
      border-bottom: 1px solid var(--border);
    }

    .toc-group { margin-bottom: 12px; }

    .toc-group-label {
      font-size: 0.65rem;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: 0.08em;
      color: var(--accent-dark);
      padding: 4px 0 4px 10px;
      margin-bottom: 2px;
    }

    .toc-link {
      display: block;
      padding: 4px 10px;
      font-size: 0.82rem;
      line-height: 1.5;
      color: var(--text-mid);
      text-decoration: none;
      border-radius: var(--radius-sm);
      border-left: 2px solid transparent;
      transition: all var(--transition);
    }
    .toc-link:hover {
      color: var(--text);
      background: var(--bg-alt);
    }
    .toc-link.active {
      color: var(--accent-dark);
      background: var(--accent-light);
      border-left-color: var(--accent);
      font-weight: 600;
    }
    .toc-link:focus-visible {
      outline: none;
      box-shadow: var(--focus-ring);
    }

    /* Mobile ToC toggle */
    .toc-toggle {
      display: none;
      position: fixed;
      bottom: 80px;
      right: 20px;
      z-index: 200;
      width: 48px;
      height: 48px;
      border-radius: 50%;
      border: none;
      background: var(--text);
      color: #fff;
      font-size: 1.1rem;
      cursor: pointer;
      box-shadow: var(--shadow-md);
      transition: transform var(--transition), background var(--transition);
      align-items: center;
      justify-content: center;
    }
    .toc-toggle:hover { background: var(--text-mid); }
    .toc-toggle:focus-visible { outline: none; box-shadow: var(--focus-ring); }
    .toc-toggle svg { width: 20px; height: 20px; fill: currentColor; }

    .toc-close {
      display: none;
      position: absolute;
      top: 12px;
      right: 12px;
      width: 32px;
      height: 32px;
      border-radius: 50%;
      border: 1px solid var(--border);
      background: var(--bg);
      color: var(--text);
      font-size: 1.2rem;
      cursor: pointer;
      align-items: center;
      justify-content: center;
      line-height: 1;
    }
    .toc-close:focus-visible { outline: none; box-shadow: var(--focus-ring); }

    /* ═══════════════════════════════════════════
       6. Main Content Area
       ═══════════════════════════════════════════ */
    .bf-main {
      max-width: var(--content-max);
      padding: 40px clamp(16px, 4vw, 48px) 64px;
    }

    /* ═══════════════════════════════════════════
       7. Hero Header
       ═══════════════════════════════════════════ */
    .bf-hero {
      text-align: center;
      margin-bottom: 40px;
      padding-bottom: 32px;
      border-bottom: 2px solid var(--accent);
    }
    .bf-hero h1 {
      font-size: clamp(1.5rem, 2.5vw + 0.5rem, 2rem);
      font-weight: 800;
      color: var(--text);
      letter-spacing: -0.025em;
      line-height: 1.25;
      margin-bottom: 8px;
    }
    .bf-hero .company {
      font-size: 1rem;
      font-weight: 600;
      color: var(--accent-dark);
      margin-bottom: 4px;
    }
    .bf-hero .stand {
      font-size: 0.85rem;
      color: var(--text-light);
    }

    /* ═══════════════════════════════════════════
       8. Section Group Dividers
       ═══════════════════════════════════════════ */
    .group-divider {
      display: flex;
      align-items: center;
      gap: 12px;
      margin: 36px 0 20px;
      padding: 0 4px;
    }
    .group-divider::before,
    .group-divider::after {
      content: '';
      flex: 1;
      height: 1px;
      background: var(--border);
    }
    .group-divider-label {
      font-size: 0.7rem;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: 0.1em;
      color: var(--text-light);
      white-space: nowrap;
      flex-shrink: 0;
    }

    /* ═══════════════════════════════════════════
       9. BF Cards (Sections)
       ═══════════════════════════════════════════ */
    .bf-card {
      background: var(--bg);
      border: 1px solid var(--border);
      border-radius: var(--radius);
      margin-bottom: 20px;
      overflow: hidden;
      transition: box-shadow var(--transition);
      scroll-margin-top: 20px;
    }
    .bf-card:hover {
      box-shadow: var(--shadow-sm);
    }
    .bf-card:target {
      box-shadow: 0 0 0 2px var(--accent);
    }

    .bf-card--highlight {
      border-left: 3px solid var(--accent);
    }
    .bf-card--highlight .bf-card-header {
      background: linear-gradient(135deg, var(--accent-light) 0%, var(--bg) 70%);
    }

    .bf-card-header {
      display: flex;
      align-items: center;
      gap: 12px;
      padding: 18px 24px 14px;
      border-bottom: 1px solid var(--border-light);
      background: var(--bg);
    }

    .badge {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      min-width: 38px;
      height: 32px;
      padding: 0 10px;
      border-radius: var(--radius-sm);
      background: var(--accent-light);
      color: var(--accent-text);
      font-size: 0.78rem;
      font-weight: 800;
      flex-shrink: 0;
      white-space: nowrap;
      border: 1px solid rgba(245,158,11,0.25);
      font-variant-numeric: tabular-nums;
    }

    .bf-card-header h2 {
      font-size: clamp(1rem, 1.5vw + 0.4rem, 1.15rem);
      font-weight: 700;
      color: var(--text);
      margin: 0;
      line-height: 1.35;
    }

    .bf-card-header h2 .anchor-link {
      display: inline-block;
      margin-left: 6px;
      font-size: 0.8em;
      color: var(--text-light);
      text-decoration: none;
      opacity: 0;
      transition: opacity var(--transition);
      vertical-align: middle;
    }
    .bf-card:hover .anchor-link,
    .anchor-link:focus {
      opacity: 0.6;
    }
    .anchor-link:hover { opacity: 1; }

    /* ═══════════════════════════════════════════
       10. Card Body & Content
       ═══════════════════════════════════════════ */
    .bf-card-body {
      padding: 20px 24px 24px;
    }

    .clause {
      display: flex;
      gap: 14px;
      padding: 10px 0;
      border-bottom: 1px solid var(--border-light);
    }
    .clause:last-child { border-bottom: none; padding-bottom: 0; }
    .clause:first-child { padding-top: 0; }

    .clause-num {
      flex-shrink: 0;
      min-width: 52px;
      font-weight: 700;
      color: var(--accent-dark);
      font-size: 0.88rem;
      font-variant-numeric: tabular-nums;
      font-family: 'SF Mono', 'Cascadia Code', 'Fira Code', ui-monospace, monospace;
      padding-top: 2px;
      line-height: 1.75;
    }

    .clause-text {
      flex: 1;
      color: var(--text);
      line-height: 1.72;
    }
    .clause-text strong {
      color: var(--text);
      font-weight: 650;
    }
    .clause-text a {
      color: var(--accent-dark);
      text-decoration: underline;
      text-decoration-color: rgba(180,83,9,0.3);
      text-underline-offset: 3px;
      transition: text-decoration-color var(--transition);
    }
    .clause-text a:hover {
      text-decoration-color: var(--accent-dark);
    }
    .clause-text a:focus-visible {
      outline: none;
      box-shadow: var(--focus-ring);
      border-radius: 2px;
    }

    /* Bulleted lists inside clauses */
    .bf-list {
      list-style: none;
      padding: 0;
      margin: 8px 0 0;
    }
    .bf-list li {
      position: relative;
      padding: 4px 0 4px 18px;
      line-height: 1.72;
    }
    .bf-list li::before {
      content: '';
      position: absolute;
      left: 0;
      top: 12px;
      width: 6px;
      height: 6px;
      border-radius: 50%;
      background: var(--accent);
    }

    /* Hint / Info box */
    .hint-box {
      display: flex;
      gap: 12px;
      padding: 14px 16px;
      background: var(--accent-light);
      border-radius: var(--radius-sm);
      border: 1px solid rgba(245,158,11,0.2);
      margin-top: 16px;
      font-size: 0.9rem;
      line-height: 1.65;
      color: var(--accent-text);
    }
    .hint-box .hint-icon {
      font-size: 1.2rem;
      flex-shrink: 0;
      margin-top: 1px;
    }

    /* Info box - neutral (blue-gray) */
    .info-box {
      display: flex;
      gap: 12px;
      padding: 14px 16px;
      background: var(--bg-alt);
      border-radius: var(--radius-sm);
      border: 1px solid var(--border);
      margin-top: 16px;
      font-size: 0.9rem;
      line-height: 1.65;
      color: var(--text-mid);
    }
    .info-box .info-icon {
      font-size: 1.2rem;
      flex-shrink: 0;
      margin-top: 1px;
    }

    /* Status badge */
    .status-badge {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      padding: 6px 14px;
      border-radius: 20px;
      font-size: 0.85rem;
      font-weight: 600;
      margin: 8px 0 16px;
    }
    .status-badge--partial {
      background: #fef3c7;
      color: #92400e;
      border: 1px solid rgba(245,158,11,0.3);
    }
    .status-badge .status-dot {
      width: 8px;
      height: 8px;
      border-radius: 50%;
      background: currentColor;
    }

    /* ═══════════════════════════════════════════
       11. Footer
       ═══════════════════════════════════════════ */
    .bf-footer {
      text-align: center;
      margin-top: 48px;
      padding-top: 28px;
      border-top: 2px solid var(--accent);
    }
    .bf-footer .company-name {
      font-weight: 700;
      font-size: 1rem;
      color: var(--text);
      margin-bottom: 8px;
    }
    .bf-footer .contact-info {
      color: var(--text-mid);
      font-size: 0.9rem;
      line-height: 1.9;
    }
    .bf-footer .contact-info a {
      color: var(--accent-dark);
      text-decoration: underline;
      text-decoration-color: rgba(180,83,9,0.3);
      text-underline-offset: 3px;
    }
    .bf-footer .contact-info a:hover { text-decoration-color: var(--accent-dark); }
    .bf-footer .contact-info a:focus-visible {
      outline: none;
      box-shadow: var(--focus-ring);
      border-radius: 2px;
    }
    .bf-footer .stand {
      margin-top: 16px;
      font-size: 0.82rem;
      color: var(--text-light);
    }

    /* ═══════════════════════════════════════════
       12. Back-to-Top Button
       ═══════════════════════════════════════════ */
    .back-to-top {
      position: fixed;
      bottom: 24px;
      right: 20px;
      width: 44px;
      height: 44px;
      border-radius: 50%;
      background: var(--accent);
      color: var(--accent-text);
      border: none;
      cursor: pointer;
      font-size: 1.2rem;
      display: flex;
      align-items: center;
      justify-content: center;
      box-shadow: var(--shadow-md);
      opacity: 0;
      transform: translateY(10px);
      transition: opacity 0.3s, transform 0.3s, background var(--transition);
      z-index: 100;
    }
    .back-to-top.visible { opacity: 1; transform: translateY(0); }
    .back-to-top:hover { background: var(--accent-dark); color: #fff; }
    .back-to-top:focus-visible { outline: none; box-shadow: var(--focus-ring); }
    .back-to-top svg { width: 18px; height: 18px; fill: currentColor; }

    /* ═══════════════════════════════════════════
       13. Focus States (WCAG 2.4.7 / 2.4.11)
       ═══════════════════════════════════════════ */
    :focus-visible {
      outline: 2px solid var(--accent);
      outline-offset: 2px;
    }
    button:focus-visible,
    a:focus-visible {
      outline: none;
      box-shadow: var(--focus-ring);
      border-radius: 4px;
    }

    /* ═══════════════════════════════════════════
       14. Print Styles
       ═══════════════════════════════════════════ */
    @media print {
      .toc, .back-to-top, .progress-bar, .toc-toggle,
      .anchor-link, .group-divider { display: none !important; }

      .bf-layout { display: block !important; }
      .bf-main { max-width: 100% !important; padding: 0 !important; }
      body { font-size: 11pt; line-height: 1.5; color: #000; background: #fff; }
      .bf-card {
        box-shadow: none !important;
        border: 1px solid #ccc;
        break-inside: avoid;
        page-break-inside: avoid;
        margin-bottom: 12pt;
      }
      .bf-card:hover, .bf-card:target { box-shadow: none !important; }
      .bf-card-header { background: #f5f5f5 !important; }
      .badge { background: #eee !important; color: #333 !important; border-color: #ccc !important; }
      a { color: inherit !important; }
      a[href^="http"]::after {
        content: " (" attr(href) ")";
        font-size: 0.75em;
        color: #666;
      }
      .bf-hero { border-bottom-color: #333; }
      .bf-footer { border-top-color: #333; }
    }

    /* ═══════════════════════════════════════════
       15. Reduced Motion (WCAG 2.3.3)
       ═══════════════════════════════════════════ */
    @media (prefers-reduced-motion: reduce) {
      *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
      }
      html { scroll-behavior: auto; }
      .progress-bar { transition: none; }
    }

    /* ═══════════════════════════════════════════
       16. Responsive – Tablet (≤ 1080px)
       ═══════════════════════════════════════════ */
    @media (max-width: 1080px) {
      .bf-layout { display: block; }

      .toc {
        position: fixed;
        top: 0;
        left: 0;
        width: 300px;
        max-width: 85vw;
        height: 100dvh;
        z-index: 500;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        border-right: 1px solid var(--border);
        box-shadow: var(--shadow-lg);
        padding-top: 48px;
      }
      .toc.open { transform: translateX(0); }
      .toc-close { display: flex; }
      .toc-toggle { display: flex; }

      .toc-backdrop {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.3);
        z-index: 499;
      }
      .toc-backdrop.visible { display: block; }

      .bf-main { max-width: 720px; margin: 0 auto; }
    }

    /* ═══════════════════════════════════════════
       17. Responsive – Mobile (≤ 640px)
       ═══════════════════════════════════════════ */
    @media (max-width: 640px) {
      .bf-main { padding: 24px 16px 48px; }
      .bf-hero { margin-bottom: 28px; padding-bottom: 24px; }
      .bf-hero h1 { font-size: 1.35rem; }

      .bf-card-header { padding: 14px 16px 12px; gap: 10px; }
      .bf-card-header h2 { font-size: 0.98rem; }
      .badge { height: 28px; min-width: 34px; font-size: 0.72rem; }

      .bf-card-body { padding: 14px 16px 18px; }

      .clause { flex-direction: column; gap: 2px; }
      .clause-num { min-width: unset; }

      .group-divider { margin: 28px 0 14px; }

      .back-to-top { width: 40px; height: 40px; bottom: 18px; right: 14px; }
      .toc-toggle { bottom: 66px; right: 14px; width: 40px; height: 40px; }
    }

    /* ═══════════════════════════════════════════
       18. Responsive – Small Mobile (≤ 380px)
       ═══════════════════════════════════════════ */
    @media (max-width: 380px) {
      .bf-main { padding: 16px 12px 40px; }
      .bf-card-header { padding: 12px 12px 10px; }
      .bf-card-body { padding: 12px 12px 16px; }
      body { font-size: 14px; }
    }