/* ===== FONTS ===== */
@font-face {
    font-family: 'Gravitica Mono';
    src: url('ckhans-fonts-gravitica-mono-light-demo.otf') format('opentype');
    font-weight: normal;
    font-style: normal;
}

/* ===== CSS VARIABLES FOR THEMING ===== */
:root {
    /* Light theme (default) */
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-accordion: #f7f7f7;
    --bg-accordion-hover: #e2e2e2;
    --bg-accordion-gradient: linear-gradient(135deg, #e2e2e2 0%, #b6b5b5 100%);
    --bg-card: #ffffff;
    --bg-tag: #d0cfcf67;
    --bg-overlay: rgba(0, 0, 0, 0.751);
    --bg-hover-overlay: rgba(170, 166, 166, 0.3);
    --bg-button-container: #ffffff;
    --bg-popup: #ffffff;
    --bg-overlay-dark: rgba(0, 0, 0, 0.5);
    
    --text-primary: #000000;
    --text-secondary: #333333;
    --text-gray: gray;
    --text-white: #ffffff;
    --text-grey: grey;
    
    --border-color: #dddddd;
    --border-faint: rgba(0, 0, 0, 0.1);
    
    --shadow-color: rgba(0, 0, 0, 0.35);
    --shadow-light: rgba(0, 0, 0, 0.2);
    --shadow-strong: rgba(0, 0, 0, 0.253);
    
    --glow-color: rgb(50, 59, 227);
    --glow-soft: rgba(166, 255, 0, 0.199);
    
    --icon-color: #151414;
    --icon-hover: pink;
    --icon-active: grey;
    
    --link-color: #000000;
    --link-hover: #000000;
    
    --flip-card-bg: #ffffff;
    --quote-border: rgba(0, 0, 0, 0.1);
}

/* Dark theme variables */
[data-theme="dark"] {
    --bg-primary: #1a1a1a;
    --bg-secondary: #2d2d2d;
    --bg-accordion: #2d2d2d;
    --bg-accordion-hover: #3d3d3d;
    --bg-accordion-gradient: linear-gradient(135deg, #3d3d3d 0%, #2a2a2a 100%);
    --bg-card: #2d2d2d;
    --bg-tag: #40404067;
    --bg-overlay: linear-gradient(to bottom, rgba(0, 0, 0, 0.3), rgba(0, 0, 0, 0.9));
    --bg-hover-overlay: rgba(60, 60, 60, 0.3);
    --bg-button-container: #2d2d2d;
    --bg-popup: #2d2d2d;
    --bg-overlay-dark: rgba(0, 0, 0, 0.8);
    
    --text-primary: #ffffff;
    --text-secondary: #cccccc;
    --text-gray: #999999;
    --text-white: #ffffff;
    --text-grey: #999999;
    
    --border-color: #404040;
    --border-faint: rgba(255, 255, 255, 0.1);
    
    --shadow-color: rgba(0, 0, 0, 0.6);
    --shadow-light: rgba(0, 0, 0, 0.4);
    --shadow-strong: rgba(0, 0, 0, 0.5);
    
    --glow-color: #4caf50;
    --glow-soft: rgba(76, 175, 80, 0.3);
    
    --icon-color: #cccccc;
    --icon-hover: #ff69b4;
    --icon-active: #999999;
    
    --link-color: #cccccc;
    --link-hover: #ffffff;
    
    --flip-card-bg: #2d2d2d;
    --quote-border: rgba(255, 255, 255, 0.1);
}

/* ===== RESET & BASE STYLES ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Gravitica Mono', sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    padding: 0 15px;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* ===== TYPOGRAPHY & COMMON ELEMENTS ===== */
h1 {
    font-size: clamp(20px, 5vw, 24px);
    font-weight: normal;
    margin-bottom: 10px;
    color: var(--text-primary);
}

p, .nametitle, .nametitle2, .summary {
    font-size: clamp(16px, 4vw, 18px);
    max-width: 600px;
    margin: 0 auto 20px;
    line-height: 1.6;
    width: 100%;
    color: var(--text-primary);
}

/* ===== HEADER SECTION ===== */
.header-container {
    width: 100%;
    display: flex;
    justify-content: flex-start;
    padding: 0;
    margin: 30px 0 20px;
}

.logo {
    width: clamp(40px, 8vw, 50px);
    height: auto;
    filter: var(--logo-filter, none);
}

[data-theme="dark"] .logo {
    filter: brightness(0.8) invert(1);
}

.container {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    max-width: 600px;
    margin: 0 auto;
    gap: 20px;
}

.container img {
    max-width: clamp(40px, 8vw, 50px);
    border-radius: 50%;
    display: block;
}

/* ===== GLOWING DOT ===== */
.glowing-dot {
    width: 10px;
    height: 10px;
    background-color: var(--glow-color);
    border-radius: 50%;
    box-shadow: 0 0 10px var(--glow-color);
    animation: pulse 4s infinite alternate;
    transform: scale(0.2);
}

@keyframes pulse {
    0% { transform: scale(1); opacity: 1; }
    100% { transform: scale(1.5); opacity: 0; }
}

/* ===== FEATURED SECTION ===== */
.featured {
    text-align: center;
    margin: 30px 0;
}

.featured img,
.video-container {
    width: 100%;
    max-width: 600px;
    margin: 20px auto;
    border-radius: 10px;
}

.video-container {
    overflow: hidden;
    box-shadow: var(--shadow-color) 0px 5px 15px;
}

.video-container video {
    width: 100%;
    height: auto;
    display: block;
}

/* ===== ACCORDION SECTION ===== */
.accordion {
    width: 100%;
    max-width: 1200px;
    margin: 5px 0;
}

.accordion-item {
    border-bottom: 1px solid var(--border-color);
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 10px;
}

.accordion-header {
    background-color: var(--bg-accordion);
    color: var(--text-primary);
    cursor: pointer;
    padding: 15px;
    width: 100%;
    text-align: left;
    border: none;
    outline: none;
    transition: all 0.4s ease;
    font-family: inherit;
    font-size: inherit;
}

.accordion-header:hover {
    background-color: var(--bg-accordion-hover);
    box-shadow: 0 0 10px var(--glow-soft);
    transform: scale(1.01);
    background-image: var(--bg-accordion-gradient);
}

.accordion-content {
    padding: 0 0 0 20px;
    display: none;
    overflow: hidden;
    background-color: var(--bg-primary);
    border-radius: 10px;
}

/* ===== FLIP CARDS ===== */
.flip-card {
    background-color: transparent;
    width: 100%;
    height: auto;
    perspective: 1000px;
    margin: 20px 0;
}

.flip-card-inner {
    position: relative;
    width: 100%;
    min-height: 200px;
    text-align: center;
    transition: transform 0.6s;
    transform-style: preserve-3d;
    box-shadow: 0 4px 8px var(--shadow-light);
}

.flip-card:hover .flip-card-inner {
    transform: rotateY(180deg);
}

.flip-card-front, .flip-card-back {
    position: absolute;
    width: 100%;
    height: auto;
    min-height: 200px;
    backface-visibility: hidden;
    border-radius: 10px;
    padding: 20px;
    background-color: var(--flip-card-bg);
    color: var(--text-primary);
}

.flip-card-back {
    transform: rotateY(180deg);
    background-color: var(--flip-card-bg);
    color: var(--text-primary);
}

.flip-card img {
    max-width: 100%;
    height: auto;
    margin-top: 10px;
    border-radius: 10px;
}

/* ===== BOOKS & PODCASTS GRIDS ===== */
.books-section,
.podcasts-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 15px;
    text-align: center;
    margin-top: 20px;
}

.book-item,
.podcast-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px;
    border: 1px solid var(--border-faint);
    border-radius: 8px;
    background-color: var(--bg-card);
    transition: transform 0.3s ease;
    color: var(--text-primary);
}

