/* ==========================================================================
   Minimal + Quirky + Collaborative Canvas
   ========================================================================== */

:root {
    --black: #1a1a1a;
    --gray: #666;
    --gray-light: #999;
    --light: #e8e8e8;
    --white: #fafafa;
    --accent: #2d5a3d;
    --accent-light: #4a8c5f;
    --warm: #c45d3a;
    --warm-light: #e8a090;
    --pencil: rgba(80, 60, 40, 0.6);
}

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

html {
    scroll-behavior: smooth;
}

/* Content loading state - prevents flash of default content */
body.content-loading main section,
body.content-loading main #intro-content {
    opacity: 0;
    transition: opacity 0.2s ease;
}

body.content-loaded main section,
body.content-loaded main #intro-content {
    opacity: 1;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
    font-size: 16px;
    line-height: 1.7;
    color: var(--black);
    background: var(--white);
    min-height: 100vh;
    position: relative;
}

/* Subtle paper texture overlay */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%' height='100%' filter='url(%23noise)'/%3E%3C/svg%3E");
    opacity: 0.03;
    pointer-events: none;
    z-index: 1000;
}

/* Drawing canvas - absolute so it scrolls with page */
#whiteboard {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 1;
    cursor: crosshair;
}

/* Mobile draw mode toggle */
.mobile-draw-toggle {
    display: none;
    position: fixed;
    top: 1rem;
    right: 1rem;
    width: 48px;
    height: 48px;
    border: none;
    border-radius: 50%;
    background: var(--white);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    z-index: 101;
    transition: transform 0.2s ease, background 0.2s ease;
}

.mobile-draw-toggle:hover {
    transform: scale(1.05);
}

.mobile-draw-toggle.active {
    background: var(--accent);
    color: white;
}

.mobile-draw-toggle .toggle-icon {
    font-size: 1.25rem;
}

/* Show on touch devices */
@media (pointer: coarse) {
    .mobile-draw-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .draw-hint {
        display: none;
    }

    /* Hide toolbar by default on mobile */
    .draw-toolbar {
        opacity: 0;
        pointer-events: none;
        transform: translateY(10px);
    }

    .draw-toolbar.visible {
        opacity: 1;
        pointer-events: auto;
        transform: translateY(0);
    }

    /* Disable drawing by default on mobile */
    #whiteboard {
        pointer-events: none;
    }

    #whiteboard.draw-enabled {
        pointer-events: auto;
    }
}

/* Draw hint */
.draw-hint {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    color: var(--gray-light);
    letter-spacing: 0.05em;
    z-index: 10;
    pointer-events: none;
    animation: hintPulse 3s ease-in-out infinite;
    transition: opacity 0.5s ease;
}

.draw-hint.hidden {
    opacity: 0;
}

.hint-icon {
    font-size: 1rem;
    animation: wigglePencil 2s ease-in-out infinite;
}

.hint-text {
    opacity: 0.7;
}

@keyframes hintPulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 0.8; }
}

@keyframes wigglePencil {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(-5deg); }
    75% { transform: rotate(5deg); }
}

