/* ============================================
   archetypos.dev - Street-Style Meets Hardware Nostalgia
   Palette: Creamy-Pastel / Earth Tones
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
    --cream-linen: #F5EDE0;
    --warm-ivory: #FBF7F0;
    --kraft-tan: #D4B896;
    --charcoal-soot: #362A1E;
    --faded-denim: #7A7068;
    --circuit-copper: #C47A4A;
    --roasted-peanut: #8B5E3C;
    --dusty-rose: #C9A0A0;
    --faded-mustard: #D4A843;
    --espresso-board: #2B1F15;

    --font-display: 'Roboto Slab', serif;
    --font-body: 'Nunito Sans', sans-serif;
    --font-code: 'Fira Code', monospace;

    --reel-speed: 12s;
    --section-progress: 0;
}

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

html {
    scroll-behavior: smooth;
    scroll-padding-top: 20px;
}

body {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(0.95rem, 1.05vw, 1.1rem);
    line-height: 1.75;
    letter-spacing: 0.01em;
    color: var(--charcoal-soot);
    background-color: var(--cream-linen);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* --- Entry Overlay --- */
#entry-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background-color: var(--cream-linen);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    transition: opacity 0.6s cubic-bezier(0.22, 1, 0.36, 1), visibility 0.6s;
}

#entry-overlay.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

#entry-trace {
    width: 80%;
    max-width: 700px;
    height: auto;
    margin-bottom: 20px;
}

#trace-line {
    transition: stroke-dashoffset 0.6s ease-out;
}

#solder-left, #solder-right {
    transition: opacity 0.2s, transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    transform-origin: center;
}

#solder-left.visible, #solder-right.visible {
    opacity: 1;
}

#entry-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(2.5rem, 6vw, 5rem);
    color: var(--charcoal-soot);
    letter-spacing: 0.06em;
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

#entry-title.visible {
    opacity: 1;
    transform: translateY(0);
}

#entry-tagline {
    font-family: var(--font-body);
    font-weight: 300;
    font-size: clamp(0.9rem, 1.5vw, 1.1rem);
    color: var(--faded-denim);
    opacity: 0;
    transition: opacity 0.4s ease;
    margin-top: 8px;
}

#entry-tagline.visible {
    opacity: 1;
}

/* --- Sidebar Shelf (Desktop Only) --- */
#sidebar-shelf {
    display: none;
    position: fixed;
    left: 0;
    top: 0;
    width: 240px;
    height: 100vh;
    background-color: var(--warm-ivory);
    z-index: 100;
    padding: 100px 20px 100px 20px;
    overflow-y: auto;
}

.shelf-border {
    position: absolute;
    right: 0;
    top: 0;
    width: 2px;
    height: 100%;
    border-right: 2px dashed var(--kraft-tan);
}

@media (min-width: 1201px) {
    #sidebar-shelf {
        display: block;
    }
    #main-content {
        margin-left: 240px;
    }
    #control-strip {
        margin-left: 240px;
    }
}

/* --- Cassette Tape Navigation --- */
#cassette-nav {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.cassette-card {
    width: 180px;
    height: 112px;
    background-color: var(--cream-linen);
    border: 1.5px solid var(--kraft-tan);
    border-radius: 4px;
    padding: 12px 10px 8px;
    cursor: pointer;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.cassette-card:hover,
.cassette-card.active {
    border-color: var(--circuit-copper);
    box-shadow: 2px 3px 6px rgba(54, 42, 30, 0.12);
}

.cassette-body {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex: 1;
}

.cassette-reel {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 1.5px solid var(--charcoal-soot);
    background: transparent;
    flex-shrink: 0;
    position: relative;
}

.cassette-reel::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: var(--charcoal-soot);
    transform: translate(-50%, -50%);
}

.cassette-card.active .cassette-reel {
    animation: reelSpin var(--reel-speed) linear infinite;
    border-color: var(--circuit-copper);
}

.cassette-card.active .cassette-reel::after {
    background-color: var(--circuit-copper);
}

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

.cassette-label {
    font-family: var(--font-display);
    font-size: 0.7rem;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--charcoal-soot);
    text-align: center;
    flex: 1;
    padding: 0 6px;
}

.cassette-card.active .cassette-label {
    color: var(--circuit-copper);
}

.cassette-progress {
    width: 100%;
    height: 2px;
    background-color: var(--kraft-tan);
    border-radius: 1px;
    overflow: hidden;
    margin-top: 6px;
}