.book-item:hover,
.podcast-item:hover {
    transform: scale(1.02);
}

.book-cover,
.podcast-cover {
    width: 100%;
    max-width: 100px;
    height: auto;
    border-radius: 8px;
}

.book-title,
.podcast-title {
    font-weight: bold;
    margin-top: 10px;
    font-size: 14px;
    color: var(--text-primary);
}

.book-author {
    color: var(--text-gray);
    font-size: 12px;
}

/* ===== MOTIVATIONAL QUOTES ===== */
.motivational-quotes {
    margin: 20px 0 20px 15px;
}

.motivational-quotes blockquote {
    font-size: 16px;
    margin: 15px 0;
    padding-left: 15px;
    border-left: 3px solid var(--quote-border);
    color: var(--text-secondary);
    font-style: italic;
}

/* ===== TECHNOLOGY SLIDER ===== */
.technology-section {
    overflow: hidden;
    width: 100%;
    position: relative;
    margin: 20px 0;
}

.tech-slider {
    display: flex;
    white-space: nowrap;
    animation: slide 30s linear infinite;
}

.tech-slide {
    display: inline-flex;
}

.tech-item {
    text-align: center;
    margin: 10px;
    padding: 10px;
    border: 1px solid var(--border-faint);
    border-radius: 8px;
    background-color: var(--bg-card);
    transition: transform 0.3s ease;
    color: var(--text-primary);
}

