/* Bubbly 3D Design System - Deep 3D & Glass */

:root {
    /* Lighting & Materials */
    --glass-surface: rgba(255, 255, 255, 0.15);
    --glass-border: 1px solid rgba(255, 255, 255, 0.3);
    --glass-highlight: rgba(255, 255, 255, 0.5);
    --glass-shadow: rgba(0, 0, 0, 0.2);

    /* Deep 3D Shadows */
    --shadow-layer-1: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-layer-2: 0 10px 15px rgba(0, 0, 0, 0.15);
    --shadow-layer-3: 0 20px 30px rgba(0, 0, 0, 0.2);
    --inner-glow: inset 0 0 12px rgba(255, 255, 255, 0.3), inset 2px 2px 6px rgba(255, 255, 255, 0.4);

    /* Animation Timing */
    --bounce-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Base Bubbly Icon Container */
.bubbly-icon {
    position: relative;
    width: 64px;
    height: 64px;
    border-radius: 18px;
    /* Squircle-ish */
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.02));
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.25);
    box-shadow:
        var(--shadow-layer-1),
        var(--shadow-layer-2),
        var(--inner-glow);

    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s var(--bounce-spring), box-shadow 0.3s ease;
    transform-style: preserve-3d;
    cursor: pointer;
    overflow: visible;
    /* Needed for 3D elements popping out */
}

/* Rim Light / Bevel Effect */
.bubbly-icon::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 18px;
    padding: 1px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.6), rgba(255, 255, 255, 0.1) 50%, rgba(255, 255, 255, 0) 50%, rgba(255, 255, 255, 0.4));
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
    z-index: 10;
}

/* Inner Reflection (Gloss) */
.bubbly-icon::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    right: 2px;
    height: 30%;
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0.3), rgba(255, 255, 255, 0));
    border-radius: 16px 16px 60% 60% / 12px 12px 8px 8px;
    pointer-events: none;
    opacity: 0.7;
}

.bubbly-icon:hover {
    transform: translateY(-6px) scale(1.05) rotateX(5deg);
    box-shadow:
        0 20px 40px rgba(0, 0, 0, 0.3),
        0 10px 10px rgba(0, 0, 0, 0.15),
        var(--inner-glow);
    z-index: 100;
}

/* Active Press State */
.bubbly-icon:active {
    transform: scale(0.95);
    box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);
}

/* --- Internal 3D Content (The "Smart" Parts) --- */

.bubbly-icon-content {
    width: 100%;
    height: 100%;
    position: relative;
    border-radius: 18px;
    overflow: hidden;
    transform-style: preserve-3d;
    /* Default Gradient Backgrounds for standard apps */
}

/* === APP SPECIFIC STYLES === */

