:root {
  --main-color: #3498db;
  --font-size-lg: 1.5rem;
  --font-family-primary: 'SF Pro Regular', sans-serif;
  --font-family-secondary: 'Franklin Gothic';
  --font-family-tertiary: 'Helvetica Neue Thin'
}

@font-face {
    font-family: "SF Pro Regular";
    src: url("./assets/SFProRegular.otf") format('truetype');
}

@font-face {
    font-family: "Franklin Gothic";
    src: url("./assets/FranklinGothic.ttf") format('truetype');
}

@font-face {
    font-family: "Helvetica Neue Thin";
    src: url("./assets/HelveticaNeue-Thin.otf") format('opentype');
}

body,
html {
    font-family: var(--font-family-primary);
    background: url("assets/bliss.jpg") no-repeat center center fixed;
    background-size: cover; /* Zoom to cover entire area, keeping aspect ratio */
    background-position: center center; /* Center the image */
    background-repeat: no-repeat; /* No tiling */
    margin: 0;
    padding: 0;
    height: 100%;
    overflow: hidden;
}

* {
    box-sizing: border-box;
}

#desktop {
    position: relative;
    width: 100%;
    height: 100vh;
    background-image:
        radial-gradient(
            circle at 20% 80%,
            rgba(120, 200, 120, 0.3) 0%,
            transparent 50%
        ),
        radial-gradient(
            circle at 80% 20%,
            rgba(255, 255, 255, 0.2) 0%,
            transparent 50%
        );
}

.icon {
    position: absolute;
    width: 90px;
    text-align: center;
    color: white;
    cursor: pointer;
    padding: 10px;
    border-radius: 4px;
    transition: top 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94), 
                left 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94), 
                background 0.2s ease,
                transform 0.2s ease;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
    backface-visibility: hidden;
    will-change: transform, top, left;
    transform: translateZ(0);
}

.icon:hover,
.icon.selecting {
    background: rgba(255, 255, 255, 0.2);
    /* transform: translateY(-2px); */
    box-shadow: 0 4px 12px rgba(255, 255, 255, 0.1);
}

/* Active state for better feedback */
.icon:active {
    /* Just change background slightly for click feedback */
    background: rgba(255, 255, 255, 0.3);
    /* Keep the hover transform instead of shrinking */
    /* transform: translateY(-2px); */
}

/* Smooth transitions for dragging state */
.icon.dragging {
    transition: background 0.2s ease;
    z-index: 1000;
    /* Remove the scale effect during dragging too */
    /* transform: scale(1.05); */
}

.icon img {
    width: 56px;
    height: 56px;
    margin-bottom: 4px;
    filter: drop-shadow(1px 1px 2px rgba(0, 0, 0, 0.5));
    /* Smooth image transitions */
    transition: filter 0.2s ease;
}

.icon:hover img {
    filter: drop-shadow(1px 1px 2px rgba(0, 0, 0, 0.5)) 
            drop-shadow(0 0 8px rgba(255, 255, 255, 0.2));
}

.icon span {
    display: block;
    font-size: .9rem;
    font-weight: bold;
    /* Add transition for text shadow */
    transition: text-shadow 0.2s ease;
}

.icon:hover span {
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8), 
                 0 0 4px rgba(255, 255, 255, 0.3);
}

/* Responsive adjustments for mobile */
@media (max-width: 768px) {
    .icon {
        transition: top 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94), 
                    left 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94), 
                    background 0.2s ease,
                    transform 0.2s ease;
        min-height: 100px;
        width: 85px;
        padding: 8px;
    }
    
    .icon img {
        width: 52px;
        height: 52px;
    }
    
    .icon span {
        font-size: 0.85rem;
    }
    
    .icon:hover {
        transform: none;
        box-shadow: none;
    }
    
    /* Update mobile active state to not shrink */
    .icon:active {
        background: rgba(255, 255, 255, 0.3);
        /* Remove the scaling effect */
        /* transform: scale(0.95); */
    }
}

/* Smooth desktop icon grid container */
#desktop-icons {
    position: relative;
    width: 100%;
    height: 100%;
    /* Ensure smooth rendering */
    transform: translateZ(0);
}