.tech-item:hover {
    transform: scale(1.05);
}

.tech-icon {
    width: 40px;
    height: auto;
    filter: var(--tech-icon-filter, none);
}

[data-theme="dark"] .tech-icon {
    filter: brightness(0.9) invert(0.9);
}

.tech-name {
    font-weight: bold;
    margin-top: 5px;
    font-size: 12px;
    color: var(--text-primary);
}

@keyframes slide {
    0% { transform: translateX(0); }
    100% { transform: translateX(-100%); }
}

/* ===== PROJECTS SECTION ===== */
.project-container {
    border-radius: 15px;
    overflow: hidden;
    position: relative;
    margin: 2px 0 20px;
    box-shadow: 0 4px 8px var(--shadow-strong);
    width: 100%;
    max-width: 600px;
    background-color: var(--bg-secondary);
    height: 400px;
    transition: transform 0.3s ease-in-out;
}

@media (min-width: 768px) {
    .project-container {
        height: 600px;
    }
}

@media (min-width: 1024px) {
    .project-container {
        height: 800px;
    }
}

.project-container:hover {
    transform: scale(1.02);
}

.image-container {
    position: relative;
    overflow: hidden;
    border-radius: 15px;
    height: 100%;
}

.project-image {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

.gradient-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.3), var(--bg-overlay));
}

.hover-overlay-left,
.hover-overlay-right {
    position: absolute;
    top: 0;
    width: 50%;
    height: 100%;
    background: var(--bg-hover-overlay);
    transition: transform 0.5s ease-in-out;
}

.hover-overlay-left {
    left: 0;
    transform: translateX(-100%);
}

.hover-overlay-right {
    right: 0;
    transform: translateX(100%);
}

.project-container:hover .hover-overlay-left,
.project-container:hover .hover-overlay-right {
    transform: translateX(0);
}

.project-details {
    position: absolute;
    bottom: 15px;
    left: 15px;
    color: var(--text-white);
    right: 15px;
}