/* Settings - Metal Gear */
.app-icon-settings .bubbly-icon-content {
    background: linear-gradient(135deg, #4b6cb7, #182848);
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-gear-3d {
    width: 44px;
    height: 44px;
    position: relative;
    background: conic-gradient(from 0deg, #dadddf, #aeb5b9, #dadddf, #aeb5b9, #dadddf);
    border-radius: 50%;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: spin-slow 10s linear infinite;
    border: 4px solid #8e9eab;
}

.icon-gear-3d::before {
    /* Teeth */
    content: '';
    position: absolute;
    inset: -6px;
    background: repeating-conic-gradient(from 0deg, #aeb5b9 0deg 30deg, transparent 30deg 45deg);
    -webkit-mask: radial-gradient(farthest-side, transparent 65%, black 66%);
    mask: radial-gradient(farthest-side, transparent 65%, black 66%);
    border-radius: 50%;
}

.icon-gear-3d::after {
    /* Inner Hole */
    content: '';
    width: 14px;
    height: 14px;
    background: #182848;
    border-radius: 50%;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.5);
}

@keyframes spin-slow {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* Browser - 3D Globe */
.app-icon-browser .bubbly-icon-content {
    background: linear-gradient(135deg, #00c6ff, #0072ff);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.icon-globe-grid {
    width: 80%;
    height: 80%;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.6);
    /* High contrast border */
    background:
        radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.9), transparent 40%),
        repeating-linear-gradient(0deg, transparent, transparent 10%, rgba(255, 255, 255, 0.4) 11%),
        repeating-linear-gradient(90deg, transparent, transparent 10%, rgba(255, 255, 255, 0.4) 11%);
    box-shadow:
        inset 0 0 20px rgba(0, 0, 255, 0.6),
        0 5px 15px rgba(0, 0, 0, 0.3);
    transform: rotate(-15deg);
    animation: float-globe 4s ease-in-out infinite;
}

.icon-globe-ring {
    position: absolute;
    width: 110%;
    height: 15%;
    border: 3px solid rgba(255, 255, 255, 0.8);
    /* High contrast ring */
    border-radius: 50%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotateX(70deg) rotateY(15deg);
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

@keyframes float-globe {

    0%,
    100% {
        transform: rotate(-15deg) translateY(0);
    }

    50% {
        transform: rotate(-15deg) translateY(-3%);
    }
}

/* FILES (Blue Glass Folder) - Max Visibility */
.app-icon-files .bubbly-icon-content,
.app-icon-folder .bubbly-icon-content {
    background: linear-gradient(135deg, #2980b9, #6dd5fa);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    perspective: 200px;
    transform-style: preserve-3d;
}

.icon-folder-back {
    position: absolute;
    top: 25%;
    width: 70%;
    height: 55%;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 8% 8% 0 0;
    border: 2px solid rgba(255, 255, 255, 0.8);
    z-index: 1;
}

.icon-folder-paper {
    position: absolute;
    top: 15%;
    left: 30%;
    width: 50%;
    height: 50%;
    background: #fff;
    border-radius: 2px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    transform: rotate(-5deg);
    z-index: 2;
}

.icon-folder-front {
    position: absolute;
    top: 40%;
    width: 75%;
    height: 45%;
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.5));
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    border-radius: 0 0 8% 8%;
    border-top: 2px solid #fff;
    border-bottom: 1px solid rgba(255, 255, 255, 0.6);
    transform-origin: bottom;
    transform: rotateX(15deg);
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.2);
    z-index: 3;
}

/* CALCULATOR — Icon fit hardened (no bottom cut) */
.app-icon-calculator .bubbly-icon-content {
    background: linear-gradient(135deg, #2d3436, #000000);
    display:flex;
    flex-direction:column;
    /* Percent padding + percent gaps can overflow on some tile aspect ratios.
       Use a tighter, safer budget. */
    /* Use px here to avoid percent-based overflow in some grid tiles */
    padding: 7px;
    gap: 6px;
    box-sizing: border-box;
    min-height: 0;
}

.icon-calc-display{
    flex: 0 0 22%;
    min-height: 0;
    background: rgba(0,0,0,0.55);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 10px;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.8);
    display:flex;
    align-items:center;
    justify-content:flex-end;
    padding: 0 10%;
    color:#fff;
    font-size: 0.62em;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    font-weight: 800;
    letter-spacing: 0.02em;
}

.icon-calc-grid{
    flex: 1 1 auto;
    min-height: 0;
    display:grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-template-rows: repeat(5, minmax(0, 1fr));
    /* % gaps can add up to overflow; keep it predictable */
    gap: 5px;
}

.icon-calc-btn{
    background: rgba(255, 255, 255, 0.28);
    border-radius: 999px;
    display:flex;
    align-items:center;
    justify-content:center;
    font-size: 0.38em;
    color:#fff;
    font-weight: 900;
    box-shadow:
      inset 0 1px 0 rgba(255,255,255,0.22),
      0 6px 14px rgba(0,0,0,0.35);
}

.icon-calc-btn.orange{ background: linear-gradient(180deg, #ffb340, #ff8f00); }
.icon-calc-btn.grey{ background: linear-gradient(180deg, #cfcfcf, #9a9a9a); color:#101010; }

.icon-calc-btn.zero{
    grid-column: span 2;
    border-radius: 999px;
    justify-content:flex-start;
    padding-left: 22%;
}


/* WEATHER - Distinct Elements */
.app-icon-weather .bubbly-icon-content {
    background: linear-gradient(to top, #4facfe, #00f2fe);
    position: relative;
    overflow: hidden;
}

.icon-sun {
    position: absolute;
    top: -10%;
    right: -10%;
    width: 60%;
    height: 60%;
    background: radial-gradient(circle, #ffd200, #f7971e);
    border-radius: 50%;
    box-shadow: 0 0 20px rgba(255, 210, 0, 0.8);
    animation: sun-pulse 3s ease-in-out infinite;
    z-index: 1;
}

.icon-cloud {
    position: absolute;
    bottom: 15%;
    left: 10%;
    width: 70%;
    height: 40%;
    background: #fff;
    border-radius: 50px;
    opacity: 1;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.2));
    animation: cloud-float 6s ease-in-out infinite;
    z-index: 2;
}

.icon-cloud::before,
.icon-cloud::after {
    content: '';
    position: absolute;
    background: #fff;
    border-radius: 50%;
}

.icon-cloud::before {
    width: 50%;
    height: 90%;
    top: -60%;
    left: 15%;
}

.icon-cloud::after {
    width: 40%;
    height: 70%;
    top: -40%;
    left: 55%;
}

@keyframes sun-pulse {

    0%,
    100% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.1);
        opacity: 1;
    }
}

@keyframes cloud-float {

    0%,
    100% {
        transform: translateX(0);
    }

    50% {
        transform: translateX(5%);
    }
}

/* CLOCK - Mobile Optimized & Visible Markings */
.app-icon-clock .bubbly-icon-content {
    background: radial-gradient(circle, #232526, #414345);
    display: flex;
    justify-content: center;
    align-items: center;
}

.smart-clock-face {
    width: 90%;
    height: 90%;
    border-radius: 50%;
    background: radial-gradient(circle, #222, #000);
    border: 2px solid rgba(255, 255, 255, 0.5);
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.8);
    position: relative;
}

/* Visible Cardinal Markings */
.smart-clock-face::after {
    content: '';
    position: absolute;
    top: 5%;
    bottom: 5%;
    left: 50%;
    width: 2px;
    background: linear-gradient(to bottom, #fff 15%, transparent 15%, transparent 85%, #fff 85%);
    transform: translateX(-50%);
    opacity: 0.8;
}

.smart-clock-face::before {
    content: '';
    position: absolute;
    left: 5%;
    right: 5%;
    top: 50%;
    height: 2px;
    background: linear-gradient(to right, #fff 15%, transparent 15%, transparent 85%, #fff 85%);
    transform: translateY(-50%);
    opacity: 0.8;
}

.smart-clock-dot {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 10%;
    height: 10%;
    background: #ff3b30;
    border-radius: 50%;
    z-index: 10;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.smart-clock-hand {
    position: absolute;
    bottom: 50%;
    left: 50%;
    transform-origin: bottom center;
    border-radius: 2px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

.smart-clock-hour {
    background: #fff;
    width: 8%;
    height: 28%;
    z-index: 5;
}

.smart-clock-minute {
    background: #ccc;
    width: 5%;
    height: 38%;
    z-index: 6;
}

.smart-clock-second {
    background: #ff3b30;
    width: 2%;
    height: 42%;
    z-index: 7;
}

/* NOTES - Solid Paper Stack */
.app-icon-notes .bubbly-icon-content {
    background: linear-gradient(135deg, #fce38a, #f38181);
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-paper-stack {
    position: relative;
    width: 65%;
    height: 80%;
}

.icon-paper {
    position: absolute;
    inset: 0;
    background: #fff;
    border-radius: 4px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    border: 1px solid #ddd;
}

.icon-paper:nth-child(1) {
    transform: rotate(-6deg);
    opacity: 1;
    background: #fdfdfd;
}

.icon-paper:nth-child(2) {
    transform: rotate(3deg);
    opacity: 1;
    background: #fff;
}

.icon-paper:nth-child(3) {
    transform: rotate(0deg);
    display: flex;
    flex-direction: column;
    padding: 10% 12%;
    gap: 10%;
    background: #fff;
}

.paper-line {
    height: 4%;
    background: #999;
    border-radius: 2px;
    width: 100%;
}

.paper-line.short {
    width: 60%;
}

/* --- Premium Smart Icons: Maps / Photos / Weather --- */
.bubbly-icon .smart-photos .ph-shine {
  stroke-dasharray: 120;
  stroke-dashoffset: 120;
  animation: y_ph_shine 2.8s ease-in-out infinite;
  opacity: 0.65;
}
@keyframes y_ph_shine {
  0%, 35% { stroke-dashoffset: 120; opacity: 0; }
  55% { opacity: 0.65; }
  100% { stroke-dashoffset: 0; opacity: 0; }
}

.bubbly-icon .smart-maps .mp-pin {
  transform-origin: 32px 36px;
  animation: y_mp_bob 2.6s var(--bounce-spring) infinite;
}
@keyframes y_mp_bob {
  0%, 55%, 100% { transform: translateY(0); }
  70% { transform: translateY(-1.6px); }
  85% { transform: translateY(0); }
}

.bubbly-icon:active {
  transform: translateY(1px) scale(0.985);
}

/* Weather refresh (subtle) */
.bubbly-icon .weather-icon svg {
  filter: drop-shadow(0 6px 12px rgba(0,0,0,0.22));
}


/* =========================
   GAME ICONS — premium bubbly set
   ========================= */

/* Unified "arcade glass" base so the games look like one premium set */
.bubbly-icon-content.smart-game,
.hex-icon-content.smart-game,
.smart-game{
    position: relative;
    overflow: hidden;
    background:
      radial-gradient(circle at 30% 22%, rgba(255,255,255,0.18), rgba(255,255,255,0) 46%),
      linear-gradient(135deg, rgba(15,18,28,0.92), rgba(4,6,12,0.96));
}

/* Accent glow per game (subtle, consistent) */
.app-icon-snake .bubbly-icon-content, .app-icon-snake .hex-icon-content{ --game-accent: rgba(60,255,180,0.55); }
.app-icon-memory .bubbly-icon-content, .app-icon-memory .hex-icon-content{ --game-accent: rgba(120,210,255,0.55); }
.app-icon-tictactoe .bubbly-icon-content, .app-icon-tictactoe .hex-icon-content{ --game-accent: rgba(255,120,210,0.55); }
.app-icon-minesweeper .bubbly-icon-content, .app-icon-minesweeper .hex-icon-content{ --game-accent: rgba(255,205,120,0.55); }
.app-icon-solitaire .bubbly-icon-content, .app-icon-solitaire .hex-icon-content{ --game-accent: rgba(255,110,130,0.55); }
.app-icon-spider-solitaire .bubbly-icon-content, .app-icon-spider-solitaire .hex-icon-content{ --game-accent: rgba(255,90,110,0.55); }
.app-icon-mahjong .bubbly-icon-content, .app-icon-mahjong .hex-icon-content{ --game-accent: rgba(120,255,200,0.55); }
.app-icon-tarneeb .bubbly-icon-content, .app-icon-tarneeb .hex-icon-content{ --game-accent: rgba(100,120,255,0.55); }
.app-icon-trix .bubbly-icon-content, .app-icon-trix .hex-icon-content{ --game-accent: rgba(180,80,255,0.55); }

.app-icon-snake .bubbly-icon-content::before,
.app-icon-memory .bubbly-icon-content::before,
.app-icon-tictactoe .bubbly-icon-content::before,
.app-icon-minesweeper .bubbly-icon-content::before,
.app-icon-solitaire .bubbly-icon-content::before,
.app-icon-spider-solitaire .bubbly-icon-content::before,
.app-icon-mahjong .bubbly-icon-content::before,
.app-icon-tarneeb .bubbly-icon-content::before,
.app-icon-trix .bubbly-icon-content::before,
.app-icon-snake .hex-icon-content::before,
.app-icon-memory .hex-icon-content::before,
.app-icon-tictactoe .hex-icon-content::before,
.app-icon-minesweeper .hex-icon-content::before,
.app-icon-solitaire .hex-icon-content::before,
.app-icon-spider-solitaire .hex-icon-content::before,
.app-icon-mahjong .hex-icon-content::before,
.app-icon-tarneeb .hex-icon-content::before,
.app-icon-trix .hex-icon-content::before{
    content: '';
    position: absolute;
    inset: -30%;
    background: radial-gradient(circle at 28% 22%, var(--game-accent, rgba(255,255,255,0.25)), rgba(255,255,255,0) 55%);
    opacity: 0.55;
    pointer-events: none;
    filter: blur(1px);
}

/* Structure inserted by SmartIcon */
.game-tint{
    position:absolute;
    inset:0;
    pointer-events:none;
    mix-blend-mode: soft-light;
    opacity: 0.9;
}
.game-wrap{
    position: relative;
    width: 100%;
    height: 100%;
    display:flex;
    align-items:center;
    justify-content:center;
    z-index: 2;
}

/* shared SVG look */
.bubbly-icon-content .game-svg,
.hex-icon-content .game-svg{
    width: 86%;
    height: 86%;
    display:block;
    filter: drop-shadow(0 10px 14px rgba(0,0,0,0.38));
}

@keyframes gameFloat {
    0% { transform: translateY(0px); }
    50% { transform: translateY(-2.5px); }
    100% { transform: translateY(0px); }
}
@keyframes gameShine {
    0% { transform: translateX(-40%) rotate(20deg); opacity: 0; }
    15% { opacity: 0.55; }
    45% { opacity: 0.25; }
    70% { opacity: 0; }
    100% { transform: translateX(140%) rotate(20deg); opacity: 0; }
}
.game-float { animation: gameFloat 3.1s ease-in-out infinite; transform-origin: center; }
.game-shine {
    position:absolute;
    inset:-40%;
    background: linear-gradient(90deg, rgba(255,255,255,0), rgba(255,255,255,0.20), rgba(255,255,255,0));
    transform: translateX(-40%) rotate(20deg);
    /* Micro-polish: keep the whole icon set in sync (same duration/phase) */
    animation: gameShine 6s ease-in-out infinite;
    pointer-events:none;
    mix-blend-mode: screen;
}

@media (prefers-reduced-motion: reduce) {
    .game-float, .game-shine {
        animation: none !important;
    }
}

/* Game mini-icons inside folder previews */
.folder-preview-game {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.folder-preview-game svg {
    width: 85%;
    height: 85%;
    border-radius: 20%;
}
