/* GitHub Calendar Custom Styles */

/* Container matching the "Resume" card style */
.calendar {
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 20px;
    background-color: var(--background-light, rgba(30, 30, 31, 0.7)); /* Fallback if var not ready */
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1), 0 0 15px var(--glow-color, rgba(43, 255, 0, 0.05));
    /* Removed width: 100% !important; to allow more flexible sizing */
    min-height: 150px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
}

.total-contributions-display .short-text {
    display: none; /* Hide short text by default */
}

@media (max-width: 768px) {
    .mobile-total-contributions .total-contributions-display .long-text {
        display: none; /* Hide long text on mobile */
    }
    .mobile-total-contributions .total-contributions-display .short-text {
        display: inline; /* Show short text on mobile */
    }

    /* Adjusting weekday positioning for text.wday (SVG elements) */
    .calendar .wday {
        transform: translateX(-10px); /* Move SVG weekdays further left if they are overlapping */
    }

    /* Hiding only the weekday spans on mobile, identified by their inline style `bottom: -3px` */
    .calendar .ContributionCalendar-label span[aria-hidden="true"][style*="bottom: -3px"] {
        display: none !important;
    }
}

/* Hide standard footer text */
/* Custom Footer Wrapper */
.erfan-custom-calendar-footer {
    display: flex !important;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    margin-top: 15px;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.1); /* Separator line */
    flex-wrap: wrap;
    gap: 10px;
}

.total-contributions-display {
    color: #a0a0a0;
    /* font-family removed to inherit standard sans-serif from container */
    font-size: 12px; /* Standard GitHub footer text size */
    text-shadow: none;
}

.total-contributions-display strong {
    font-size: 1.2em;
    font-weight: bold;
    margin-right: 4px;
}

/* Ensure the moved legend looks correct */
.erfan-custom-calendar-footer .moved-legend {
    display: flex !important;
    align-items: center;
    gap: 5px;
    margin: 0;
}

/* Ensure legend items (squares) are visible */
.erfan-custom-calendar-footer .moved-legend div {
    display: inline-block !important;
}

/* Axis Labels */
.calendar text.Month,
.calendar text.wday {
    fill: #a0a0a0 !important;
    font-size: 10px;
}

/* Contribution Colors (Strict Green Scale: Dark to Bright) */
/* IMPORTANT: We use both 'fill' (for SVG) and 'background-color' (for HTML Table) to ensure compatibility */

/* Level 0: No contribution - Background color but lighter */
/* Using a very low opacity white to create a "lighter" version of the dark background */
.calendar .ContributionCalendar-day[data-level="0"] {
    fill: rgba(255, 255, 255, 0.05) !important;
    background-color: rgba(255, 255, 255, 0.05) !important;
    shape-rendering: geometricPrecision;
    border-radius: 3px;
}

/* Level 1: Dark Green */
.calendar .ContributionCalendar-day[data-level="1"] {
    fill: oklch(35% 0.1 144) !important;
    background-color: oklch(35% 0.1 144) !important;
    border-radius: 3px;
}

/* Level 2: Medium Green */
.calendar .ContributionCalendar-day[data-level="2"] {
    fill: oklch(48% 0.19 144) !important;
    background-color: oklch(48% 0.19 144) !important;
    border-radius: 3px;
}

/* Level 3: Light Green */
.calendar .ContributionCalendar-day[data-level="3"] {
    fill: oklch(61% 0.28 144) !important;
    background-color: oklch(61% 0.28 144) !important;
    border-radius: 3px;
}

/* Level 4: Brightest Green (From your request) */
.calendar .ContributionCalendar-day[data-level="4"] {
    fill: oklch(74% 0.37 144) !important;
    background-color: oklch(74% 0.37 144) !important;
    border-radius: 3px;
}

/* Ensure no default filters apply */
.calendar .ContributionCalendar-day {
    filter: none;
    border: none !important; /* Remove any default borders causing white lines */
    outline: none !important; /* Force remove outlines */
}

/* Responsive SVG */
.js-calendar-graph-svg {
    width: 100%;
}

.calendar-graph text.month {
    fill: #ccc;
    font-size: 10px;
}

.calendar-graph text.wday {
    fill: #ccc;
    font-size: 9px;
}

/* Tooltip customization */
.svg-tip {
    position: absolute;
    z-index: 99999;
    padding: 10px;
    font-size: 12px;
    color: #fff;
    text-align: center;
    background: rgba(0, 0, 0, 0.9);
    border: 1px solid #009900;
    border-radius: 4px;
    box-shadow: 0 0 10px rgba(0, 153, 0, 0.3);
}

.svg-tip:after {
    position: absolute;
    bottom: -10px;
    left: 50%;
    width: 0;
    height: 0;
    border-color: #009900 transparent transparent transparent;
    border-style: solid;
    border-width: 10px 10px 0;
    content: " ";
    margin-left: -10px;
}

/* Hide accessibility link scraped from GitHub */
.calendar a[href^="#year-link-"] {
    display: none !important;
}

/* Hide default GitHub stats column (Contributions, streaks) */
.calendar .contrib-column {
    display: none !important;
}

/* GitHub Calendar Matrix Theme */
.calendar-section {
    margin-bottom: 30px;
    margin-top: 90px;
    /* Removed padding as it will be handled by .portfolio-content-area */
    box-sizing: border-box; /* Include padding in the width calculation */
}

