/* styles.css */

#dataFreshness {
    position: fixed;
    top: 10px;
    left: 10px;
    padding: 5px 10px;
    background-color: rgba(0, 0, 0, 0.7);
    color: #fff;
    border-radius: 5px;
    font-size: 12px;
    z-index: 1000;
}

/* =====================================================
   GLOBAL
   ===================================================== */
   body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #121212;
    margin: 0;
    padding: 0;
    color: #e0e0e0;
  }
  
  /* Screen-reader-only utility */
  .sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border: 0;
  }
  
  /* =====================================================
     LAYOUT / CONTAINER
     ===================================================== */
  .container {
    width: 90%;
    max-width: 1400px;
    margin: 40px auto;
    padding: 20px;
    background: #1e1e1e;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
  }
  
  /* Header */
  header h1 {
    text-align: center;
    margin-bottom: 20px;
    color: #f39c12;
  }
  
  /* =====================================================
     THREE-COLUMN layout for ranking / chart+status / params
     ===================================================== */
  .chart-params-container {
    display: grid;
    /* LEFT column now auto-sized to its content */
    grid-template-columns: auto minmax(800px, 2fr) minmax(200px, 3fr);
    gap: 20px;
    align-items: start;
  }
  
  /* allow the left & right panels to shrink */
  .chart-params-container > .ranking-section,
  .chart-params-container > .params-section {
    min-width: 0;
  }
  
  /* keep the middle (chart) column at least as wide as the canvas */
  .chart-params-container > .chart-status-section {
    min-width: 800px;
  }
  

  
  /* =====================================================
     RANKING SECTION
     ===================================================== */
  .ranking-section {
    background: rgba(0,0,0,0.3);
    padding: 1em;
    border-radius: 4px;
    color: white;
  }
  .ranking-section h2 {
    margin-top: 0;
  }
  .ranking-section ol {
    list-style: none;
    padding-left: 0;
  }
  
  /* each item is one line, no wrapping, with ellipsis */
  .ranking-section li {
    position: relative;
    padding-right: 4.5em;    /* leave room for the percent */
    margin-bottom: 0.5em;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }
  
  /* percentage always at right, vertically centered */
  .ranking-section .rank-pct {
    position: absolute;
    right: 0.5em;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.9em;
    color: #ccc;
    white-space: nowrap;
  }
  
  /* Total summary box */
  .ranking-total {
    margin-top: 1em;
    padding: 0.75em;
    background: rgba(243, 156, 18, 0.2);
    border: 1px solid #f39c12;
    border-radius: 4px;
    font-weight: bold;
    text-align: center;
    color: #f39c12;
  }
  
  /* =====================================================
     Chart + status section container
     ===================================================== */
  .chart-status-section {
    display: flex;
    flex-direction: column;
    gap: 1em;
  }
  
  /* =====================================================
     Chart box
     ===================================================== */
  .chart-box {
    background: #333;
    padding: 20px;
    border-radius: 8px;
    text-align: center;
    position: relative; /* for overlay positioning */
  }
  #playerCountDisplay {
    margin-top: 10px;
    font-size: 18px;
  }
  /* make canvases scale down to the container width */
  .chart-box canvas {
    max-width: 100%;
    height: auto !important;
    display: block;
    margin: 0 auto;
  }

  /* =====================================================
     CHART LOADING OVERLAY
     ===================================================== */
  .chart-overlay {
    position: absolute;
    inset: 0;
    display: none; /* shown via JS */
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: rgba(0,0,0,0.35);
    z-index: 10;
  }
  .chart-overlay .spinner {
    width: 28px; height: 28px;
    border: 3px solid rgba(255,255,255,0.3);
    border-top-color: #f39c12;
    border-radius: 50%;
    animation: spin 1s linear infinite;
  }
  .chart-overlay .overlay-text {
    color: #fff;
    font-size: 14px;
    letter-spacing: 0.3px;
  }
  @keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
  
  /* =====================================================
     Buttons
     ===================================================== */
  .btn-group {
    display: inline-flex;
    gap: 10px;
    margin-bottom: 15px;
  }
  .btn {
    padding: 10px 20px;
    background-color: #f39c12;
    border: none;
    border-radius: 4px;
    color: #fff;
    cursor: pointer;
    font-size: 16px;
    transition: background-color .3s ease;
  }
  .btn:hover {
    background-color: #d35400;
  }
  
  /* =====================================================
     Status panel
     ===================================================== */
  .status-section {
    background: #333;
    padding: 20px;
    border-radius: 8px;
    text-align: center;
  }
  .status-section h2 {
    color: #f39c12;
    margin-bottom: 15px;
  }
  .status-section p {
    margin: 5px 0;
    font-size: 16px;
  }
  
  /* =====================================================
     Parameters panel
     ===================================================== */
  .params-section {
    background: #2c2c2c;
    padding: 20px;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
  }
  .params-section h2 {
    text-align: center;
    margin-bottom: 20px;
    color: #f39c12;
  }
  
  .form-group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 15px;
  }
  .form-group label {
    flex: 1 1 200px;
    margin-right: 10px;
    text-align: right;
  }
  .form-group > * {
    min-width: 0;
  }
  .form-group input,
  .form-group select {
    flex: 2 1 300px;
    padding: 8px;
    border: 1px solid #444;
    border-radius: 4px;
    background: #1e1e1e;
    color: #e0e0e0;
  }
  /* Do not apply text-input styling to range sliders */
  .form-group input[type="range"] {
    padding: 0;
    border: 0;
    background: transparent;
  }
  #fastWriteGroup,
  #runtimeMinutesGroup {
    display: none;
  }
  @media (max-width: 600px) {
    .form-group {
      flex-direction: column;
      align-items: flex-start;
    }
    .form-group label {
      text-align: left;
      margin-bottom: 5px;
    }
  }
  
  /* =====================================================
     FOOTER
     ===================================================== */
  footer {
    background: #1e1e1e;
    padding: 20px 0;
    color: #e0e0e0;
    margin-top: 40px;
    text-align: center;
  }
  /* =====================================================
     GITHUB CORNER (top-right “notch”)
     ===================================================== */
  .github-corner svg {
    position: fixed;
    top: 0;
    right: 0;
    z-index: 1000;
    width: 100px;
    height: 100px;
    fill: #f39c12;
    color: #ffffff;
    transition: transform .3s ease;
  }
  .github-corner:hover svg {
    transform: scale(1.1);
  }
  .github-corner .octo-arm {
    transform-origin: 130px 106px;
  }
  .github-corner:hover .octo-arm {
    animation: octo-wave 560ms ease-in-out;
  }
  @keyframes octo-wave {
    0%,100% { transform: rotate(0deg); }
    20%,60% { transform: rotate(-25deg); }
    40%,80% { transform: rotate(10deg); }
  }
  @media (max-width: 500px) {
    .github-corner:hover .octo-arm { animation: none; }
    .github-corner .octo-arm       { animation: octo-wave 560ms ease-in-out; }
  }
  
  /* Connection status colours */
  #connectionStatus.connected    { color: #14c521; }
  #connectionStatus.disconnected { color: #e02424; }


  /* make the chart container scrollable if it still overflows */