/* ============ RESET & BASE ============ */
* { margin:0; padding:0; box-sizing:border-box; }
body, html {
    width:100vw; min-height:100vh; overflow-x:hidden; overflow-y:auto;
    font-family: -apple-system, BlinkMacSystemFont, 'Inter', sans-serif;
    cursor: default;
    user-select: none;
}
::selection { background: rgba(0, 122, 255, 0.3); }

/* ============ SCROLLBARS ============ */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.2); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.3); }

.wallpaper {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 0;
    background-image: url('wallpaper.jpg');
    background-size: cover;
    background-position: center;
    background-color: #000;
}


/* ============ MENUBAR ============ */
.menubar {
    position:fixed; top:0; left:0; right:0; height:30px; z-index:9999;
    display:flex; justify-content:space-between; align-items:center;
    background: rgba(20, 20, 20, 0.65);
    backdrop-filter: blur(40px) saturate(180%); -webkit-backdrop-filter: blur(40px) saturate(180%);
    padding: 0 16px;
    font-size: 13px; font-weight: 400;
    color: rgba(255,255,255,0.9);
    box-shadow: 0 1px 0 rgba(0,0,0,0.3);
}
.menubar-left, .menubar-right { display:flex; align-items:center; gap:0; }
.menu-text { padding: 0 12px; height:30px; line-height:30px; cursor:pointer; transition: background 0.15s; }
.menu-text:hover { background: rgba(255,255,255,0.12); border-radius:4px; }
.bold { font-weight:700; }

/* ============ DESKTOP ICONS ============ */
.desktop-grid {
    position:fixed; top:35px; right:20px; z-index:10;
    display:flex; flex-direction:column; gap:5px;
    align-items:center;
}
.mac-icon {
    width:85px; height:90px;
    display:flex; flex-direction:column; align-items:center;
    justify-content:center;
    cursor:pointer; border-radius:8px; padding:5px;
    transition: transform 0.15s ease, background 0.15s;
}
.mac-icon:hover, .folder:hover { background:rgba(255,255,255,0.15); box-shadow: 0 4px 12px rgba(0,0,0,0.1); border-radius: 8px; }
.mac-icon:active, .folder:active { transform: scale(0.95); background:rgba(0,100,255,0.2); }
.mac-icon:active .icon-label, .folder.selected .folder-name { background:rgba(0,122,255,0.8); color:white; }

.mac-folder-icon, .mac-file-icon { width:65px; height:65px; transition: transform 0.2s; }
.mac-folder-icon svg, .mac-file-icon svg { width:100%; height:100%; filter:drop-shadow(0 3px 5px rgba(0,0,0,0.25)); }

.icon-label, .folder-name {
    margin-top:4px; font-size:12px; font-weight: 500; color:white;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
    text-align:center; padding:2px 6px; border-radius:4px;
    max-width:85px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
    transition: background 0.1s, color 0.1s;
}

/* ============ WINDOWS ============ */
.mac-window {
    position:fixed; z-index:100;
    background: rgba(255, 255, 255, 0.65);
    backdrop-filter: blur(40px) saturate(180%);
    -webkit-backdrop-filter: blur(40px) saturate(180%);
    border-radius:12px;
    box-shadow: 0 25px 50px rgba(0,0,0,0.25), 
                0 0 0 1px rgba(255,255,255,0.5),
                inset 0 1px 0 rgba(255,255,255,1);
    display:flex; flex-direction:column;
    overflow:hidden;
    animation: windowOpen 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes windowOpen {
    0% { transform:scale(0.9); opacity:0; }
    100% { transform:scale(1); opacity:1; }
}

.win-titlebar {
    height:50px; display:flex; align-items:center;
    background: transparent;
    border-bottom:1px solid rgba(0,0,0,0.06);
    position:relative; cursor:grab;
    flex-shrink:0;
}
.win-titlebar:active { cursor:grabbing; }

.titlebar-dark {
    background: rgba(40, 40, 40, 0.95) !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1) !important;
}
.titlebar-light {
    background: rgba(240, 240, 240, 0.9) !important;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1) !important;
}

