/* ==========================================================
   ppuzzl.net - Isometric Technical Blueprint Puzzle Assembly
   ========================================================== */

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

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    background-color: #fafafa;
    color: #2a2a2a;
    font-family: 'IBM Plex Sans', sans-serif;
    font-weight: 400;
    font-size: clamp(0.95rem, 1.2vw, 1.1rem);
    line-height: 1.6;
    letter-spacing: 0.02em;
    overflow-x: hidden;
    position: relative;
}

/* --- Typography --- */
.headline {
    font-family: 'Courier Prime', monospace;
    font-weight: 700;
    font-size: clamp(2.2rem, 5vw, 4rem);
    letter-spacing: 0.12em;
    line-height: 1.2;
    text-transform: uppercase;
    color: #2a2a2a;
}

.subheading {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 500;
    font-size: clamp(1.2rem, 2.5vw, 1.8rem);
    letter-spacing: 0.08em;
    color: #5a5a5a;
    margin-top: 0.5rem;
}

.body-text {
    font-family: 'IBM Plex Sans', sans-serif;
    font-weight: 400;
    font-size: clamp(0.95rem, 1.2vw, 1.1rem);
    line-height: 1.6;
    letter-spacing: 0.02em;
    color: #5a5a5a;
    max-width: 65ch;
}

.data-text {
    font-family: 'Space Mono', monospace;
    font-weight: 400;
    font-size: 0.85rem;
    color: #5a5a5a;
}

/* --- Isometric Background Grid --- */
#iso-grid-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    opacity: 0.08;
    background-image:
        linear-gradient(30deg, #d0d0d0 1px, transparent 1px),
        linear-gradient(150deg, #d0d0d0 1px, transparent 1px),
        linear-gradient(90deg, #d0d0d0 1px, transparent 1px);
    background-size: 60px 60px, 60px 60px, 60px 60px;
    transition: transform 0.3s ease-out;
}

/* --- Progress Bar --- */
#progress-bar-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 20px 8px 80px;
    background: rgba(250, 250, 250, 0.95);
    border-bottom: 1px solid #d0d0d0;
    backdrop-filter: blur(4px);
}

#progress-bar-track {
    flex: 1;
    height: 4px;
    background: #d0d0d0;
    position: relative;
    overflow: hidden;
}

#progress-bar-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #1e90ff, #2ecc71);
    transition: width 0.3s ease-out;
}

#progress-label {
    white-space: nowrap;
    font-size: 0.75rem;
    color: #5a5a5a;
    min-width: 100px;
    text-align: right;
}

/* --- Timeline --- */
#timeline {
    position: fixed;
    top: 32px;
    left: 80px;
    right: 0;
    z-index: 90;
    padding: 10px 20px;
    background: rgba(250, 250, 250, 0.9);
    border-bottom: 1px solid #d0d0d0;
    overflow-x: auto;
    backdrop-filter: blur(4px);
}

.timeline-track {
    display: flex;
    align-items: center;
    gap: 0;
    min-width: max-content;
}

.timeline-marker {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    padding: 4px 8px;
    transition: opacity 0.3s ease;
    opacity: 0.4;
}

.timeline-marker.active {
    opacity: 1;
}

.timeline-marker.visited {
    opacity: 0.8;
}

.timeline-dot {
    width: 12px;
    height: 12px;
    border: 2px solid #4a4a4a;
    border-radius: 50%;
    background: transparent;
    transition: background 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

.timeline-marker.active .timeline-dot {
    background: #1e90ff;
    border-color: #1e90ff;
    box-shadow: 0 0 8px rgba(30, 144, 255, 0.4);
}

.timeline-marker.visited .timeline-dot {
    background: #2ecc71;
    border-color: #2ecc71;
}

.timeline-label {
    font-size: 0.7rem;
    letter-spacing: 0.1em;
}

.timeline-connector {
    width: 40px;
    height: 2px;
    background: #d0d0d0;
    flex-shrink: 0;
}

/* --- Sidebar --- */
#sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 72px;
    height: 100vh;
    z-index: 95;
    background: rgba(250, 250, 250, 0.95);
    border-right: 1px solid #d0d0d0;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 80px;
    gap: 8px;
    backdrop-filter: blur(4px);
}

.sidebar-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 8px 4px;
    cursor: pointer;
    opacity: 0.35;
    transition: opacity 0.3s ease, color 0.3s ease;
    color: #4a4a4a;
    width: 100%;
}

.sidebar-item:hover {
    opacity: 0.7;
}

.sidebar-item.active {
    opacity: 1;
    color: #1e90ff;
}

.sidebar-item.visited {
    opacity: 0.7;
    color: #2ecc71;
}

.sidebar-icon {
    width: 24px;
    height: 24px;
}

.sidebar-label {
    font-size: 0.6rem;
    letter-spacing: 0.1em;
    text-align: center;
}

#coord-display {
    margin-top: auto;
    padding: 12px 4px 20px;
    text-align: center;
    font-size: 0.7rem;
    line-height: 1.6;
    color: #5a5a5a;
    border-top: 1px solid #d0d0d0;
    width: 100%;
}

