/* Builds Grid & Cards */
#build-grid {
    perspective: 1000px;
}

.build-card {
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(148, 163, 184, 0.15);
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
    display: flex;
    flex-direction: column;
}

.build-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
    border-color: rgba(245, 158, 11, 0.4);
    /* Amber border on hover */
}

/* Card Header with Civ Flag Background or Accent */
.card-header {
    height: 8px;
    width: 100%;
    background: linear-gradient(to right, var(--civ-color, #fbbf24), transparent);
}

.card-body {
    padding: 1.5rem;
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Difficulty Badges */
.badge-easy {
    background: rgba(34, 197, 94, 0.2);
    color: #4ade80;
    border: 1px solid rgba(74, 222, 128, 0.2);
}

.badge-medium {
    background: rgba(234, 179, 8, 0.2);
    color: #facc15;
    border: 1px solid rgba(250, 204, 21, 0.2);
}

.badge-hard {
    background: rgba(239, 68, 68, 0.2);
    color: #f87171;
    border: 1px solid rgba(248, 113, 113, 0.2);
}

/* Civ Filter Buttons */
.civ-filter {
    padding: 0.5rem 1rem;
    border-radius: 8px;
    background: rgba(30, 41, 59, 0.5);
    border: 1px solid rgba(148, 163, 184, 0.2);
    transition: all 0.2s;
    opacity: 0.7;
    filter: grayscale(100%);
}

.civ-filter:hover {
    opacity: 1;
    filter: grayscale(0%);
    background: rgba(51, 65, 85, 0.8);
}

.civ-filter.active {
    opacity: 1;
    filter: grayscale(0%);
    border-color: #fbbf24;
    background: rgba(251, 191, 36, 0.1);
    box-shadow: 0 0 10px rgba(251, 191, 36, 0.2);
}

/* Metro Map Timeline Styles (Redesigned) */
.metro-container {
    position: relative;
    max-width: 800px;
    margin: 0 auto;
    padding: 20px 4px 50px;
    overflow-x: hidden;
    /* Prevent horizontal scroll triggers */
}

/* Vertical Line (metro track) */
.metro-line {
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 4px;
    background: linear-gradient(180deg,
            #475569 0%,
            #fbbf24 100%);
    transform: translateX(-2px);
    z-index: 0;
}

/* Station (step) */
.station {
    position: relative;
    margin-bottom: 40px;
    animation: slideIn 0.5s ease-out backwards;
}

/* Stagger animations */
.station:nth-child(1) {
    animation-delay: 0.1s;
}

.station:nth-child(2) {
    animation-delay: 0.15s;
}

.station:nth-child(3) {
    animation-delay: 0.2s;
}

.station:nth-child(4) {
    animation-delay: 0.25s;
}

.station:nth-child(5) {
    animation-delay: 0.3s;
}

.station:nth-child(6) {
    animation-delay: 0.35s;
}

.station:nth-child(7) {
    animation-delay: 0.4s;
}

.station:nth-child(8) {
    animation-delay: 0.45s;
}

.station:nth-child(9) {
    animation-delay: 0.5s;
}

.station:nth-child(10) {
    animation-delay: 0.55s;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Global Mobile Layout (Wide Alternating) */
.station {
    width: 85%;
    /* Wide cards for readability */
    position: relative;
    z-index: 10;
    /* Ensure active cards sit above line */
}

/* Odd steps: Align Left */
.station:nth-child(odd) {
    margin-right: auto;
    margin-left: 0;
    text-align: left;
    padding-right: 0;
    padding-left: 10px;
    /* Small buffer */
}

/* Even steps: Align Right */
.station:nth-child(even) {
    margin-left: auto;
    margin-right: 0;
    text-align: left;
    /* Keep text left-aligned for readability */
    padding-left: 0;
    padding-right: 10px;
}

/* Dots - Always Centered */
.station .station-dot {
    left: 50% !important;
    right: auto !important;
    transform: translateX(-50%) !important;
    top: -10px;
    /* Pull dot up to sit on top edge or just above */
    z-index: 20;
}

/* Adjust Age-Up Dot for Mobile */
.station.age-up .station-dot {
    top: -14px;
}

/* Hide connection lines on mobile to reduce clutter with overlap */
.connection-line {
    display: none;
}

/* Desktop Styles (Split 50/50 Layout) */
@media (min-width: 768px) {
    .station {
        width: auto;
        /* Reset width */
    }

    .station:nth-child(odd) {
        padding-right: 55%;
        padding-left: 0;
        margin: 0;
        text-align: right;
    }

    .station:nth-child(even) {
        padding-left: 55%;
        padding-right: 0;
        margin: 0;
        text-align: left;
    }

    /* Restore connection lines */
    .station:nth-child(odd) .connection-line {
        display: block;
        right: 45%;
        width: 10%;
        left: auto;
        top: 25px;
    }

    .station:nth-child(even) .connection-line {
        display: block;
        left: 45%;
        width: 10%;
        right: auto;
        top: 25px;
    }

    /* Center Dots relative to line */
    .station .station-dot {
        top: 15px;
        /* Reset top */
    }

    .station.age-up .station-dot {
        top: 10px;
    }

    /* Icons alignment */
    .station:nth-child(odd) .station-icons {
        justify-content: flex-end;
    }
}


@keyframes pulse {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(251, 191, 36, 0.7);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(251, 191, 36, 0);
    }
}

/* Station Card */
.station-card {
    background: rgba(30, 41, 59, 0.7);
    border-radius: 12px;
    padding: 15px;
    border: 1px solid rgba(148, 163, 184, 0.2);
    backdrop-filter: blur(10px);
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.station-card:hover {
    background: rgba(51, 65, 85, 0.9);
    border-color: rgba(251, 191, 36, 0.5);
    transform: translateY(-2px);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3);
}

.station-card.expanded {
    background: rgba(30, 41, 59, 1);
    border-color: #fbbf24;
    box-shadow: 0 0 0 1px #fbbf24, 0 20px 40px -10px rgba(0, 0, 0, 0.5);
    z-index: 10;
}

/* Time Badge */
.time-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(251, 191, 36, 0.1);
    color: #fbbf24;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 700;
    font-family: monospace;
    width: fit-content;
}

/* Title & Desc */
.station-title {
    font-weight: 700;
    color: #f1f5f9;
    font-size: 1.1rem;
    line-height: 1.3;
}

.station-desc {
    font-size: 0.9rem;
    color: #94a3b8;
    line-height: 1.5;
}

/* Expanded Details */
.station-details {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s cubic-bezier(0, 1, 0, 1);
    /* Toggle effect */
    opacity: 0;
}

.station-card.expanded .station-details {
    max-height: 500px;
    opacity: 1;
    transition: max-height 0.5s ease-in-out, opacity 0.3s ease-in;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.expand-hint {
    text-align: center;
    color: #64748b;
    font-size: 0.75rem;
    margin-top: 4px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    opacity: 0;
    transition: opacity 0.3s;
}

.station-card:hover .expand-hint {
    opacity: 1;
}

.station-card.expanded .expand-hint {
    display: none;
}

/* Connection Line styling */
.connection-line {
    position: absolute;
    top: 25px;
    height: 1px;
    background: rgba(148, 163, 184, 0.3);
    z-index: 1;
}

/* Age Badges in Card */
.age-badge {
    background: linear-gradient(135deg, #fbbf24, #d97706);
    color: #fff;
    font-weight: 900;
    text-align: center;
    padding: 8px;
    border-radius: 6px;
    margin-bottom: 8px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    font-family: 'Cinzel', serif;
}

.castle-badge {
    background: linear-gradient(135deg, #f472b6, #be185d);
    /* Pinkish for castle? or keep generic */
}

/* Info Grid */
.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    gap: 8px;
}

.info-item {
    background: rgba(15, 23, 42, 0.4);
    padding: 6px;
    border-radius: 4px;
    text-align: center;
}

.info-label {
    font-size: 0.7rem;
    color: #94a3b8;
    text-transform: uppercase;
}

.info-value {
    color: #e2e8f0;
    font-weight: 700;
    font-size: 0.9rem;
}

/* Resource Icons in Text */
.res-icon {
    height: 1.5rem !important;
    width: auto !important;
    vertical-align: middle !important;
    display: inline-block !important;
    margin-right: 4px;
    margin-top: -3px;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5));
}

/* Resource Grid in Step (Kept as backup or integrated) */
.resource-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
    margin-top: 0.5rem;
    /* background: rgba(15, 23, 42, 0.5); */
    /* Remove bg inside info-grid */
    /* padding: 0.5rem; */
}

.res-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 0.75rem;
    font-weight: 600;
}

.res-food {
    color: #f87171;
}

.res-wood {
    color: #a3e635;
}

.res-gold {
    color: #facc15;
}

.res-stone {
    color: #94a3b8;
}

/* Custom Scrollbar */
.custom-scrollbar::-webkit-scrollbar {
    width: 8px;
}

.custom-scrollbar::-webkit-scrollbar-track {
    background: #0f172a;
}

.custom-scrollbar::-webkit-scrollbar-thumb {
    background: #334155;
    border-radius: 4px;
}

.custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background: #475569;
}

