/* ═══════════════════════════════════════════════════════════
   owencasey.me
   ═══════════════════════════════════════════════════════════ */

/* ── Reset ── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

/* ── Custom Properties ── */
:root {
    /* Palette */
    --bg:           #f8f5ef;
    --card:         #fff;
    --card-border:  #e8e3d8;
    --border-hover: #1a1a1a;
    --text:         #1a1a1a;
    --text-muted:   #888;
    --text-light:   #aaa;

    --primary:      #ff6b35;
    --secondary:    #4ecdc4;
    --highlight:    #ffe66d;
    --dark:         #1a1a1a;

    /* Chrome bar */
    --chrome-bg:    #f5f1ea;
    --chrome-border:#e8e3d8;

    /* Typography */
    --font-heading: 'Syne', sans-serif;
    --font-body:    'DM Sans', sans-serif;
    --font-mono:    'Space Mono', monospace;

    /* Spacing */
    --space-xs:  0.25rem;
    --space-sm:  0.5rem;
    --space-md:  1rem;
    --space-lg:  1.5rem;
    --space-xl:  2.5rem;
    --space-2xl: 4rem;

    /* Misc */
    --radius:       12px;
    --radius-sm:    8px;
    --shadow-hover: 5px 5px 0 var(--dark);
    --bounce:       cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* ── Dark Mode ── */
[data-theme="dark"] {
    --bg:           #151515;
    --card:         #1e1e1e;
    --card-border:  #2e2e2e;
    --border-hover: #ccc;
    --text:         #e8e3d8;
    --text-muted:   #999;
    --text-light:   #666;
    --chrome-bg:    #252525;
    --chrome-border:#2e2e2e;
    --shadow-hover: 5px 5px 0 rgba(255,255,255,0.06);
    color-scheme: dark;
}

[data-theme="dark"] .hero-text h1 {
    color: var(--text);
}

[data-theme="dark"] .logo {
    background: var(--text);
    color: #151515;
}

[data-theme="dark"] .filter-tab.active {
    background: var(--text);
    border-color: var(--text);
    color: var(--card);
}

[data-theme="dark"] .btn:hover {
    border-color: var(--border-hover);
    box-shadow: 2px 2px 0 rgba(255,255,255,0.06);
}

[data-theme="dark"] .btn-download:hover,
[data-theme="dark"] .btn-launch:hover {
    border-color: var(--border-hover);
}

[data-theme="dark"] .marquee {
    background: #0e0e0e;
}

[data-theme="dark"] .project-notice {
    background: #2a2518;
    border-color: #665c2e;
}

/* ── Base ── */
html { scroll-behavior: smooth; }

body {
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
    /* Subtle noise texture for paper feel */
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.03'/%3E%3C/svg%3E");
}

h1, h2, h3, h4, h5 {
    font-family: var(--font-heading);
    font-weight: 800;
    line-height: 1.15;
}

a { color: inherit; text-decoration: none; }
code, kbd {
    font-family: var(--font-mono);
    font-size: 0.85em;
    background: var(--chrome-bg);
    padding: 0.15em 0.4em;
    border-radius: 4px;
    border: 1px solid var(--card-border);
}
kbd {
    font-weight: 700;
    box-shadow: 0 1px 0 var(--card-border);
}

img { max-width: 100%; display: block; }

main {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 var(--space-lg);
}


/* ═══════════════════════════════════════════════════════════
   TOPBAR
   ═══════════════════════════════════════════════════════════ */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-md) var(--space-lg);
    max-width: 960px;
    margin: 0 auto;
}

.logo {
    font-family: var(--font-heading);
    font-weight: 800;
    font-size: 1.1rem;
    color: #fff;
    background: var(--dark);
    padding: 0.35em 0.75em;
    border-radius: var(--radius-sm);
    transform: rotate(-1.5deg);
    display: inline-block;
    transition: transform 0.2s var(--bounce);
    white-space: nowrap;
}
.logo:hover { transform: rotate(0deg) scale(1.05); }

.topbar-nav {
    display: flex;
    gap: var(--space-lg);
}
.topbar-nav a {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    transition: color 0.15s;
}
.topbar-nav a:hover { color: var(--primary); }

.theme-toggle {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    transition: color 0.15s;
    padding: 0;
    display: flex;
    align-items: center;
    line-height: 1;
}
.theme-toggle:hover { color: var(--primary); }
.theme-toggle svg { display: block; }


/* ═══════════════════════════════════════════════════════════
   TICKER
   ═══════════════════════════════════════════════════════════ */