/* --- Main Content --- */
#content {
    margin-left: 72px;
    padding-top: 80px;
    position: relative;
    z-index: 1;
}

/* --- Isometric Sections --- */
.iso-section {
    position: relative;
    min-height: 100vh;
    padding: 80px 60px;
    border-bottom: 1px solid #d0d0d0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.iso-section:nth-child(even) {
    margin-left: 40px;
}

.iso-section:nth-child(odd) {
    margin-left: 0;
}

.section-inner {
    max-width: 1100px;
    width: 100%;
    position: relative;
    opacity: 0;
    transform: translateY(40px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

.iso-section.in-view .section-inner {
    opacity: 1;
    transform: translateY(0);
}

/* --- Corner Brackets --- */
.corner-bracket {
    position: absolute;
    width: 20px;
    height: 20px;
}

.corner-bracket.top-left {
    top: 20px;
    left: 20px;
    border-top: 2px solid #4a4a4a;
    border-left: 2px solid #4a4a4a;
}

.corner-bracket.top-right {
    top: 20px;
    right: 20px;
    border-top: 2px solid #4a4a4a;
    border-right: 2px solid #4a4a4a;
}

.corner-bracket.bottom-left {
    bottom: 20px;
    left: 20px;
    border-bottom: 2px solid #4a4a4a;
    border-left: 2px solid #4a4a4a;
}

.corner-bracket.bottom-right {
    bottom: 20px;
    right: 20px;
    border-bottom: 2px solid #4a4a4a;
    border-right: 2px solid #4a4a4a;
}

/* --- Section Coordinate Labels --- */
.section-coord {
    position: absolute;
    top: 24px;
    right: 48px;
    font-size: 0.7rem;
    color: #b8b8b8;
    letter-spacing: 0.1em;
    transition: color 0.5s ease;
}

.iso-section.in-view .section-coord {
    color: #5a5a5a;
}

/* --- Isometric Divider --- */
.iso-divider {
    width: 120px;
    height: 2px;
    background: linear-gradient(90deg, #1e90ff, transparent);
    margin: 1.5rem 0;
    transform: skewX(-30deg);
}

/* --- Content Grid --- */
.content-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
    margin-top: 2rem;
}

.content-grid.two-col {
    grid-template-columns: repeat(2, 1fr);
}

.grid-cell {
    border: 2px solid #4a4a4a;
    padding: 24px;
    position: relative;
    background: rgba(250, 250, 250, 0.8);
    transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
}

.grid-cell:hover {
    transform: translateY(-4px);
    box-shadow: 4px 8px 0 rgba(30, 144, 255, 0.15);
    border-color: #1e90ff;
}

.grid-cell.wide {
    grid-column: span 2;
}

.cell-header {
    display: flex;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 12px;
}

.cell-id {
    font-size: 0.7rem;
    color: #1e90ff;
    letter-spacing: 0.12em;
    flex-shrink: 0;
}

.cell-header .subheading {
    font-size: clamp(1rem, 1.5vw, 1.3rem);
    margin-top: 0;
}

.cell-stat {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid #d0d0d0;
    font-size: 0.75rem;
    color: #b8b8b8;
    letter-spacing: 0.1em;
}

/* --- Difficulty Indicators --- */
.difficulty-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 2rem;
}

.diff-box {
    width: 16px;
    height: 16px;
    border: 2px solid #4a4a4a;
    transform: rotate(45deg) skewX(-10deg);
    transition: background 0.3s ease, border-color 0.3s ease;
}

.diff-box.filled {
    background: #1e90ff;
    border-color: #1e90ff;
}

.difficulty-indicator .data-text {
    margin-left: 8px;
    font-size: 0.75rem;
}

/* --- Puzzle Pieces (CSS Isometric) --- */
.puzzle-pieces-container {
    display: flex;
    gap: 40px;
    margin-top: 3rem;
    justify-content: center;
    perspective: 600px;
}

.puzzle-piece {
    width: 80px;
    height: 80px;
    border: 2px solid #4a4a4a;
    position: relative;
    cursor: pointer;
    transition: transform 0.4s ease, box-shadow 0.4s ease, border-color 0.4s ease;
    transform: rotateX(15deg) rotateY(-10deg);
}

.puzzle-piece::before {
    content: '';
    position: absolute;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #fafafa;
    border: 2px solid #4a4a4a;
    transition: border-color 0.4s ease;
}

.puzzle-piece.piece-a {
    clip-path: polygon(0 0, 40% 0, 40% 15%, 60% 15%, 60% 0, 100% 0, 100% 100%, 0 100%);
    background: rgba(30, 144, 255, 0.08);
}

.puzzle-piece.piece-a::before {
    top: -14px;
    left: 50%;
    transform: translateX(-50%);
}

.puzzle-piece.piece-b {
    clip-path: polygon(0 0, 100% 0, 100% 40%, 85% 40%, 85% 60%, 100% 60%, 100% 100%, 0 100%);
    background: rgba(46, 204, 113, 0.08);
}

.puzzle-piece.piece-b::before {
    right: -14px;
    top: 50%;
    transform: translateY(-50%);
}

.puzzle-piece.piece-c {
    clip-path: polygon(0 0, 100% 0, 100% 100%, 60% 100%, 60% 85%, 40% 85%, 40% 100%, 0 100%);
    background: rgba(255, 107, 107, 0.08);
    /* #ff6b6b warm rust-red: puzzle error/warning accent */
}

.puzzle-piece.error {
    border-color: #ff6b6b;
    box-shadow: 0 0 12px rgba(255, 107, 107, 0.3);
}

.cell-stat.warning {
    color: #ff6b6b;
    border-top-color: #ff6b6b;
}

.puzzle-piece.piece-c::before {
    bottom: -14px;
    left: 50%;
    transform: translateX(-50%);
}

.puzzle-piece:hover {
    transform: rotateX(15deg) rotateY(-10deg) translateZ(20px) rotate(3deg);
    box-shadow: 6px 12px 0 rgba(30, 144, 255, 0.2);
    border-color: #1e90ff;
}

.puzzle-piece:hover::before {
    border-color: #1e90ff;
}

.puzzle-piece.snapped {
    border-color: #1e90ff;
    box-shadow: 0 0 20px rgba(30, 144, 255, 0.4);
    transform: rotateX(0) rotateY(0) translateZ(0) rotate(0);
}

/* --- Progress Graph --- */
.progress-graph {
    margin-top: 20px;
    padding: 16px 0;
}

.graph-line {
    height: 4px;
    background: #d0d0d0;
    position: relative;
    margin-bottom: 8px;
}

.graph-line::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #1e90ff, #2ecc71);
    transition: width 1.5s ease;
}

