:root {
    --iphone-width: 375px;
    --iphone-height: 812px;
    --screen-bezel: 12px;
    --screen-border-radius: 40px;

    /* Liquid Glass Effect Variables */
    --glass-blur: 30px;
    --glass-bg-color: rgba(255, 255, 255, 0.1);
    --glass-border-color: rgba(255, 255, 255, 0.2);
    --liquid-animation: liquid-flow 15s ease-in-out infinite;
}

@keyframes liquid-flow {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

body {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background-color: #e0e0e0;
    font-family: 'Inter', sans-serif;
    -webkit-font-smoothing: antialiased;
    margin: 0;
    padding: 20px;
    box-sizing: border-box;
    transition: background-color 0.3s ease;
}

#iphone {
    position: relative;
    width: var(--iphone-width);
    height: var(--iphone-height);
    transform: scale(0.95);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

@media (min-height: 900px) and (min-width: 500px) {
    #iphone {
        transform: scale(1);
    }
}

.iphone-bezel {
    width: 100%;
    height: 100%;
    background: #000;
    border-radius: 50px;
    padding: var(--screen-bezel);
    box-sizing: border-box;
    box-shadow: 0px 0px 0px 4px #111, 0px 20px 40px rgba(0,0,0,0.5);
}

#screen {
    position: relative;
    width: 100%;
    height: 100%;
    background-image: url('/IMG_1512.webp');
    background-size: cover;
    background-position: center;
    border-radius: var(--screen-border-radius);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

#screen.broken-state {
    /* Apply heavy visual degradation to the entire screen */
    filter: saturate(0.2) hue-rotate(180deg) contrast(1.5);
    background-image: none !important; /* Remove wallpaper visual identity */
    background-color: #333 !important; /* Dark, grey base */
}

/* We need to ensure the app icons themselves look broken when the screen is broken */
#screen.broken-state .app-icon img {
    filter: brightness(0.5) contrast(2) sepia(1) hue-rotate(270deg);
    border: 2px dashed #ff453a;
    opacity: 0.6;
    animation: glitch 0.5s infinite alternate steps(2);
}

#screen.broken-state .app-icon span {
    color: #ff453a; /* Red text for error */
    text-shadow: 0 0 5px rgba(255, 0, 0, 0.7);
}

@keyframes glitch {
    0% { transform: translate(1px, 1px); }
    50% { transform: translate(-1px, -1px); }
    100% { transform: translate(0, 0); }
}

/* Optional: Add a static/scanline overlay to the broken screen */
#screen.broken-state::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        0deg, 
        rgba(0, 0, 0, 0.1), 
        rgba(0, 0, 0, 0.1) 1px, 
        transparent 1px, 
        transparent 3px
    ),
    repeating-linear-gradient(
        90deg, 
        rgba(255, 0, 0, 0.05), 
        rgba(0, 255, 255, 0.05) 50%
    );
    pointer-events: none;
    mix-blend-mode: overlay;
    opacity: 0.7;
    animation: static-shift 0.5s infinite linear; /* Faster shift for more distress */
}

@keyframes static-shift {
    0% { background-position: 0 0; }
    100% { background-position: 500px 500px; } /* Larger shift for visible motion */
}

#iphone-notch {
    position: absolute;
    top: var(--screen-bezel);
    left: 50%;
    transform: translateX(-50%);
    width: 180px;
    height: 30px;
    background: #000;
    border-bottom-left-radius: 20px;
    border-bottom-right-radius: 20px;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
}

#iphone-notch .speaker {
    width: 60px;
    height: 6px;
    background: #1c1c1c;
    border-radius: 3px;
}

#iphone-notch .camera {
    width: 10px;
    height: 10px;
    background: #151525;
    border-radius: 50%;
    border: 1px solid #252535;
}

#screen.broken-state #status-bar {
    color: #ff453a;
    text-shadow: 0 0 5px rgba(255, 0, 0, 0.5);
}

#screen.broken-state #status-bar img {
    filter: invert(1) hue-rotate(180deg) saturate(3);
}

#status-bar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 44px;
    padding: 0 24px;
    color: white;
    font-weight: 500;
    font-size: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 5;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.3);
}