.cassette-progress-fill {
    height: 100%;
    width: calc(var(--section-progress) * 100%);
    background-color: var(--circuit-copper);
    transition: width 0.1s linear;
}

/* Active cassette navigation glow */
.cassette-card.active {
    box-shadow: 2px 3px 6px rgba(54, 42, 30, 0.12), 0 0 8px rgba(196, 122, 74, 0.2);
}

/* --- Main Content --- */
#main-content {
    position: relative;
    padding-bottom: 100px;
    min-height: 100vh;
}

/* --- Background Watermark --- */
#bg-watermark {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

.watermark-path {
    stroke-dasharray: 5000;
    stroke-dashoffset: 5000;
}

/* --- The Viewfinder (CRT Hero) --- */
#viewfinder {
    padding: 40px 5%;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    z-index: 1;
}

.crt-bezel {
    width: 100%;
    max-width: 900px;
    aspect-ratio: 4 / 3;
    max-height: 70vh;
    border: 12px solid var(--kraft-tan);
    border-radius: 12px;
    box-shadow: inset 0 0 30px rgba(54, 42, 30, 0.3), 4px 6px 20px rgba(43, 31, 21, 0.2);
    overflow: hidden;
    position: relative;
    background-color: var(--espresso-board);
}

.crt-screen {
    width: 100%;
    height: 100%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse at center, #3a2e22 0%, var(--espresso-board) 100%);
    border-radius: 4px;
}

.scanline-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(54, 42, 30, 0.04) 2px,
        rgba(54, 42, 30, 0.04) 4px
    );
    pointer-events: none;
    z-index: 2;
    border-radius: 4px;
}

.crt-screen::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    box-shadow: inset 0 0 60px rgba(54, 42, 30, 0.12);
    border-radius: 4px;
    pointer-events: none;
    z-index: 3;
}

.crt-content {
    position: relative;
    z-index: 1;
    text-align: center;
    padding: 40px;
}

.channel-indicator {
    position: absolute;
    top: 16px;
    right: 20px;
    z-index: 4;
}

.channel-num {
    font-family: var(--font-display);
    font-size: 0.75rem;
    font-weight: 400;
    color: var(--roasted-peanut);
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.crt-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(2.2rem, 5.5vw, 4.8rem);
    color: var(--cream-linen);
    letter-spacing: 0.06em;
    margin-bottom: 16px;
    text-shadow: 0 0 20px rgba(196, 122, 74, 0.3);
}

.crt-subtitle {
    font-family: var(--font-body);
    font-weight: 300;
    font-size: clamp(0.9rem, 1.3vw, 1.05rem);
    color: var(--kraft-tan);
    max-width: 500px;
    margin: 0 auto;
    line-height: 1.8;
}

.bg-circuit-trace {
    width: 80%;
    max-width: 700px;
    height: 40px;
    margin-top: 30px;
}

/* --- Circuit Dividers --- */
.circuit-divider {
    width: 60%;
    max-width: 500px;
    margin: 40px auto;
    position: relative;
    z-index: 1;
}

.circuit-divider svg {
    width: 100%;
    height: auto;
}

/* --- Section Blocks --- */
.section-block {
    position: relative;
    z-index: 1;
    padding: 40px 5%;
    max-width: 1100px;
    margin: 0 auto;
}

.section-heading {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(1.2rem, 2.5vw, 1.8rem);
    color: var(--charcoal-soot);
    letter-spacing: 0.06em;
    margin-bottom: 30px;
    position: relative;
    display: inline-block;
}

.section-heading::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 0;
    width: 40px;
    height: 3px;
    background-color: var(--circuit-copper);
    border-radius: 2px;
}

/* --- Skeleton Loading --- */
.section-skeleton {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    padding: 20px;
    opacity: 1;
    transition: opacity 0.3s ease;
    position: absolute;
    top: 40px;
    left: 5%;
    right: 5%;
    z-index: 2;
}

.section-skeleton.hidden {
    opacity: 0;
    pointer-events: none;
}

.skel-trace {
    width: 100%;
    height: 3px;
    border-radius: 2px;
    background: linear-gradient(90deg, var(--cream-linen) 25%, var(--faded-mustard) 50%, var(--cream-linen) 75%);
    background-size: 200% 100%;
    animation: skeletonShimmer 1.5s infinite;
}

.skel-trace.short {
    width: 60%;
}

.skel-chip {
    width: 80px;
    height: 30px;
    border-radius: 3px;
    background: linear-gradient(90deg, var(--cream-linen) 25%, var(--faded-mustard) 50%, var(--cream-linen) 75%);
    background-size: 200% 100%;
    animation: skeletonShimmer 1.5s infinite;
    animation-delay: 0.2s;
}