/* Animation for real-time resize transitions */
@media (prefers-reduced-motion: no-preference) {
    .icon {
        /* Faster transitions optimized for real-time resizing */
        transition: top 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94), 
                    left 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94), 
                    background 0.2s ease,
                    transform 0.2s ease;
    }
    
    /* Smooth transition during orientation changes (slightly longer) */
    .icon.orientation-changing {
        transition: top 0.5s cubic-bezier(0.34, 1.56, 0.64, 1), 
                    left 0.5s cubic-bezier(0.34, 1.56, 0.64, 1), 
                    background 0.2s ease,
                    transform 0.2s ease;
    }
}

/* Respect user preference for reduced motion */
@media (prefers-reduced-motion: reduce) {
    .icon {
        transition: background 0.2s ease;
    }
    
    .icon:hover,
    .icon:active {
        transform: none;
    }
}

/* High contrast mode adjustments */
@media (prefers-contrast: high) {
    .icon:hover,
    .icon.selecting {
        background: rgba(255, 255, 255, 0.4);
        border: 2px solid white;
    }
}

.window {
    /* align-items: stretch; */
    display: flex;
    flex-direction: column;
    resize: none;
    overflow: hidden;
    display: none;
    position: absolute;
    top: 100px;
    left: 100px;
    /* min-height: 30px; */
    min-width: 400px;
    height: auto;
    background: #f0f0f0;
    border: 1px solid #0054e3;
    box-shadow: 2px 2px 8px rgba(0, 0, 0, 0.3);
    z-index: 1000;
}

