/* ===========================
   Spooky Spectral Ghost Page
   Layout + Responsive Styles
   =========================== */


:root {
    --bg-body: #020617;
    --bg-window: #050814;
    --bg-panel: #020617;
    --bg-preview: #020617;
    --border-window: #111827;
    --border-preview: #1f2937;
    --accent: #22c55e;
    --accent-soft: rgba(34, 197, 94, 0.25);
    --text-main: #e5e7eb;
    --text-muted: #9ca3af;
    --shadow-window: 0 24px 80px rgba(0, 0, 0, 0.7);
    --radius-lg: 18px;
    --radius-md: 14px;
}

/* ======= Page base ======= */

html,
body {
    margin: 0;
    padding: 0;
    height: 100%;
}

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "JetBrains Mono",
        monospace;
    background: radial-gradient(circle at top left, #020617 0%, #020617 45%, #020617 100%);
    color: var(--text-main);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 32px 24px;
    box-sizing: border-box;
}

/* Main card window that wraps EVERYTHING on this page */
.page-window {
    width: 100%;
    max-width: 960px;
    background: linear-gradient(145deg, #020617 0%, #050814 50%, #020617 100%);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-window);
    box-shadow: var(--shadow-window);
    overflow: hidden;
}

/* ======= Title bar (red/yellow/green dots) ======= */

.title-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 18px;
    background: #020617;
    border-bottom: 1px solid #111827;
}

.tb-dots {
    display: flex;
    gap: 6px;
}

.tb-dot {
    width: 10px;
    height: 10px;
    border-radius: 999px;
}

.tb-dot.red {
    background: #ff5f57;
}

.tb-dot.yellow {
    background: #febc2e;
}

.tb-dot.green {
    background: #28c840;
}

.tb-title {
    font-size: 13px;
    color: var(--text-muted);
}

/* ======= Page content layout ======= */

.page-content {
    padding: 28px 32px 28px;
}

/* Header row: title + home button + "View Code" button */
.demo-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
}

.demo-title-block h1 {
    font-size: 26px;
    margin: 0 0 4px;
}

.demo-title-block p {
    margin: 0;
    font-size: 13px;
    color: var(--text-muted);
}

.demo-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.btn-ghost,
.btn-code {
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.5);
    background: rgba(15, 23, 42, 0.9);
    color: var(--text-main);
    font-size: 12px;
    padding: 8px 14px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s ease, border-color 0.15s ease,
        transform 0.1s ease;
}

.btn-ghost:hover,
.btn-code:hover {
    background: rgba(15, 23, 42, 1);
    border-color: var(--accent);
    transform: translateY(-1px);
}

/* ======= Description list above preview ======= */

.demo-description {
    margin-bottom: 22px;
    font-size: 13px;
    color: var(--text-muted);
}

.demo-description ul {
    list-style: disc;
    padding-left: 18px;
    margin: 8px 0 0;
}

/* ======= Preview card + iframe ======= */

.preview-box {
    background: radial-gradient(circle at top left, #020617, #020617 55%, #020617);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-preview);
    padding: 18px;
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.7);
}

/* This inner wrapper controls the aspect ratio */
.preview-inner {
    position: relative;
    width: 100%;
    max-width: 100%;
    border-radius: var(--radius-md);
    background: #000;
    overflow: hidden;
    /* On desktop: 16:9 */
    aspect-ratio: 16 / 9;
}

/* Fallback for very old browsers (no aspect-ratio support) */
@supports not (aspect-ratio: 1 / 1) {
    .preview-inner {
        padding-top: 56.25%;
        /* 16:9 */
    }

    .preview-inner iframe {
        position: absolute;
        inset: 0;
    }
}

/* The iframe itself (Three.js demo) */
.preview-inner iframe,
#spookyPreview {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

/* Optionally add a subtle “glow” border */
.preview-inner::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    pointer-events: none;
    box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.9),
        0 0 60px var(--accent-soft);
}

/* ======= Footer / note under the preview (if you have one) ======= */

.demo-footer {
    margin-top: 14px;
    font-size: 12px;
    color: var(--text-muted);
}

/* ===========================
   Responsive Behaviour
   =========================== */

/* --- Large tablets & small laptops --- */
@media (max-width: 1024px) {
    body {
        padding: 24px 16px;
    }

    .page-window {
        max-width: 860px;
    }

    .page-content {
        padding: 24px 22px 24px;
    }
}

/* --- Tablets / landscape phones --- */
@media (max-width: 768px) {
    body {
        padding: 18px 10px;
    }

    .page-window {
        border-radius: 14px;
    }

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

    .demo-title-block h1 {
        font-size: 22px;
    }

    .demo-title-block p {
        font-size: 12px;
    }

    .demo-actions {
        width: 100%;
        justify-content: flex-start;
        flex-wrap: wrap;
    }

    .btn-ghost,
    .btn-code {
        font-size: 11px;
        padding: 7px 12px;
    }

    /* Slightly taller preview so more of the iframe content is visible */
    .preview-inner {
        aspect-ratio: 4 / 5;
    }
}

/* --- Small phones --- */
@media (max-width: 480px) {
    body {
        padding: 12px 6px;
    }

    .page-window {
        border-radius: 10px;
    }

    .title-bar {
        padding-inline: 12px;
    }

    .page-content {
        padding: 18px 14px 20px;
    }

    .demo-title-block h1 {
        font-size: 19px;
    }

    .demo-description {
        font-size: 12px;
    }

    /* Taller preview so the whole experience fits on screen */
    .preview-inner {
        aspect-ratio: 3 / 4;
        /* nice tall card on mobile */
    }
}

/* --- Ultra-small screens (older phones) --- */
@media (max-width: 360px) {
    .demo-title-block h1 {
        font-size: 17px;
    }

    .btn-ghost,
    .btn-code {
        padding: 6px 10px;
    }

    .preview-inner {
        aspect-ratio: 2.8 / 4;
    }
}