@import url('https://fonts.googleapis.com/css2?family=DotGothic16&display=swap');

:root {
    --color-bg-dither-1: #d3d3d3;
    --color-bg-dither-2: #ffffff;
    --color-blue: #0080ff; /* Bright blue from Pope image */
    --color-yellow: #ffff00; /* Yellow from Pope face */
    --color-magenta: #ff0080; /* Hot pink from Pope hearts */
    --color-red: #800020; /* Dark red from Image 2 */
    --color-black: #000000;
    --color-white: #ffffff;
    --color-cyan: #00ffff;
    --color-orange: #ff8000;
    --color-menu-bg: #c0c0c0; /* Classic Windows gray */
    --border-thickness: 3px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    /* Dithered gray background for the body */
    background-image: 
        repeating-linear-gradient(45deg, #000 25%, transparent 25%, transparent 75%, #000 75%, #000),
        repeating-linear-gradient(45deg, #000 25%, #fff 25%, #fff 75%, #000 75%, #000);
    background-size: 2px 2px;
    background-position: 0 0, 1px 1px;
    font-family: 'DotGothic16', sans-serif;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    color: var(--color-black);
    overflow: hidden;
}

/* Crisp rendering */
h1, h2, h3, p, span, div, button, input {
    font-smooth: never;
    -webkit-font-smoothing: none;
}

.os-window {
    width: 100vw;
    height: 100vh;
    background: var(--color-blue);
    border: none;
    display: flex;
    flex-direction: column;
    box-shadow: none;
}

.menu-bar {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    border-bottom: 2px solid #000;
    padding: 2px 10px;
    background: var(--color-menu-bg);
    color: var(--color-black);
    font-weight: normal;
    font-size: 16px;
}

/* Container for dropdown */
.menu-items {
    display: flex;
    gap: 10px;
    position: relative;
}

.menu-dropdown-container {
    position: relative;
}

.menu-item {
    cursor: pointer;
    padding: 2px 8px;
    user-select: none;
}
.menu-item:hover, .menu-dropdown-container.active .menu-item {
    background: var(--color-blue);
    color: var(--color-white);
}

/* Dropdown Content */
.dropdown-content {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background-color: var(--color-menu-bg);
    min-width: 160px;
    box-shadow: 2px 2px 0px #000;
    border-top: 2px solid #fff;
    border-left: 2px solid #fff;
    border-right: 2px solid #000;
    border-bottom: 2px solid #000;
    z-index: 1000;
}
.menu-dropdown-container.active .dropdown-content {
    display: flex;
    flex-direction: column;
}

.dropdown-content a {
    color: black;
    padding: 6px 12px;
    text-decoration: none;
    display: block;
    font-size: 16px;
}

.dropdown-content a:hover {
    background-color: var(--color-blue);
    color: white;
}

.dropdown-content .separator {
    height: 2px;
    background-color: #888;
    border-bottom: 1px solid #fff;
    margin: 4px 2px;
}


.url-bar {
    font-size: 16px;
    margin-left: auto;
    margin-right: 20px;
    padding: 2px 10px;
    background: var(--color-blue);
}

.window-controls {
    display: flex;
    gap: 4px;
}

.win-btn {
    width: 24px;
    height: 24px;
    border-top: 2px solid #fff;
    border-left: 2px solid #fff;
    border-right: 2px solid #000;
    border-bottom: 2px solid #000;
    background: var(--color-menu-bg);
    font-family: 'DotGothic16', sans-serif;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    line-height: 1;
    color: var(--color-black);
}
.win-btn:active {
    border-top: 2px solid #000;
    border-left: 2px solid #000;
    border-right: 2px solid #fff;
    border-bottom: 2px solid #fff;
    padding-top: 2px;
    padding-left: 2px;
}

.workspace {
    display: flex;
    flex: 1;
    overflow: hidden;
    /* Dithered workspace background like wigglypaint */
    background-image: 
        repeating-linear-gradient(45deg, #aaa 25%, transparent 25%, transparent 75%, #aaa 75%, #aaa),
        repeating-linear-gradient(45deg, #aaa 25%, #fff 25%, #fff 75%, #aaa 75%, #aaa);
    background-size: 4px 4px;
    background-position: 0 0, 2px 2px;
}

.toolbar {
    width: 120px;
    background: var(--color-menu-bg);
    border-right: 2px solid #000;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 15px 0;
    gap: 8px;
    z-index: 10;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Ukrycie domyślnego paska przewijania w toolbarze, by wyglądało czysto */
.toolbar::-webkit-scrollbar {
    width: 6px;
}
.toolbar::-webkit-scrollbar-track {
    background: var(--color-menu-bg);
}
.toolbar::-webkit-scrollbar-thumb {
    background: #000;
}

.tool-icon {
    width: 48px;
    height: 48px;
    border-top: 2px solid #fff;
    border-left: 2px solid #fff;
    border-right: 2px solid #000;
    border-bottom: 2px solid #000;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 24px;
    cursor: pointer;
    background: var(--color-menu-bg);
    user-select: none;
}
.tool-icon:active, .tool-icon.selected {
    border-top: 2px solid #000;
    border-left: 2px solid #000;
    border-right: 2px solid #fff;
    border-bottom: 2px solid #fff;
    background: #e0e0e0;
    transform: translate(1px, 1px);
}

.color-picker-ui {
    margin-top: auto;
    padding-bottom: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.current-colors {
    position: relative;
    width: 60px;
    height: 60px;
}
.current-colors .color-box {
    width: 36px;
    height: 36px;
    border-top: 2px solid #888;
    border-left: 2px solid #888;
    border-right: 2px solid #fff;
    border-bottom: 2px solid #fff;
    position: absolute;
    box-shadow: inset 1px 1px 0 #000, inset -1px -1px 0 #ccc;
}
.current-colors .color-box:first-child {
    top: 0; left: 0; z-index: 2;
}
.current-colors .color-box:last-child {
    bottom: 0; right: 0; z-index: 1;
}

.palette-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 2px;
    border-top: 2px solid #888;
    border-left: 2px solid #888;
    border-right: 2px solid #fff;
    border-bottom: 2px solid #fff;
    padding: 2px;
    background: var(--color-menu-bg);
}
.color-swatch {
    width: 25px;
    height: 25px;
    border: 1px solid #888;
    cursor: pointer;
}
.color-swatch:active {
    border: 1px solid #000;
}

/* Background Color Helpers */
.bg-magenta { background-color: var(--color-magenta); }
.bg-yellow { background-color: var(--color-yellow); }
.bg-blue { background-color: var(--color-blue); }
.bg-black { background-color: var(--color-black); }
.bg-white { background-color: var(--color-white); }
.bg-red { background-color: var(--color-red); }
.bg-cyan { background-color: var(--color-cyan); }
.bg-orange { background-color: var(--color-orange); }

.canvas-container {
    flex: 1;
    margin: 10px;
    background-color: var(--color-blue);
    /* Retro graph paper / blueprint grid pattern */
    background-image: 
        linear-gradient(rgba(255, 255, 255, 0.2) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.2) 1px, transparent 1px),
        linear-gradient(rgba(255, 255, 255, 0.1) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.1) 1px, transparent 1px);
    background-size: 100px 100px, 100px 100px, 20px 20px, 20px 20px;
    background-position: -1px -1px, -1px -1px, -1px -1px, -1px -1px;
    border-top: 2px solid #888;
    border-left: 2px solid #888;
    border-right: 2px solid #fff;
    border-bottom: 2px solid #fff;
    position: relative;
    overflow-y: auto;
    overflow-x: hidden;
    /* Cursors updated via JS based on selected tool */
}

/* Tool specific cursors handled by classes on the container */
.cursor-brush { cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M4 20l4-4 12-12-4-4-12 12-4 4z" fill="%23000" stroke="%23fff" stroke-width="1"/></svg>') 0 24, crosshair; }
.cursor-bucket { cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><rect x="6" y="8" width="12" height="14" fill="%23000" stroke="%23fff" stroke-width="1"/><path d="M4 6h16l-2-2h-12z" fill="%23000"/></svg>') 12 12, cell; }
.cursor-text { cursor: text; }
.cursor-line { cursor: crosshair; }
.cursor-heart { cursor: pointer; }
.cursor-eraser { cursor: cell; }

.scroll-wrapper {
    position: relative;
    min-height: 100%;
}

#wigglyCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none; /* Prevent blocking clicks at all costs */
}

.canvas-content {
    position: relative;
    z-index: 2;
    padding: 60px 40px;
}

/* Typography & Content Styling inside Canvas */
.portfolio-header {
    text-align: center;
    margin-bottom: 60px;
}
.wiggly-text {
    font-size: 64px;
    color: var(--color-yellow);
    /* Thick black outline similar to the pope drawing */
    text-shadow: 
        4px 4px 0 var(--color-black),
        -2px -2px 0 var(--color-black),
        2px -2px 0 var(--color-black),
        -2px 2px 0 var(--color-black),
        2px 2px 0 var(--color-black);
    margin-bottom: 20px;
    letter-spacing: 2px;
}
.subtitle {
    font-size: 28px;
    color: var(--color-magenta);
    background: var(--color-black);
    display: inline-block;
    padding: 8px 20px;
    border: var(--border-thickness) solid var(--color-black);
    box-shadow: 4px 4px 0px var(--color-yellow);
}

.portfolio-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 40px;
    margin-bottom: 60px;
    padding: 0 20px;
}

.project-card {
    background: var(--color-white);
    border: var(--border-thickness) solid var(--color-black);
    padding: 20px;
    box-shadow: 8px 8px 0px rgba(0,0,0,1);
    transition: transform 0.1s, box-shadow 0.1s;
    display: flex;
    flex-direction: column;
}
.project-card:hover {
    transform: translate(-4px, -4px);
    box-shadow: 12px 12px 0px rgba(0,0,0,1);
}

.project-img {
    height: 180px;
    border: var(--border-thickness) solid var(--color-black);
    margin-bottom: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 80px;
    color: var(--color-black);
}

.project-card h2 {
    font-size: 24px;
    margin-bottom: 15px;
    background: var(--color-yellow);
    display: inline-block;
    padding: 4px 12px;
    border: var(--border-thickness) solid var(--color-black);
}

.project-card p {
    font-size: 18px;
    line-height: 1.5;
    margin-bottom: 20px;
    font-weight: bold;
}

.retro-btn {
    display: inline-block;
    background: var(--color-magenta);
    color: var(--color-black);
    text-decoration: none;
    padding: 8px 16px;
    border: var(--border-thickness) solid var(--color-black);
    font-weight: bold;
    font-size: 18px;
    box-shadow: 4px 4px 0px var(--color-black);
}
.retro-btn:hover {
    background: var(--color-cyan);
    transform: translate(-2px, -2px);
    box-shadow: 6px 6px 0px var(--color-black);
}
.retro-btn:active {
    transform: translate(2px, 2px);
    box-shadow: 2px 2px 0px var(--color-black);
}

.about-section {
    background: var(--color-white);
    border: var(--border-thickness) solid var(--color-black);
    padding: 40px;
    box-shadow: 8px 8px 0px rgba(0,0,0,1);
    max-width: 800px;
    margin: 0 auto;
}

.about-section h2 {
    font-size: 36px;
    color: var(--color-white);
    background: var(--color-magenta);
    display: inline-block;
    padding: 5px 15px;
    border: var(--border-thickness) solid var(--color-black);
    margin-bottom: 25px;
}

.about-section p {
    font-size: 20px;
    line-height: 1.6;
    font-weight: bold;
}

.contact-box {
    margin-top: 30px;
    padding: 20px;
    background: var(--color-yellow);
    border: var(--border-thickness) dashed var(--color-black);
}

.contact-box h3 {
    font-size: 24px;
    margin-bottom: 10px;
}

.contact-box a {
    color: var(--color-blue);
    text-decoration: none;
    font-weight: bold;
}
.contact-box a:hover {
    text-decoration: underline;
    color: var(--color-magenta);
}

/* Hidden input for text tool */
.hidden-input {
    position: absolute;
    left: -9999px;
    top: -9999px;
    opacity: 0;
}

/* Floating Input overlay for text tool */
.text-tool-input {
    position: absolute;
    z-index: 100;
    background: transparent;
    border: 1px dashed black;
    font-family: 'DotGothic16', sans-serif;
    font-size: 24px;
    color: var(--color-magenta);
    text-shadow: 2px 2px 0 #000;
    outline: none;
    min-width: 100px;
}

/* =========================================
   DESKTOP SIMULATOR & EXPLORER VIEWS
   ========================================= */

.hidden {
    display: none !important;
}

/* SVG Rendering */
.pixel-icon {
    width: 64px;
    height: 64px;
    image-rendering: pixelated;
    shape-rendering: crispEdges;
}

.card-pixel-icon {
    width: 48px;
    height: 48px;
    image-rendering: pixelated;
    shape-rendering: crispEdges;
}

.explorer-desktop {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    height: 100%;
}

.desktop-header {
    margin-top: 40px;
    margin-bottom: 20px;
}

.desktop-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 40px;
    justify-content: center;
    align-items: center;
    width: 100%;
    max-width: 1200px;
    padding: 40px;
}

.desktop-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 250px;
    height: 250px;
    margin: 0 auto;
    cursor: pointer;
    text-align: center;
    user-select: none;
    border: var(--border-thickness) solid var(--color-black);
    background: var(--color-white);
    padding: 20px;
    box-shadow: 8px 8px 0px rgba(0,0,0,1);
    transition: transform 0.1s, box-shadow 0.1s;
    pointer-events: auto !important; /* Tiles MUST be clickable */
    position: relative;
    z-index: 100;
}

.desktop-tile .tile-icon {
    margin-bottom: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    pointer-events: none; /* Let the tile handle the click */
}

.desktop-tile .tile-label {
    color: var(--color-black);
    font-size: 24px;
    font-weight: bold;
    padding: 4px 10px;
    background: var(--color-yellow);
    border: 2px solid var(--color-black);
    word-break: break-word;
    pointer-events: none; /* Let the tile handle the click */
}

/* Hover effect */
.desktop-tile:hover {
    transform: translate(-4px, -4px);
    box-shadow: 12px 12px 0px rgba(0,0,0,1);
    background: var(--color-cyan);
}

/* Selected Style */
.desktop-tile.selected {
    border: 4px dashed var(--color-magenta);
}

.desktop-tile.selected .tile-label {
    background-color: var(--color-magenta); 
    color: var(--color-white);
}

.desktop-tile.tile-highlight {
    background: var(--color-black);
    color: var(--color-yellow);
    border-color: var(--color-magenta);
}

.desktop-tile.tile-highlight .tile-label {
    background: none;
    border: none;
}

.desktop-tile.tile-highlight:hover {
    background: #333;
}

/* Explorer Folder View */
.explorer-folder {
    background: #ffffff;
    border: var(--border-thickness) solid var(--color-black);
    box-shadow: 6px 6px 0px rgba(0,0,0,1);
    min-height: 500px;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
}

.explorer-toolbar {
    display: flex;
    align-items: center;
    gap: 15px;
    background: var(--color-menu-bg);
    border-bottom: 2px solid #888;
    padding: 8px;
}

.explorer-path {
    display: flex;
    flex: 1;
    align-items: center;
    background: var(--color-white);
    border-top: 2px solid #888;
    border-left: 2px solid #888;
    border-right: 2px solid #fff;
    border-bottom: 2px solid #fff;
    padding: 4px 8px;
    font-size: 16px;
}

.path-label {
    color: #888;
    margin-right: 8px;
    font-weight: bold;
}

.path-text {
    color: var(--color-black);
    font-weight: bold;
}

/* Notepad View */
.explorer-notepad {
    background: #ffffff;
    border: var(--border-thickness) solid var(--color-black);
    box-shadow: 6px 6px 0px rgba(0,0,0,1);
    display: flex;
    flex-direction: column;
    max-width: 800px;
    margin: 0 auto;
}

.notepad-header {
    background: var(--color-menu-bg);
    border-bottom: 2px solid #000;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 10px;
}

.notepad-menu {
    font-size: 16px;
    font-weight: bold;
    display: flex;
    gap: 15px;
}

.notepad-content {
    padding: 10px;
    flex: 1;
}

.notepad-textarea {
    width: 100%;
    height: 400px;
    border: 2px solid #000;
    background: #ffffcc; /* Yellowish retro paper */
    font-family: 'DotGothic16', monospace;
    font-size: 18px;
    font-weight: bold;
    padding: 15px;
    resize: none;
    outline: none;
}

.text-tool-input {
    position: fixed;
    background: transparent;
    border: 2px dashed #000;
    font-family: 'DotGothic16', sans-serif;
    font-size: 32px;
    outline: none;
    z-index: 9999;
    padding: 2px;
    transform: translateY(-50%);
}

/* Mail Client View */
.explorer-mail {
    background: var(--color-menu-bg);
    border: var(--border-thickness) solid var(--color-black);
    box-shadow: 6px 6px 0px rgba(0,0,0,1);
    display: flex;
    flex-direction: column;
    max-width: 700px;
    margin: 0 auto;
}

.mail-header {
    background: #000080;
    color: white;
    border-bottom: 2px solid #000;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 10px;
}

.mail-title {
    font-weight: bold;
    font-size: 16px;
}

.mail-content {
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.mail-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.mail-label {
    width: 60px;
    font-weight: bold;
}

.mail-input {
    flex: 1;
    padding: 4px 8px;
    border: 2px solid #000;
    font-family: 'DotGothic16', sans-serif;
    font-size: 16px;
    outline: none;
}

.mail-body-container {
    margin-top: 10px;
}

.mail-body-textarea {
    width: 100%;
    height: 250px;
    padding: 10px;
    border: 2px solid #000;
    font-family: 'DotGothic16', sans-serif;
    font-size: 16px;
    resize: none;
    outline: none;
}

.mail-footer {
    display: flex;
    justify-content: flex-end;
    margin-top: 10px;
}

/* =======================================
   ANIMACJE OKIEN (TRANSITIONS)
   ======================================= */
@keyframes retroOpen {
    0% { transform: scale(0) rotate(-30deg) translateY(100px); opacity: 0; filter: hue-rotate(90deg) contrast(200%) saturate(200%); }
    40% { opacity: 1; transform: scale(1.05) rotate(3deg) translateY(-10px); filter: hue-rotate(45deg) contrast(150%) saturate(150%); }
    70% { transform: scale(0.98) rotate(-1deg) translateY(5px); filter: hue-rotate(0deg) contrast(100%) saturate(100%); }
    100% { transform: scale(1) rotate(0deg) translateY(0); opacity: 1; filter: contrast(100%) saturate(100%); }
}

@keyframes retroFolderOpen {
    0% { transform: scaleX(0); opacity: 0; filter: invert(100%); }
    100% { transform: scaleX(1); opacity: 1; filter: invert(0%); }
}

@keyframes retroNotepadOpen {
    0% { transform: translateY(-100vh) rotate(-10deg); opacity: 0; }
    80% { transform: translateY(20px) rotate(2deg); opacity: 1; }
    100% { transform: translateY(0) rotate(0); opacity: 1; }
}

@keyframes retroMailOpen {
    0% { transform: translateX(100vw) scale(0.5); opacity: 0; }
    80% { transform: translateX(-20px) scale(1.1); opacity: 1; }
    100% { transform: translateX(0) scale(1); opacity: 1; }
}

.explorer-desktop { animation: retroOpen 1.2s cubic-bezier(0.22, 1, 0.36, 1) forwards; transform-origin: center center; }
.explorer-folder { animation: retroFolderOpen 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards; transform-origin: left center; }
.explorer-notepad { animation: retroNotepadOpen 0.7s cubic-bezier(0.25, 1, 0.5, 1) forwards; transform-origin: center center; }
.explorer-mail { animation: retroMailOpen 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards; transform-origin: right center; }

/* =======================================
   RETRO MODAL (COLORFUL POP-ART)
   ======================================= */
.retro-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.retro-modal.hidden {
    display: none;
}

.retro-modal-window {
    background: #fff;
    border: 4px solid #000;
    min-width: 280px;
    max-width: 80vw;
    font-family: 'DotGothic16', sans-serif;
    box-shadow: 8px 8px 0 #00ffff;
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
    0% { transform: scale(0.8); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.retro-modal-header {
    background: #ff0080;
    color: #fff;
    padding: 6px 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 18px;
    border-bottom: 4px solid #000;
    font-weight: bold;
    text-shadow: 2px 2px 0 #000;
}

.retro-modal-close {
    background: #ffff00;
    border: 2px solid #000;
    color: #000;
    font-weight: bold;
    cursor: pointer;
    font-size: 16px;
    padding: 0 6px;
    text-shadow: none;
}

.retro-modal-close:active {
    background: #00ffff;
    transform: translate(2px, 2px);
}

.retro-modal-content {
    display: flex;
    align-items: center;
    padding: 25px 20px;
    gap: 15px;
    background: #fff;
}

.retro-modal-icon {
    font-size: 36px;
}

.retro-modal-text {
    font-size: 18px;
    color: #000;
    line-height: 1.4;
}

.retro-modal-footer {
    display: flex;
    justify-content: center;
    padding: 0 20px 20px 20px;
    background: #fff;
}

.retro-modal-footer .retro-btn {
    background: #ffff00;
    border: 3px solid #000;
    font-size: 18px;
    padding: 8px 25px;
    box-shadow: 4px 4px 0 #000;
    color: #000;
}

.retro-modal-footer .retro-btn:active {
    box-shadow: 0 0 0 #000;
    transform: translate(4px, 4px);
    background: #00ffff;
}
