/* =============================================
   FONTS
   ============================================= */
@font-face {
    font-family: 'Boldini';
    src: url('fonts/Boldini/Boldini Regular.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
}

@font-face {
    font-family: 'Inter';
    src: url('fonts/Inter/Inter-VariableFont_opsz,wght.ttf') format('truetype');
    font-weight: 100 900;
    font-style: normal;
}

@font-face {
    font-family: 'Inter';
    src: url('fonts/Inter/Inter-Italic-VariableFont_opsz,wght.ttf') format('truetype');
    font-weight: 100 900;
    font-style: italic;
}


/* =============================================
   CSS VARIABLES
   ============================================= */
:root {
    --color-bg-base: #000000;
    --color-bg-surface: #1a1a1a;
    --color-text-primary: #ffffff;
    --color-text-secondary: #a0a0a0;
    --color-orange: #fc4c02;
    --color-hover: #e04402;
    --color-correct: #22c55e;
    --color-wrong: #ef4444;
}


/* =============================================
   RESET & BASE
   ============================================= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    overflow-x: hidden;
    width: 100%;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--color-bg-base);
    color: var(--color-text-primary);
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
}

.hidden {
    display: none !important;
}

#errorMessage {
    color: var(--color-wrong);
    text-align: center;
    padding: 1rem;
}


/* =============================================
   AUTH SCREEN
   ============================================= */
.auth-wrapper {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-bg-base);
    z-index: 100;
    overflow: hidden;
}

.auth-bg-polygon {
    position: absolute;
    right: 10%;
    left: 45%;
    top: 50%;
    transform: translateY(-45%);
    height: 85%;
    opacity: 0.4;
    pointer-events: none;
}

.auth-content {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    max-width: 480px;
    width: 100%;
    padding: 3rem;
}

.auth-logo {
    font-family: 'Boldini', serif;
    font-size: 5rem;
    font-weight: normal;
    color: var(--color-orange);
    margin-bottom: 1rem;
    display: block;
    letter-spacing: 0.05em;
    line-height: 1;
}

.auth-tagline {
    color: var(--color-text-secondary);
    font-size: 1.05rem;
    line-height: 1.7;
    margin-bottom: 2.5rem;
}


/* =============================================
   BUTTONS
   ============================================= */
.btn {
    background: var(--color-orange);
    color: white;
    border: none;
    padding: 1rem 2rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
}

.btn:hover {
    background: var(--color-hover);
    /* transform: translateY(-2px); */
    box-shadow: 0 4px 12px rgba(252, 76, 2, 0.3);
}

.btn-secondary {
    background: transparent;
    color: var(--color-orange);
    border: 2px solid var(--color-orange);
}

.btn-secondary:hover {
    background: var(--color-orange);
    color: white;
}

.btn-new-activities {
    background: transparent;
    color: var(--color-orange);
    border: 2px solid var(--color-orange);
    padding: 1rem 2rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    width: auto;
    flex: 1;
}

.btn-new-activities:hover {
    background: var(--color-orange);
    color: white;
    transform: translateY(-0px);
    box-shadow: 0 4px 12px rgba(34, 197, 94, 0.3);
}

.btn-logout {
    background: transparent;
    color: rgba(239, 68, 68, 0.5);
    border: 1px solid rgba(239, 68, 68, 0.25);
    padding: 0.5rem 2.5rem;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: block;
    margin: 1rem auto 0;
    opacity: 0;
}

.btn-logout:hover {
    color: #ef4444;
    border-color: rgba(239, 68, 68, 0.6);
    background: rgba(239, 68, 68, 0.08);
}

.btn-row {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 2rem;
    width: 100%;
}

.btn-row .btn {
    width: auto;
    flex: 1;
}

.full-width {
    flex: 1 !important;
    width: 100% !important;
    min-width: 0 !important;
}


/* =============================================
   STICKY HEADER
   ============================================= */