.resize-handle {
    position: absolute;
    z-index: 10;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

/* Corner handles (larger, easier to grab) */
.resize-nw, .resize-ne, .resize-sw, .resize-se {
    width: 10px;
    height: 10px;
}

/* Edge handles */
.resize-n, .resize-s {
    height: 4px;
    left: 10px;
    right: 10px;
}

.resize-e, .resize-w {
    width: 4px;
    top: 10px;
    bottom: 10px;
}

/* Position each handle */
.resize-nw {
    top: -5px;
    left: -5px;
    cursor: nw-resize;
}

.resize-n {
    top: -2px;
    cursor: n-resize;
}

.resize-ne {
    top: -5px;
    right: -5px;
    cursor: ne-resize;
}

.resize-e {
    right: -2px;
    cursor: e-resize;
}

.resize-se {
    bottom: -5px;
    right: -5px;
    cursor: se-resize;
}

.resize-s {
    bottom: -2px;
    cursor: s-resize;
}

.resize-sw {
    bottom: -5px;
    left: -5px;
    cursor: sw-resize;
}

.resize-w {
    left: -2px;
    cursor: w-resize;
}

/* Visual feedback on hover (debug) */
/* .resize-handle:hover {
    background-color: rgba(0, 120, 212, 0.3);
} */

/* Corner handles get rounded corners for better visual */
.resize-nw, .resize-ne, .resize-sw, .resize-se {
    border-radius: 2px;
}

/* Enhanced window styles to work better with resize handles and content constraints */
.window {
    /* Add a subtle border to make resize area more visible */
    box-shadow: 
        2px 2px 8px rgba(0, 0, 0, 0.3),
        0 0 0 1px rgba(0, 0, 0, 0.1);
    
    /* Ensure minimum sizes (these will be overridden by dynamic calculations) */
    min-width: 300px;
    min-height: 150px;
}

:root {
  --window-padding: 16px; /* Adjust this value to your preference */
  --button-margin-bottom: 16px; /* Same as window padding for consistency */
}

/* Ensure content doesn't get crushed during resize */
.window-body,
.window-body-contact {
    min-height: 60px; /* Minimum content area height */
    overflow-y: auto; /* Add scroll if content is too tall */
    box-sizing: border-box;
}

/* Ensure header has minimum space for text and buttons */
.window-header {
    min-height: 30px;
    flex-shrink: 0; /* Prevent header from shrinking */
    white-space: nowrap;
    overflow: hidden;
}

/* Ensure buttons in header don't get crushed */
.window-header button {
    flex-shrink: 0;
    min-width: 20px;
    min-height: 18px;
}

/* Contact window specific constraints */
.window-body-contact {
    min-height: 120px; /* Ensure contact icons have space */
}

.contact-icon {
    min-width: 80px; /* Prevent contact icons from getting too small */
}

/* Prevent scrolling text from breaking layout */
.scrolling-text-parent {
    flex-shrink: 0;
    min-height: 30px;
}

/* Mobile-specific adjustments */
@media (max-width: 768px) {
    /* Make handles larger on mobile for easier touch interaction */
    .resize-nw, .resize-ne, .resize-sw, .resize-se {
        width: 15px;
        height: 15px;
    }
    
    .resize-n, .resize-s {
        height: 8px;
    }
    
    .resize-e, .resize-w {
        width: 8px;
    }
    
    /* Adjust positioning for larger handles */
    .resize-nw {
        top: -7px;
        left: -7px;
    }
    
    .resize-ne {
        top: -7px;
        right: -7px;
    }
    
    .resize-se {
        bottom: -7px;
        right: -7px;
    }
    
    .resize-sw {
        bottom: -7px;
        left: -7px;
    }
    
    .resize-n {
        top: -4px;
    }
    
    .resize-s {
        bottom: -4px;
    }
    
    .resize-e {
        right: -4px;
    }
    
    .resize-w {
        left: -4px;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .resize-handle:hover {
        background-color: rgba(255, 255, 255, 0.8);
        border: 1px solid #000;
    }
}

/* Smooth transitions for resize operations */
.window.resizing {
    transition: none;
}

/* Ensure resize handles don't interfere with window content */
.window-header,
.window-body,
.window-body-contact {
    position: relative;
    z-index: 1;
}

/* Optional: Add visual indicators for resize areas */
.window:hover .resize-handle {
    opacity: 0.7;
}

.resize-handle {
    opacity: 0;
    transition: opacity 0.2s ease;
}

/* Show handles when window is focused or hovered */
.window:hover .resize-handle,
.window:focus-within .resize-handle {
    opacity: 1;
}

.window-header {
    user-select: none;
    background: #1f1fcd;
    color: white;
    padding: 6px 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: move;
    font-size: 13px;
    font-weight: bold;
}

.window-header button {
    font-family: var(--font-family-primary);
    background: #eae9e7;
    border: 2px outset #c0c0c0;
    color: black;
    width: 20px;
    height: 18px;
    cursor: pointer;
    font-size: 12px;
    /* font-weight: bold; */
    display: flex;
    align-items: center;
    justify-content: center;
}

.window-header button:active {
    border: 1px inset #c0c0c0;
}

.window-body {
    flex: 1;
    overflow-y: hidden;
    padding: var(--window-padding);
    background: #f0f0f0;
    /* Remove the old padding declaration */
    /* padding: 12px 16px; - REMOVE THIS LINE */
}

.window-buttons {
    font-family: var(--font-family-primary);
    border: 2px outset #fff;
    color: black;
    cursor: pointer;
    font-size: 1rem;
    padding: 2px 15px;
    margin-right: 8px; /* Space between buttons */
    margin-bottom: 0; /* Remove bottom margin that might be causing issues */
    user-select: none;
    background-color: #fafafa;
}

.window-buttons:active {
    border: 2px inset #fff;
}

.window-buttons:last-child {
    margin-right: 0; /* Remove margin from last button */
}

.window-buttons:active {
    border: 2px inset #fff;
}

#taskbar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #ccc;
    display: flex;
    align-items: center;
    color: white;
    z-index: 2000;
    border: 2px outset #fff;
    /* padding: 1px 0; */
}

#start-button {
    border: 3px outset #fff;
    color: black;
    cursor: pointer;
    font-weight: bold;
    display: flex;
    align-items: center;
    font-size: 1rem;
    padding: 3px;
    margin-left: 2px;
    /* margin: 1px 0; */
    user-select: none;
}

#start-button img {
    width: 20px;
    margin-right: 3px;
}

#start-button:active {
    border: 2px inset #fff;
}

#taskbar-right {
    margin-left: auto;
    display: flex;
    align-items: center;
}

#clock {
    font-size: 0.85rem;
    color: black;
    text-align: center;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 8px;
    border: 2px inset #fff;
}

