/* share.css */

/* Share Modal Overlay */
#share-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.85);
    z-index: 99999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start; /* Start from top so tall content can scroll down */
    overflow-y: auto; /* Enable vertical scrolling */
    padding: 20px 0; /* Breathing room at top matching padding at bottom */
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

#share-modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

/* Modal Actions Header */
#share-modal-actions {
    width: 100%;
    max-width: 400px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    color: white;
    z-index: 10;
}

#share-modal-actions button {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: bold;
    cursor: pointer;
    backdrop-filter: blur(5px);
    transition: background 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}

#share-modal-actions button:hover {
    background: rgba(255, 255, 255, 0.3);
}

.share-close-btn {
    background: rgba(255, 0, 0, 0.6) !important;
}

.share-close-btn:hover {
    background: rgba(255, 0, 0, 0.8) !important;
}

/* Share Editor Area */
.share-editor-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 10px;
    margin-bottom: 5px;
}

/* 9:16 Aspect Ratio Card */
#share-card {
    position: relative;
    width: 100%;
    max-width: 360px; /* Force small card width on desktops to look like phone */
    aspect-ratio: 9 / 16;
    background-color: #111;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    margin: 0 auto;
    flex-shrink: 0;
}

/* Background Layers */
#share-card-map-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    z-index: 1;
}

#share-card-photo-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    z-index: 2;
}

/* Gradient Overlays for Readability */
.share-gradient-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 70%;
    background: linear-gradient(to top, rgba(0,0,0,0.95) 0%, rgba(0,0,0,0.7) 30%, transparent 100%);
    z-index: 3;
}

.share-top-gradient {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 20%;
    background: linear-gradient(to bottom, rgba(0,0,0,0.7) 0%, transparent 100%);
    z-index: 3;
}

/* Transparent GPX Route Overlay */
#share-gpx-canvas {
    position: absolute;
    top: 15%;
    left: 0;
    width: 100%;
    height: 60%;
    z-index: 4;
    pointer-events: none;
    opacity: 0.9;
}

/* Event Logo / Header */
.share-header {
    position: absolute;
    top: 20px;
    left: 20px;
    right: 20px;
    z-index: 5;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.share-watermark {
    display: flex;
    align-items: center;
    gap: 10px;
}

.share-watermark img {
    height: 32px;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.8));
}

.share-event-name {
    font-size: 14px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: white;
    text-shadow: 0 2px 5px rgba(0,0,0,0.8);
}

.share-status-badge {
    font-size: 10px;
    font-weight: bold;
    color: white;
    padding: 3px 8px;
    border-radius: 4px;
    text-transform: uppercase;
    box-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

/* Data Content Container */
.share-data-content {
    position: absolute;
    bottom: 20px;
    left: 20px;
    right: 20px;
    z-index: 5;
    color: white;
}

/* Profile Row (Flag, BIB, Name) */
.share-profile-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 5px;
}

.share-profile-row img {
    height: 14px;
    border-radius: 2px;
}

.share-bib {
    background: rgba(255,255,255,0.2);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 12px;
    font-weight: bold;
    border: 1px solid rgba(255,255,255,0.4);
}

.share-user-name {
    font-size: 24px;
    font-weight: 900;
    line-height: 1.1;
    text-shadow: 0 2px 8px rgba(0,0,0,0.8);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Route Info */
.share-route-info {
    font-size: 12px;
    color: #ffd700;
    font-weight: bold;
    margin-bottom: 12px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.8);
}

/* Rivals Row */
.share-rivals {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 15px;
    font-size: 11px;
    color: #eee;
}
.share-rivals div {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(4px);
    width: fit-content;
    padding: 2px 8px;
    border-radius: 4px;
}

/* Stats Grid */
.share-stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    background: transparent;
    border: none;
    padding: 0;
    border-radius: 0;
    margin-bottom: 5px;
}

.share-stat-item {
    display: flex;
    flex-direction: column;
}

.share-stat-label {
    font-size: 9px;
    text-transform: uppercase;
    font-weight: bold;
    color: #ccc;
    letter-spacing: 1px;
    margin-bottom: 2px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.share-stat-value {
    font-size: 16px;
    font-weight: 900;
}

/* Passing Last CP */
.share-passing {
    font-size: 11px;
    background: rgba(52, 152, 219, 0.2);
    border-left: 3px solid #3498db;
    padding: 6px 10px;
    border-radius: 0 4px 4px 0;
    margin-bottom: 15px;
}

.share-passing b {
    color: #63b4f6;
}

/* Checkpoints List in Share */
.share-cp-list {
    margin-top: 15px;
    display: flex;
    gap: 10px;
    overflow: hidden;
    flex-wrap: wrap;
}

.share-cp-item {
    background: rgba(255, 255, 255, 0.15);
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 11px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.share-cp-item span {
    font-weight: bold;
    color: #4CAF50;
    margin-left: 4px;
}

/* Bottom Controls (Upload Photo & Share) */
.share-controls {
    width: 100%;
    max-width: 400px;
    padding: 10px 20px 30px 20px;
    display: flex;
    flex-direction: row; /* SIDE-BY-SIDE */
    align-items: stretch;
    gap: 10px;
}

.share-secondary-btn {
    flex: 1;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px dashed rgba(255, 255, 255, 0.4);
    padding: 12px 6px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    text-align: center;
}

.share-secondary-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.share-primary-btn {
    flex: 1;
    background: linear-gradient(135deg, #fc466b, #3f5efb);
    color: white;
    border: none;
    padding: 12px 6px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    box-shadow: 0 5px 15px rgba(252, 70, 107, 0.4);
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    text-align: center;
}

.share-primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(252, 70, 107, 0.6);
}

/* Hide file input */
#share-file-input {
    display: none;
}