#status-icons {
    display: flex;
    align-items: center;
    gap: 5px;
}

#status-icons img {
    height: 14px;
}

#battery-percentage {
    font-size: 14px;
    font-weight: 500;
}

#status-icons img.hidden {
    display: none;
}

.app-view {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0s 0.3s, transform 0.35s cubic-bezier(0.45, 0, 0.55, 1);
    transform: translateX(100%);
    flex-direction: column;
    background-color: #f0f0f0;
    display: flex;
}

.app-view.active {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
    z-index: 2;
    transition: opacity 0.3s ease, transform 0.35s cubic-bezier(0.45, 0, 0.55, 1);
}

.app-view.hiding-left {
    z-index: 1;
    opacity: 1;
    visibility: visible;
    transform: translateX(-30%);
    transition: opacity 0.3s ease, transform 0.35s cubic-bezier(0.45, 0, 0.55, 1);
}

#home-screen {
    background-color: transparent;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    overflow: hidden;
}

#app-grid-container {
    display: flex;
    width: 200%;
    height: 100%;
    transition: transform 0.4s cubic-bezier(0.45, 0, 0.55, 1);
}

.page {
    width: 50%;
    flex-shrink: 0;
}

#app-grid, #app-grid-2 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    padding: 20px;
    padding-top: 50px;
    box-sizing: border-box;
}

#pagination-dots {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    height: 20px;
    position: absolute;
    bottom: 45px;
    width: 100%;
    z-index: 4;
}

#pagination-dots.hidden {
    display: none;
}

#pagination-dots .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.5);
    transition: background-color 0.3s, transform 0.3s;
    cursor: pointer;
}

#pagination-dots .dot.active {
    background-color: white;
    transform: scale(1.1);
}

.app-icon {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    text-decoration: none;
    gap: 6px;
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
    color: white;
    font-size: 12px;
}

.app-icon img {
    width: 60px;
    height: 60px;
    border-radius: 15px;
    box-shadow: 0 5px 10px rgba(0,0,0,0.1), 
                inset 0 1px 1px rgba(255,255,255,0.2), 
                inset 0 -1px 1px rgba(0,0,0,0.1);
    transition: transform 0.2s ease;
    position: relative; /* For pseudo-element */
    overflow: hidden; /* To contain gloss */
}

.app-icon img::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.2) 0%, rgba(255,255,255,0) 60%);
    transform: rotate(45deg) translateY(-40%);
    opacity: 0.5;
}

.app-icon:active img {
    transform: scale(0.9);
}

.app-icon span {
    text-shadow: 1px 1px 2px rgba(0,0,0,0.3);
}

#home-button-wrapper {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 40px;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
}

#home-button {
    width: 135px;
    height: 5px;
    background-color: rgba(255, 255, 255, 0.5);
    border-radius: 2.5px;
    cursor: pointer;
    transition: background-color 0.2s;
}

#home-button:hover {
    background-color: white;
}

/* App Specific Styles */
/* Note: App-specific styles have been moved to their own CSS files (e.g., settings.css, weather.css) */
.app-header {
    background-color: #fafafa;
    padding: 12px 20px;
    font-size: 17px;
    font-weight: 600;
    text-align: center;
    border-bottom: 1px solid #ddd;
    color: #888;
}

.placeholder-text {
    text-align: center;
    margin-top: 50px;
    color: #888;
}

/* Alert Styles */
#custom-alert {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.4);
    z-index: 100;
    display: flex;
    justify-content: center;
    align-items: center;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

#custom-alert.visible {
    visibility: visible;
    opacity: 1;
}

.alert-box {
    background-color: rgba(240, 240, 240, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 14px;
    text-align: center;
    padding: 20px;
    width: 270px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

.alert-box p {
    margin: 0 0 20px 0;
    font-size: 17px;
    color: #000;
}

.alert-box button {
    width: 100%;
    padding: 12px;
    border: none;
    background-color: transparent;
    border-top: 1px solid #dbdbdd;
    color: #007aff;
    font-size: 17px;
    font-weight: 600;
    cursor: pointer;
}

.alert-box button:active {
    background-color: rgba(0,0,0,0.05);
}