#stickyHeader {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 9999 !important;
    background: rgba(10, 10, 10, 0.8) !important;
    backdrop-filter: blur(12px);
    text-align: center;
    padding: 0px 0 10px;
    font-family: 'Boldini', Georgia, serif;
    font-size: 1.6rem;
    color: var(--color-orange);
    letter-spacing: 0.05em;
    transform: translateY(-100%);
    transition: transform 0.3s ease-out;
}

#stickyHeader.visible {
    transform: translateY(0);
}


/* =============================================
   HERO / MAP
   ============================================= */
#heroSection {
    position: relative;
    width: 100%;
    height: 50vh;
    min-height: 320px;
}

#heroSection::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 45%;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.85) 0%, transparent 100%);
    z-index: 2;
    pointer-events: none;
}

#heroSection::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 50%;
    background: linear-gradient(to top, #000 0%, transparent 100%);
    z-index: 2;
    pointer-events: none;
}

.hero-title {
    position: absolute;
    top: 2rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 3;
    text-align: center;
    pointer-events: none;
    white-space: nowrap;
}

.hero-title h1 {
    font-family: 'Boldini', serif;
    font-size: 5rem;
    color: var(--color-orange);
    font-weight: normal;
    letter-spacing: 0.06em;
    line-height: 1;
    text-shadow: 0 2px 30px rgba(0, 0, 0, 0.8);
}

#alsterMap {
    width: 100%;
    height: 100%;
    background: var(--color-bg-base) !important;
}

#alsterMap .gm-style {
    background: var(--color-bg-base) !important;
}

#alsterMap .gm-style-cc,
#alsterMap .gmnoprint:not(.gm-style-cc),
#alsterMap button.gm-fullscreen-control,
#alsterMap [title="Open this area in Google Maps"],
#alsterMap a[href*="maps.google"],
#alsterMap .gm-iv-address,
#alsterMap .gm-iv-marker {
    display: none !important;
}

.gm-style-moc,
.gm-style-mot {
    display: none !important;
}


/* =============================================
   LOADING SCREEN
   ============================================= */
#loadingMessage {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--color-bg-base);
    z-index: 50;
    padding: 2rem;
}

#loadingMessage.hidden {
    display: none;
}

.spinner {
    display: block;
    width: 36px;
    height: 36px;
    border: 3px solid #333;
    border-top-color: var(--color-orange);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    margin: 1rem auto 0;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.progress-bar-wrap {
    background: #1a1a1a;
    border-radius: 8px;
    height: 6px;
    margin: 1rem 0 0.5rem;
    overflow: hidden;
    width: 300px;
    max-width: 90vw;
}

.progress-bar {
    height: 100%;
    background: var(--color-orange);
    border-radius: 8px;
    width: 0%;
    transition: width 0.3s ease;
}

.progress-label {
    color: var(--color-text-secondary);
    font-size: 0.85rem;
    text-align: center;
}

#progressWrap,
#progressLabel {
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 0.3s ease-out, transform 0.3s ease-out;
    display: block !important;
}

#progressWrap:not(.hidden),
#progressLabel:not(.hidden) {
    opacity: 1;
    transform: translateY(0);
}


/* =============================================
   STATS
   ============================================= */
.total-laps-block {
    text-align: center;
    margin: 0 0 2.5rem;
}

.total-laps-display {
    font-size: 6rem;
    font-weight: 800;
    color: var(--color-orange);
    line-height: 1;
}

.total-laps-label {
    color: var(--color-text-secondary);
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    margin-top: 0.5rem;
}

.total-km-display {
    color: var(--color-text-secondary);
    font-size: 0.82rem;
    margin-top: 0.3rem;
    letter-spacing: 0.05em;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--color-bg-surface);
    padding: 1.5rem;
    border-radius: 12px;
    text-align: center;
}

.stat-card.fastest {
    cursor: pointer;
    transition: outline 0.15s, box-shadow 0.15s;
}

.stat-card.fastest:hover {
    outline: 2px solid var(--color-orange);
    box-shadow: 0 0 16px rgba(252, 76, 2, 0.2);
}

