﻿*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --bg: #08080c;
    --surface: #0c0c14;
    --card: #111119;
    --border: #1a1a28;
    --border-subtle: #14141f;
    --gold: #c9a96e;
    --gold-dim: rgba(201, 169, 110, 0.08);
    --gold-glow: rgba(201, 169, 110, 0.15);
    --text: #e8e4de;
    --muted: #5a5a6e;
    --font-display: 'Syne', sans-serif;
    --font-body: 'IBM Plex Mono', monospace;

    /* Forge specimen */
    --spec-color: #c9a96e;
    --spec-r: 201;
    --spec-g: 169;
    --spec-b: 110;
}

html { scroll-behavior: smooth; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    min-height: 100vh;
    overflow: hidden;
    cursor: none;
    position: relative;
}

/* ========== AMBIENT GLOW ========== */
.ambient-glow {
    position: fixed;
    top: 50%;
    left: 60%;
    width: 700px;
    height: 700px;
    transform: translate(-50%, -50%);
    background: radial-gradient(
        circle,
        rgba(var(--spec-r), var(--spec-g), var(--spec-b), 0.06) 0%,
        rgba(var(--spec-r), var(--spec-g), var(--spec-b), 0.02) 35%,
        transparent 65%
    );
    pointer-events: none;
    z-index: 0;
    transition: background 0.8s ease;
}

/* ========== CUSTOM CURSOR ========== */
.cursor-dot {
    position: fixed;
    width: 6px; height: 6px;
    background: var(--gold);
    border-radius: 50%;
    pointer-events: none;
    z-index: 9999;
    transform: translate(-50%, -50%);
    transition: width 0.15s, height 0.15s, background 0.3s;
}

.cursor-ring {
    position: fixed;
    width: 36px; height: 36px;
    border: 1px solid rgba(201, 169, 110, 0.3);
    border-radius: 50%;
    pointer-events: none;
    z-index: 9998;
    transition: all 0.18s ease-out;
    transform: translate(-50%, -50%);
}

.cursor-ring.hovering {
    width: 50px; height: 50px;
    border-color: rgba(201, 169, 110, 0.5);
    background: rgba(201, 169, 110, 0.04);
}

/* ========== NAVIGATION ========== */
.back-link {
    position: fixed;
    top: 1.5rem;
    left: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: var(--font-body);
    font-size: 0.7rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted);
    text-decoration: none;
    transition: color 0.3s ease;
    z-index: 100;
    cursor: none;
}
.back-link:hover { color: var(--gold); }
.back-link svg { transition: transform 0.3s ease; }
.back-link:hover svg { transform: translateX(-4px); }

.project-label {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    font-family: var(--font-body);
    font-size: 0.58rem;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    color: var(--gold);
    z-index: 100;
    opacity: 0;
    animation: fadeIn 0.6s ease forwards 0.2s;
}

/* ========== FORGE LAYOUT ========== */
.forge-layout {
    display: grid;
    grid-template-columns: 340px 1fr;
    height: 100vh;
    position: relative;
    z-index: 1;
}

/* ========== CONTROLS PANEL ========== */
.controls {
    padding: 4.5rem 1.8rem 1.5rem;
    border-right: 1px solid var(--border-subtle);
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    gap: 1.6rem;
    background: rgba(8, 8, 12, 0.6);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);

    /* Scrollbar */
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.controls::-webkit-scrollbar { width: 3px; }
.controls::-webkit-scrollbar-track { background: transparent; }
.controls::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ---- Header ---- */
.controls-header {
    opacity: 0;
    transform: translateY(15px);
    animation: fadeUp 0.7s ease forwards 0.3s;
}

.forge-title {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: clamp(2rem, 4vw, 2.8rem);
    line-height: 1.0;
    letter-spacing: -0.04em;
}

.forge-title .title-line {
    display: block;
    overflow: hidden;
}

.forge-title .title-line span {
    display: inline-block;
    opacity: 0;
    transform: translateY(110%);
    animation: slideUp 0.9s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.forge-title .title-line:nth-child(1) span { animation-delay: 0.4s; color: var(--text); }
.forge-title .title-line:nth-child(2) span { animation-delay: 0.55s; }

.accent {
    color: transparent;
    -webkit-text-stroke: 1.5px var(--gold);
    filter: drop-shadow(0 0 30px rgba(201, 169, 110, 0.2));
}

.forge-sub {
    margin-top: 0.8rem;
    font-size: 0.72rem;
    font-weight: 300;
    color: var(--muted);
    line-height: 1.65;
    opacity: 0;
    animation: fadeIn 0.6s ease forwards 0.8s;
}

/* ---- Control Stack ---- */
.control-stack {
    display: flex;
    flex-direction: column;
    gap: 0;
    opacity: 0;
    animation: fadeIn 0.6s ease forwards 1.1s;
}

.control-row {
    padding: 0.7rem 0;
    border-bottom: 1px solid var(--border-subtle);
}

.control-row:last-child { border-bottom: none; }

.control-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.control-meta label {
    font-size: 0.62rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text);
    font-weight: 400;
    cursor: none;
}