#left-bar {
    /* height: 100%; */
    background: #84878C;
    width: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

#left-bar-text-container {
    writing-mode: vertical-rl;
    transform: rotate(180deg); /* Text bottom to top */
    color: #ccc;
    font-family: var(--font-family-secondary);
    font-size: 1.5rem;
    text-align: center;
    min-height: 95px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#left-bar-text {
    position: absolute;
    transform: rotate(270deg);
    font-family: var(--font-family-secondary);
    color: #C0C0C0;
    /* font-size: 10rem; */
    display: inline;
    width: 100px;
}

.logo-secondary-font {
    color: white;
    font-family: var(--font-family-tertiary);
}

#start-menu {
    display: none;
    position: fixed;
    bottom: 45px;
    /* top: 780px; THIS IS HARD CODED!!!!!! */
    left: 0;
    width: 300px;
    /* min-height: 200px; */
    background: #fafafa;
    border: 3px outset #c0c0c0;
    box-shadow: 3px 3px 8px rgba(0, 0, 0, 0.3);
    font-size: 0.75rem;
    z-index: 2001;
    flex-direction: row;
    user-select: none;
}

#start-menu-items {
    flex: 1;
    display: grid;
    grid-auto-rows: 1fr;
    overflow-x: hidden;
}

.start-menu-item {
    cursor: pointer;
    color: black;
    display: flex;
    align-items: center;
    padding: 6px 8px;
    overflow-x: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.start-menu-item-text {
    overflow-x: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.start-menu-item img {
    width: 20px;
    height: 20px;
    display: inline-block;
    margin-right: 8px;
}

.start-menu-item:hover {
    background: #316ac5;
    color: white;
}

/* Contact icon styles */
.window-body-contact {
    display: flex;
    padding: var(--window-padding); /* Use consistent padding */
    background: #f0f0f0;
    flex-direction: row;
    justify-content: space-around;
    align-items: center;
    /* Remove the old padding declaration */
    /* padding: 20px; - REMOVE THIS LINE */
}

.button-group {
    margin-top: 12px; /* Space between text and buttons */
    margin-bottom: 0; /* Remove any bottom margin */
    padding-bottom: 0; /* Remove any bottom padding */
}

.contact-icon {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    cursor: pointer;
    padding: 15px;
    border-radius: 8px;
    transition: background 0.2s;
    flex: 1;
    max-width: 100px;
}

.contact-icon:hover {
    background: rgba(0, 120, 212, 0.1);
}

.contact-icon img {
    width: 48px;
    height: 48px;
    margin-bottom: 8px;
    filter: drop-shadow(1px 1px 2px rgba(0, 0, 0, 0.3));
}

.contact-icon span {
    font-size: 12px;
    font-weight: bold;
    color: #333;
}

.scrolling-text-parent {
    overflow: hidden;
    margin-bottom: -0.5rem;
}

.scrolling-text {
    overflow: hidden;
    white-space: nowrap;
    background: #f0f0f0;
    border-top: 1px solid #ccc;
    margin: 0;
    padding: 0;
}

.scrolling-track {
    display: inline-flex;
    animation: scroll-left 40s linear infinite;
}

.scrolling-track span {
    display: inline-block;
    color: #333;
    font-size: 12px;
    font-family: var(--font-family-primary);
    padding-right: 0rem;
}

@keyframes scroll-left {
    0% {
        transform: translateX(0);
    }
    100% {
        transform: translateX(-50%);
    }
}

/* Synchronized RGB Wave Effect for Rainbow Window */

/* Single keyframe animation that all elements will share */
@keyframes synced-rgb-wave {
  0% { 
    background-position: 0% 50%;
    filter: hue-rotate(0deg) brightness(1.1);
  }
  25% {
    background-position: 75% 50%;
    filter: hue-rotate(90deg) brightness(1.2);
  }
  50% {
    background-position: 150% 50%;
    filter: hue-rotate(180deg) brightness(1.3);
  }
  75% {
    background-position: 225% 50%;
    filter: hue-rotate(270deg) brightness(1.2);
  }
  100% { 
    background-position: 300% 50%;
    filter: hue-rotate(360deg) brightness(1.1);
  }
}

/* Header uses the shared animation */
.rainbow-window .window-header {
  background: linear-gradient(90deg, 
    hsl(0, 100%, 50%),    /* Red */
    hsl(60, 100%, 50%),   /* Yellow */
    hsl(120, 100%, 50%),  /* Green */
    hsl(180, 100%, 50%),  /* Cyan */
    hsl(240, 100%, 50%),  /* Blue */
    hsl(300, 100%, 50%),  /* Magenta */
    hsl(360, 100%, 50%)   /* Red again */
  );
  background-size: 300% 100%;
  animation: synced-rgb-wave 4s linear infinite;
  color: white;
  text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
  font-weight: bold;
}

/* Border uses the same shared animation */
.rainbow-window {
  border: 1px solid;
  border-image: linear-gradient(90deg,
    hsl(0, 100%, 50%),
    hsl(60, 100%, 50%),
    hsl(120, 100%, 50%),
    hsl(180, 100%, 50%),
    hsl(240, 100%, 50%),
    hsl(300, 100%, 50%),
    hsl(360, 100%, 50%)
  ) 1;
  animation: synced-rgb-wave 4s linear infinite;
  box-shadow: 0 0 20px rgba(255, 255, 255, 0.3);
}

/* Buttons also use the shared animation with a gradient background */
.rainbow-window .window-buttons {
  background: linear-gradient(90deg, 
    hsl(240, 100%, 60%), 
    hsl(300, 100%, 60%),
    hsl(0, 100%, 60%),
    hsl(60, 100%, 60%),
    hsl(120, 100%, 60%),
    hsl(180, 100%, 60%),
    hsl(240, 100%, 60%)
  );
  background-size: 300% 100%;
  animation: synced-rgb-wave 4s linear infinite;
  border: 2px solid rgba(255, 255, 255, 0.3);
  color: white;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.6);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.rainbow-window .window-buttons:hover {
  transform: translateY(-1px);
  box-shadow: 0 5px 15px rgba(0, 255, 255, 0.4);
  /* Keep the same animation running on hover */
}

/* Optional: Synchronized glow effect */
.rainbow-window::before {
  content: '';
  position: absolute;
  top: -5px;
  left: -5px;
  right: -5px;
  bottom: -5px;
  background: linear-gradient(90deg,
    hsl(0, 100%, 50%),
    hsl(120, 100%, 50%),
    hsl(240, 100%, 50%),
    hsl(0, 100%, 50%)
  );
  background-size: 300% 100%;
  border-radius: inherit;
  z-index: -1;
  animation: synced-rgb-wave 4s linear infinite;
  opacity: 0.7;
  filter: blur(8px);
}

/* Alternative: Ultra-smooth synchronized version */
.rainbow-window.ultra-smooth .window-header,
.rainbow-window.ultra-smooth,
.rainbow-window.ultra-smooth .window-buttons,
.rainbow-window.ultra-smooth::before {
  background: linear-gradient(90deg, 
    #ff0000, #ff4000, #ff8000, #ffbf00, #ffff00,
    #bfff00, #80ff00, #40ff00, #00ff00, #00ff40,
    #00ff80, #00ffbf, #00ffff, #00bfff, #0080ff,
    #0040ff, #0000ff, #4000ff, #8000ff, #bf00ff,
    #ff00ff, #ff00bf, #ff0080, #ff0040, #ff0000
  );
  background-size: 500% 100%;
  animation: ultra-smooth-synced-wave 6s linear infinite;
}

@keyframes ultra-smooth-synced-wave {
  0% { 
    background-position: 0% 50%; 
    filter: hue-rotate(0deg) brightness(1.1);
  }
  25% {
    background-position: 125% 50%;
    filter: hue-rotate(90deg) brightness(1.2);
  }
  50% {
    background-position: 250% 50%;
    filter: hue-rotate(180deg) brightness(1.3);
  }
  75% {
    background-position: 375% 50%;
    filter: hue-rotate(270deg) brightness(1.2);
  }
  100% { 
    background-position: 500% 50%; 
    filter: hue-rotate(360deg) brightness(1.1);
  }
}