.stat-icon {
    font-size: 1.6rem;
    margin-bottom: 0.4rem;
    line-height: 1.2;
}

.stat-card:nth-child(1) .stat-icon {
    color: var(--color-orange);
}

.stat-card:nth-child(2) .stat-icon {
    color: var(--color-orange);
}

.stat-card:nth-child(3) .stat-icon {
    color: #22c55e;
}

.stat-card:nth-child(4) .stat-icon {
    color: #ef4444;
}

.stat-value {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--color-orange);
    margin-bottom: 0.5rem;
}

.stat-label {
    color: var(--color-text-secondary);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-card.correct .stat-value {
    color: var(--color-correct);
}

.stat-card.wrong .stat-value {
    color: var(--color-wrong);
    opacity: 0.8;
}


/* =============================================
   LAPS LIST
   ============================================= */
.laps-list {
    background: none;
    padding: 0;
    border-radius: 12px;
    margin-top: 2rem;
}

.year-section {
    background: var(--color-bg-surface);
    padding: 1rem;
    border-radius: 12px;
    margin-bottom: 2rem;
}

.year-section:last-child {
    margin-bottom: 0;
}

.year-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 1rem;
    background: none;
    border-radius: 8px;
    margin-bottom: 0.75rem;
}

.year-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--color-orange);
}

.year-meta {
    display: flex;
    gap: 1rem;
    color: var(--color-text-secondary);
    font-size: 0.82rem;
    flex-wrap: wrap;
}

.year-avg {
    display: inline-flex;
    align-items: center;
    gap: 0.1rem;
    line-height: 1;
}

.stat-icon-avg {
    font-size: 1rem;
    var(--color-text-secondary);
    line-height: 0.95;
    position: relative;
    top: 3px;
}

.correct-count {
    color: var(--color-correct);
}

.wrong-count {
    color: var(--color-wrong);
}

.lap-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.85rem 1rem 0.85rem 2.5rem;
    border-radius: 8px;
    margin-bottom: 0.5rem;
    text-decoration: none;
    color: var(--color-text-primary);
    transition: background 0.15s;
    background: rgba(255, 255, 255, 0.025);
    position: relative;
    border-left: none;
}

.lap-item::before {
    content: '';
    position: absolute;
    left: 1rem;
    top: 0.25rem;
    bottom: 0.25rem;
    width: 3px;
    border-radius: 2px;
}

.lap-item:hover {
    background: rgba(255, 255, 255, 0.075);
}

.counterclockwise-item::before {
    background: var(--color-correct);
}

.clockwise-item::before {
    background: var(--color-wrong);
}

.incomplete-item::before {
    background: #666;
}

.counterclockwise-item {
    border-left-color: var(--color-correct);
}

.clockwise-item {
    border-left-color: var(--color-wrong);
}

.lap-name {
    font-size: 0.9rem;
    font-weight: 500;
}

.lap-meta-text {
    font-size: 0.78rem;
    color: var(--color-text-secondary);
    margin-top: 2px;
}

.lap-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
}

.lap-time {
    font-size: 1.1rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.lap-direction {
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 20px;
    font-weight: 600;
}

.lap-direction.counterclockwise {
    background: rgba(34, 197, 94, 0.15);
    color: var(--color-correct);
}

.lap-direction.clockwise {
    background: rgba(239, 68, 68, 0.12);
    color: var(--color-wrong);
}

/* Fastest laps */
.fastest-lap {
    opacity: 1 !important;
    background: rgba(255, 215, 0, 0.07);
}

.lap-item.fastest-lap:hover {
    background: rgba(255, 215, 0, 0.13);
}

.lap-item.second-fastest {
    opacity: 1 !important;
    background: rgba(192, 192, 192, 0.07);
}

.lap-item.second-fastest:hover {
    background: rgba(192, 192, 192, 0.13);
}

.lap-item.third-fastest {
    opacity: 1 !important;
    background: rgba(205, 127, 50, 0.07);
}

.lap-item.third-fastest:hover {
    background: rgba(205, 127, 50, 0.13);
}

/* Badges */
.fastest-badge,
.second-badge,
.third-badge {
    font-size: 0.7rem;
    color: white;
    padding: 2px 7px;
    border-radius: 20px;
    font-weight: 700;
}

.fastest-badge {
    background: #826E00;
    color: #FFD700;
}

.second-badge {
    background: #6B6B6B;
    color: #C0C0C0;
}

.third-badge {
    background: #8B4513;
    color: #ce9f71;
}


/* =============================================
   INCOMPLETE SECTION
   ============================================= */
#incompleteSection {
    background: var(--color-bg-surface);
    border-radius: 12px;
    margin: 24px 0 24px 0;
    padding: 0 1rem;
    opacity: 0.7;
}

