/* xity.dev - Glitched City Terminal */
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
    --bg-vintage: #18161A;
    --card-surface: #221F24;
    --muted-olive: #808868;
    --muted-rose: #A87878;
    --muted-gold: #B8A870;
    --scan-line: rgba(224, 216, 200, 0.03);
    --glitch-artifact: rgba(168, 120, 120, 0.4);
    --text-primary: #E0D8C8;
    --text-body: #B8B0A0;
    --code-green: #80A890;
    --geo-frag: rgba(128, 136, 104, 0.2);
}

body {
    background: var(--bg-vintage);
    color: var(--text-primary);
    font-family: 'Albert Sans', sans-serif;
    font-size: 1rem;
    line-height: 1.7;
    font-weight: 400;
    overflow-x: hidden;
}

/* Header */
.site-header {
    text-align: center;
    padding: 4rem 2rem 3rem;
    position: relative;
}
.site-title {
    font-family: 'Albert Sans', sans-serif;
    font-size: clamp(1.5rem, 3vw, 2.5rem);
    font-weight: 700;
    color: var(--text-primary);
    opacity: 0;
    animation: assembleTitle 0.4s ease forwards 0.6s;
}
@keyframes assembleTitle {
    0% { opacity: 0; transform: translateX(-4px); letter-spacing: 0.3em; }
    50% { transform: translateX(2px); }
    100% { opacity: 1; transform: translateX(0); letter-spacing: normal; }
}
.site-sub {
    font-family: 'Source Code Pro', monospace;
    font-size: 0.85rem;
    color: var(--code-green);
    margin-top: 0.5rem;
}

/* Masonry Grid */
.masonry-grid {
    max-width: 1080px;
    margin: 0 auto 3rem;
    padding: 0 20px;
    columns: 3;
    column-gap: 20px;
    position: relative;
}

/* Cards */
.m-card {
    break-inside: avoid;
    margin-bottom: 20px;
    perspective: 800px;
    cursor: pointer;
}
.card-front, .card-back {
    background: var(--card-surface);
    border-radius: 6px;
    padding: 24px;
    backface-visibility: hidden;
    transition: transform 0.4s ease;
}
.card-front {
    position: relative;
    overflow: hidden;
}
.card-back {
    position: absolute;
    inset: 0;
    transform: rotateY(180deg);
    background: var(--muted-olive);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
}
.m-card.flipped .card-front { transform: rotateY(180deg); }
.m-card.flipped .card-back { transform: rotateY(0); position: relative; }
.m-card.flipped .card-front { position: absolute; inset: 0; }

.card-tall .card-front { min-height: 320px; }
.card-medium .card-front { min-height: 240px; }
.card-short .card-front { min-height: 180px; }

.glitch-offset { transform: translateX(2px); }

/* Scan Line Overlay */
.scan-overlay {
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        0deg,
        transparent 0%,
        transparent 50%,
        var(--scan-line) 50%,
        var(--scan-line) 50.5%,
        transparent 51%
    );
    background-size: 100% 4px;
    pointer-events: none;
    opacity: 0.5;
    animation: scanFlicker 4s ease-in-out infinite;
}
@keyframes scanFlicker {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 0.6; }
}

/* Card Typography */
.card-label {
    font-family: 'Source Code Pro', monospace;
    font-size: 0.75rem;
    color: var(--muted-gold);
    letter-spacing: 0.06em;
    display: block;
    margin-bottom: 0.5rem;
}
.card-title {
    font-family: 'Albert Sans', sans-serif;
    font-size: clamp(1.5rem, 3vw, 2.5rem);
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
}
.card-body {
    font-family: 'Albert Sans', sans-serif;
    font-size: 1rem;
    color: var(--text-body);
    line-height: 1.7;
    margin-bottom: 0.75rem;
}
.card-code {
    font-family: 'Source Code Pro', monospace;
    font-size: 0.85rem;
    color: var(--code-green);
}
.code-block {
    font-family: 'Source Code Pro', monospace;
    font-size: 0.85rem;
    color: var(--bg-vintage);
    white-space: pre-wrap;
    line-height: 1.6;
}

/* Glitch entrance */
.m-card {
    opacity: 0;
    transition: opacity 0.3s ease;
}
.m-card.visible {
    opacity: 1;
    animation: glitchIn 0.2s ease;
}
@keyframes glitchIn {
    0% { transform: translateX(-4px); }
    33% { transform: translateX(4px); }
    66% { transform: translateX(-2px); }
    100% { transform: translateX(0); }
}
.glitch-offset.visible {
    animation: glitchInOffset 0.2s ease;
}
@keyframes glitchInOffset {
    0% { transform: translateX(-2px); }
    33% { transform: translateX(6px); }
    66% { transform: translateX(0); }
    100% { transform: translateX(2px); }
}

/* Ambient Glitch */
@keyframes ambientGlitch {
    0%, 95%, 100% { transform: translateX(0); text-shadow: none; }
    96% { transform: translateX(-3px); text-shadow: 2px 0 var(--muted-rose), -2px 0 var(--code-green); }
    97% { transform: translateX(3px); text-shadow: -2px 0 var(--muted-rose), 2px 0 var(--code-green); }
    98% { transform: translateX(-1px); text-shadow: 1px 0 var(--muted-rose), -1px 0 var(--code-green); }
}
.m-card.ambient-glitch {
    animation: ambientGlitch 0.15s ease;
}

/* Geometric Fragments */
.geo-frag {
    position: absolute;
    pointer-events: none;
    opacity: 0.2;
}
.frag-1 {
    width: 20px;
    height: 20px;
    background: var(--muted-olive);
    clip-path: polygon(50% 0%, 100% 100%, 0% 100%);
    top: 15%;
    left: 33%;
}
.frag-2 {
    width: 30px;
    height: 30px;
    border: 1.5px solid var(--muted-rose);
    border-radius: 50%;
    clip-path: inset(0 0 50% 0);
    top: 45%;
    right: 33%;
}
.frag-3 {
    width: 15px;
    height: 15px;
    background: var(--muted-gold);
    clip-path: polygon(50% 0%, 100% 100%, 0% 100%);
    bottom: 20%;
    left: 66%;
}

/* Footer */
.site-footer {
    text-align: center;
    padding: 3rem 2rem;
}
.footer-text {
    font-family: 'Source Code Pro', monospace;
    font-size: 0.8rem;
    color: var(--text-body);
}

@media (max-width: 1024px) { .masonry-grid { columns: 2; } }
@media (max-width: 640px) { .masonry-grid { columns: 1; } }
