/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: #ffffff;
    /* Clean white background */
    color: #111;
    font-family: 'Inter', sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
}


/* Interactive Background Dots */
#background-dots {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

/* Drawing Canvas Background */
#drawing-boards {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    /* Default cursor, only changes to pencil when UI is hidden */
    cursor: default;
}

/* Disable pointer events on the container so the canvas behind gets clicks for drawing,
   but re-enable on specific interactive elements */
.pointer-events-none {
    pointer-events: none;
}

.pointer-events-auto {
    pointer-events: auto;
}

/* Layout Container */
.container {
    max-width: 100%;
    margin: 0 auto;
    padding: 40px 48px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 2;
    /* Sits above canvas */
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: auto;
    /* Pushes the rest of the content down */
}

.logo {
    font-size: 20px;
    font-weight: 800;
    letter-spacing: -0.5px;
    display: flex;
    align-items: center;
    cursor: default;
}

.logo-rest {
    display: inline-block;
    max-width: 0;
    overflow: hidden;
    transition: max-width 0.4s ease;
    vertical-align: bottom;
}

.logo:hover .logo-rest {
    max-width: 32px;
    /* Expanding to show "as" */
}

.drawing-prompt {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    font-size: 14px;
    font-weight: 500;
    color: #888;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
    white-space: nowrap;
}

body.dark-theme .drawing-prompt {
    color: #aaa;
}

.drawing-prompt.visible {
    opacity: 1;
}

.theme-switch {
    background: none;
    border: none;
    cursor: pointer;
    color: #111;
    padding: 8px;
    transition: transform 0.2s;
}

.theme-switch:hover {
    transform: rotate(15deg);
}