.ticker {
    background: var(--primary);
    overflow: hidden;
    white-space: nowrap;
    padding: 0.5em 0;
}
.ticker-track {
    display: inline-flex;
    animation: ticker-scroll 45s linear infinite;
}
.ticker-item {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    font-weight: 700;
    color: #fff;
    padding: 0 var(--space-md);
}
.ticker-sep {
    color: rgba(255,255,255,0.5);
    padding: 0 var(--space-sm);
}

@keyframes ticker-scroll {
    from { transform: translateX(0); }
    to   { transform: translateX(-50%); }
}

/* Pause ticker on hover */
.ticker:hover .ticker-track { animation-play-state: paused; }


/* ═══════════════════════════════════════════════════════════
   ENTRANCE ANIMATIONS
   ═══════════════════════════════════════════════════════════ */
@keyframes fade-up {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.hero {
    animation: fade-up 0.6s ease-out both;
}

.card {
    animation: fade-up 0.5s ease-out both;
}
.card:nth-child(1) { animation-delay: 0.08s; }
.card:nth-child(2) { animation-delay: 0.16s; }
.card:nth-child(3) { animation-delay: 0.24s; }
.card:nth-child(4) { animation-delay: 0.32s; }
.card:nth-child(5) { animation-delay: 0.40s; }
.card:nth-child(6) { animation-delay: 0.48s; }

.about {
    animation: fade-up 0.5s ease-out both;
    animation-delay: 0.3s;
}


/* ═══════════════════════════════════════════════════════════
   WINDOW CHROME (shared)
   ═══════════════════════════════════════════════════════════ */
.window-chrome {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    background: var(--chrome-bg);
    border-bottom: 2px solid var(--chrome-border);
    padding: 0.5em 0.75em;
    border-radius: var(--radius) var(--radius) 0 0;
}
.window-dots { display: flex; gap: 5px; }
.dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}
.dot-red    { background: #ff5f57; }
.dot-yellow { background: #ffbd2e; }
.dot-green  { background: #28c840; }

.window-title {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-left: var(--space-xs);
}


/* ═══════════════════════════════════════════════════════════
   HERO
   ═══════════════════════════════════════════════════════════ */
.hero {
    margin-top: var(--space-xl);
    border: 2px solid var(--card-border);
    border-radius: var(--radius);
    background: var(--card);
    overflow: hidden;
}

.hero-body {
    position: relative;
    height: 380px;
    background: var(--bg);
    overflow: hidden;
}

#hero-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
}

.hero-text {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    pointer-events: none;
    padding: var(--space-xl);
    z-index: 2;
}

.hero-text h1 {
    font-size: clamp(1.8rem, 5vw, 3rem);
    line-height: 1.1;
    color: var(--dark);
    margin-bottom: 0.3em;
    /* text outline for readability over particles */
    text-shadow:
        2px 2px 0 var(--bg),
        -2px 2px 0 var(--bg),
        2px -2px 0 var(--bg),
        -2px -2px 0 var(--bg),
        0 2px 0 var(--bg),
        0 -2px 0 var(--bg),
        2px 0 0 var(--bg),
        -2px 0 0 var(--bg);
}

.hero-text p {
    font-family: var(--font-mono);
    font-size: clamp(0.85rem, 2vw, 1.05rem);
    color: var(--text-muted);
    text-shadow:
        1px 1px 0 var(--bg),
        -1px 1px 0 var(--bg),
        1px -1px 0 var(--bg),
        -1px -1px 0 var(--bg);
}

.hero-hint {
    position: absolute;
    bottom: var(--space-lg);
    left: 50%;
    transform: translateX(-50%);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-light);
    z-index: 2;
    transition: opacity 0.8s ease;
    pointer-events: none;
}
.hero-hint.hidden { opacity: 0; }


/* ═══════════════════════════════════════════════════════════
   PROJECT CARDS
   ═══════════════════════════════════════════════════════════ */
.projects {
    margin-top: var(--space-2xl);
}

.projects-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: var(--space-lg);
    flex-wrap: wrap;
    gap: var(--space-md);
}

.projects-header h2 {
    font-size: 1.6rem;
}

.filter-tabs {
    display: flex;
    gap: var(--space-xs);
}
.filter-tab {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 700;
    background: none;
    border: 2px solid var(--card-border);
    border-radius: 999px;
    padding: 0.3em 0.9em;
    cursor: pointer;
    color: var(--text-muted);
    transition: all 0.15s;
}
.filter-tab:hover {
    border-color: var(--text);
    color: var(--text);
}
.filter-tab.active {
    background: var(--dark);
    border-color: var(--dark);
    color: #fff;
}

/* Grid */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: var(--space-lg);
}