/* Print Overrides - Compact List View */
@media print {

    /* Hide Timeline Elements */
    .metro-line,
    .station-dot,
    .connection-line {
        display: none !important;
    }

    /* Reset Container */
    .metro-container {
        padding: 0 !important;
        max-width: 100% !important;
        margin: 0 !important;
    }

    /* Compact Step Item */
    .station {
        padding: 5px 0 !important;
        margin-bottom: 5px !important;
        page-break-inside: avoid;
        text-align: left !important;
        width: 100% !important;
        border-bottom: 1px dashed #ccc;
    }

    /* Simplify Card to Plain Text */
    .station-card {
        background: transparent !important;
        border: none !important;
        box-shadow: none !important;
        padding: 0 !important;
        display: block !important;
        margin: 0 !important;
        gap: 0 !important;
    }

    /* Text Adjustments */
    .station-title {
        color: black !important;
        font-size: 10pt !important;
        margin-bottom: 0 !important;
        display: inline-block;
        margin-right: 10px;
    }

    .station-desc {
        color: black !important;
        font-size: 10pt !important;
        display: inline;
    }

    .time-badge {
        color: black !important;
        background: none !important;
        border: 1px solid #000;
        padding: 0 4px !important;
        font-size: 8pt !important;
        height: auto !important;
        margin-right: 5px;
    }

    /* HIDE Details for Compact Print (Saves ~4 pages) */
    .station-details {
        display: none !important;
    }

    /* Hide UI Elements */
    .expand-hint,
    .age-badge {
        display: none !important;
    }

    /* Ensure icons print clearly */
    .res-icon {
        filter: none !important;
        height: 12px !important;
    }
}

/* Fix Print Layout - Ensure Modal Prints Fully */
@media print {

    body,
    html {
        overflow: visible !important;
        height: auto !important;
    }

    /* Hide everything except the modal content */
    body>*:not(#build-modal) {
        display: none !important;
    }

    #build-modal {
        position: static !important;
        display: block !important;
        inset: auto !important;
        width: 100% !important;
        height: auto !important;
        overflow: visible !important;
        background: white !important;
    }

    /* Reset strict positioning on modal children */
    #build-modal>div {
        position: static !important;
        inset: auto !important;
        width: 100% !important;
        height: auto !important;
        overflow: visible !important;
        padding: 0 !important;
    }

    /* The scrollable container */
    #build-modal .overflow-y-auto {
        overflow: visible !important;
        height: auto !important;
        flex: none !important;
    }

    /* Hide modal UI elements */
    #modal-backdrop,
    #build-modal button,
    #build-modal .sticky {
        display: none !important;
    }
}