.traffic-lights { position:absolute; left:16px; display:flex; gap:8px; }
.tl { width:12px; height:12px; border-radius:50%; cursor:pointer; border:0.5px solid rgba(0,0,0,0.12); box-shadow: inset 0 1px 0 rgba(255,255,255,0.2); }
.tl.red { background: #FF5F56; }
.tl.yellow { background: #FFBD2E; }
.tl.green { background: #27C93F; }
.tl.red:hover { background: #FF4A40; }

.win-title {
    flex:1; text-align:center;
    font-size:13px; font-weight:600; color:#555;
    pointer-events:none;
}

.win-toolbar {
    height:36px; display:flex; align-items:center;
    background:transparent; border-bottom:1px solid rgba(0,0,0,0.06);
    padding:0 16px; font-size:12px; color:#555; gap:12px;
    flex-shrink:0;
}
.toolbar-btn { color:#888; font-size: 16px; display:flex; gap:10px; cursor:default; }
.toolbar-path { color:#666; font-weight: 500; }

/* Finder layout */
.win-content-flex { display:flex; flex:1; min-height:300px; background: rgba(255,255,255,0.4); }

.finder-sidebar {
    width:160px; background:transparent;
    border-right:1px solid rgba(0,0,0,0.06);
    padding:15px 0; flex-shrink:0;
}
@media (max-width: 600px) { .finder-sidebar { display: none; } }
.sb-section { font-size:11px; font-weight:600; color:#888; padding:5px 12px; }
.sb-item {
    font-size:12px; padding:4px 12px; cursor:pointer;
    margin: 0 8px; border-radius:4px;
    display:flex; align-items:center; gap:6px;
}
.sb-item:hover { background:rgba(0,0,0,0.05); }

.folder-grid {
    flex: 1;
    padding: 20px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(95px, 1fr));
    gap: 15px;
    align-content: flex-start;
    overflow-y: auto;
}
.folder-grid .folder-name { 
    color: #333; 
    text-shadow: none; 
    white-space: normal; 
    display: -webkit-box; 
    -webkit-line-clamp: 3; 
    -webkit-box-orient: vertical; 
    line-height: 1.2;
}
.sb-item.active { background:rgba(0,0,0,0.08); border-radius:6px; margin:0 8px; padding-left:12px; font-weight:600; color:#333; }

.win-body { flex: 1; padding: 20px; overflow-y: auto; background: rgba(255, 255, 255, 0.4); }

/* Text Edit style */
.textedit { background: #ffffff !important; color:#333; font-size:15px; line-height:1.6; border-radius: 0 0 12px 0; padding: 25px; user-select: text; }
.textedit p { margin-bottom:12px; }
.textedit h2 { font-weight:600; font-size:1.6rem; letter-spacing:-0.5px; margin-bottom: 10px; }

/* Desktop Right Files */
.desktop-files-right {
    position: fixed;
    top: 50px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    z-index: 10;
}
.mobile-apps-grid { display: none; }

/* Finder Grid */
.finder-grid {
    display:grid; grid-template-columns:repeat(auto-fill, minmax(90px, 1fr));
    gap:15px; padding:20px; align-content:start;
}
.finder-file {
    display:flex; flex-direction:column; align-items:center;
    cursor:pointer; padding:8px; border-radius:6px;
    border: 1px solid transparent; transition: background 0.1s;
}
.finder-file:hover { background:rgba(0,122,255,0.12); }
.finder-file.selected { background: rgba(0, 0, 0, 0.2); border: 1px solid rgba(255, 255, 255, 0.15); }
.finder-file.selected .file-name { background: #0058d0; color: white; padding: 2px 6px; border-radius: 4px; }
.finder-file .file-icon { font-size:40px; margin-bottom:4px; }
.finder-file .file-name { font-size:11px; text-align:center; color:#333; word-break:break-word; }

/* Skills Grid */
.skills-grid {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)) !important;
}
.skill-card {
    display:flex; flex-direction:column; align-items:center;
    background:white; border:1px solid #ddd; border-radius:10px;
    padding:15px 10px; transition: transform 0.15s;
    box-shadow: 0 2px 5px rgba(0,0,0,0.08);
}
.skill-card:hover { transform:translateY(-3px); box-shadow:0 5px 12px rgba(0,0,0,0.15); }
.skill-icon { font-size:2rem; margin-bottom:5px; }
.skill-name { font-size:12px; font-weight:600; color:#333; }

/* Contact Form */
#contact-form { display:flex; flex-direction:column; gap:12px; }
#contact-form input, #contact-form textarea {
    font-family:inherit; padding:10px 12px;
    border:1px solid #ccc; border-radius:6px;
    font-size:13px; outline:none; resize:none;
    background:#f9f9f9;
}
#contact-form input:focus, #contact-form textarea:focus {
    border-color:#007AFF; box-shadow: 0 0 0 3px rgba(0,122,255,0.15);
}
#contact-form button {
    background:linear-gradient(#3b9eff, #007AFF);
    color:white; border:none; padding:10px; border-radius:6px;
    font-size:14px; font-weight:600; cursor:pointer;
}
#contact-form button:hover { background:linear-gradient(#5aafff, #0088ff); }
#form-status { font-size:12px; font-weight:600; text-align:center; min-height:1.2em; }

.social-row { margin-top:20px; display:flex; gap:15px; justify-content:center; }
.social-row a {
    color:#007AFF; text-decoration:none; font-size:13px; font-weight:600;
    padding:5px 10px; border:1px solid #007AFF; border-radius:6px;
}
.social-row a:hover { background:#007AFF; color:white; }

.loading-msg { grid-column:1/-1; text-align:center; color:#888; padding:40px; }

/* ============ DOCK ============ */
.dock-bar {
    position: fixed;
    bottom: 20px;
    left: 0; right: 0;
    display: flex;
    justify-content: center;
    z-index: 100;
}
.dock-glass {
    background: rgba(50, 50, 50, 0.35);
    backdrop-filter: blur(60px) saturate(220%);
    -webkit-backdrop-filter: blur(60px) saturate(220%);
    border-radius: 24px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 10px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 30px 60px rgba(0,0,0,0.6), 
                inset 0 1px 1px rgba(255,255,255,0.4),
                inset 0 -1px 1px rgba(0,0,0,0.3);
}
.dock-icon {
    width: 48px; height: 48px;
    background: linear-gradient(180deg, #444, #1a1a1a);
    border-radius: 12px;
    padding: 6px;
    box-sizing: border-box;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3), inset 0 1px 1px rgba(255,255,255,0.2);
    border: 1px solid rgba(0,0,0,0.6);
    object-fit: contain;
    transition: transform 0.2s;
}
.social-icon {
    width: 55px; height: 55px; 
    border-radius: 12px;
    padding: 0;
    box-sizing: border-box;
    background: none;
    border: none;
    box-shadow: none;
    object-fit: cover;
}
.gh-icon { width: 62px; height: 62px; }
.trash-icon-emoji {
    font-size: 50px;
    width: 55px; height: 55px;
    display: flex; justify-content: center; align-items: center;
    margin-bottom: 0;
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.5));
}
.dock-item { position: relative; display: flex; justify-content: center; align-items: center; transition: transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275); cursor: pointer; }
.dock-item:hover { transform: scale(1.3) translateY(-12px); z-index: 10; }



/* ============ WIDGETS ============ */
.left-column { display: flex; flex-direction: column; gap: 15px; width: fit-content; }
.desktop-folders { display: flex; flex-direction: row; gap: 15px; margin-top: 10px; }

.widget-row { display: flex; gap: 15px; }

.widget {
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(60px) saturate(250%) contrast(110%);
    -webkit-backdrop-filter: blur(60px) saturate(250%) contrast(110%);
    border-radius: 20px;
    border: 1px solid rgba(255,255,255,0.3);
    box-shadow: 0 10px 30px rgba(0,0,0,0.2),
                inset 0 1px 1px rgba(255,255,255,0.7),
                inset 0 -1px 1px rgba(0,0,0,0.1);
    color: white; overflow: hidden;
    width: 170px; /* Base width for square widgets */
    cursor: pointer; transition: transform 0.1s;
}
.widget:active { transform: scale(0.97); }

/* Clock Widget */
.clock-widget { aspect-ratio: 1; background: rgba(255, 255, 255, 0.95); color: black; display: flex; justify-content: center; align-items: center; position: relative; }
.clock-display { font-size: 52px; font-weight: 900; letter-spacing: -2px; z-index: 2; }
.clock-border { position: absolute; top: 10px; bottom: 10px; left: 10px; right: 10px; border: 1px dashed rgba(0,0,0,0.2); border-radius: 12px; }

/* Calendar Widget */
.calendar-widget { aspect-ratio: 1; background: rgba(40, 40, 40, 0.7); padding: 10px; display: flex; flex-direction: column; justify-content: space-between; }
.cal-header { color: #FF3B30; font-size: 11px; font-weight: 700; margin-bottom: 2px; }
.cal-days-header, .cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; }
.cal-days-header { font-size: 9px; color: rgba(255,255,255,0.5); margin-bottom: 2px; }
.cal-grid { gap: 1px; font-size: 9px; color: rgba(255,255,255,0.9); }
.cal-grid span { display: flex; justify-content: center; align-items: center; height: 16px; border-radius: 4px; }
.active-day { background: #FF3B30; color: white !important; font-weight: 700; border-radius: 50% !important; justify-self: center; align-self: center; }
.calendar-widget .active-day { width: 16px; height: 16px; margin: auto; }

/* Weather Widget */
.weather-widget {
    width: 355px; height: 170px;
    background: linear-gradient(to bottom, #4A90E2, #2B5B84);
    padding: 15px; display: flex; flex-direction: column; justify-content: space-between;
}
.weather-top { display: flex; justify-content: space-between; }
.weather-city { font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 4px; }
.weather-temp { font-size: 36px; font-weight: 400; margin-top: -5px; }
.weather-main-icon { font-size: 32px; }
.weather-alert { background: rgba(255, 149, 0, 0.2); border-left: 3px solid #FF9500; padding: 6px 10px; border-radius: 4px; font-size: 11px; font-weight: 500; }
.weather-forecast { display: flex; justify-content: space-between; margin-top: 5px; border-top: 1px solid rgba(255,255,255,0.2); padding-top: 10px; }
.forecast-item { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 12px; font-weight: 500; }

/* ============ FOLDERS ============ */
.desktop-folders {
    display: flex;
    flex-direction: row;
    gap: 15px;
    margin-top: 10px;
}
.folder { display: flex; flex-direction: column; align-items: center; gap: 5px; cursor: pointer; width: 95px; padding: 8px 4px; border-radius: 6px; border: 1px solid transparent; transition: background 0.1s; }
.folder.selected { background: rgba(0, 0, 0, 0.2); border: 1px solid rgba(255, 255, 255, 0.15); }
.folder-icon { width: 70px; height: 70px; object-fit: contain; filter: drop-shadow(0 3px 5px rgba(0,0,0,0.4)); }
.folder-name { color: white; font-size: 12px; text-align: center; text-shadow: 0 1px 3px rgba(0,0,0,0.8); font-weight: 500; padding: 2px 6px; border-radius: 4px; max-width: 100%; word-break: break-word; white-space: normal; line-height: 1.3; display: inline-block; }
.folder.selected .folder-name { background: #0058d0; }

.system-icon-desktop {
    width: 60px; height: 60px;
    margin: 0 auto 5px;
    object-fit: contain;
    border-radius: 14px;
    display: block;
}

.system-icon-dock {
    width: 55px; height: 55px;
    object-fit: contain;
    border-radius: 12px;
    transition: transform 0.2s cubic-bezier(0.2, 0, 0, 1.2);
}

.app-icon-black {
    width: 60px; height: 60px;
    margin: 0 auto 5px;
    object-fit: contain;
    background: #1c1c1e;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 14px;
    padding: 8px;
    box-sizing: border-box;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    display: block;
}

/* Desktop container */
.desktop-content { position:fixed; top:50px; left:20px; right:20px; bottom:100px; display:flex; justify-content:space-between; z-index:10; }

.dock-icon { width: 55px; height: 55px; object-fit: contain; filter: drop-shadow(0 5px 10px rgba(0,0,0,0.3)); }
.dock-icon-black {
    width: 55px; height: 55px;
    object-fit: contain;
    background: #1c1c1e;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 7px;
    box-sizing: border-box;
    filter: drop-shadow(0 2px 5px rgba(0,0,0,0.3));
    transition: transform 0.2s cubic-bezier(0.2, 0, 0, 1.2);
}
.dock-item:hover .dock-icon-black { transform: scale(1.2); filter: drop-shadow(0 4px 10px rgba(0,0,0,0.4)); }
.dock-item { position: relative; display: flex; justify-content: center; align-items: flex-start; transition: transform 0.2s cubic-bezier(0.2, 0.8, 0.2, 1); cursor: pointer; }
.dock-item:hover { transform: scale(1.35) translateY(-10px); z-index: 10; }
.dock-item::before { content: attr(data-title); position: absolute; top: -20px; color: white; font-size: 13px; font-weight: 600; white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity 0.15s, top 0.15s; text-shadow: 0 2px 4px rgba(0,0,0,0.8), 0 0 2px rgba(0,0,0,1); }
.dock-item:hover::before { opacity: 1; top: -32px; }
.dock-sep {
    width: 1px;
    height: 40px;
    background: rgba(0,0,0,0.15);
    box-shadow: 1px 0 0 rgba(255,255,255,0.3);
    margin: 0 6px;
}



/* ============ MOBILE RESPONSIVE ============ */
@media (max-width: 768px) {
    body { overflow-x: hidden; overflow-y: auto; }
    
    /* Menubar */
    .menubar-left .menu-text:not(.apple-logo):not(.bold) { display: none; }
    .status-icon { display: none; }
    
    /* Layout */
    .desktop-content { 
        position: relative; top: 35px; left: 0; right: 0; bottom: 0;
        padding: 15px; 
        padding-bottom: 140px; /* Ensure content is scrollable past dock */
        display: flex; flex-direction: column; gap: 20px;
    }
    
    /* Widgets Stacked */
    .left-column { width: 100%; display: flex; flex-direction: column; gap: 15px; align-items: stretch; padding-left: 8px; overflow: visible; }
    .widget-row { 
        display: flex; flex-direction: row; flex-wrap: wrap; 
        width: 100%; max-width: 360px; gap: 12px; margin: 0; 
    }
    .widget { padding: 14px; border-radius: 18px; }
    .weather-widget { width: 100% !important; max-width: 360px; height: auto; margin: 0; }
    .clock-widget, .calendar-widget { width: calc(50% - 6px) !important; aspect-ratio: 1 !important; min-height: unset; padding: 12px; }
    
    .clock-display { font-size: 44px !important; }
    .weather-temp { font-size: 34px !important; }
    .forecast-item span { font-size: 11px; }
    .calendar-widget .cal-header { font-size: 11px; margin-bottom: 4px; }
    .calendar-widget .cal-days-header { font-size: 9px; }
    .calendar-widget .cal-grid { font-size: 9px; gap: 2px; }
    .calendar-widget .cal-grid span { height: 16px; }
    .calendar-widget .active-day { width: 16px; height: 16px; font-size: 9px; line-height: 16px; }
    
    /* Folders Grid */
    .desktop-folders, .mobile-apps-grid, .desktop-files-right {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        gap: 15px;
        width: 100%;
        padding: 0;
        margin-top: 15px;
        position: static;
        align-items: start;
        justify-items: center;
    }
    .desktop-files-right {
        /* Padding removed as it is now handled by .desktop-content */
    }
    
    /* Windows (Pop-up on mobile) */
    .mac-window { 
        width: 90vw !important; 
        height: auto !important;
        max-height: 80vh !important;
        left: 5vw !important; 
        top: 10vh !important; 
        border-radius: 12px !important;
        border: 1px solid rgba(0,0,0,0.2) !important;
        box-shadow: 0 10px 30px rgba(0,0,0,0.3) !important;
    }
    .win-titlebar { border-radius: 12px 12px 0 0 !important; cursor: default; }
    .textedit { padding: 15px !important; border-radius: 0 !important; }
    .win-content-flex { flex-direction: column; }
    .finder-sidebar { display: none !important; }
    
    /* Notes App Mobile */
    #notes-sidebar { display: none !important; }
    #notes-list { width: 100% !important; border-right: none !important; border-bottom: 1px solid rgba(255,255,255,0.05); max-height: 140px; }
    #win-notes .win-body { flex-direction: column !important; }
    #notes-editor { padding: 20px !important; }
    
    .folder-grid { padding: 12px !important; gap: 12px !important; grid-template-columns: repeat(auto-fill, minmax(85px, 1fr)) !important; }
    

    
    .folder { width: 100%; } /* Fit grid */

    /* Dock */
    .dock-bar { bottom: 15px; }
    .dock-glass { 
        max-width: 95vw; 
        overflow-x: auto; 
        padding: 10px 14px; 
        gap: 10px;
        justify-content: center;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        border-radius: 24px;
        margin: 0 auto;
    }
    .dock-glass::-webkit-scrollbar { display: none; }
    .dock-glass .dev-tool { display: none; }
    .dock-glass .dock-sep { display: none; }
    .dock-icon, .social-icon { 
        width: 50px !important; 
        height: 50px !important; 
        border-radius: 12px !important;
    }
    .trash-icon-emoji {
        width: 50px !important; 
        height: 50px !important;
        font-size: 46px;
        line-height: 50px;
        margin-bottom: 0 !important;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .dock-sep { height: 30px; margin: 0 4px; }
    .dock-item:hover { transform: scale(1.05) translateY(-3px); }
    .dock-item:active { transform: scale(0.95); }
    .dock-item::before { display: none; } /* Hide tooltips on mobile */
}

/* Maximized Window State */
.mac-window.maximized {
    top: 25px !important;
    left: 0 !important;
    width: 100vw !important;
    height: calc(100vh - 25px) !important;
    border-radius: 0 !important;
    transform: none !important;
    transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
    z-index: 999 !important;
}

/* RTF Dark Mode Content */
.textedit-dark {
    background: #1e1e1e;
    color: #ddd;
    padding: 30px 40px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    font-size: 15px;
    line-height: 1.6;
    overflow-y: auto;
    overflow-x: hidden;
    word-break: break-word;
    flex: 1;
}

.skills-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 25px;
    margin-top: 20px;
}

@media (max-width: 768px) {
    .textedit-dark {
        padding: 20px !important;
        font-size: 14px;
    }
    .skills-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
}

/* Window Animations */
@keyframes windowOpen {
    0% { transform: scale(0.95); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}
@keyframes windowClose {
    0% { transform: scale(1); opacity: 1; }
    100% { transform: scale(0.95); opacity: 0; }
}
.mac-window.opening {
    animation: windowOpen 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.1) forwards;
}
.mac-window.closing {
    animation: windowClose 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

/* PORTFOLIO APP */
.portfolio-hero {
    position: relative;
    width: 100%;
    height: 480px;
    background: radial-gradient(circle at center, #ffffff 0%, #fef9e6 50%, #fbe8a6 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-bottom: 1px solid rgba(0,0,0,0.05);
}

.hero-bg-dots {
    position: absolute;
    inset: 0;
    background-image: radial-gradient(rgba(0,0,0,0.15) 1px, transparent 1px);
    background-size: 40px 40px;
    opacity: 0.7;
}

.hero-content {
    position: relative;
    text-align: center;
    z-index: 10;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.hero-subtitle {
    font-size: 20px;
    font-weight: 600;
    letter-spacing: 4px;
    color: #444;
    margin-bottom: -15px;
    font-family: 'Inter', sans-serif;
    text-transform: uppercase;
}

.hero-title {
    font-size: 120px;
    font-weight: 900;
    letter-spacing: -4px;
    color: #111;
    margin: 0;
    font-family: 'Inter', sans-serif;
    line-height: 1.1;
    background: linear-gradient(180deg, #111 0%, #333 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0px 4px 20px rgba(0,0,0,0.05));
}

.hero-badge {
    display: inline-block;
    padding: 10px 30px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 40px;
    font-weight: 700;
    font-size: 16px;
    color: #111;
    margin-top: 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.08), inset 0 0 0 1px rgba(255,255,255,1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

/* Floating Icons */
.float-icon {
    position: absolute;
    object-fit: contain;
    filter: drop-shadow(0 20px 40px rgba(0,0,0,0.2));
    animation: floatAnim 8s ease-in-out infinite;
    z-index: 5;
    border-radius: 16px;
}

.float-1 { top: 15%; left: 12%; --rot: -12deg; animation-delay: 0s; width: 75px; }
.float-2 { bottom: 18%; right: 15%; --rot: 12deg; animation-delay: -2s; width: 95px; }
.float-3 { bottom: 18%; left: 22%; --rot: 18deg; animation-delay: -4s; width: 85px; }
.float-4 { top: 20%; right: 18%; --rot: -20deg; animation-delay: -6s; width: 80px; }

@keyframes floatAnim {
    0%, 100% { transform: translateY(0) rotate(var(--rot)); }
    50% { transform: translateY(-25px) rotate(var(--rot)); }
}

/* PROJECTS SECTION */
.portfolio-projects {
    padding: 60px 40px;
    background: #f4f5f7;
    position: relative;
}

.section-title {
    font-size: 32px;
    font-weight: 800;
    margin-bottom: 40px;
    color: #111;
    font-family: 'Inter', sans-serif;
    text-align: center;
}

.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 40px;
    max-width: 1200px;
    margin: 0 auto;
}

.project-card {
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(25px) saturate(200%);
    -webkit-backdrop-filter: blur(25px) saturate(200%);
    border-radius: 24px;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0,0,0,0.06), inset 0 0 0 1px rgba(255,255,255,0.8);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    flex-direction: column;
}

.project-card:hover {
    transform: translateY(-12px) scale(1.02);
    box-shadow: 0 20px 50px rgba(0,0,0,0.12), inset 0 0 0 1px rgba(255,255,255,1);
}

.project-img-wrapper {
    height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    border-bottom: 1px solid rgba(0,0,0,0.03);
}

.project-logo {
    width: 90px;
    height: 90px;
    object-fit: contain;
    filter: drop-shadow(0 12px 24px rgba(0,0,0,0.15));
    z-index: 2;
    transition: transform 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.project-card:hover .project-logo {
    transform: scale(1.15);
}

.project-info {
    padding: 35px 30px;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.project-info h4 {
    margin: 0 0 15px 0;
    font-size: 24px;
    font-weight: 800;
    color: #111;
    font-family: 'Inter', sans-serif;
}

.project-info p {
    margin: 0 0 30px 0;
    font-size: 16px;
    color: #555;
    line-height: 1.6;
    flex: 1;
    font-family: 'Inter', sans-serif;
}

.btn-primary, .btn-secondary {
    padding: 14px 24px;
    border-radius: 12px;
    font-weight: 700;
    font-size: 15px;
    cursor: pointer;
    text-align: center;
    border: none;
    transition: all 0.25s ease;
    font-family: 'Inter', sans-serif;
    width: 100%;
}

.btn-primary {
    background: #111;
    color: white;
    box-shadow: 0 8px 20px rgba(0,0,0,0.15);
}

.btn-primary:hover {
    background: #000;
    transform: translateY(-2px);
    box-shadow: 0 12px 25px rgba(0,0,0,0.2);
}

.btn-secondary {
    background: #f2f2f7;
    color: #111;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
}

.btn-secondary:hover {
    background: #e5e5ea;
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(0,0,0,0.08);
}

/* Analog Clock Icon */
.analog-clock-icon {
    width: 55px; height: 55px;
    background: #222;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.15);
    box-shadow: 0 4px 10px rgba(0,0,0,0.3), inset 0 0 5px rgba(255,255,255,0.1);
    position: relative;
    display: flex; justify-content: center; align-items: center;
}
.clock-face {
    width: 46px; height: 46px;
    border-radius: 50%;
    border: 1px solid rgba(255,255,255,0.05);
    position: relative;
    background: #000;
}
.hand { position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 2;}
.hour-hand::after { content: ''; position: absolute; bottom: 50%; left: 50%; transform: translateX(-50%); width: 3.5px; height: 12px; background: #fff; border-radius: 4px; }
.min-hand::after { content: ''; position: absolute; bottom: 50%; left: 50%; transform: translateX(-50%); width: 2.5px; height: 18px; background: #fff; border-radius: 4px; }
.second-hand::after { content: ''; position: absolute; bottom: 35%; left: 50%; transform: translateX(-50%); width: 1.5px; height: 25px; background: #ff9500; border-radius: 2px; }
.clock-center { position: absolute; top: 50%; left: 50%; width: 4.5px; height: 4.5px; background: #ff9500; border-radius: 50%; transform: translate(-50%, -50%); z-index: 3;}

/* BENTO SCATTERED DESKTOP UI */
.portfolio-bento {
    position: relative;
    width: 100%;
    min-height: 850px;
    background: #f4f5f7;
    overflow: hidden;
}
.bento-bg-dots {
    position: absolute;
    inset: 0;
    background-image: radial-gradient(#d1d1d6 2px, transparent 2px);
    background-size: 40px 40px;
    opacity: 0.5;
}

/* Base Window Style for Bento Items */
.bento-window {
    position: absolute;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-radius: 20px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.06), inset 0 0 0 1px rgba(255,255,255,0.8);
    overflow: hidden;
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.4s ease;
    display: flex;
    flex-direction: column;
}
.bento-window:hover {
    transform: translateY(-8px) scale(1.02) !important;
    box-shadow: 0 20px 50px rgba(0,0,0,0.1), inset 0 0 0 1px rgba(255,255,255,1);
    z-index: 50 !important;
}
.b-win-header {
    height: 35px;
    background: rgba(255,255,255,0.5);
    border-bottom: 1px solid rgba(0,0,0,0.05);
    display: flex;
    align-items: center;
    padding: 0 15px;
    position: relative;
}
.b-win-dots {
    display: flex;
    gap: 6px;
}
.b-win-dots span {
    width: 10px; height: 10px; border-radius: 50%; display: inline-block;
}
.b-win-dots .r { background: #ff5f56; }
.b-win-dots .y { background: #ffbd2e; }
.b-win-dots .g { background: #27c93f; }
.b-win-title {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    font-size: 13px;
    font-weight: 600;
    color: #444;
}
.b-win-body {
    padding: 25px;
    flex: 1;
}

/* Notes (Biografia) */
.bento-notes {
    top: 50px;
    left: 10%;
    width: 400px;
    transform: rotate(-2deg);
    z-index: 10;
}
.bento-notes h3 { font-size: 20px; font-weight: 800; margin-top: 0; color: #111; }
.bento-notes p { font-size: 14px; line-height: 1.5; color: #555; }

/* Photo Booth (Foto) */
.bento-photo {
    top: 300px;
    left: 8%;
    width: 300px;
    transform: rotate(3deg);
    z-index: 12;
}
.bento-photo .b-win-body { padding: 0; }
.bento-photo img { width: 250px; height: 250px; object-fit: cover; display: block; border-radius: 50%; margin: 25px auto; box-shadow: 0 10px 20px rgba(0,0,0,0.15); }
.b-win-footer { height: 60px; display: flex; justify-content: center; align-items: center; background: #fff;}
.b-shutter-btn { width: 40px; height: 40px; border-radius: 50%; background: #ff3b30; border: 3px solid #fff; box-shadow: 0 0 0 1px #ddd; cursor: pointer; transition: transform 0.2s;}
.b-shutter-btn:hover { transform: scale(0.9); }

/* Mail/Calendar (Formazione) */
.bento-edu {
    top: 80px;
    right: 12%;
    width: 380px;
    transform: rotate(1deg);
    z-index: 11;
}
.edu-item { margin-bottom: 20px; }
.edu-date { font-size: 11px; font-weight: 700; color: #888; margin-bottom: 5px; }
.edu-card { padding: 15px; border-radius: 12px; background: rgba(0,0,0,0.03); border-left: 4px solid #000; }
.edu-card.blue { border-left-color: #007aff; background: rgba(0, 122, 255, 0.05); }
.edu-card.green { border-left-color: #34c759; background: rgba(52, 199, 89, 0.05); }
.edu-card h4 { margin: 0 0 5px 0; font-size: 16px; color: #111; }
.edu-card p { margin: 0; font-size: 13px; color: #555; line-height: 1.4;}

/* Finder (Competenze) */
.bento-skills {
    top: 480px;
    right: 18%;
    width: 350px;
    transform: rotate(-1deg);
    z-index: 13;
}
.finder-grid-bento {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    justify-items: center;
}
.b-icon-file {
    display: flex; flex-direction: column; align-items: center; gap: 5px; cursor: pointer; transition: transform 0.2s;
}
.b-icon-file:hover { transform: scale(1.1); }
.b-icon-file img { width: 45px; height: 45px; object-fit: contain; }
.b-icon-file span { font-size: 11px; font-weight: 500; color: #333; }

/* Contatti Popup */
.bento-contact {
    top: 400px;
    left: 45%;
    width: 300px;
    transform: translateX(-50%) rotate(0deg);
    z-index: 15;
}
.contact-item { font-size: 13px; color: #333; margin-bottom: 8px; font-weight: 500; }

/* Mini Dock */
.bento-dock-container {
    position: absolute;
    bottom: 50px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 20;
}
.bento-dock-label {
    background: rgba(255,255,255,0.8);
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    color: #444;
    margin-bottom: 10px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
}
.bento-dock {
    display: flex;
    gap: 15px;
    background: rgba(255,255,255,0.6);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 12px 20px;
    border-radius: 24px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1), inset 0 0 0 1px rgba(255,255,255,0.8);
}
.bento-dock-icon {
    width: 45px; height: 45px;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    cursor: pointer;
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.1));
}
.bento-dock-icon:hover { transform: scale(1.3) translateY(-10px); }

/* ANIMATIONS */
.fade-up {
    opacity: 0;
    transform: translateY(50px) rotate(var(--rot, 0deg));
    transition: opacity 0.8s ease, transform 0.8s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.fade-up.visible {
    opacity: 1;
    /* Restore the original rotation logic via nth-child or specific classes. 
       We use a trick: we set --rot in inline style or redefine classes */
}
.bento-notes.visible { transform: translateY(0) rotate(-2deg); }
.bento-photo.visible { transform: translateY(0) rotate(3deg); }
.bento-edu.visible { transform: translateY(0) rotate(1deg); }
.bento-skills.visible { transform: translateY(0) rotate(-1deg); }
.bento-contact.visible { transform: translateX(-50%) translateY(0) rotate(0deg); }
.bento-dock-container.visible { transform: translateX(-50%) translateY(0); }

/* Floating animation overlay */
@keyframes bentoFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}
.bento-window.visible { animation: bentoFloat 8s ease-in-out infinite; }
.bento-window:hover { animation-play-state: paused; }
.delay-1 { transition-delay: 0.1s; animation-delay: 0s; }
.delay-2 { transition-delay: 0.2s; animation-delay: -1.5s; }
.delay-3 { transition-delay: 0.3s; animation-delay: -3s; }
.delay-4 { transition-delay: 0.4s; animation-delay: -4.5s; }
.delay-5 { transition-delay: 0.5s; animation-delay: -6s; }
.delay-6 { transition-delay: 0.6s; animation-delay: -7.5s; }

/* Mobile Adjustments */
@media (max-width: 900px) {
    .portfolio-bento { display: flex; flex-direction: column; align-items: center; min-height: auto; padding: 40px 20px; gap: 30px;}
    .bento-window { position: relative; top: auto !important; left: auto !important; right: auto !important; transform: none !important; width: 100% !important; max-width: 400px; animation: none !important;}
    .bento-contact { transform: none !important; }
    .bento-dock-container { position: relative; bottom: auto; left: auto; transform: none !important; margin-top: 20px;}
    .bento-notes.visible, .bento-photo.visible, .bento-edu.visible, .bento-skills.visible, .bento-contact.visible, .bento-dock-container.visible { transform: translateY(0) !important; }
}

/* HERO DESKTOP SECTION */
#desktop-hero {
    position: relative;
    width: 100%;
    height: 100vh;
    z-index: 5;
    /* ensure desktop items are clipped if needed, but not necessarily */
}

/* PORTFOLIO SCROLLABLE CONTENT */
#portfolio-scrollable-content {
    position: relative;
    width: 100%;
    z-index: 10;
    background: transparent;
    padding-bottom: 100px; /* buffer at bottom */
}

/* Fix bento container */
.portfolio-bento {
    background: transparent !important; /* use the OS wallpaper */
}
.bento-bg-dots {
    display: none; /* remove dots, let wallpaper show through, or keep if preferred? I'll keep them but faint */
}
.bento-bg-dots {
    display: block;
    background-image: radial-gradient(rgba(255,255,255,0.2) 2px, transparent 2px) !important;
}

/* Adjust projects section */
.portfolio-projects {
    padding: 50px;
    max-width: 1200px;
    margin: 0 auto;
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(30px);
    border-radius: 30px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
    margin-top: 50px;
    border: 1px solid rgba(255,255,255,0.1);
}
.portfolio-projects h3 {
    color: #fff;
}
.project-info {
    color: #eee;
}

/* SCROLL INDICATOR */
.scroll-indicator {
    position: absolute;
    bottom: 90px; /* above dock */
    left: 50%;
    transform: translateX(-50%);
    color: #fff;
    font-size: 24px;
    z-index: 9;
    animation: bounce 2s infinite;
    cursor: pointer;
    text-shadow: 0 2px 10px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
    align-items: center;
}
.scroll-indicator span {
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 2px;
    opacity: 0.8;
}
@keyframes bounce {
    0%, 20%, 50%, 80%, 100% { transform: translateY(0) translateX(-50%); }
    40% { transform: translateY(-15px) translateX(-50%); }
    60% { transform: translateY(-7px) translateX(-50%); }
}

/* iPhone 17 Mockup */
.bento-social {
    top: 150px;
    left: 70%;
    width: 250px;
    height: 520px;
    transform: rotate(2deg);
    z-index: 14;
    background: transparent !important;
    box-shadow: none !important;
    border: none !important;
}
.iphone-17-mockup {
    position: relative;
    width: 100%;
    height: 100%;
    border-radius: 40px;
    background: #000;
    box-shadow: 
        0 0 0 8px #1c1c1e,
        0 0 0 10px #333,
        0 20px 50px rgba(0,0,0,0.5);
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.iphone-17-mockup:hover {
    transform: scale(1.03) translateY(-10px);
}
.iphone-17-mockup img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: 32px;
}
/* Dynamic Island */
.iphone-notch {
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    width: 85px;
    height: 25px;
    background: #000;
    border-radius: 20px;
    z-index: 5;
    box-shadow: inset 0 0 2px rgba(255,255,255,0.1);
}
/* Home Bar */
.iphone-home-bar {
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 100px;
    height: 4px;
    background: #fff;
    border-radius: 4px;
    z-index: 5;
    opacity: 0.8;
}
.bento-social.visible { transform: translateY(0) rotate(2deg); }

/* Mobile Adjustments for social */
@media (max-width: 900px) {
    .bento-social {
        transform: none !important;
        left: auto !important;
        margin: 20px 0;
    }
}