/* Card */
.card {
    display: flex;
    flex-direction: column;
    background: var(--card);
    border: 2px solid var(--card-border);
    border-radius: var(--radius);
    overflow: hidden;
    transition:
        transform 0.25s var(--bounce),
        border-color 0.2s,
        box-shadow 0.25s var(--bounce);
    cursor: pointer;
}
.card:hover {
    transform: translateY(-5px) rotate(-1deg);
    border-color: var(--border-hover);
    box-shadow: var(--shadow-hover);
}

.card .window-chrome {
    border-radius: 0;
}

/* Card preview */
.card-preview {
    height: 140px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}
.card-icon {
    font-family: var(--font-mono);
    font-size: 2rem;
    font-weight: 700;
    color: var(--dark);
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.08));
}
.card-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Card body */
.card-body {
    padding: var(--space-md);
    flex: 1;
}
.card-meta {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-xs);
}
.card-category {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}
.badge {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    font-weight: 700;
    padding: 0.15em 0.5em;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.badge-new {
    background: var(--primary);
    color: #fff;
}
.badge-version {
    background: var(--chrome-bg);
    color: var(--text-muted);
    border: 1px solid var(--card-border);
}

.card-title {
    font-size: 1.15rem;
    margin-bottom: 0.2em;
}
.card-tagline {
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.4;
}

/* Card hidden by filter */
.card[data-hidden] {
    display: none;
}

/* Card focus-visible for keyboard nav */
.card:focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
}

/* Selection color */
::selection {
    background: var(--highlight);
    color: var(--dark);
}


/* ═══════════════════════════════════════════════════════════
   ABOUT
   ═══════════════════════════════════════════════════════════ */
.about {
    margin-top: var(--space-2xl);
    border: 2px solid var(--card-border);
    border-radius: var(--radius);
    background: var(--card);
    overflow: hidden;
}
.about-body {
    padding: var(--space-xl);
}
.about-body h2 {
    font-size: 1.4rem;
    margin-bottom: var(--space-md);
}
.about-body p {
    color: var(--text-muted);
    max-width: 55ch;
    margin-bottom: var(--space-md);
}
.about-body p:last-child { margin-bottom: 0; }


/* ═══════════════════════════════════════════════════════════
   MARQUEE
   ═══════════════════════════════════════════════════════════ */
.marquee {
    background: var(--dark);
    overflow: hidden;
    white-space: nowrap;
    padding: 0.8em 0;
    margin-top: var(--space-2xl);
}
.marquee-track {
    display: inline-flex;
    animation: marquee-scroll 25s linear infinite;
}
.marquee-track span {
    font-family: var(--font-heading);
    font-weight: 800;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: rgba(255,255,255,0.7);
    padding: 0 var(--space-xl);
}

@keyframes marquee-scroll {
    from { transform: translateX(0); }
    to   { transform: translateX(-50%); }
}

.marquee:hover .marquee-track { animation-play-state: paused; }


/* ═══════════════════════════════════════════════════════════
   FOOTER
   ═══════════════════════════════════════════════════════════ */
.site-footer {
    padding: var(--space-xl) var(--space-lg);
    text-align: center;
}
.footer-inner {
    max-width: 960px;
    margin: 0 auto;
}
.site-footer p {
    font-size: 0.8rem;
    color: var(--text-light);
}
.footer-links {
    margin-top: var(--space-xs);
}
.footer-links a:hover { color: var(--primary); }
.footer-dot { padding: 0 var(--space-sm); }


/* ═══════════════════════════════════════════════════════════
   PROJECT PAGE
   ═══════════════════════════════════════════════════════════ */
.project-page {
    padding-top: var(--space-lg);
}

/* Toolbar */
.project-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-lg);
    flex-wrap: wrap;
    gap: var(--space-sm);
}
.project-toolbar-right {
    display: flex;
    gap: var(--space-sm);
}

/* Buttons */
.btn {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    font-weight: 700;
    padding: 0.5em 1em;
    border-radius: var(--radius-sm);
    border: 2px solid var(--card-border);
    background: var(--card);
    color: var(--text);
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.4em;
}
.btn:hover {
    border-color: var(--dark);
    box-shadow: 2px 2px 0 var(--dark);
    transform: translate(-1px, -1px);
}
.btn-download {
    background: var(--secondary);
    border-color: var(--secondary);
    color: #fff;
}
.btn-download:hover {
    background: #3dbdb5;
    border-color: var(--dark);
    color: #fff;
}

/* Embed */
.project-embed {
    border: 2px solid var(--card-border);
    border-radius: var(--radius);
    background: var(--card);
    overflow: hidden;
}
.project-embed .window-chrome { border-radius: 0; }

.embed-frame {
    position: relative;
    background: #000;
}
.embed-fullscreen .embed-frame { height: 70vh; min-height: 400px; }
.embed-contained .embed-frame { height: 560px; }

