/* ========================================
   SIMULATION CONTAINER
   ======================================== */
.sim-container {
    background: white;
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.sim-container h1 {
    text-align: center;
    font-size: 24px;
    color: #2c3e50;
}

/* ========================================
   SIMULATION AREA
   ======================================== */
.simulation-area {
    background: #F5F5F5;
    border-radius: 10px;
    border: 1px solid #ccc;
    margin: 20px 0;
    position: relative;
    height: 250px;
    width: 100%;
    min-width: 800px;
    overflow: hidden;
}

/* ========================================
   FLOOR & TICK MARKS
   ======================================== */
.sim-floor {
    position: absolute;
    bottom: 36px;
    left: 0;
    right: 0;
    height: 3px;
    background: #555;
    z-index: 5;
}

.sim-tick-marks {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 14px;
    /* Small ticks every 50px */
    background-image: repeating-linear-gradient(
        to right,
        #aaa 0px, #aaa 1px,
        transparent 1px, transparent 50px
    );
    background-size: 50px 8px;
    background-repeat: repeat-x;
    background-position: top left;
}

/* Taller ticks every 100px */
.sim-tick-marks::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 14px;
    background-image: repeating-linear-gradient(
        to right,
        #777 0px, #777 1.5px,
        transparent 1.5px, transparent 100px
    );
}

.collision-indicator {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 193, 7, 0.95);
    color: #333;
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: bold;
    font-size: 16px;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 30;
}

.collision-indicator.fading {
    transition: opacity 1s ease;
}

/* ========================================
   CARTS
   ======================================== */
.cart-container {
    position: absolute;
    bottom: 36px;
    display: flex;
    align-items: center;
    height: 90px;
}

.cart1-container { flex-direction: row; }
.cart2-container { flex-direction: row-reverse; }

.cart {
    height: 65px;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    font-weight: bold;
    font-size: 24px;
    color: white;
    border: 3px solid #2c3e50;
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.2);
    position: relative;
    z-index: 10;
}

.cart-name {
    font-size: 10px;
    font-weight: bold;
    color: rgba(255, 255, 255, 0.9);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
    line-height: 1;
}