/* Floating Tools (Text & Download) */
.floating-tools {
    position: absolute;
    top: 96px;
    right: 48px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.floating-tools.visible {
    opacity: 1;
    pointer-events: auto;
}

.floating-tools .theme-switch.active {
    background-color: #f0f0f0;
    border-radius: 6px;
}

/* Canvas Text Input Overlay */
.canvas-text-input {
    position: absolute;
    background: transparent;
    border: 1px dashed #999;
    outline: none;
    font-family: 'Inter', sans-serif;
    font-size: 24px;
    font-weight: 500;
    color: #ff3366;
    /* Matching the pen color */
    z-index: 1000;
    padding: 2px 4px;
    margin: 0;
    pointer-events: auto;
    resize: none;
    overflow: hidden;
    white-space: pre-wrap;
    min-width: 20px;
    min-height: 32px;
}

/* Main Content Area */
.main-content {
    display: flex;
    flex-direction: column;
    width: 100%;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

/* Hide UI State */
.main-content.content-hidden,
.main-content.content-hidden * {
    opacity: 0;
    pointer-events: none !important;
}

.main-content.content-hidden {
    transform: translateY(-10px);
}

.footer-fixed {
    transition: opacity 0.3s ease;
}

/* Bio Section centered vertically */
.bio-section {
    max-width: 100%;
    /* Take full width so notes can hang right */
    margin-top: auto;
    margin-bottom: 32px;
    display: flex;
    position: relative;
}

/* Important: Allow cursor to still look like a pencil when hovering over the text but NOT blocking the canvas behind it */
.bio-title {
    font-size: 28px;
    line-height: 1.4;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: #000;
    max-width: 760px;
    /* Constrain text so notes don't overlap */
}

/* Sticky Notes */
.sticky-notes-wrapper {
    position: absolute;
    right: 48px;
    top: -40px;
    /* Peek out enough above the usecases grid to easily hover */
    display: flex;
    pointer-events: auto;
    z-index: 10;
    /* Keep underneath grid */
}

/* Global Tooltip for Sticky Notes */
.global-tooltip {
    position: absolute;
    background-color: #111;
    color: #fff;
    font-size: 13px;
    padding: 6px 14px;
    border-radius: 8px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    transform: translateX(-50%) translateY(10px);
    font-weight: 500;
    font-family: 'Inter', sans-serif;
    z-index: 9999;
    /* Highest priority so it never gets hidden */
}

.global-tooltip.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.sticky-note {
    width: 220px;
    /* Made smaller */
    padding: 20px 24px;
    box-shadow: 2px 4px 12px rgba(0, 0, 0, 0.1);
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    /* Smaller text */
    line-height: 1.4;
    color: #111;
    position: relative;
    transition: transform 0.2s, box-shadow 0.2s, opacity 0.3s ease;
    cursor: grab;
    user-select: none;
    /* Prevent text selection while dragging */
}

.sticky-note.content-hidden {
    opacity: 0;
    pointer-events: none !important;
}

/* Actively dragged note */
.sticky-note.dragging {
    cursor: grabbing !important;
    z-index: 100 !important;
    box-shadow: 10px 15px 30px rgba(0, 0, 0, 0.2);
    transform: scale(1.05) rotate(0deg) !important;
}

.sticky-note a {
    color: inherit;
    text-decoration: underline;
    font-weight: 600;
}

.sticky-note:hover {
    transform: scale(1.05) rotate(0deg) !important;
    /* Removed z-index: 10 !important; which caused dragging to break over the grid */
}

.sticky-note strong {
    font-size: 14px;
    /* Scaled down slightly */
    display: block;
    margin-bottom: 8px;
}

.sticky-note ol {
    padding-left: 16px;
    margin: 0;
}

/* The thumbtack illusion */
.sticky-note::before {
    content: '';
    position: absolute;
    top: 6px;
    left: 50%;
    transform: translateX(-50%);
    width: 6px;
    height: 6px;
    background: #444;
    border-radius: 50%;
    box-shadow: 0 2px 2px rgba(0, 0, 0, 0.3);
}

.note-yellow {
    background: #fdf57d;
    transform: rotate(-3deg);
    z-index: 2;
}

.note-green {
    background: #bbf793;
    transform: rotate(5deg);
    margin-left: -20px;
    margin-top: 20px;
    z-index: 1;
}

.note-blue {
    background: #ade1ff;
    transform: rotate(-2deg);
    margin-left: -20px;
    margin-top: 40px;
    z-index: 0;
}

/* Selected Works Section */
.works-section {
    width: 100%;
    margin-bottom: 32px;
    position: relative;
    z-index: 20;
    /* Creates stacking context higher than the resting sticky notes */
}

.section-label {
    font-size: 13px;
    color: #666;
    margin-bottom: 16px;
    font-weight: 400;
}

/* Grid Layout for Use Cases */
.use-cases-grid {
    display: grid;
    /* Creating a 6-column grid so we can span columns to perfectly center 2 items below 3 */
    grid-template-columns: repeat(6, 1fr);
    gap: 0;
    position: relative;
    z-index: 20;
    /* High z-index to fully cover the resting sticky notes behind it */
}

/* Individual Card */
.use-case-card {
    padding: 24px 32px;
    border: 1px solid #d0d0d0;
    background-color: #fff;
    cursor: auto;
    position: relative;
    transition: border-radius 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
    border-radius: 12px;
    /* Start round */
    margin: -1px 0 0 -1px;
    /* Overlap borders elegantly */
    grid-column: span 2;
    /* Default spans 2 out of 6 (3 in a row) */
}

/* Make bottom 2 items span wider to center gracefully */
.use-case-card.span-col {
    grid-column: span 3;
    /* Spans 3 out of 6 (2 in a row) */
}

.use-case-card h3 {
    font-size: 16px;
    font-weight: 700;
    margin: 0 0 8px 0;
    color: #333;
}

.use-case-card p {
    margin: 0 0 16px 0;
    font-size: 14px;
    font-weight: 400;
    color: #444;
}

.use-case-card .label {
    display: block;
    font-size: 12px;
    color: #666;
}

/* MICRO-INTERACTIONS */

/* Individual Card Hover */
.use-case-card:hover {
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.06);
    z-index: 10;
    border-color: #999;
}

/* Drag State for SortableJS */
.use-case-card:active {
    cursor: grabbing;
}

.sortable-ghost {
    opacity: 0.2;
    background-color: #f0f0f0;
}

.sortable-drag {
    cursor: grabbing !important;
    background-color: #fff !important;
    box-shadow: 15px 15px 40px rgba(0, 0, 0, 0.1);
    z-index: 99 !important;
}

/* Footer Section */
.footer {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    /* When UI is hidden, we need to ensure the footer stays visible and anchored.
       It will be moved outside of .main-content in HTML to preserve it. */
    width: 100%;
}

/* Social Links */
.social-links {
    display: flex;
    gap: 12px;
    align-items: center;
}

.social-icon {
    text-decoration: none;
    transition: transform 0.2s ease, opacity 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.social-icon:hover {
    transform: translateY(-4px);
    opacity: 0.8;
}

/* Contact Wrap & Copy Tooltip */
.contact-wrap {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.copy-tooltip {
    position: absolute;
    top: -30px;
    right: 0;
    background: #111;
    color: #fff;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transform: translateY(5px);
    transition: all 0.2s ease;
    pointer-events: none;
}

.copy-tooltip.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.contact-link {
    font-size: 13px;
    color: #666;
    text-decoration: none;
    transition: color 0.2s ease;
}

.contact-link:hover {
    color: #111;
    text-decoration: underline;
}

/* 
=============================
 USE CASE MODAL
============================= 
*/
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background: rgba(255, 255, 255, 0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 2000;
    display: flex;
    align-items: flex-end;
    /* Align modal content to bottom */
    transition: opacity 0.4s ease, visibility 0.4s ease;
    visibility: visible;
    opacity: 1;
}

.modal-overlay.content-hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

/* Slide up from bottom */
.modal-content {
    width: 100%;
    height: 90vh;
    background-color: #ffffff;
    border-radius: 24px 24px 0 0;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.1);
    padding: 64px 48px 0 48px;
    position: relative;
    transform: translateY(0);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-overlay.content-hidden .modal-content {
    transform: translateY(100%);
}

.modal-close {
    position: absolute;
    top: 32px;
    right: 48px;
    background: none;
    border: none;
    cursor: pointer;
    color: #111;
    padding: 8px;
    transition: transform 0.2s;
    background-color: #f5f5f5;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    transform: rotate(90deg);
    background-color: #e5e5e5;
}

.modal-body {
    width: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    height: 100%;
    padding-bottom: 64px;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.modal-body::-webkit-scrollbar {
    display: none;
}

.modal-body h2 {
    max-width: 900px;
    margin: 0 auto 24px auto;
    font-size: 32px;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: #111;
}

.modal-desc {
    max-width: 900px;
    margin: 0 auto 24px auto;
    font-size: 16px;
    line-height: 1.6;
    color: #444;
}

.modal-project-link-wrap {
    max-width: 900px;
    margin: 16px auto 0 auto;
    width: 100%;
}

.modal-project-link {
    display: inline-block;
    max-width: fit-content;
    padding: 8px 20px;
    font-size: 13px;
    font-weight: 400;
    color: #666;
    text-decoration: none;
    border: 1px solid #ddd;
    border-radius: 999px;
    /* Full pill shape */
    transition: all 0.2s ease;
    background-color: transparent;
}

.modal-project-link:hover {
    background-color: #f8f8f8;
    color: #111;
    border-color: #bbb;
}

.modal-gallery-header {
    max-width: 900px;
    margin: 32px auto 16px auto;
    /* Centered margin to align with text */
    font-size: 14px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #888;
    display: flex;
    align-items: center;
}

.gallery-scroll-hint {
    margin-left: 8px;
    font-size: 12px;
    text-transform: none;
    font-style: italic;
    font-weight: 400;
    color: #bbb;
    letter-spacing: 0;
}

/* Horizontal Gallery with Mouse Wheel Scroll */
.modal-gallery {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 32px;
    margin: 16px -48px 0 -48px;
    /* Break out of 48px content padding */
    padding: 24px 48px 48px 48px;
    /* Restore visual padding inside scroll */
    width: calc(100% + 96px);
    overflow-x: auto;
    overflow-y: hidden;
    scroll-behavior: smooth;
    /* Remove 'scrollbar-width: none' and '-ms-overflow-style: none' to allow scrollbars */
    cursor: grab;
    user-select: none;
}

.modal-gallery:active {
    cursor: grabbing;
}

/* Elegant webkit scrollbar */
.modal-gallery::-webkit-scrollbar {
    height: 6px;
    background-color: transparent;
}

.modal-gallery::-webkit-scrollbar-track {
    background: transparent; 
    margin: 0 48px; /* Align with content padding */
}

.modal-gallery::-webkit-scrollbar-thumb {
    background: #e0e0e0;
    border-radius: 10px;
}

.modal-gallery::-webkit-scrollbar-thumb:hover {
    background: #ccc;
}

.modal-gallery-item {
    height: 600px;
    width: auto;
    flex-shrink: 0;
    border-radius: 8px;
    overflow: hidden;
    /* Key for zoom-in-place effect */
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    cursor: help;
    background-color: #f8f8f8;
}

.modal-gallery img {
    height: 100%;
    width: auto;
    display: block;
    transition: transform 0.4s cubic-bezier(0.165, 0.84, 0.44, 1), transform-origin 0.1s linear;
    /* High-Quality UI Sharpening */
    image-rendering: -webkit-optimize-contrast;
    /* Hardware Acceleration */
    transform: translate3d(0, 0, 0);
    backface-visibility: hidden;
    will-change: transform;
}

.modal-gallery-item:hover img {
    transform: scale(1.3);
    /* 30% zoom */
}

.gallery-placeholder {
    min-width: 400px;
    height: 300px;
    background-color: #f0f0f0;
    border: 1px dashed #ccc;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #888;
    font-weight: 500;
    flex-shrink: 0;
}

/* Responsive adjustments */
@media (max-width: 1024px) {
    .use-cases-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .use-case-card.span-col {
        grid-column: span 1 !important;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 24px;
    }

    .use-cases-grid {
        grid-template-columns: 1fr;
    }

    .bio-title {
        font-size: 24px;
    }

    .footer {
        flex-direction: column;
        align-items: flex-start;
        gap: 24px;
    }
}

/* 
=============================
 DARK THEME STYLES 
=============================
*/
body.dark-theme {
    background-color: #111;
    color: #fff;
}

body.dark-theme .bio-title,
body.dark-theme .logo,
body.dark-theme .theme-switch {
    color: #fff;
}

body.dark-theme .floating-tools .theme-switch.active {
    background-color: #333;
}

body.dark-theme .canvas-text-input {
    border-color: #555;
}

body.dark-theme .contact-link {
    color: #bbb;
}

body.dark-theme .contact-link:hover {
    color: #fff;
}

body.dark-theme .social-icon svg rect,
body.dark-theme .social-icon svg circle {
    fill: #fff;
}

body.dark-theme .social-icon svg path {
    fill: #111;
    /* invert the paths inside the icons */
}

body.dark-theme .social-icon div {
    background: #fff;
    color: #111;
}

body.dark-theme .drawing-tools {
    background: #222;
    border-color: #333;
}

body.dark-theme .pencil-anim {
    color: #fff;
}

body.dark-theme .tools-panel {
    border-color: #444;
}

body.dark-theme .tools-panel button {
    color: #aaa;
}

body.dark-theme .tools-panel button:hover {
    background: #333;
    color: #fff;
}

body.dark-theme .tools-panel button.active {
    background: #444;
    color: #fff;
}

body.dark-theme .use-case-card {
    background-color: #1a1a1a;
    border-color: #333;
}

body.dark-theme .use-case-card h3 {
    color: #fff;
}

body.dark-theme .use-case-card p {
    color: #aaa;
}

body.dark-theme .use-case-card .label {
    color: #888;
}

body.dark-theme .use-case-card:hover {
    border-color: #555;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

body.dark-theme .sortable-ghost {
    opacity: 0.2;
    background-color: #333;
}

body.dark-theme .sortable-drag {
    background-color: #222 !important;
    box-shadow: 15px 15px 40px rgba(0, 0, 0, 0.5);
}

body.dark-theme .modal-overlay {
    background: rgba(17, 17, 17, 0.6);
}

body.dark-theme .modal-content {
    background-color: #1a1a1a;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.5);
}

body.dark-theme .modal-body h2 {
    color: #fff;
}

body.dark-theme .modal-desc {
    color: #aaa;
}

body.dark-theme .modal-project-link {
    color: #fff;
    border-color: #444;
}

body.dark-theme .modal-project-link:hover {
    background-color: #333;
    border-color: #666;
}

body.dark-theme .modal-gallery-header {
    color: #666;
}

body.dark-theme .modal-close {
    color: #fff;
    background-color: #333;
}

body.dark-theme .modal-close:hover {
    background-color: #444;
}

body.dark-theme .gallery-placeholder {
    background-color: #222;
    border-color: #444;
}