/* Repository Grid Styles */
.repos-section {
    margin-top: 30px;
    margin-bottom: 50px;
}

.matrix-heading {
    color: #00ff00;
    font-family: 'Courier New', Courier, monospace;
    text-shadow: 0 0 5px rgba(0, 255, 0, 0.5);
    margin-bottom: 20px;
    font-size: 1.5rem;
    padding-left: 5px;
    border-left: 3px solid #00ff00;
}

.repo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); /* Adjusted minmax for better mobile fit */
    gap: 20px;
    width: 100%;
    /* Removed padding as it will be handled by .portfolio-content-area */
    box-sizing: border-box; /* Include padding in the width calculation */
}

@media (max-width: 768px) {
    .repo-grid {
        grid-template-columns: 1fr; /* Force a single column on mobile */
        gap: 20px; /* Maintain gap between cards */
    }

    .repo-card, .project-card-matrix {
        width: 100%; /* Ensure cards take full width */
        padding: 15px 10px; /* Reduced vertical padding, more horizontal padding for small screens */
        box-sizing: border-box; /* Include padding in width calculation */
        min-width: 0; /* Allow cards to shrink below their intrinsic content size */
    }
}

@media (max-width: 768px) {
    .repo-stats {
        flex-wrap: wrap; /* Allow items to wrap on smaller screens */
    }
}

@media (max-width: 768px) {
    .repo-card p, .project-card-matrix p {
        word-break: break-all; /* Force break long words to prevent overflow */
    }
}

.repo-card, .project-card-matrix {
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 20px;
    background-color: var(--background-light, rgba(30, 30, 31, 0.7));
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1), 0 0 10px var(--glow-color, rgba(43, 255, 0, 0.05));
    transition: all 0.3s ease;
    text-decoration: none;
    color: #ccc;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

.repo-card:hover, .project-card-matrix:hover {
    box-shadow: 0 0 20px rgba(0, 255, 0, 0.2);
    border-color: rgba(0, 255, 0, 0.4);
    transform: translateY(-2px);
}

.repo-card h4, .project-card-matrix h4 {
    color: #00ff00;
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 1.2rem;
    font-family: 'Courier New', Courier, monospace;
}

.repo-card p, .project-card-matrix p {
    font-size: 0.9rem;
    color: #a0a0a0;
    line-height: 1.4;
    flex-grow: 1;
    margin-bottom: 15px;
}

.repo-stats {
    display: flex;
    justify-content: space-between;
    align-items: flex-start; /* Aligns items to the top so stars align with language */
    font-size: 0.9rem; /* Increased base font size slightly */
    color: #666;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 10px;
}

.repo-left-col {
    flex-grow: 1;
    margin-right: 10px;
}

.repo-right-col {
    flex-shrink: 0;
}

/* Unified Sizing for all Repo Stats */
.github-stars,
.github-forks-count,
.fork-icon {
    font-size: 1rem; /* CHANGE THIS VALUE to scale stars, fork icon, and numbers all at once */
    vertical-align: middle;
}

.fork-icon {
    width: 0.8em; /* Size relative to the font-size above */
    height: auto;
    display: inline-block;
    margin-right: 4px;
    margin-bottom: 0px; /* Slight optical adjustment */
    /* Target color #666 (gray) */
    filter: brightness(0) saturate(100%) invert(39%) sepia(0%) saturate(0%) hue-rotate(204deg) brightness(94%) contrast(88%) drop-shadow(0.5px 0 0 #666);
    opacity: 1;
    transition: all 0.3s ease;
}

.repo-card:hover .fork-icon,
.project-card-matrix:hover .fork-icon {
    /* Maintain gray color and boldness on hover */
    filter: brightness(0) saturate(100%) invert(39%) sepia(0%) saturate(0%) hue-rotate(204deg) brightness(94%) contrast(88%) drop-shadow(0.5px 0 0 #666);
}

.repo-lang-circle {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 5px;
    background-color: #00ff00; /* Default if language color unknown */
}

/* Glitch animation application for repo cards */
.repo-card.matrix-glitch-active,
.project-card-matrix.matrix-glitch-active {
    animation: matrix-glitch-anim 0.3s steps(2) infinite;
}

/* Loading state for stars */
.github-stars[data-loading="true"] {
    opacity: 0.5;
    animation: blink 1s infinite;
}

@keyframes blink {
    50% { opacity: 0.2; }
}

/* Glitch Effect for Calendar Boxes */
@keyframes matrix-glitch-anim {
    0% {
        filter: none;
        opacity: 1;
    }
    20% {
        filter: url('#matrix-glitch-1');
        fill: #ffffff !important; /* Flash white */
        opacity: 0.8;
    }
    40% {
        filter: none;
        opacity: 1;
    }
    60% {
        filter: url('#matrix-glitch-2');
        fill: #00ff00 !important; /* Flash bright green */
        opacity: 0.9;
    }
    80% {
        filter: url('#matrix-glitch-1');
        transform: translateX(-2px); /* Slight shift */
    }
    100% {
        filter: none;
        transform: none;
        opacity: 1;
    }
}

.calendar .ContributionCalendar-day.matrix-glitch-active {
    animation: matrix-glitch-anim 0.3s steps(2) infinite;
}