/* ============================================================
   Skill Pills (shared between desktop preview & mobile overlay)
   ============================================================ */

.skill-pills-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    --skill-pill-text-color: #ffffff;
}

@media (prefers-color-scheme: light) {
    .skill-pills-container {
        --skill-pill-text-color: #000000;
    }
}

.skill-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.3rem 0.6rem;
    border-radius: 30px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    transition: all 0.2s ease;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.skill-pill:hover { 
    transform: scale(1.05) translateY(-2px);
    background-color: rgba(255, 255, 255, 0.15);
}

.skill-pill-red    { background-color: rgba(255,  56,  60, 0.25); }
.skill-pill-blue   { background-color: rgba(  0, 136, 255, 0.25); }
.skill-pill-green  { background-color: rgba( 52, 199,  89, 0.25); }
.skill-pill-yellow { background-color: rgba(255, 204,   0, 0.25); }
.skill-pill-purple { background-color: rgba(175,  82, 222, 0.25); }

.skill-pill > p { margin: 0; }

.skill-text {
    font-weight: bold;
    font-size: 0.75rem;
    color: var(--skill-pill-text-color);
}

.skill-icon {
    font-family: 'Material Symbols Outlined';
    font-size: 1rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--skill-pill-text-color);
}

/* ============================================================
   Projects Section Background
   ============================================================ */

#projects {
    position: relative;
    z-index: 1;
    padding: 1.5rem 2rem;
    overflow: hidden;
    /* Transition for theme switching if implemented */
    transition: background-color 0.3s ease;
}

#projects::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: -1;
    background-image: var(--projects-bg, url('/assets/images/projects-wallpaper-dark.webp'));
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    /* Subtle overlay to keep content readable */
    background-color: rgba(0, 0, 0, 0.4);
    background-blend-mode: overlay;
    transition: background-image 0.5s ease;
    margin-top: 2.5rem;
}

/* On desktop: flex column so the dock anchors to the bottom */
@media (min-width: 701px) {
    #projects {
        display: flex;
        flex-direction: column;
        min-height: 110lvh;
    }

    .dock-layout {
        flex: 1;
        justify-content: flex-end;
        padding-top: 0;
        padding-bottom: 1rem;
        position: relative;
        z-index: 9999;
        pointer-events: none;
    }

    .dock-shell {
        pointer-events: auto;
    }

    .mac-window-float {
        position: absolute;
        width: 540px;
        max-width: calc(100% - 2rem);
    }
}

/* On desktop: mask out the header area so wallpaper only covers the dock zone */
@media (min-width: 701px) {
    #projects::before {
        /* transparent over section padding + title bar (~7rem), fade in over 4rem,
           stay opaque through dock area, fade out over 5rem at the bottom */
        mask-image: linear-gradient(
            to bottom,
            transparent 0,
            transparent 7rem,
            black 11rem,
            black calc(100% - 5rem),
            transparent 100%
        );
        -webkit-mask-image: linear-gradient(
            to bottom,
            transparent 0,
            transparent 7rem,
            black 11rem,
            black calc(100% - 5rem),
            transparent 100%
        );
    }
}

@media (prefers-color-scheme: light) {
    #projects::before {
        background-image: var(--projects-bg-light, url('/assets/images/projects-wallpaper-light.webp'));
        background-color: rgba(255, 255, 255, 0.1);
    }
}

/* ============================================================
   Desktop: Dock layout
   ============================================================ */

.dock-layout {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    padding: 2rem 1rem;
    width: 100%;
    max-width: 62rem;
    margin: 0 auto;
}

/* macOS window preview — always in layout to reserve space */
.dock-preview {
    width: 100%;
    min-height: 320px; /* Ensure enough space for the window */
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease, transform 0.4s ease;
    transform: translateY(10px);
}

