/* trcp-styles.css - Improved Version */

/* --- Global Styles --- */
html {
    scroll-behavior: smooth;
    /* scroll-padding-top is set dynamically by JS */
  }
  
  body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.6;
    margin: 0 auto;
    padding: 20px 15px;
    max-width: 900px;
    background-color: #f8f9fa;
    color: #343a40;
  }
  
  h1 {
    text-align: center;
    margin-bottom: 20px;
    color: #212529;
    font-weight: 600;
    font-size: 1.8rem;
  }
  
  h2 {
    font-size: 1.2em;
    color: #0055aa;
    margin-top: 24px;
    margin-bottom: 16px;
  }
  
  /* Rule heading links */
  a.rule-heading-link {
    text-decoration: none;
    color: inherit;
  }
  
  /* --- Search Container Styles --- */
  .search-container {
    position: sticky;
    top: 10px;
    z-index: 100;
    margin: 0 auto 20px auto;
    max-width: 600px;
    padding: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    border-radius: 8px;
    background-color: white;
  }
  
  .search-container input[type="text"] {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 16px;
    box-sizing: border-box;
  }
  
  .search-results {
    margin-top: 10px;
    max-height: 300px;
    overflow-y: auto;
  }
  
  /* --- Search Result Styles --- */
  .search-result {
    padding: 8px 12px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    transition: background-color 0.2s ease;
  }
  
  .search-result:hover {
    background-color: #f0f0f0;
  }
  
  .search-result strong {
    display: block;
    margin-bottom: 2px;
  }
  
  .search-result em {
    font-size: 0.8em;
    color: #777;
  }
  
  .search-result div {
    font-size: 0.85em;
    margin-top: 5px;
    line-height: 1.4;
    color: #555;
  }
  
  .search-highlight {
    animation: highlight-fade 1.5s ease-in-out;
    box-shadow: 0 0 0 1px #FFDA63;
    border-radius: 2px;
    background-color: #FFFF88;
    padding: 2px;
  }
  
  @keyframes highlight-fade {
    0% { background-color: #FFFF00; }
    100% { background-color: #FFFF88; }
  }
  
  /* --- Expand/Collapse Button --- */
  .controls {
    text-align: left;
    margin-bottom: 25px;
  }
  
  #toggleButton {
    background-color: #007bff;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    font-size: 1rem;
    cursor: pointer;
    transition: background-color 0.2s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  }
  
  #toggleButton:hover {
    background-color: #0056b3;
  }
  
  /* --- Details & Summary Styling --- */
  details {
    background-color: #ffffff;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    margin-bottom: 15px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    overflow: hidden;
    padding: 0;
  }
  
  details[open] {
    border-left: 3px solid #007bff;
  }
  
  summary {
    font-size: 1.05em;
    font-weight: 600;
    padding: 15px 20px 15px 50px;
    cursor: pointer;
    outline: none;
    list-style: none;
    position: relative;
    transition: background-color 0.2s ease;
  }
  
  summary:hover {
    background-color: #f1f3f5;
  }
  
  /* Custom Marker */
  summary::before {
    content: '+';
    display: inline-block;
    font-weight: bold;
    font-size: 1.2em;
    width: 20px;
    margin-right: 10px;
    text-align: center;
    color: #007bff;
    transition: transform 0.2s ease-in-out;
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%) rotate(0deg);
  }
  
  details[open] > summary::before {
    content: '−';
    transform: translateY(-50%) rotate(0deg);
  }
  
  /* --- TOC Entry Styling --- */
  .toc-entry {
    margin: 0;
    padding: 8px 20px 8px 50px;
    border-top: 1px solid #f1f3f5;
    background-color: #ffffff;
    word-wrap: break-word;
    transition: all 0.3s ease;
    cursor: pointer;
  }
  
  .toc-entry:first-of-type {
    border-top: 1px solid #e9ecef;
  }
  
  .toc-entry:last-of-type {
    padding-bottom: 15px;
  }
  
  .toc-entry:hover {
    background-color: #f0f0f0;
  }
  
  .active-toc-entry {
    box-shadow: 0 0 5px rgba(0, 102, 204, 0.3);
    font-weight: bold;
    background-color: #e6f0ff !important;
  }
  
  /* --- Rule Link Styling --- */
  a.rule-link {
    color: #0056b3;
    text-decoration: none;
    transition: color 0.2s ease;
    display: block;
    padding: 5px 0;
  }
  
  a.rule-link:hover,
  a.rule-link:focus {
    color: #003d80;
    text-decoration: underline;
  }
  
  /* --- Rule Container --- */
  .rule-container {
    padding: 15px;
    margin-bottom: 15px;
    border-radius: 6px;
    border: 1px solid #e9ecef;
    background-color: #ffffff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    transition: background-color 0.2s ease;
  }
  
  .active-rule {
    background-color: #f0f7ff;
  }
  
  /* --- Heading Container --- */
  .heading-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #e9ecef;
  }
  
  /* --- Back to TOC Button --- */
  .back-to-toc {
    font-size: 0.8em;
    padding: 5px 10px;
    background-color: transparent;
    border: 1px solid #007bff;
    color: #007bff;
    border-radius: 4px;
    cursor: pointer;
    margin-left: 15px;
    transition: all 0.2s ease;
  }
  
  .back-to-toc:hover {
    background-color: #e6f0ff;
    text-decoration: underline;
  }
  
  /* --- Back to Top Button --- */
  body .back-to-top-button {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 10px 15px;
    background-color: #0066cc;
    color: white;
    border: none;
    border-radius: 5px;
    width: 50px;
    height: 50px;
    font-size: 20px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease, background-color 0.2s, transform 0.2s, box-shadow 0.2s;
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
  }
  
  body .back-to-top-button:hover {
    background-color: #0056b3;
    transform: translateY(-3px); /* Optional: Add slight lift effect */
    box-shadow: 0 4px 8px rgba(0,0,0,0.3); /* Optional: Enhance shadow on hover */
  }
  
  /* --- Paragraph Styling --- */
  .rule-container p, details > div:not(.heading-container) > p {
    margin: 10px 0;
    padding-left: 20px;
  }
  
  .notes {
    font-style: italic;
    color: #666;
    padding-left: 20px;
  }
  
  /* --- Indentation Classes --- */
  .indent-0 { padding-left: 0in; }
  .indent-1 { padding-left: 0.25in; }
  .indent-2 { padding-left: 0.5in; }
  .indent-3 { padding-left: 0.75in; }
  
  /* --- Mobile Responsiveness --- */
  @media (max-width: 768px) {
    body {
      padding: 15px 10px;
    }
  
    h1 {
      font-size: 1.5rem;
      margin-bottom: 15px;
    }
  
    h2 {
      font-size: 1.1em;
    }
  
    summary {
      font-size: 1rem;
      padding: 12px 12px 12px 40px;
    }
  
    summary::before {
      left: 12px;
      font-size: 1.1em;
    }
  
    .toc-entry {
      padding: 6px 12px 6px 40px;
    }
  
    a.rule-link {
      padding: 8px 0;
      font-size: 0.95rem;
    }
  
    .rule-container {
      padding: 10px !important;
    }
  
    .back-to-toc {
      font-size: 0.7em !important;
      padding: 3px 6px !important;
      margin-left: 8px !important;
    }
  }
  
  /* Touch-friendly targets for mobile */
  @media (max-width: 480px) {
    summary, a.rule-link {
      min-height: 44px;
      display: flex;
      align-items: center;
    }
  
    #toggleButton {
      padding: 12px 24px;
      width: 80%;
      max-width: 300px;
    }
  
    .back-to-toc {
      display: none;
    }
  
    .heading-container {
      justify-content: flex-start;
    }

    /* Added from script */
    html {
        scroll-behavior: smooth;
        /* scroll-padding-top set by JS */
    }
    .search-result { transition: background-color 0.2s ease; }
    .search-result:hover { background-color: #f0f0f0; }
    .search-highlight { animation: highlight-fade 1.5s ease-in-out; box-shadow: 0 0 0 1px #FFDA63; border-radius: 2px; background-color: #FFFF88; padding: 2px;} /* Added background-color directly */
    @keyframes highlight-fade { 0% { background-color: #FFFF00; } 100% { background-color: #FFFF88; } }
    .toc-entry { transition: all 0.3s ease; }
    .active-toc-entry { box-shadow: 0 0 5px rgba(0, 102, 204, 0.3); font-weight: bold; background-color: #e6f0ff !important; }
    @media (max-width: 768px) {
        .rule-container { padding: 10px !important; }
        .back-to-toc { font-size: 0.7em !important; padding: 3px 6px !important; margin-left: 8px !important; }
        h2 { font-size: 1.1em; }
    }
    @media (max-width: 480px) {
        .back-to-toc { display: none; }
        .heading-container { justify-content: flex-start; }
    }
}