.technology-tags {
    margin-top: 10px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.tag {
    background-color: var(--bg-tag);
    color: var(--text-primary);
    border-radius: 12px;
    padding: 4px 8px;
    font-size: 0.7em;
    backdrop-filter: blur(2px);
}

/* ===== HIGHLIGHT EFFECT ===== */
@keyframes flicker {
    0% { background-color: rgba(var(--highlight-rgb), 0.4); }
    50% { background-color: transparent; }
    100% { background-color: rgba(var(--highlight-rgb), 0.381); }
}

:root {
    --highlight-rgb: 140, 140, 140;
}

[data-theme="dark"] {
    --highlight-rgb: 200, 200, 200;
}

.highlight {
    animation: flicker 0.5s infinite;
}

/* ===== SOCIAL SECTION ===== */
.social-container {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 15px;
    gap: 10px;
}

.social-icon {
    width: clamp(35px, 8vw, 40px);
    height: clamp(35px, 8vw, 40px);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.3s ease-in-out;
    background-color: transparent;
}

.social-icon:hover {
    transform: scale(1.2);
}

.social-icon svg {
    width: 100%;
    height: 100%;
    fill: var(--icon-color);
    transition: fill 0.3s ease;
}

.social-icon:hover svg {
    fill: var(--icon-hover);
}

.social-icon:active svg {
    fill: var(--icon-active);
}

/* ===== CONNECT LINKS ===== */
.connect {
    text-align: center;
    margin: 20px 0;
}

.connect a {
    text-decoration: none;
    color: var(--link-color);
    margin: 0 8px;
    font-size: 14px;
    display: inline-block;
    padding: 5px;
    transition: color 0.3s ease;
}

.connect a:hover {
    text-decoration: underline;
    color: var(--link-hover);
}

/* ===== TASKBAR / BUTTON CONTAINER ===== */
.button-container {
    display: flex;
    background-color: var(--bg-button-container);
    width: 90%;
    max-width: 250px;
    height: 40px;
    align-items: center;
    justify-content: space-around;
    position: fixed;
    bottom: 15px;
    left: 50%;
    transform: translateX(-50%);
    transition: all 0.3s ease-in-out;
    border-radius: 10px;
    box-shadow: var(--shadow-color) 0px 5px 15px, rgba(218, 210, 213, 0.5) 5px 10px 15px;
    z-index: 1000;
}

[data-theme="dark"] .button-container {
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.8), 5px 10px 15px rgba(0, 0, 0, 0.5);
}

.button-container:hover {
    transform: translateX(-50%) scale(1.05);
}

.button {
    position: relative;
    border: none;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    background-color: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--icon-color);
    transition: all ease-in-out 0.3s;
    cursor: pointer;
}

.button::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 120%;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--bg-popup);
    color: var(--text-primary);
    padding: 4px 8px;
    border-radius: 4px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease-in-out;
    pointer-events: none;
    font-size: 12px;
    border: 1px solid var(--border-faint);
    box-shadow: 0 2px 5px var(--shadow-light);
}

.button:hover::after {
    opacity: 1;
    visibility: visible;
}

.button:hover {
    transform: translateY(-3px);
}

.button:hover .icon {
    fill: var(--icon-hover);
    stroke: var(--icon-hover);
}

.icon {
    font-size: 18px;
    fill: var(--icon-color);
    stroke: var(--icon-color);
    transition: fill 0.3s ease, stroke 0.3s ease;
}

.button:focus .icon,
.button:active .icon {
    fill: var(--icon-active);
    stroke: var(--icon-active);
}

/* ===== SWITCH TOGGLE (Theme Switcher) ===== */
.switch {
    font-size: 17px;
    position: relative;
    display: inline-block;
    width: 1.2em;
    height: 3.3em;
    transform: scale(0.5);
}

.switch .chk {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 5px;
}

.slider:before {
    position: absolute;
    content: "";
    height: .5em;
    width: 2.4em;
    border-radius: 5px;
    left: -0.6em;
    top: 0.2em;
    background-color: white;
    box-shadow: 0 6px 7px rgba(0,0,0,0.3);
    transition: .4s;
}