.dock-preview.preview-open {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

@keyframes dock-slide-in {
    from {
        opacity: 0;
        transform: translateY(40px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.dock-shell.dock-visible {
    animation: dock-slide-in 0.55s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes dock-icon-bounce {
    0%   { transform: translateY(0); }
    25%  { transform: translateY(-20px); }
    50%  { transform: translateY(0); }
    70%  { transform: translateY(-10px); }
    85%  { transform: translateY(0); }
    93%  { transform: translateY(-4px); }
    100% { transform: translateY(0); }
}

.dock-icon.dock-icon-bounce {
    animation: dock-icon-bounce 0.58s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

@keyframes mac-window-open {
    from {
        opacity: 0;
        transform: scale(0.85);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.mac-window {
    --mac-win-bg: rgba(240, 240, 240, 0.5);
    --mac-win-border: rgba(0, 0, 0, 0.05);
    --mac-win-shadow: 0 20px 50px rgba(0, 0, 0, 0.15), 0 10px 20px rgba(0, 0, 0, 0.1);
    --mac-title-bg: rgba(225, 225, 225, 0.8);
    --mac-title-text: rgba(0, 0, 0, 0.6);
    --mac-body-bg: #f5f5f5;
    --mac-info-bg: rgba(255, 255, 255, 0.3);
    --mac-hero-fade: rgba(245, 245, 245, 1);
    --mac-hero-fade-low: rgba(245, 245, 245, 0.4);
    --mac-text-title: #1a1a1a;
    --mac-text-body: rgba(0, 0, 0, 0.75);
    --mac-text-bold: #000000;
    --mac-footer-border: rgba(0, 0, 0, 0.08);

    border-radius: 24px;
    overflow: hidden;
    box-shadow: 
        0 0 0 1px var(--mac-win-border),
        var(--mac-win-shadow);
    background: var(--mac-win-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    transform-origin: center center;
}

@media (prefers-color-scheme: dark) {
    .mac-window {
        --mac-win-bg: rgba(25, 25, 25, 0.4);
        --mac-win-border: rgba(255, 255, 255, 0.1);
        --mac-win-shadow: 0 20px 50px rgba(0, 0, 0, 0.3), 0 10px 20px rgba(0, 0, 0, 0.2);
        --mac-title-bg: rgba(45, 45, 45, 0.7);
        --mac-title-text: rgba(255, 255, 255, 0.8);
        --mac-body-bg: #1a1a1a;
        --mac-info-bg: rgba(26, 26, 26, 0.5);
        --mac-hero-fade: rgba(26, 26, 26, 1);
        --mac-hero-fade-low: rgba(26, 26, 26, 0.4);
        --mac-text-title: #ffffff;
        --mac-text-body: rgba(255, 255, 255, 0.85);
        --mac-text-bold: #ffffff;
        --mac-footer-border: rgba(255, 255, 255, 0.1);
    }
}

.mac-window.mac-window-enter {
    animation: mac-window-open 0.45s cubic-bezier(0.23, 1, 0.32, 1) forwards;
}

.mac-titlebar {
    height: 40px;
    background: linear-gradient(to bottom, 
        rgba(255, 255, 255, 0.1) 0%, 
        transparent 1px,
        var(--mac-title-bg) 1px);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    display: flex;
    align-items: center;
    padding: 0 14px;
    position: relative;
    flex-shrink: 0;
    border-bottom: 1px solid var(--mac-win-border);
    cursor: grab;
    user-select: none;
}

.mac-titlebar:active {
    cursor: grabbing;
}

.mac-traffic-lights {
    display: flex;
    gap: 8px;
    align-items: center;
    z-index: 2;
}

.mac-title-wrapper {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    max-width: 65%;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.mac-titlebar-icon {
    width: 20px;
    height: 20px;
    object-fit: contain;
    border-radius: 5px;
}

.mac-window-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--mac-title-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: 0.01em;
    opacity: 0.9;
}

.mac-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
    transition: filter 0.1s ease;
}

.mac-dot:active {
    filter: brightness(0.8);
}

.mac-dot::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    box-shadow: inset 0 1px 1px rgba(0,0,0,0.1);
    pointer-events: none;
}

.mac-close    { background: #FF5F57; border: 0.5px solid #E0443E; }
.mac-minimize { background: #FFBD2E; border: 0.5px solid #DEA123; }
.mac-maximize { background: #28C840; border: 0.5px solid #1AAB29; }

.mac-dot::before {
    content: '';
    display: block;
    width: 6.5px;
    height: 6.5px;
    background-color: rgba(0, 0, 0, 0.6);
    -webkit-mask-size: contain;
    mask-size: contain;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-position: center;
    opacity: 0;
    transition: opacity 0.1s ease;
    pointer-events: none;
}

.mac-close::before {
    -webkit-mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 6 6' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1.2 1.2l3.6 3.6M4.8 1.2L1.2 4.8' stroke='black' stroke-width='1.2' stroke-linecap='round'/%3E%3C/svg%3E");
    mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 6 6' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1.2 1.2l3.6 3.6M4.8 1.2L1.2 4.8' stroke='black' stroke-width='1.2' stroke-linecap='round'/%3E%3C/svg%3E");
}

.mac-minimize::before {
    -webkit-mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 6 6' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0.8 3h4.4' stroke='black' stroke-width='1.2' stroke-linecap='round'/%3E%3C/svg%3E");
    mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 6 6' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0.8 3h4.4' stroke='black' stroke-width='1.2' stroke-linecap='round'/%3E%3C/svg%3E");
}

.mac-maximize::before {
    -webkit-mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 6 6' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M3.8 1.2h1v1M2.2 4.8h-1v-1M1.2 4.8l3.6-3.6' stroke='black' stroke-width='1.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 6 6' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M3.8 1.2h1v1M2.2 4.8h-1v-1M1.2 4.8l3.6-3.6' stroke='black' stroke-width='1.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

.mac-dot:hover::before {
    opacity: 1;
}

.mac-traffic-lights .mac-dot {
    cursor: pointer;
    transition: filter 0.12s ease;
}

.mac-traffic-lights .mac-dot:hover {
    filter: brightness(0.82);
}

.mac-window-body {
    position: relative;
    display: flex;
    flex-direction: column;
    background: var(--mac-body-bg);
    min-height: 300px;
    max-height: 80vh;
}

.mac-window-hero {
    position: relative;
    width: 100%;
    height: 220px;
    flex-shrink: 0;
    overflow: hidden;
}

.mac-window-bg {
    width: 100%;
    height: 100%;
    object-fit: cover;
    pointer-events: none;
}

/* Bottom fade on hero to blend into info */
.mac-window-hero-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, var(--mac-hero-fade) 0%, var(--mac-hero-fade-low) 20%, transparent 50%);
    pointer-events: none;
}

.mac-window-info {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    background: var(--mac-info-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    flex-grow: 1;
    overflow-y: auto;
}

.mac-window-header {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}

.mac-window-logo {
    width: 4.5rem;
    height: 4.5rem;
    object-fit: contain;
    border-radius: 14px;
    flex-shrink: 0;
}

.mac-window-header-text {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-width: 0;
}

.mac-window-title-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.mac-window-title-inner {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--mac-text-title);
    margin: 0;
}

.mac-window-type-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.25rem 0.75rem;
    /* Mix with white first to 'solidify' transparent colors, then apply opacity */
    background: color-mix(in srgb, color-mix(in srgb, var(--accent-color), white 20%), transparent 85%);
    border-radius: 20px;
    border: 1px solid color-mix(in srgb, var(--accent-color), transparent 60%);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.mac-window-type-icon {
    font-size: 0.9rem !important;
    /* Brighten the color by mixing with white for better visibility */
    color: color-mix(in srgb, var(--accent-color), var(--text-color-primary) 40%);
    display: flex;
    align-items: center;
    filter: drop-shadow(0 0 2px color-mix(in srgb, var(--accent-color), transparent 50%));
}

.mac-window-type {
    font-size: 0.72rem;
    font-weight: 800;
    /* Brighten the text for contrast */
    color: color-mix(in srgb, var(--accent-color), var(--text-color-primary) 40%);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    filter: drop-shadow(0 0 1px color-mix(in srgb, var(--accent-color), transparent 70%));

    
}

.mac-window-description {
    font-size: 0.95rem;
    line-height: 1.5;
    color: var(--mac-text-body);
    text-align: start;
}

.mac-window-description p {
    margin: 0 0 0.75rem 0;
}

.mac-window-description p:last-child {
    margin-bottom: 0;
}

.mac-window-description b, 
.mac-window-description strong {
    color: var(--mac-text-bold);
}

.mac-window-description a {
    color: var(--accent-color);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.mac-window-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-top: auto;
    padding-top: 0.5rem;
    border-top: 1px solid var(--mac-footer-border);
}

.mac-window-tags {
    min-width: 0;
    flex-grow: 1;
}

.mac-window-link {
    display: inline-flex;
    align-items: center;
    padding: 0.6rem 1.2rem;
    background: var(--accent-color);
    border: none;
    border-radius: 12px;
    color: white;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 700;
    white-space: nowrap;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.mac-window-link:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

/* Dock shelf */
.dock-shell {
    display: flex;
    justify-content: center;
    padding: 12px 14px;
    margin-top: 0;
    background: rgba(30, 42, 80, 0.36);
    backdrop-filter: blur(48px) saturate(180%) brightness(1.08);
    -webkit-backdrop-filter: blur(48px) saturate(180%) brightness(1.08);
    border: 0.5px solid rgba(255, 255, 255, 0.18);
    border-radius: 24px;
    box-shadow:
        /* Top-edge inner highlight — the hallmark of macOS glass */
        inset 0 1px 0 rgba(255, 255, 255, 0.28),
        /* Subtle bottom inner shadow for depth */
        inset 0 -1px 0 rgba(0, 0, 0, 0.12),
        /* Main elevation shadow */
        0 24px 56px rgba(0, 0, 0, 0.45),
        /* Soft ambient shadow */
        0 8px 20px rgba(0, 0, 0, 0.22),
        /* Tight contact shadow */
        0 2px 6px rgba(0, 0, 0, 0.18);
}

@media (prefers-color-scheme: light) {
    .dock-shell {
        background: rgba(220, 230, 255, 0.38);
        backdrop-filter: blur(48px) saturate(160%) brightness(1.12);
        -webkit-backdrop-filter: blur(48px) saturate(160%) brightness(1.12);
        border-color: rgba(255, 255, 255, 0.55);
        box-shadow:
            inset 0 1px 0 rgba(255, 255, 255, 0.75),
            inset 0 -1px 0 rgba(0, 0, 100, 0.06),
            0 20px 48px rgba(0, 40, 120, 0.2),
            0 8px 18px rgba(0, 20, 80, 0.12),
            0 2px 5px rgba(0, 10, 60, 0.08);
    }
}

.dock-container {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    height: 56px; 
    padding-bottom: 2px;
}

.dock-icon {
    position: relative;
    width: 56px;
    height: 56px;
    flex-shrink: 0;
    cursor: pointer;
    transition: width 0.3s ease, height 0.3s ease, transform 0.3s ease;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    filter: drop-shadow(0 4px 14px rgba(0, 0, 0, 0.35)) drop-shadow(0 1px 3px rgba(0, 0, 0, 0.2));
}

/* Disable transitions during active magnification to prevent lag */
.dock-container.is-magnifying .dock-icon {
    transition: none;
}

.dock-icon-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
    user-select: none;
    -webkit-user-drag: none;
    -webkit-touch-callout: none;
    transition: filter 0.2s ease, transform 0.2s ease;
}

.dock-icon:hover .dock-icon-img {
    filter: brightness(1.1) contrast(1.05);
}

/* Active indicator dot */
.dock-icon.dock-icon-active::after {
    content: '';
    position: absolute;
    bottom: -7px;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 4px;
    background: var(--text-color, #fff);
    border-radius: 50%;
    opacity: 0.75;
}

/* Tooltip */
.dock-icon-tooltip {
    position: absolute;
    bottom: calc(100% + 15px);
    left: 50%;
    transform: translateX(-50%) translateY(5px);
    background: rgba(30, 30, 30, 0.7);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: white;
    font-size: 0.8rem;
    font-weight: 500;
    padding: 6px 12px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: all 0.2s cubic-bezier(0.23, 1, 0.32, 1);
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.dock-icon:hover .dock-icon-tooltip {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.dock-separator {
    width: 1px;
    height: 32px;
    align-self: center;
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0.06));
    margin: 0 6px;
    flex-shrink: 0;
}

/* ============================================================
   Mobile: iOS Homescreen  (hidden on desktop)
   ============================================================ */

.ios-homescreen {
    display: none;
}

.ios-folder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    flex: 1;
    max-width: 180px;
}

.ios-folder-toggle {
    width: 78px;
    height: 78px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(12px) saturate(150%);
    -webkit-backdrop-filter: blur(12px) saturate(150%);
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 
        inset 0 0 0 1px rgba(255, 255, 255, 0.2),
        0 4px 12px rgba(0, 0, 0, 0.1);
    padding: 8px;
    cursor: pointer;
    transition: transform 0.2s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.2s ease;
    overflow: hidden;
    position: relative;
}

.ios-folder-toggle:hover {
    transform: scale(1.06);
    box-shadow: 0 6px 24px rgba(0,0,0,0.25);
}

.ios-folder-toggle:active {
    transform: scale(0.94);
}

.ios-mini-grid {
    width: 100%;
    height: 100%;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 4px;
    padding: 2px;
}

.ios-mini-icon {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 4px;
    pointer-events: none;
    box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.ios-folder-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
    text-align: center;
    white-space: nowrap;
}

/* ============================================================
   Folder popup (morph level 1)
   ============================================================ */

.ios-folder-popup {
    background: color-mix(in srgb, var(--bg-color, #fff) 20%, transparent);
    backdrop-filter: blur(40px) saturate(200%);
    -webkit-backdrop-filter: blur(40px) saturate(200%);
    /* Specular highlight border */
    border: 1px solid rgba(255, 255, 255, 0.4);
    box-shadow: 
        0 10px 30px rgba(0, 0, 0, 0.1),
        inset 0 1px 1px rgba(255, 255, 255, 0.5),
        inset 0 0 0 1px rgba(255, 255, 255, 0.2);
}
@media (prefers-color-scheme: dark) {
    .ios-folder-popup {
        background: rgba(255, 255, 255, 0.08);
        border: 1px solid rgba(255, 255, 255, 0.15);
    }
}

/* Floating title: fixed element above the popup, on the blurred overlay */
.ios-folder-floating-title {
    position: fixed;
    /* Left-align with the popup edge (popup = min(vw,vh) * 0.8, centred) */
    left: calc((100vw - min(100vw, 100vh) * 0.8) / 2);
    /* Just above the popup top edge (half-height = min * 0.4) */
    bottom: calc(50vh + min(100vw, 100vh) * 0.4 + 0.75rem);
    z-index: 1001;
    font-size: 1.8rem;
    font-weight: 700;
    color: white;
    text-shadow: 0 1px 8px rgba(0, 0, 0, 0.5);
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.ios-folder-floating-title.visible {
    opacity: 1;
}

.ios-folder-popup-inner {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 1rem;
    overflow: visible;
}

.ios-folder-popup-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 0.5rem;
    flex: 1;
    min-height: 0;
    overflow: visible;
}

.ios-project-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    transition: transform 0.15s ease;
    width: 100%;
    height: 100%;
}

.ios-project-btn:hover { transform: scale(1.08); }
.ios-project-btn:active { transform: scale(0.94); }

.ios-project-empty {
    /* grid stretches it to fill the 1fr cell — no explicit size needed */
}

.ios-project-icon {
    width: 64px;
    height: 64px;
    object-fit: cover;
    border-radius: 16px;  /* used in corner radius formula: popup = 16 + 16 = 32px */
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.35);
}

.ios-project-label {
    font-size: 0.68rem;
    color: rgba(255,255,255,0.9);
    text-align: center;
    width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ============================================================
   iOS App Popup (morph target)
   ============================================================ */

.ios-app-popup {
    --popup-background: #1c1c1e;
    --popup-text-primary: #ffffff;
    --popup-text-secondary: rgba(255, 255, 255, 0.6);
    background: var(--popup-background);
    border-radius: 38px;
    overflow: hidden;
    position: relative;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

@media (prefers-color-scheme: light) {
    .ios-app-popup {
        --popup-background: #f2f2f7;
        --popup-text-primary: #000000;
        --popup-text-secondary: rgba(0, 0, 0, 0.55);
    }
}

.ios-app-inner {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.ios-app-popup .ios-status-bar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10;
    background: transparent;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.4rem 0.4rem 0;
}

.ios-status-img {
    height: 18px;
    object-fit: contain;
    pointer-events: none;
    user-select: none;
    filter: invert(1);
}

.ios-status-img-left  { object-position: left center; }
.ios-status-img-right { object-position: right center; }

.ios-nav-back {
    position: absolute;
    top: calc(44px + 0.5rem);
    left: 0.75rem;
    z-index: 3;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.22);
    backdrop-filter: blur(24px) saturate(1.6);
    -webkit-backdrop-filter: blur(24px) saturate(1.6);
    border: 0.5px solid rgba(255, 255, 255, 0.4);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.45),
        0 2px 10px rgba(0, 0, 0, 0.28);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    cursor: pointer;
    transition: background 0.15s, transform 0.12s;
}

.ios-nav-back:active {
    background: rgba(255, 255, 255, 0.36);
    transform: scale(0.9);
}

.ios-nav-back .material-symbols-outlined {
    font-size: 1.3rem !important;
    line-height: 1;
}

.ios-app-scrollable {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    min-height: 0;
}

.ios-app-hero {
    position: relative;
    width: 100%;
    flex-shrink: 0;
}

.ios-app-hero-bg {
    width: 100%;
    height: 200px;
    overflow: hidden;
    position: relative;
}

.ios-app-bg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ios-app-hero-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(
        to bottom,
        rgba(0, 0, 0, 0.48) 0%,
        rgba(0, 0, 0, 0.18) 25%,
        transparent 48%,
        var(--popup-background) 100%
    );
    pointer-events: none;
    z-index: 1;
}

.ios-app-content {
    padding: 1rem 1.25rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.ios-app-header {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    margin-top: -36px;
    padding: 0 1rem 1rem;
    z-index: 2;
}

.ios-app-logo {
    width: 72px;
    height: 72px;
    object-fit: cover;
    border-radius: 18px;
}

.ios-app-header-text {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    text-align: center;
}

.ios-app-title {
    color: var(--popup-text-primary);
    font-size: 1.15rem;
    font-weight: 800;
    margin: 0;
    line-height: 1.2;
    text-align: center;
}

.ios-app-type-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.2rem 0.55rem;
    background: color-mix(in srgb, var(--accent-color, #007aff), transparent 78%);
    border-radius: 20px;
    border: 1px solid color-mix(in srgb, var(--accent-color, #007aff), transparent 65%);
}

.ios-app-type-icon {
    font-size: 0.78rem !important;
    line-height: 1;
    color: color-mix(in srgb, var(--accent-color, #007aff), var(--popup-text-primary) 30%);
    display: flex;
    align-items: center;
}

.ios-app-type-text {
    font-size: 0.65rem;
    font-weight: 700;
    color: color-mix(in srgb, var(--accent-color, #007aff), var(--popup-text-primary) 30%);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ios-app-description {
    font-size: 0.875rem;
    line-height: 1.6;
    color: var(--popup-text-secondary);
    width: 100%;
}

.ios-app-description p {
    margin: 0 0 0.5rem 0;
}

.ios-app-description p:last-child {
    margin-bottom: 0;
}

.ios-app-description b,
.ios-app-description strong {
    color: var(--popup-text-primary);
}

.ios-app-description a {
    color: var(--accent-color, #007aff);
    text-underline-offset: 2px;
}

/* iOS Navbar Redesign */
.ios-app-navbar {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.25rem;
    background: var(--popup-background);
    border-top: 1px solid rgba(128, 128, 128, 0.15);
    flex-shrink: 0;
}

.ios-nav-primary-btn {
    flex: 1;
    height: 50px;
    background: var(--accent-color);
    color: white;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    font-weight: 700;
    font-size: 1rem;
    box-shadow: 0 4px 14px color-mix(in srgb, var(--accent-color), transparent 50%);
    transition: transform 0.15s;
}

.ios-nav-secondary-btn {
    width: 50px;
    height: 50px;
    background: rgba(128, 128, 128, 0.15);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--popup-text-primary);
    text-decoration: none;
    transition: background 0.2s;
}

.github-icon-svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
}

.ios-nav-secondary-btn:active, .ios-nav-primary-btn:active {
    transform: scale(0.95);
}

.ios-home-indicator {
    width: 134px;
    height: 5px;
    background: var(--popup-text-primary, #fff);
    border-radius: 3px;
    margin: 4px auto 10px;
    opacity: 0.2;
    align-self: center;
    flex-shrink: 0;
}

/* ============================================================
   Responsive: switch between dock and folders
   ============================================================ */

@media (max-width: 700px) {
    .dock-layout {
        display: none;
    }

    #projects {
        padding: 1.5rem 1rem 3rem;
        min-height: 100svh;
        display: flex;
        flex-direction: column;
    }

    /* Same gradient mask as desktop: transparent over the title bar, fade in,
       stay opaque through the homescreen, fade out before the footer */
    #projects::before {
        mask-image: linear-gradient(
            to bottom,
            transparent 0,
            transparent 4rem,
            black 7rem,
            black calc(100% - 5rem),
            transparent 100%
        );
        -webkit-mask-image: linear-gradient(
            to bottom,
            transparent 0,
            transparent 4rem,
            black 7rem,
            black calc(100% - 5rem),
            transparent 100%
        );
    }

    /* ── Homescreen shell ── */
    .ios-homescreen {
        display: flex;
        flex-direction: column;
        flex: 1;
        margin-top: 0.75rem;
    }

    /* Status bar */
    .ios-status-bar {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0 0.75rem;
        height: 44px;
        flex-shrink: 0;
    }

    .ios-status-time {
        font-size: 1rem;
        font-weight: 700;
        color: white;
        text-shadow: 0 1px 5px rgba(0, 0, 0, 0.7);
        letter-spacing: 0.02em;
    }

    .ios-status-right {
        display: flex;
        gap: 4px;
        align-items: center;
    }

    .ios-status-icon {
        font-size: 1.05rem !important;
        line-height: 1;
        color: white;
        text-shadow: 0 1px 5px rgba(0, 0, 0, 0.7);
        opacity: 0.92;
        font-variation-settings: 'FILL' 1;
    }

    /* ── App grid ── */
    .ios-homescreen-grid {
        flex: 1;
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        grid-template-rows: repeat(6, 1fr);
        gap: 0.5rem;
        padding: 0 0.5rem 1rem;
    }

    /* Empty grid cells */
    .ios-grid-cell {
        border-radius: 18px;
        /* Placeholder — invisible by default, ready to receive content */
    }

    /* iOS folder in grid context */
    .ios-folder {
        flex: unset;
        max-width: unset;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 5px;
    }

    .ios-folder-toggle {
        width: 60px;
        height: 60px;
    }

    .ios-folder-label {
        font-size: 0.75rem;
    }
}