.incomplete-list-content {
    height: 0;
    overflow: hidden;
    transition: height 0.4s ease-out;
}

.incomplete-list-content.expanded {
    max-height: none !important;
}

.incomplete-item {
    opacity: 0.7;
}

.incomplete-item:hover {
    opacity: 1;
}

.incompleteListSpacer {
    height: 1rem;
}

.clickable-label {
    padding: 1rem 1rem 1rem 1rem;
    background: none;
    border-radius: 8px;
    border-left: none;
    margin: 2rem 0 0 0;
    /* ← Fix: war falsch zusammengeschrieben */
    color: rgba(255, 255, 255, 0.8);
    transition: all 0.2s;
    font-size: 1rem;
}

.clickable-label:hover {
    color: rgba(255, 255, 255, 1);
}

.section-label {
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items;
}

#incompleteToggleIcon {
    font-size: 19px;
    display: inline-block;
    transition: transform 0.3s ease;
    line-height: 1.2;
}

#incompleteToggleIcon.open {
    transform: rotate(-180deg);
}


/* =============================================
   SHARE MODAL
   ============================================= */
.share-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 1rem;
}

.share-modal.active {
    display: flex;
}

.share-modal-inner {
    background: #111;
    border-radius: 16px;
    padding: 2rem;
    max-width: 520px;
    width: 100%;
    text-align: center;
}

.share-modal-inner img {
    width: 100%;
    border-radius: 8px;
    margin-bottom: 1.5rem;
}

.share-modal-btns {
    display: flex;
    gap: 1rem;
}

.share-modal-btns .btn {
    flex: 1;
}


/* =============================================
   FOOTER
   ============================================= */
.page-footer {
    opacity: 0;
    text-align: center;
    padding: 0 0 3rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 3rem;
    border-top: 1px solid rgba(255, 255, 255, 0.04);
}

.made-by {
    font-size: 0.85rem !important;
    color: var(--color-text-secondary);
}

.made-by a {
    color: var(--color-text-secondary);
    text-decoration: none;
    transition: color 0.2s;
}

.made-by a:hover {
    color: #fff;
}

.made-by .heart {
    color: var(--color-orange);
}

.legal-disclaimer {
    color: #666;
    font-size: 0.75rem;
    line-height: 1.5;
}


/* =============================================
   RESPONSIVE
   ============================================= */
@media (max-width: 700px) {

    .lap-item.fastest-lap .lap-direction,
    .lap-item.second-fastest .lap-direction,
    .lap-item.third-fastest .lap-direction,
    .lap-direction.clockwise,
    .lap-direction.counterclockwise {
        display: none !important;
    }
}

@media (max-width: 600px) {
    .hero-title h1 {
        font-size: 3.5rem;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }

    .total-laps-display {
        font-size: 4rem;
    }

    .auth-content {
        padding: 2rem 2.5rem;
    }

    .auth-logo {
        font-size: 3.5rem;
    }

    .laps-list {
        padding: 0;
    }

    .year-meta {
        gap: 0.5rem;
    }
}

@media (max-width: 500px) {

    .fastest-badge,
    .second-badge,
    .third-badge {
        display: none !important;
    }
}