.skel-chip.wide {
    width: 140px;
}

.skel-pad {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: linear-gradient(90deg, var(--cream-linen) 25%, var(--faded-mustard) 50%, var(--cream-linen) 75%);
    background-size: 200% 100%;
    animation: skeletonShimmer 1.5s infinite;
    animation-delay: 0.4s;
}

@keyframes skeletonShimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* --- Section Content (revealed after skeleton) --- */
.section-content {
    opacity: 0;
    transition: opacity 0.3s ease;
    position: relative;
    z-index: 1;
}

.section-content.visible {
    opacity: 1;
}

/* --- Pin Board (Grid) --- */
.pin-board {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    position: relative;
}

/* --- Pin Cards --- */
.pin-card {
    background-color: var(--cream-linen);
    border-radius: 4px;
    padding: 24px 20px 20px;
    position: relative;
    box-shadow: 3px 4px 8px rgba(54, 42, 30, 0.15);
    transform: rotate(var(--card-rotation, 0deg));
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    overflow: visible;
}

.pin-card.span-2 {
    grid-column: span 2;
}

.pin-card:hover {
    transform: translateY(-4px) rotate(0deg);
    box-shadow: 5px 6px 14px rgba(54, 42, 30, 0.2);
}

.pin-card:hover .pushpin {
    background-color: var(--circuit-copper);
}

.pin-card:hover .card-circuit-bottom {
    width: 100%;
}

/* --- Pushpin --- */
.pushpin {
    position: absolute;
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: var(--dusty-rose);
    border: 1px solid var(--charcoal-soot);
    z-index: 3;
    box-shadow: 1px 2px 3px rgba(54, 42, 30, 0.2);
    transition: background-color 0.2s ease;
}

/* --- Tape Strip --- */
.tape-strip {
    position: absolute;
    top: -6px;
    left: 50%;
    transform: translateX(-50%) rotate(2deg);
    width: 60px;
    height: 16px;
    background-color: rgba(251, 247, 240, 0.7);
    border-radius: 1px;
    z-index: 3;
    box-shadow: 0 1px 2px rgba(54, 42, 30, 0.1);
}

/* --- Card Content --- */
.card-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(0.95rem, 1.8vw, 1.3rem);
    color: var(--charcoal-soot);
    letter-spacing: 0.06em;
    margin-bottom: 10px;
}

.card-body {
    font-family: var(--font-body);
    font-weight: 300;
    font-size: clamp(0.85rem, 1vw, 0.95rem);
    color: var(--charcoal-soot);
    line-height: 1.75;
    margin-bottom: 12px;
}

.card-tag {
    display: inline-block;
    font-family: var(--font-code);
    font-size: 0.8rem;
    letter-spacing: 0.04em;
    color: var(--roasted-peanut);
    background-color: var(--warm-ivory);
    padding: 2px 10px;
    border-left: 2px solid var(--circuit-copper);
    border-radius: 0 2px 2px 0;
}

.card-caption {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: 0.85rem;
    color: var(--faded-denim);
    margin-top: 8px;
    font-style: italic;
}

/* --- Card Circuit Bottom Trace --- */
.card-circuit-bottom {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 2px;
    width: 0;
    background-color: var(--circuit-copper);
    transition: width 0.3s ease;
    border-radius: 0 0 4px 4px;
}

/* --- Card Image (Polaroid Treatment) --- */
.card-image-wrap {
    position: relative;
    overflow: hidden;
    border-radius: 4px;
    margin-bottom: 14px;
    border: 1px solid var(--kraft-tan);
    box-shadow: 4px 4px 0 var(--kraft-tan);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card-image-wrap:hover {
    transform: translate(-2px, -2px);
    box-shadow: 6px 6px 0 var(--kraft-tan);
}

.card-image {
    width: 100%;
    height: 160px;
    filter: sepia(15%) contrast(1.05) saturate(0.9) brightness(1.02);
    transition: filter 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.card-image.wide {
    height: 200px;
}

.card-image.tall {
    height: 240px;
}

/* Polaroid Cover (for reveal animation) */
.polaroid-cover {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--kraft-tan);
    z-index: 2;
    transition: opacity 0.4s ease;
}

.polaroid-reveal.revealed .polaroid-cover {
    opacity: 0;
}

.polaroid-reveal .card-image {
    filter: grayscale(100%) blur(8px);
}

.polaroid-reveal.revealed .card-image {
    filter: sepia(15%) contrast(1.05) saturate(0.9) brightness(1.02);
}

/* --- Gallery Grid --- */
.gallery-grid {
    grid-template-columns: repeat(3, 1fr);
    grid-auto-rows: auto;
}

.gallery-card {
    padding: 16px 14px 14px;
}

/* --- Contact Board --- */
.contact-board {
    grid-template-columns: repeat(3, 1fr);
}

.contact-details {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px dashed var(--kraft-tan);
}

.contact-item {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: 0.9rem;
    color: var(--charcoal-soot);
}

.contact-label {
    font-family: var(--font-code);
    font-size: 0.75rem;
    color: var(--circuit-copper);
    letter-spacing: 0.04em;
    display: inline-block;
    min-width: 80px;
    margin-right: 8px;
}

/* --- Control Strip (Fixed Bottom Nav) --- */
#control-strip {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 80px;
    background-color: var(--warm-ivory);
    border-top: 2px solid var(--kraft-tan);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 -4px 12px rgba(43, 31, 21, 0.1);
}