.cart1 { background: linear-gradient(145deg, #3498db, #2980b9); }
.cart2 { background: linear-gradient(145deg, #e74c3c, #c0392b); }

/* Wheels */
.cart::before,
.cart::after {
    content: '';
    position: absolute;
    bottom: -14px;
    width: 22px;
    height: 22px;
    background: #444;
    border-radius: 50%;
    border: 2px solid #333;
}

.cart::before { left: 12px; }
.cart::after { right: 12px; }

/* ========================================
   SPRINGS
   ======================================== */
.cart-spring {
    width: 80px;
    height: 25px;
    margin: 0;
    flex-shrink: 0;
    display: block;
}

.spring2-instance { transform: scaleX(-1); }

/* ========================================
   MASS LABEL (inside cart body, below cart-name)
   ======================================== */
.mass-label {
    font-weight: bold;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.95);
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
    line-height: 1;
}

/* ========================================
   VELOCITY ARROWS (above cart)
   ======================================== */
/* Velocity arrow is inside the cart-container flex but positioned absolutely
   so it floats above the cart without affecting layout */
.velocity-arrow {
    position: absolute;
    top: -38px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 15;
    pointer-events: none;
}

.vel-text {
    font-size: 11px;
    font-weight: bold;
    color: #2c3e50;
    white-space: nowrap;
}

.vel-arrow-line {
    height: 3px;
    background: #2c3e50;
    position: relative;
    border-radius: 1px;
}

/* Right-pointing arrow */
.vel-arrow-right::after {
    content: '';
    position: absolute;
    right: -8px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
    border-left: 8px solid #2c3e50;
}

/* Left-pointing arrow */
.vel-arrow-left::before {
    content: '';
    position: absolute;
    left: -8px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
    border-right: 8px solid #2c3e50;
}

/* ========================================
   FORCE INDICATOR (column: N labels on top, arrows below)
   ======================================== */
.force-indicator {
    position: absolute;
    display: none;
    z-index: 20;
    transform: translateX(-50%);
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.force-value-row {
    display: flex;
    flex-direction: row;
    gap: 8px;
    align-items: center;
    white-space: nowrap;
}

.force-value {
    font-size: 12px;
    font-weight: bold;
    color: #c0392b;
    white-space: nowrap;
}

.force-arrows-row {
    display: flex;
    flex-direction: row;
    align-items: center;
}

.force-vector-half {
    position: relative;
    height: 3px;
    background-color: #c0392b;
}

.force-left-half::before {
    content: '';
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    left: -10px;
    width: 0;
    height: 0;
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
    border-right: 10px solid #c0392b;
}

.force-right-half::after {
    content: '';
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    right: -10px;
    width: 0;
    height: 0;
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
    border-left: 10px solid #c0392b;
}

/* ========================================
   CONTROLS
   ======================================== */
.controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin: 20px 0;
}

.cart-controls {
    background: #f9f9f9;
    border-radius: 12px;
    padding: 20px;
}

.cart1-controls { border-left: 4px solid #3498db; }
.cart2-controls { border-left: 4px solid #e74c3c; }

.control-row {
    display: flex;
    align-items: center;
    gap: 15px;
    margin: 15px 0;
}

.control-label {
    min-width: 80px;
    font-weight: bold;
}

select {
    flex: 1;
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 5px;
    background-color: #fff !important;
    color: #111 !important;
}

/* ========================================
   ACTION BUTTONS
   ======================================== */
.action-buttons {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    margin: 20px 0;
}

.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
    color: white;
}

.btn-start { background-color: #27ae60; }
.btn-start:hover:not(:disabled) { background-color: #1e8e4e; }
.btn-start:disabled { background-color: #555; color: #888; cursor: not-allowed; }

.btn-reset { background-color: #f39c12; }
.btn-reset:hover { background-color: #d35400; }

.btn-clear { background-color: #e74c3c; }
.btn-clear:hover { background-color: #c0392b; }

/* ========================================
   DATA TABLE
   ======================================== */

/* Column widths via colgroup — keeps table within container */
.col-trial      { width: 4%; }
.col-data       { width: 6%; }
.col-force      { width: 9%; }
.col-comp       { width: 8%; }
.col-screenshot { width: 15%; }

.findings-table {
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
    border-spacing: 0;
    border: 1px solid #d1d1d1;
}

/* Unified light-gray border on every cell */
.findings-table th,
.findings-table td {
    padding: 4px 3px;
    border: 1px solid #d1d1d1;
    text-align: center;
    vertical-align: middle;
    overflow: hidden;
}

/* ---- Group header row (top row) ---- */
.findings-table thead tr.header-groups th {
    font-family: 'Segoe UI', sans-serif;
    font-size: 10px;
    font-weight: 700;
    color: #222;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    padding: 6px 3px;
    border-bottom: none;
}

/* Trial and Screenshot rowspan cells */
.findings-table thead tr.header-groups th[rowspan] {
    background: #f0f0f0;
    color: #333;
    border-bottom: 2px solid #bbb;
    vertical-align: middle;
}

/* ---- Variable label row (bottom row) ---- */
.findings-table thead tr.header-labels th {
    font-family: 'Segoe UI', sans-serif;
    font-size: 10px;
    font-weight: 600;
    color: #333;
    padding: 3px 2px;
    border-top: 1px solid #bbb;
    border-bottom: 2px solid #bbb;
    line-height: 1.2;
}

/* Unit text inside header cells */
.th-unit {
    font-size: 9px;
    font-weight: 400;
    color: #777;
    line-height: 1;
}

/* ---- Group accent backgrounds (tint only, no colored borders) ---- */
.group-initial { background-color: #dbeafe; color: #1e3a8a; }
.group-final   { background-color: #ffedd5; color: #7c2d12; }
.group-forces  { background-color: #f3e8ff; color: #4a1772; }
.group-comp    { background-color: #fef9c3; color: #713f12; }
.group-energy  { background-color: #dcfce7; color: #14532d; }

/* Label row inherits the same tint as its group */
.findings-table thead tr.header-labels th:nth-child(1) { background: #dbeafe; }
.findings-table thead tr.header-labels th:nth-child(2) { background: #dbeafe; }
.findings-table thead tr.header-labels th:nth-child(3) { background: #dbeafe; }
.findings-table thead tr.header-labels th:nth-child(4) { background: #dbeafe; }
.findings-table thead tr.header-labels th:nth-child(5) { background: #ffedd5; }
.findings-table thead tr.header-labels th:nth-child(6) { background: #ffedd5; }
.findings-table thead tr.header-labels th:nth-child(7) { background: #f3e8ff; }
.findings-table thead tr.header-labels th:nth-child(8) { background: #f3e8ff; }
.findings-table thead tr.header-labels th:nth-child(9) { background: #dcfce7; }
.findings-table thead tr.header-labels th:nth-child(10){ background: #dcfce7; }

/* Single gray divider between groups (right edge of last column in each group) */
.findings-table thead tr.header-groups th.group-initial,
.findings-table thead tr.header-labels th:nth-child(4),
.findings-table td:nth-child(5)  { border-right: 2px solid #bbb; }

.findings-table thead tr.header-groups th.group-final,
.findings-table thead tr.header-labels th:nth-child(6),
.findings-table td:nth-child(7)  { border-right: 2px solid #bbb; }

.findings-table thead tr.header-groups th.group-forces,
.findings-table thead tr.header-labels th:nth-child(8),
.findings-table td:nth-child(9)  { border-right: 2px solid #bbb; }

.findings-table thead tr.header-groups th.group-comp,
.findings-table td:nth-child(10) { border-right: 2px solid #bbb; }

.findings-table thead tr.header-groups th.group-energy,
.findings-table thead tr.header-labels th:nth-child(10),
.findings-table td:nth-child(12) { border-right: 2px solid #bbb; }

/* ---- Body rows ---- */
.findings-table tbody tr:nth-child(even) { background: #fafafa; }
.findings-table tbody tr:hover { background: #f0f7ff; }

.findings-table td {
    font-family: 'Courier New', Courier, monospace;
    font-size: 11px;
    font-variant-numeric: tabular-nums;
    color: #222;
}

/* Trial # column */
.findings-table td:first-child {
    font-family: 'Segoe UI', sans-serif;
    font-weight: 700;
    font-size: 11px;
    color: #555;
    background: #f5f5f5;
}

.findings-table input {
    width: 65px;
    text-align: center;
    padding: 3px 2px;
    border: 1px solid #ccc;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 11px;
    font-variant-numeric: tabular-nums;
    background-color: #fff !important;
    color: #111 !important;
}

/* ========================================
   SCREENSHOTS
   ======================================== */
.screenshot-thumbnail {
    max-width: 120px;
    height: auto;
    border-radius: 4px;
    border: 1px solid #ccc;
    cursor: pointer;
    transition: transform 0.2s;
}

.screenshot-thumbnail:hover { transform: scale(1.1); }

.download-link {
    font-size: 12px;
    color: #3498db;
    cursor: pointer;
    text-decoration: underline;
    display: block;
    margin-top: 5px;
}

.screenshot-status {
    font-size: 12px;
    color: #666;
}

.screenshot-tooltip {
    position: fixed;
    transform: translateX(-50%) rotate(-2deg);
    background: #fff9a0;
    color: #333;
    padding: 10px 12px;
    border-radius: 3px;
    font-size: 12px;
    font-weight: bold;
    width: 100px;
    text-align: center;
    line-height: 1.4;
    z-index: 9999;
    box-shadow: 2px 3px 8px rgba(0, 0, 0, 0.25);
    pointer-events: none;
    animation: stickyNoteFade 3s ease forwards;
}

/* Tape strip at top */
.screenshot-tooltip::before {
    content: '';
    position: absolute;
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 36px;
    height: 14px;
    background: rgba(200, 200, 100, 0.5);
    border-radius: 2px;
}

@keyframes stickyNoteFade {
    0%   { opacity: 0; }
    12%  { opacity: 1; }
    78%  { opacity: 1; }
    100% { opacity: 0; }
}

/* Persistent sticky note — shown on Simulation Intro after 2 practice trials */
.intro-ready-sticky {
    position: fixed;
    top: 45%;
    left: 38%;
    transform: translate(-50%, -50%) rotate(-2deg);
    background: #fff9a0;
    color: #333;
    padding: 28px 36px;
    border-radius: 3px;
    font-size: 1.1em;
    font-weight: bold;
    width: 360px;
    text-align: center;
    line-height: 1.5;
    z-index: 9999;
    box-shadow: 4px 6px 16px rgba(0, 0, 0, 0.3);
    pointer-events: none;
    animation: stickyNoteAppear 0.3s ease forwards;
}

.intro-ready-sticky::before {
    content: '';
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 18px;
    background: rgba(200, 200, 100, 0.5);
    border-radius: 2px;
}

@keyframes stickyNoteAppear {
    from { opacity: 0; transform: translate(-50%, -44%) rotate(-2deg); }
    to   { opacity: 1; transform: translate(-50%, -50%) rotate(-2deg); }
}
