body {
    margin: 0;
    padding: 20px;
    background-image: url('./public/Curvature_of_the_Earth.png');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    background-repeat: no-repeat;
    font-family: 'IBM Plex Sans', system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
}

#sketch-container {
    width: 75vw;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    padding-top: 56px; /* space for top buttons */
    background-color: rgba(255, 255, 255, 0.9);
    border-radius: 14px;
    padding: 56px 28px 28px 28px;
    backdrop-filter: blur(6px);
    box-shadow: 0 10px 36px rgba(0, 0, 0, 0.28);
}

#sketch-holder {
    width: 100%;
    height: 60vh;
    background-color: rgba(255, 255, 255, 0.88);
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.08);
    position: relative;
    overflow: hidden;
    border-radius: 10px;
    margin-top: 12px; /* subtle padding under the controls */
}

canvas {
    display: block;
}

/* Hide p5.js default loading text */
#sketch-holder p {
    display: none !important;
}
/* p5 adds a global loader element; hide it explicitly */
#p5_loading,
.p5_loading {
    display: none !important;
}

/* Popups */
.popup {
    display: none;
    position: absolute;
    background-color: #fff;
    border: 1px solid #2e3b6b;
    font-size: 12px;
    padding: 10px;
    z-index: 100;
    width: 260px;
    text-align: center;
    box-shadow: 0 8px 20px rgba(0,0,0,0.15);
}

.popup button {
    margin-top: 10px;
}

/* Status indicator - right aligned, same visual chrome as controls */
#statusIndicator {
    position: absolute;
    top: 10px;
    right: 28px; /* align with sketch-holder right edge (container inner padding) */
    left: auto;
    font-size: 12px;
    padding: 0 10px; /* height will be synced to .top-buttons */
    background: rgba(255,255,255,0.85);
    color: #222;
    border: 1px solid rgba(46, 59, 107, 0.25);
    border-radius: 8px;
    white-space: nowrap; /* no wrapping */
    z-index: 20;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    display: none; /* hidden until we have text */
    align-items: center; /* vertically center when shown as flex */
    height: var(--control-height);
}
#statusIndicator::after { display: none; }

/* Hide status on small mobile sizes */
@media (max-width: 600px) { #statusIndicator { display: none !important; } }

/* Responsive spacing for compact contexts (mobile/iframes) */
@media (max-width: 900px) {
  #statusIndicator {
    font-size: 11px;
    right: 28px;
    top: 8px;
  }
}
@media (max-width: 600px) {
  #statusIndicator {
    font-size: 10px;
    right: 28px;
    top: 6px;
  }
}

/* Remove legacy ellipsis animation rules */
/* (intentionally left blank; previous @keyframes/::after were removed) */

#timeLabels {
    display: flex;
    justify-content: space-between;
    margin-top: -39px;
    font-size: 11px;
}

#timeSlider {
    width: 100%;
    margin-top: 24px;
    position: relative;
}

#timeSlider input[type="range"] {
    width: 100%;
    position: relative;
    z-index: 2; /* Ensure the slider is above the time markers */
}

#timeMarkers {
    position: absolute;
    top: 2px;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1; /* Time markers below the slider */
}

.time-marker { position: absolute; width: 1px; height: 10px; background-color: #000; top: 0; pointer-events: none; }
.marker-line { width: 1px; height: 15px; background-color: #000; pointer-events: none; }
.marker-time {
    position: absolute;
    top: 24px;
    left: 3px;
    width: 40px;
    font-size: 10px;
    text-align: center;
    transform: rotate(60deg);
    transform-origin: top left;
    white-space: nowrap;
    pointer-events: none;
}

.date-display { position: absolute; bottom: -20px; left: 0; width: 100%; text-align: center; font-size: 12px; font-weight: bold; }

/* Top buttons */
.top-buttons {
    position: absolute;
    top: 10px;
    left: 28px; /* align with container padding */
    display: grid;
    grid-template-columns: auto auto minmax(160px, 1fr) auto; /* play | loop | slider | info */
    align-items: center;
    gap: 12px;
    background: rgba(255,255,255,0.85);
    border: 1px solid rgba(46, 59, 107, 0.25);
    padding: 6px 10px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    max-width: calc(100% - 56px); /* respect container padding */
    height: var(--control-height);
}

/* Slider should flex */
.top-buttons input[type="range"] {
    width: 100%;
    min-width: 120px;
}

/* Stack the slider on its own row on narrow viewports */
@media (max-width: 560px) {
  .top-buttons {
    grid-template-columns: auto auto auto; /* buttons on first row */
    gap: 8px;
    padding: 6px 8px;
  }
  .top-buttons input[type="range"] {
    grid-column: 1 / -1; /* full width row */
    width: 100%;
    min-width: 0;
  }
}

.bottom-buttons {
    display: flex;
    justify-content: space-between;
    width: 100%;
    margin-top: 90px;
    padding-bottom: 16px;
}

/* Buttons */
button {
    padding: 6px 12px;
    font-family: 'IBM Plex Sans', system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
    font-size: 12px;
    color: #222;
    background: linear-gradient(#ffffff, #f2f2f2);
    border: 1px solid #2e3b6b;
    border-radius: 6px;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.9), 0 1px 2px rgba(0,0,0,0.06);
    cursor: pointer;
}
button:hover { background: linear-gradient(#ffffff, #e9edf6); }
button:active { background: #e1e7f5; }

/* Range slider */
input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px; height: 14px; border-radius: 50%;
    background: #2e3b6b; border: 1px solid #1e2647;
}
input[type="range"] { accent-color: #2e3b6b; }

/* Legend balloon icon */
.balloon-icon { position: absolute; transform: translate(-50%, -100%); font-size: 17px; pointer-events: none; z-index: 3; opacity: 0; transition: opacity 0.5s ease-in-out; }
.balloon-icon.visible { opacity: 1; animation: floatUpDown 2s ease-in-out infinite; }
@keyframes floatUpDown { 0% { transform: translate(-50%, calc(-100% + 9px)); } 50% { transform: translate(-50%, calc(-100% - 0px)); } 100% { transform: translate(-50%, calc(-100% + 9px)); } }

/* Shared control height for alignment */
:root { --control-height: 32px; }