.graph-line.animate::after {
    width: var(--progress, 0%);
}

.graph-markers {
    display: flex;
    justify-content: space-between;
    font-size: 0.7rem;
    color: #b8b8b8;
}

/* --- Completion Section --- */
.completion-display {
    display: flex;
    gap: 60px;
    margin-top: 2rem;
    align-items: flex-start;
}

.completion-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    flex-shrink: 0;
}

.comp-piece {
    width: 48px;
    height: 48px;
    border: 2px solid #d0d0d0;
    background: transparent;
    transition: background 0.5s ease, border-color 0.5s ease, box-shadow 0.5s ease;
}

.comp-piece.placed.reveal {
    background: rgba(30, 144, 255, 0.15);
    border-color: #1e90ff;
}

.comp-piece.placed.reveal:nth-child(even) {
    background: rgba(46, 204, 113, 0.15);
    border-color: #2ecc71;
}

.completion-stats {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    gap: 40px;
    padding: 8px 0;
    border-bottom: 1px solid #d0d0d0;
}

.stat-val {
    color: #2a2a2a;
    font-weight: 700;
}

.stat-val.solved {
    color: #2ecc71;
}

.completion-note {
    margin-top: 3rem;
    font-style: italic;
    color: #b8b8b8;
}

/* --- Connectors Overlay --- */
.connectors-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2;
}

/* --- Responsive --- */
@media (max-width: 1024px) {
    .content-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .content-grid.two-col {
        grid-template-columns: repeat(2, 1fr);
    }
    .grid-cell.wide {
        grid-column: span 2;
    }
    .iso-section {
        padding: 60px 40px;
    }
    .completion-display {
        flex-direction: column;
        gap: 30px;
    }
}

@media (max-width: 768px) {
    #sidebar {
        width: 56px;
        padding-top: 72px;
    }
    .sidebar-label {
        display: none;
    }
    #content {
        margin-left: 56px;
    }
    #progress-bar-container {
        padding-left: 64px;
    }
    #timeline {
        left: 56px;
    }
    .content-grid,
    .content-grid.two-col {
        grid-template-columns: 1fr;
    }
    .grid-cell.wide {
        grid-column: span 1;
    }
    .iso-section {
        padding: 40px 20px;
    }
    .iso-section:nth-child(even) {
        margin-left: 0;
    }
    .headline {
        font-size: clamp(1.6rem, 5vw, 2.5rem);
    }
    .puzzle-pieces-container {
        gap: 20px;
    }
    .puzzle-piece {
        width: 60px;
        height: 60px;
    }
    .completion-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    .comp-piece {
        width: 36px;
        height: 36px;
    }
    #coord-display {
        font-size: 0.6rem;
    }
}

@media (max-width: 480px) {
    #sidebar {
        width: 44px;
    }
    .sidebar-icon {
        width: 18px;
        height: 18px;
    }
    #content {
        margin-left: 44px;
    }
    #progress-bar-container {
        padding-left: 52px;
    }
    #timeline {
        left: 44px;
    }
}

/* --- Selection Style --- */
::selection {
    background: rgba(30, 144, 255, 0.2);
    color: #2a2a2a;
}

/* --- Scrollbar --- */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: #fafafa;
}

::-webkit-scrollbar-thumb {
    background: #d0d0d0;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #b8b8b8;
}