.slider:after {
    content: "";
    display: block;
    background: linear-gradient(transparent 50%, rgba(255, 255, 255, 0.15) 0) 0 50% / 50% 100%,
        repeating-linear-gradient(90deg, #fff 0, #fff, #fff 20%, #fff 20%, #fff 40%) 0 50% / 50% 100%,
        radial-gradient(circle at 50% 50%, #fff 25%, transparent 26%);
    background-repeat: no-repeat;
    border: 0.25em solid transparent;
    border-left: 0.4em solid #fff;
    border-right: 0 solid transparent;
    transition: border-left-color 0.1s 0.3s ease-out, transform 0.3s ease-out;
    transform: translateX(-22.5%) rotate(90deg);
    transform-origin: 25% 50%;
    position: relative;
    top: 0.5em;
    left: 0.55em;
    width: 2em;
    height: 1em;
    box-sizing: border-box;
}

.chk:checked + .slider {
    background-color: limegreen;
}

.chk:focus + .slider {
    box-shadow: 0 0 1px limegreen;
}

.chk:checked + .slider:before {
    transform: translateY(2.3em);
}

.chk:checked + .slider:after {
    transform: rotateZ(90deg) rotateY(180deg) translateY(0.45em) translateX(-1.4em);
}

/* ===== POPUP CARD ===== */
.popup-card {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: var(--bg-popup);
    color: var(--text-primary);
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 4px 8px var(--shadow-light);
    width: 90%;
    max-width: 300px;
    max-height: 80vh; /* Limits height to 80% of viewport height */
    overflow-y: auto; /* Adds vertical scrolling when content overflows */
    z-index: 1001;
    border: 1px solid var(--border-faint);
}

/* Optional: Style the scrollbar for better aesthetics */
.popup-card::-webkit-scrollbar {
    width: 5px;
}

.popup-card::-webkit-scrollbar-track {
    background: var(--bg-primary);
    border-radius: 10px;
}

.popup-card::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 10px;
}

.popup-card::-webkit-scrollbar-thumb:hover {
    background: var(--text-gray);
}

/* Ensure the close button stays accessible */
.popup-card .close-btn {
    position: sticky; /* Changes from absolute to sticky */
    top: 0;
    float: right; /* Keeps it at the top right */
    background: var(--bg-popup);
    z-index: 2;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    margin: -10px -10px 0 0; /* Adjusts positioning */
}

/* Optional: Add a slight shadow to the close button when scrolling */
.popup-card .close-btn {
    box-shadow: 0 2px 5px var(--shadow-light);
}

/* Style the content inside popup to have better spacing */
.popup-card h2 {
    margin-top: 0;
    font-size: 20px;
    color: var(--text-primary);
    padding-right: 30px; /* Prevents text from going under close button */
}

.popup-card-content {
    margin-top: 10px;
}
.overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-overlay-dark);
    z-index: 1000;
}

/* ===== COLOPHON LINK ===== */
#colophon-link,
#colophon-link:hover,
#colophon-link:active,
#colophon-link:visited {
    color: var(--text-grey);
    text-decoration: underline;
}

/* ===== MEDIA QUERIES FOR SMALL DEVICES ===== */
@media (max-width: 480px) {
    body {
        padding: 0 10px;
    }
    
    .header-container {
        margin-top: 20px;
    }
    
    .container {
        gap: 10px;
    }
    
    .button-container {
        width: 95%;
        bottom: 10px;
    }
    
    .button {
        width: 30px;
        height: 30px;
    }
    
    .icon {
        font-size: 16px;
    }
    
    .books-section,
    .podcasts-section {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .flip-card-inner {
        min-height: 250px;
    }
    
    .flip-card-front,
    .flip-card-back {
        min-height: 250px;
        padding: 15px;
    }
    
    .project-details {
        font-size: 14px;
    }
    
    .technology-tags {
        gap: 5px;
    }
    
    .tag {
        padding: 3px 6px;
        font-size: 0.65em;
    }
}

/* ===== TOUCH DEVICE OPTIMIZATIONS ===== */
@media (hover: none) and (pointer: coarse) {
    .button:hover,
    .project-container:hover,
    .social-icon:hover,
    .book-item:hover,
    .podcast-item:hover,
    .tech-item:hover {
        transform: none;
    }
    
    .button::after {
        display: none;
    }
    
    .button:active,
    .social-icon:active {
        opacity: 0.7;
    }
    
    .flip-card-inner {
        transition: transform 0.6s;
    }
    
    .flip-card.flipped .flip-card-inner {
        transform: rotateY(180deg);
    }
}

/* ===== ACCESSIBILITY IMPROVEMENTS ===== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

.button:focus-visible,
.social-icon:focus-visible,
.accordion-header:focus-visible,
a:focus-visible {
    outline: 2px solid var(--text-primary);
    outline-offset: 2px;
}

/* ===== SCROLLBAR STYLING (Optional) ===== */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-gray);
}