.control-val {
    font-size: 0.6rem;
    font-family: var(--font-body);
    color: var(--gold);
    background: var(--gold-dim);
    padding: 0.15rem 0.5rem;
    border-radius: 2px;
    min-width: 52px;
    text-align: center;
    transition: background 0.3s;
}

/* ---- Color input ---- */
.color-input-wrap {
    position: relative;
    height: 28px;
}

.color-input-wrap input[type="color"] {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: none;
    border: none;
}

.color-swatch {
    width: 100%;
    height: 100%;
    border-radius: 4px;
    background: var(--spec-color);
    border: 1px solid var(--border);
    pointer-events: none;
    transition: background 0.2s, box-shadow 0.3s;
    box-shadow: 0 0 20px rgba(var(--spec-r), var(--spec-g), var(--spec-b), 0.15);
}

/* ---- Custom Range Slider ---- */
.slider-track {
    position: relative;
    height: 28px;
    display: flex;
    align-items: center;
}

.slider-track input[type="range"] {
    width: 100%;
    height: 2px;
    border-radius: 1px;
    background: var(--border);
    outline: none;
    cursor: none;
    -webkit-appearance: none;
    appearance: none;
    position: relative;
    z-index: 2;
}

.slider-fill {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    height: 2px;
    background: var(--gold);
    border-radius: 1px;
    pointer-events: none;
    z-index: 1;
    transition: width 0.05s;
}

input[type="range"]::-webkit-slider-thumb {
    width: 12px;
    height: 12px;
    background: var(--gold);
    border-radius: 50%;
    cursor: none;
    border: 2px solid var(--bg);
    -webkit-appearance: none;
    appearance: none;
    box-shadow: 0 0 8px rgba(201, 169, 110, 0.3);
    transition: box-shadow 0.2s, transform 0.2s;
}

input[type="range"]::-webkit-slider-thumb:hover {
    box-shadow: 0 0 16px rgba(201, 169, 110, 0.5);
    transform: scale(1.2);
}

input[type="range"]::-moz-range-thumb {
    width: 12px;
    height: 12px;
    background: var(--gold);
    border-radius: 50%;
    cursor: none;
    border: 2px solid var(--bg);
    box-shadow: 0 0 8px rgba(201, 169, 110, 0.3);
}

input[type="range"]::-moz-range-track {
    height: 2px;
    background: var(--border);
    border: none;
    border-radius: 1px;
}

/* ---- Reset Button ---- */
.reset-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.7rem;
    font-family: var(--font-body);
    font-size: 0.62rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--muted);
    cursor: none;
    transition: all 0.3s ease;
    opacity: 0;
    animation: fadeIn 0.6s ease forwards 1.3s;
}

.reset-btn:hover {
    border-color: rgba(230, 57, 70, 0.3);
    color: #e63946;
    background: rgba(230, 57, 70, 0.05);
}

/* ========== FORGE CHAMBER ========== */
.chamber {
    position: relative;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 22vh;
    overflow: hidden;
    background:
        radial-gradient(circle at 50% 50%, rgba(var(--spec-r), var(--spec-g), var(--spec-b), 0.015) 0%, transparent 50%),
        var(--bg);
    transition: background 1s ease;
}

/* ---- Crosshair Grid ---- */
.chamber-grid {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 0;
}

.grid-line-h {
    position: absolute;
    top: 40%;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent 0%, var(--border-subtle) 20%, var(--border-subtle) 80%, transparent 100%);
    opacity: 0.5;
}

.grid-line-v {
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 1px;
    background: linear-gradient(180deg, transparent 0%, var(--border-subtle) 20%, var(--border-subtle) 80%, transparent 100%);
    opacity: 0.5;
}

.grid-ring {
    position: absolute;
    top: 40%;
    left: 50%;
    border-radius: 50%;
    border: 1px solid var(--border-subtle);
    opacity: 0.25;
    transform: translate(-50%, -50%);
}

.ring-1 { width: 300px; height: 300px; }
.ring-2 { width: 500px; height: 500px; opacity: 0.12; }