.knob-group {
    display: flex;
    gap: 32px;
    align-items: center;
}

.knob {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    cursor: pointer;
}

.knob-circle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid var(--circuit-copper);
    background-color: var(--kraft-tan);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease-out, background-color 0.3s ease;
    position: relative;
}

.knob-indicator {
    width: 2px;
    height: 10px;
    background-color: var(--charcoal-soot);
    border-radius: 1px;
    position: absolute;
    top: 6px;
}

.knob:hover .knob-circle {
    transform: rotate(45deg);
    background-color: var(--circuit-copper);
}

.knob:hover .knob-indicator {
    background-color: var(--cream-linen);
}

.knob.active .knob-circle {
    background-color: var(--circuit-copper);
    box-shadow: 0 0 8px rgba(196, 122, 74, 0.4);
}

.knob.active .knob-indicator {
    background-color: var(--cream-linen);
}

.knob-label {
    font-family: var(--font-display);
    font-weight: 400;
    font-size: 0.65rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--charcoal-soot);
    transition: color 0.3s ease;
}

.knob.active .knob-label {
    color: var(--circuit-copper);
}

/* --- Footer --- */
#site-footer {
    background-color: var(--espresso-board);
    padding: 60px 5% 40px;
    text-align: center;
    position: relative;
    z-index: 1;
    margin-bottom: 80px;
}

.footer-circuit {
    max-width: 300px;
    margin: 0 auto 20px;
}

.footer-circuit svg {
    width: 100%;
    height: auto;
}

.footer-text {
    font-family: var(--font-display);
    font-weight: 400;
    font-size: 0.95rem;
    color: var(--kraft-tan);
    letter-spacing: 0.06em;
    margin-bottom: 6px;
}

.footer-subtext {
    font-family: var(--font-body);
    font-weight: 300;
    font-size: 0.8rem;
    color: var(--faded-denim);
}

/* --- Responsive: Tablet --- */
@media (max-width: 900px) {
    .pin-board {
        grid-template-columns: repeat(2, 1fr);
    }
    .pin-card.span-2 {
        grid-column: span 2;
    }
    .gallery-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .contact-board {
        grid-template-columns: repeat(2, 1fr);
    }
    .knob-group {
        gap: 20px;
    }
    .knob-label {
        font-size: 0.55rem;
    }
    .crt-bezel {
        max-height: 60vh;
    }
}

/* --- Responsive: Mobile --- */
@media (max-width: 600px) {
    .pin-board {
        grid-template-columns: 1fr;
    }
    .pin-card.span-2 {
        grid-column: span 1;
    }
    .gallery-grid {
        grid-template-columns: 1fr;
    }
    .contact-board {
        grid-template-columns: 1fr;
    }
    .knob-group {
        gap: 12px;
    }
    .knob-circle {
        width: 32px;
        height: 32px;
    }
    .knob-label {
        font-size: 0.5rem;
    }
    #control-strip {
        height: 70px;
    }
    .crt-bezel {
        border-width: 8px;
        max-height: 50vh;
    }
    .crt-content {
        padding: 20px;
    }
    .section-block {
        padding: 30px 4%;
    }
    .circuit-divider {
        width: 80%;
    }
    .card-image {
        height: 120px;
    }
    .card-image.wide {
        height: 150px;
    }
    .card-image.tall {
        height: 180px;
    }
}

/* --- Scroll-driven circuit path animation --- */
.circuit-path {
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    transition: stroke-dashoffset 0.1s linear;
}