/* Drawing toolbar */
.draw-toolbar {
    position: fixed;
    bottom: 1.5rem;
    left: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(8px);
    border-radius: 20px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    z-index: 100;
    opacity: 0.3;
    transform: translateY(4px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.draw-toolbar:hover {
    opacity: 1;
    transform: translateY(0);
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.toolbar-divider {
    width: 1px;
    height: 16px;
    background: var(--light);
    margin: 0 0.25rem;
}

/* Size buttons */
.size-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    padding: 0;
    background: none;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease;
}

.size-btn:hover {
    background: var(--light);
    transform: scale(1.1);
}

.size-btn.active {
    background: var(--light);
}

.size-btn span {
    display: block;
    background: var(--black);
    border-radius: 50%;
}

.size-btn[data-size="2"] span { width: 4px; height: 4px; }
.size-btn[data-size="4"] span { width: 7px; height: 7px; }
.size-btn[data-size="8"] span { width: 10px; height: 10px; }

/* Color buttons */
.color-btn {
    width: 20px;
    height: 20px;
    padding: 0;
    border: 2px solid transparent;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.color-btn:hover {
    transform: scale(1.15);
}

.color-btn.active {
    border-color: var(--black);
}

.color-btn[data-color="#2e7d54"] { background: #2e7d54; }
.color-btn[data-color="#428995"] { background: #428995; }
.color-btn[data-color="#805f8a"] { background: #805f8a; }
.color-btn[data-color="#b55d77"] { background: #b55d77; }
.color-btn[data-color="#cc6644"] { background: #cc6644; }
.color-btn[data-color="#c7a356"] { background: #c7a356; }

.color-btn[data-color="auto"] {
    background: none;
    position: relative;
    overflow: hidden;
}

.color-btn .rainbow {
    position: absolute;
    inset: 2px;
    border-radius: 50%;
    background: conic-gradient(
        #2d5a3d 0deg,
        #7fb069 60deg,
        #c45d3a 120deg,
        #e8a090 180deg,
        #6b4423 240deg,
        #5c5347 300deg,
        #2d5a3d 360deg
    );
    animation: spinRainbow 8s linear infinite;
}

@keyframes spinRainbow {
    to { transform: rotate(360deg); }
}

/* Tool buttons */
.tool-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    padding: 0;
    background: none;
    border: none;
    border-radius: 6px;
    color: var(--gray);
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.tool-btn:hover {
    background: var(--light);
    color: var(--black);
    transform: scale(1.1);
}

.tool-btn.active {
    background: var(--warm-light);
    color: var(--warm);
}

.tool-btn svg {
    display: block;
}

/* Main content sits above canvas */
main {
    position: relative;
    z-index: 2;
    padding: 2rem;
    max-width: 650px;
    margin: 0 auto;
    pointer-events: none; /* Let clicks through to canvas */
}

/* Re-enable pointer events for interactive elements */
main a,
main button,
main input,
main iframe,
main h1 {
    pointer-events: auto;
}

/* Typography */
h1 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

h2 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--black);
}

p {
    margin-bottom: 1rem;
    color: var(--gray);
}

.tagline {
    color: var(--gray);
    font-size: 0.95rem;
    margin-bottom: 0;
}

/* Links - the fun part */
a {
    color: var(--accent);
    text-decoration: none;
    position: relative;
    transition: color 0.2s ease;
}

a:hover {
    color: var(--warm);
}

/* Quirky underline that draws in */
a::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 1px;
    background: var(--warm);
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

a:hover::after {
    width: 100%;
}

/* Navigation */
nav {
    margin: 1.5rem 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1.5rem;
}

nav a {
    font-size: 0.9rem;
}

nav a:hover {
    letter-spacing: 0.5px;
}

/* Horizontal rules - subtle decorative */
hr {
    border: none;
    border-top: 1px solid var(--light);
    margin: 2rem 0;
    position: relative;
}

/* Little decorative dot on some hrs */
hr:nth-of-type(odd)::after {
    content: '·';
    position: absolute;
    left: 50%;
    top: -0.6em;
    transform: translateX(-50%);
    background: var(--white);
    padding: 0 0.5rem;
    color: var(--light);
    font-size: 1.2rem;
}

/* Sections */
section {
    margin: 2rem 0;
}

/* Lists */
ul {
    list-style: none;
}

li {
    margin-bottom: 0.5rem;
    position: relative;
}

/* Project list styling */
#projects li {
    padding-left: 0;
    transition: padding-left 0.2s ease;
}

#projects li:hover {
    padding-left: 8px;
}

#projects li::before {
    content: '';
    position: absolute;
    left: -12px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-left: 5px solid var(--warm);
    border-top: 4px solid transparent;
    border-bottom: 4px solid transparent;
    opacity: 0;
    transition: opacity 0.2s ease, left 0.2s ease;
}

#projects li:hover::before {
    opacity: 1;
    left: 0;
}

.desc {
    color: var(--gray);
    font-size: 0.9rem;
}

/* Writing list with dates */
#writing li {
    display: flex;
    gap: 1rem;
    align-items: baseline;
}

.date {
    font-size: 0.8rem;
    color: var(--gray);
    font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
    flex-shrink: 0;
}

/* Sound embed */
.sound-embed {
    margin: 1rem 0;
    padding: 0.75rem;
    background: var(--light);
    border-radius: 4px;
    transition: background 0.3s ease;
    pointer-events: auto;
}

.sound-embed:hover {
    background: #ddd;
}

.sound-info {
    display: flex;
    gap: 0.5rem;
    align-items: baseline;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
}

.sound-title {
    font-weight: 500;
    color: var(--black);
}

.sound-artist {
    font-size: 0.9rem;
    color: var(--gray);
}

.sound-artist::before {
    content: '— ';
}

/* HTML5 Audio player styling */
.sound-embed audio {
    width: 100%;
    height: 40px;
    border-radius: 4px;
}

/* Custom audio player colors for webkit browsers */
.sound-embed audio::-webkit-media-controls-panel {
    background: var(--white);
}

.sound-embed audio::-webkit-media-controls-play-button,
.sound-embed audio::-webkit-media-controls-mute-button {
    filter: sepia(20%) saturate(70%) hue-rotate(50deg);
}

/* Iframe embeds */
.sound-embed iframe {
    border-radius: 4px;
}

/* Contact links inline */
.contact-links {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.contact-links li {
    margin: 0;
}

/* Wiggle on contact hover */
.contact-links a:hover {
    display: inline-block;
    animation: wiggle 0.4s ease;
}

/* Footer */
footer {
    margin-top: 3rem;
    color: var(--gray);
    font-size: 0.85rem;
}

footer p {
    margin-bottom: 0.25rem;
}

.small {
    font-size: 0.8rem;
    opacity: 0.7;
}

/* Header name hover effect - subtle color shift */
h1 {
    display: inline-block;
    transition: color 0.3s ease;
    cursor: pointer;
}

h1:hover {
    color: var(--accent);
}

/* Subtle hover state for sections */
section {
    padding: 0.5rem;
    margin-left: -0.5rem;
    margin-right: -0.5rem;
    border-radius: 4px;
    transition: background 0.3s ease;
}

section:hover {
    background: rgba(255, 255, 255, 0.7);
}

/* Animations */
@keyframes wiggle {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(-3deg); }
    75% { transform: rotate(3deg); }
}

/* Selection color */
::selection {
    background: var(--accent);
    color: var(--white);
}

/* Responsive */
@media (max-width: 500px) {
    main {
        padding: 1.5rem;
    }

    #writing li {
        flex-direction: column;
        gap: 0.25rem;
    }

    .contact-links {
        flex-direction: column;
        gap: 0.5rem;
    }

    .draw-hint {
        display: none;
    }
}

/* Cursor hint */
a:active {
    transform: scale(0.98);
}

/* Decorative corner marks */
body::after {
    content: '';
    position: fixed;
    top: 1rem;
    left: 1rem;
    width: 20px;
    height: 20px;
    border-left: 1px solid var(--light);
    border-top: 1px solid var(--light);
    pointer-events: none;
    z-index: 10;
}

main::after {
    content: '';
    position: fixed;
    bottom: 1rem;
    right: 4rem;
    width: 20px;
    height: 20px;
    border-right: 1px solid var(--light);
    border-bottom: 1px solid var(--light);
    pointer-events: none;
    z-index: 10;
}