/* ---- The Specimen ---- */
.specimen {
    position: relative;
    z-index: 2;
    width: 220px;
    height: 220px;
    background: var(--spec-color);
    border-radius: 16px;
    transition: all 0.15s ease;
    box-shadow:
        0 0 40px rgba(var(--spec-r), var(--spec-g), var(--spec-b), 0.2),
        0 0 80px rgba(var(--spec-r), var(--spec-g), var(--spec-b), 0.08),
        0 20px 60px rgba(0, 0, 0, 0.4);
    animation: specimenAppear 1s cubic-bezier(0.16, 1, 0.3, 1) forwards 0.6s;
    opacity: 0;
    transform: scale(0.8);
}

@keyframes specimenAppear {
    to { opacity: 1; transform: scale(1); }
}

/* ---- Dimension readout ---- */
.dimension-readout {
    position: absolute;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.58rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--muted);
    opacity: 0;
    animation: fadeIn 0.6s ease forwards 1.4s;
    z-index: 5;
}

/* ========== CSS OUTPUT ========== */
.css-output {
    position: absolute;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 50;
    width: min(520px, 80%);
    opacity: 0;
    animation: fadeIn 0.6s ease forwards 1.5s;
}

.css-output-inner {
    background: rgba(6, 6, 10, 0.92);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
}

.css-output-bar {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 0.8rem;
    background: rgba(255, 255, 255, 0.02);
    border-bottom: 1px solid var(--border-subtle);
}

.terminal-dots {
    display: flex;
    gap: 5px;
    margin-right: 0.3rem;
}

.tdot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
}

.tdot-r { background: #e63946; opacity: 0.7; }
.tdot-y { background: #e6a839; opacity: 0.7; }
.tdot-g { background: #4ecdc4; opacity: 0.7; }

.css-output-label {
    font-family: var(--font-body);
    font-size: 0.58rem;
    letter-spacing: 0.04em;
    color: var(--muted);
    flex: 1;
}

.copy-btn {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-family: var(--font-body);
    font-size: 0.5rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 3px;
    color: var(--muted);
    padding: 0.25rem 0.5rem;
    cursor: none;
    transition: all 0.25s ease;
    opacity: 0.6;
}

.copy-btn:hover {
    opacity: 1;
    color: var(--gold);
    border-color: rgba(201, 169, 110, 0.2);
}

.copy-btn.copied {
    opacity: 1;
    color: #4ecdc4;
    border-color: rgba(78, 205, 196, 0.2);
}

.css-code {
    display: block;
    font-family: var(--font-body);
    font-size: 0.6rem;
    color: var(--muted);
    line-height: 1.7;
    white-space: pre;
    overflow-x: auto;
    scrollbar-width: none;
    padding: 0.7rem 1rem;
    max-height: 180px;
    overflow-y: auto;
}

.css-code::-webkit-scrollbar { display: none; }

/* Syntax color highlights */
.css-prop { color: #c4b89a; }
.css-val { color: var(--gold); font-weight: 400; }
.css-punc { color: rgba(120, 115, 105, 0.7); }
.css-line-num {
    display: inline-block;
    width: 2ch;
    text-align: right;
    margin-right: 1.2em;
    color: rgba(120, 115, 105, 0.35);
    font-size: 0.55rem;
    user-select: none;
}

/* ========== ANIMATIONS ========== */
@keyframes fadeIn { to { opacity: 1; } }
@keyframes fadeUp { to { opacity: 1; transform: translateY(0); } }
@keyframes slideUp { to { opacity: 1; transform: translateY(0); } }

/* ========== RESPONSIVE ========== */
@media (max-width: 900px) {
    .forge-layout {
        grid-template-columns: 1fr;
        height: auto;
        min-height: 100vh;
    }

    .controls {
        padding: 4rem 1.5rem 1.5rem;
        border-right: none;
        border-bottom: 1px solid var(--border-subtle);
        max-height: 50vh;
    }

    .chamber {
        min-height: 50vh;
    }

    .css-output {
        position: relative;
        bottom: auto;
        left: auto;
        transform: none;
        width: 100%;
    }

    body {
        overflow-y: auto;
        cursor: auto;
    }

    .cursor-dot, .cursor-ring { display: none; }

    .back-link, .reset-btn,
    .control-meta label, input[type="range"],
    .copy-btn, input[type="color"] {
        cursor: pointer;
    }
}

@media (max-width: 480px) {
    .forge-title {
        font-size: 2rem;
    }

    .controls {
        padding: 3.5rem 1rem 1rem;
    }
}