.embed-frame iframe {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
    position: relative;
    z-index: 1;
}

/* Loading state for iframe */
.embed-frame::before {
    content: 'Loading\2026';
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: #555;
    background: #111;
    z-index: 0;
    pointer-events: none;
}

/* Fullscreen mode */
.project-embed.is-fullscreen {
    position: fixed;
    inset: 0;
    z-index: 9999;
    border-radius: 0;
    border: none;
}
.project-embed.is-fullscreen .embed-frame {
    height: calc(100vh - 32px);
    min-height: unset;
}

/* Launch button */
.project-launch {
    text-align: center;
    margin: var(--space-lg) 0;
}
.btn-launch {
    font-family: var(--font-heading);
    font-size: 1rem;
    font-weight: 800;
    padding: 0.75em 2em;
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}
.btn-launch:hover {
    background: #e85a26;
    border-color: var(--dark);
    color: #fff;
}

/* Project info */
.project-info {
    margin-top: var(--space-lg);
    border: 2px solid var(--card-border);
    border-radius: var(--radius);
    background: var(--card);
    overflow: hidden;
}
.project-info-body {
    padding: var(--space-xl);
}
.project-info-header {
    display: flex;
    align-items: center;
    gap: var(--space-lg);
    margin-bottom: var(--space-lg);
}
.project-icon {
    font-family: var(--font-mono);
    font-size: 2rem;
    font-weight: 700;
}
.project-icon-img {
    width: 64px;
    height: 64px;
    object-fit: cover;
    border-radius: var(--radius-sm);
}
.project-info-header h1 {
    font-size: 1.6rem;
}
.project-tagline {
    font-family: var(--font-mono);
    font-size: 0.9rem;
    color: var(--text-muted);
}

.project-section {
    margin-bottom: var(--space-lg);
}
.project-section h2 {
    font-size: 1rem;
    margin-bottom: var(--space-sm);
}
.project-section p {
    color: var(--text-muted);
    max-width: 55ch;
}

.controls-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}
.controls-list li {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.project-notice {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    background: #fff8e6;
    border: 1px solid #ffe066;
    border-radius: var(--radius-sm);
    padding: var(--space-md);
    margin-top: var(--space-lg);
}

.project-meta-bar {
    display: flex;
    gap: var(--space-sm);
    flex-wrap: wrap;
    padding-top: var(--space-lg);
    border-top: 1px solid var(--card-border);
}
.meta-chip {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.3em 0.8em;
    border-radius: 999px;
    background: var(--chrome-bg);
    color: var(--text-muted);
    border: 1px solid var(--card-border);
}
.meta-link:hover {
    border-color: var(--primary);
    color: var(--primary);
}


/* ═══════════════════════════════════════════════════════════
   404
   ═══════════════════════════════════════════════════════════ */
.page-404 {
    margin-top: var(--space-2xl);
    border: 2px solid var(--card-border);
    border-radius: var(--radius);
    background: var(--card);
    overflow: hidden;
}
.four-oh-four-body {
    padding: var(--space-2xl);
    text-align: center;
}
.four-oh-four-icon {
    font-family: var(--font-mono);
    font-size: 3rem;
    font-weight: 700;
    display: block;
    margin-bottom: var(--space-md);
}
.four-oh-four-body h1 {
    font-size: 5rem;
    line-height: 1;
    margin-bottom: var(--space-sm);
}
.four-oh-four-body p {
    font-family: var(--font-mono);
    color: var(--text-muted);
    margin-bottom: var(--space-xl);
}


/* ═══════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════ */

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .ticker-track,
    .marquee-track { animation: none !important; }
    .card { animation: none !important; }
    .hero { animation: none !important; }
    .about { animation: none !important; }
    .card:hover { transform: none; }
    html { scroll-behavior: auto; }
}

/* Print */
@media print {
    .ticker, .marquee, .hero-hint, #hero-canvas { display: none; }
    .card:hover { transform: none; box-shadow: none; }
}

@media (max-width: 640px) {
    .topbar {
        flex-direction: column;
        gap: var(--space-md);
        text-align: center;
    }

    .hero-body { height: 280px; }
    .hero-text h1 { font-size: 1.5rem; }

    .card-grid {
        grid-template-columns: 1fr;
    }

    .projects-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .project-toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    .project-toolbar-right {
        justify-content: stretch;
    }
    .project-toolbar-right .btn {
        flex: 1;
        justify-content: center;
    }

    .embed-fullscreen .embed-frame,
    .embed-contained .embed-frame {
        height: 50vh;
        min-height: 280px;
    }

    .project-info-header {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-md);
    }
}
