/* ======================================
   gabs.day - Pixel Art Value Tracker
   ====================================== */

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

html {
    scroll-behavior: auto;
    image-rendering: pixelated;
    -ms-interpolation-mode: nearest-neighbor;
}

body {
    font-family: 'VT323', monospace;
    font-weight: 400;
    font-size: clamp(16px, 2vw, 22px);
    line-height: 1.8;
    color: #F0F0E8;
    background-color: #1A1A2E;
    overflow-x: hidden;
    -webkit-font-smoothing: none;
    -moz-osx-font-smoothing: unset;
}

/* --- CRT Grain Overlay --- */
#crt-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    opacity: 0;
    background-image:
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 2px,
            rgba(0, 0, 0, 0.03) 2px,
            rgba(0, 0, 0, 0.03) 4px
        ),
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent 2px,
            rgba(0, 0, 0, 0.02) 2px,
            rgba(0, 0, 0, 0.02) 4px
        );
}

#crt-overlay.active {
    opacity: 1;
}

/* --- Parallax Background Layer --- */
#bg-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}

/* --- Pixel Clouds --- */
.pixel-cloud {
    position: absolute;
    opacity: 0;
}

.pixel-cloud.visible {
    opacity: 0.9;
}

.cloud-block {
    position: absolute;
    background: #F0F0E8;
}

.cloud-1 {
    top: 8%;
    left: -100px;
    animation: cloudDrift1 35s linear infinite;
    animation-timing-function: steps(70);
}

.cloud-2 {
    top: 15%;
    left: -80px;
    animation: cloudDrift2 45s linear infinite;
    animation-timing-function: steps(90);
}

.cloud-3 {
    top: 22%;
    left: -90px;
    animation: cloudDrift3 40s linear infinite;
    animation-timing-function: steps(80);
}

.cloud-4 {
    top: 5%;
    left: -110px;
    animation: cloudDrift4 50s linear infinite;
    animation-timing-function: steps(100);
}

.cloud-5 {
    top: 30%;
    left: -70px;
    animation: cloudDrift5 38s linear infinite;
    animation-timing-function: steps(76);
}

@keyframes cloudDrift1 {
    from { transform: translateX(-100px); }
    to { transform: translateX(calc(100vw + 200px)); }
}

@keyframes cloudDrift2 {
    from { transform: translateX(-80px); }
    to { transform: translateX(calc(100vw + 180px)); }
}

@keyframes cloudDrift3 {
    from { transform: translateX(-90px); }
    to { transform: translateX(calc(100vw + 190px)); }
}

@keyframes cloudDrift4 {
    from { transform: translateX(-110px); }
    to { transform: translateX(calc(100vw + 210px)); }
}

@keyframes cloudDrift5 {
    from { transform: translateX(-70px); }
    to { transform: translateX(calc(100vw + 170px)); }
}

/* --- Levels (Sections) --- */
.level {
    position: relative;
    min-height: 100vh;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
}

/* --- Hero Section --- */
#hero {
    position: relative;
    overflow: hidden;
    padding: 0;
}

/* Stepped Sky Gradient */
#sky-gradient {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    z-index: 0;
}

.sky-band {
    flex: 1;
    opacity: 0;
    transition: none;
}

.sky-band.visible {
    opacity: 1;
}

.sky-band[data-band="0"]  { background-color: #1A1A2E; }
.sky-band[data-band="1"]  { background-color: #222244; }
.sky-band[data-band="2"]  { background-color: #2A3366; }
.sky-band[data-band="3"]  { background-color: #334488; }
.sky-band[data-band="4"]  { background-color: #3D5599; }
.sky-band[data-band="5"]  { background-color: #4668AA; }
.sky-band[data-band="6"]  { background-color: #4F7ABB; }
.sky-band[data-band="7"]  { background-color: #5B8EE0; }
.sky-band[data-band="8"]  { background-color: #6A9AE8; }
.sky-band[data-band="9"]  { background-color: #79A6EE; }
.sky-band[data-band="10"] { background-color: #88B2F4; }
.sky-band[data-band="11"] { background-color: #97BEFA; }

/* Hero Title */
#hero-title {
    position: relative;
    z-index: 5;
    text-align: center;
    margin-bottom: 20px;
}

.pixel-title {
    font-family: 'Press Start 2P', cursive;
    font-size: clamp(32px, 8vw, 80px);
    letter-spacing: 0.02em;
    display: inline-block;
}

#gabs-text .char {
    display: inline-block;
    opacity: 0;
    color: #F0F0E8;
    text-shadow: 4px 4px 0 #1A1A2E;
}

#gabs-text .char.visible {
    opacity: 1;
}

#day-text {
    color: #F7D358;
    text-shadow: 4px 4px 0 #8B5E3C;
    opacity: 0;
}

#day-text.visible {
    opacity: 1;
}

.dot-char {
    color: #E06060;
}

/* Pixel Sun */
#pixel-sun {
    position: absolute;
    bottom: 15%;
    left: 50%;
    transform: translateX(-50%) translateY(40px);
    z-index: 2;
    opacity: 0;
    width: 60px;
    height: 60px;
}

#pixel-sun.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.sun-body {
    width: 60px;
    height: 60px;
    background: #F7D358;
    position: absolute;
    top: 0;
    left: 0;
}

.sun-ray {
    position: absolute;
    background: #F7D358;
    opacity: 0;
}

#pixel-sun.visible .sun-ray {
    opacity: 0.7;
}

.ray-top    { width: 8px; height: 20px; top: -24px; left: 26px; }
.ray-bottom { width: 8px; height: 20px; bottom: -24px; left: 26px; }
.ray-left   { width: 20px; height: 8px; top: 26px; left: -24px; }
.ray-right  { width: 20px; height: 8px; top: 26px; right: -24px; }
.ray-tl     { width: 8px; height: 8px; top: -10px; left: -10px; }
.ray-tr     { width: 8px; height: 8px; top: -10px; right: -10px; }
.ray-bl     { width: 8px; height: 8px; bottom: -10px; left: -10px; }
.ray-br     { width: 8px; height: 8px; bottom: -10px; right: -10px; }

/* Horizon */
#horizon, #footer-ground {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 60px;
    display: flex;
    align-items: flex-end;
    z-index: 3;
}

#horizon .ground-block,
#footer-ground .ground-block {
    flex: 1;
    height: 32px;
    background: #8B5E3C;
    border-top: 4px solid #38B764;
}

#horizon .ground-block.tall,
#footer-ground .ground-block.tall {
    height: 48px;
}

/* Coin Sprites */
.coin-sprite {
    width: 16px;
    height: 16px;
    background: #F7D358;
    border-left: 2px solid #FFEEBB;
    border-right: 2px solid #C4A02E;
    border-top: 2px solid #FFEEBB;
    border-bottom: 2px solid #C4A02E;
    position: absolute;
    z-index: 6;
    opacity: 0;
}

.coin-sprite.visible {
    opacity: 1;
    animation: coinBounce 1s steps(8) infinite;
}

.coin-1 { top: 35%; left: 10%; }
.coin-2 { top: 25%; right: 15%; }
.coin-3 { bottom: 25%; left: 20%; }
.coin-4 { bottom: 30%; right: 10%; }

@keyframes coinBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-12px); }
}

/* Section Coins */
.section-coin {
    position: absolute;
    z-index: 10;
}

.sc-1 { top: 15%; right: 8%; }
.sc-2 { bottom: 20%; left: 5%; }
.sc-3 { top: 10%; left: 8%; }
.sc-4 { bottom: 15%; right: 12%; }

/* Hero Subtitle */
#hero-subtitle {
    font-family: 'VT323', monospace;
    font-size: clamp(18px, 3vw, 28px);
    color: #38B764;
    position: relative;
    z-index: 5;
    opacity: 0;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

#hero-subtitle.visible {
    opacity: 1;
}

/* --- Game Window (Retro UI) --- */
.game-window {
    background: #1A1A2E;
    border: 2px solid #F0F0E8;
    max-width: 700px;
    width: 90%;
    margin: 20px auto;
    position: relative;
    opacity: 0;
    transform: translateY(40px);
}

.game-window.visible {
    opacity: 1;
    transform: translateY(0);
}

.window-titlebar {
    background: #5B8EE0;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 6px;
    border-bottom: 2px solid #F0F0E8;
}

.window-title {
    font-family: 'Silkscreen', cursive;
    font-size: 10px;
    color: #F0F0E8;
    letter-spacing: 0.05em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.window-controls {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.win-btn {
    display: block;
    width: 8px;
    height: 8px;
}

.win-minimize {
    background: #F7D358;
}

.win-close {
    background: #E06060;
}

.window-content {
    padding: 16px;
}

/* --- Typography --- */
.pixel-body {
    font-family: 'VT323', monospace;
    font-size: clamp(16px, 2vw, 22px);
    line-height: 1.8;
    color: #F0F0E8;
    margin-bottom: 16px;
}

.pixel-body:last-child {
    margin-bottom: 0;
}

.pixel-display {
    font-family: 'Press Start 2P', cursive;
    font-size: clamp(16px, 3vw, 36px);
    letter-spacing: 0.02em;
    color: #F0F0E8;
}

.pixel-label {
    font-family: 'Silkscreen', cursive;
    font-size: clamp(10px, 1.5vw, 14px);
    color: #F0F0E8;
    letter-spacing: 0.05em;
}

.highlight-green {
    color: #38B764;
}

.text-gold {
    color: #F7D358;
}

/* --- Pixel Bar Chart --- */
#pixel-chart {
    position: relative;
}

.chart-label {
    font-family: 'Silkscreen', cursive;
    font-size: 12px;
    color: #F7D358;
    text-align: center;
    margin-bottom: 12px;
    letter-spacing: 0.1em;
}

.chart-area {
    display: flex;
    gap: 8px;
    height: 160px;
    align-items: flex-end;
}

.chart-y-axis {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 100%;
    font-family: 'Silkscreen', cursive;
    font-size: 9px;
    color: #5B8EE0;
    width: 30px;
    text-align: right;
    padding-right: 4px;
}

.chart-bars {
    display: flex;
    gap: 6px;
    flex: 1;
    align-items: flex-end;
    height: 100%;
    border-left: 2px solid #F0F0E8;
    border-bottom: 2px solid #F0F0E8;
    padding: 0 4px 0 4px;
}

.pixel-bar {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    height: 100%;
}

.bar-fill {
    width: 100%;
    background: #38B764;
    border-top: 2px solid #4EE07B;
    height: 0;
    transition: height 0.6s steps(10);
}

.bar-fill.animated {
    /* height set by JS */
}

.bar-label {
    font-family: 'Silkscreen', cursive;
    font-size: 8px;
    color: #F0F0E8;
    margin-top: 4px;
    text-align: center;
}

.chart-x-label {
    font-family: 'Silkscreen', cursive;
    font-size: 10px;
    color: #5B8EE0;
    text-align: center;
    margin-top: 8px;
    letter-spacing: 0.1em;
}

/* --- Pixel Line Chart --- */
#pixel-line-chart {
    position: relative;
    height: 120px;
    border-left: 2px solid #F0F0E8;
    border-bottom: 2px solid #F0F0E8;
    margin-top: 8px;
}

.line-chart-grid {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.grid-row {
    border-bottom: 1px dashed rgba(240, 240, 232, 0.15);
    width: 100%;
}

.line-chart-points {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.line-point {
    position: absolute;
    width: 8px;
    height: 8px;
    background: #E06060;
    z-index: 2;
    opacity: 0;
}

.line-point.visible {
    opacity: 1;
}

.line-chart-segments {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.line-segment {
    position: absolute;
    height: 2px;
    background: #E06060;
    transform-origin: left center;
    opacity: 0;
}

.line-segment.visible {
    opacity: 1;
}

/* --- Inventory (Level 3) --- */
.pixel-inventory {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.inventory-item {
    border: 2px solid #F0F0E8;
    padding: 12px 8px;
    text-align: center;
    background: rgba(26, 26, 46, 0.8);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.item-sprite {
    width: 24px;
    height: 24px;
    image-rendering: pixelated;
}

/* Pixel art sprites using box-shadow */
.sprite-coffee {
    background: #8B5E3C;
    border-bottom: 4px solid #8B5E3C;
    border-right: 4px solid #8B5E3C;
    width: 16px;
    height: 20px;
    position: relative;
}

.sprite-coffee::after {
    content: '';
    position: absolute;
    top: 4px;
    right: -8px;
    width: 6px;
    height: 10px;
    border: 2px solid #8B5E3C;
    border-left: none;
}

.sprite-bread {
    background: #F7D358;
    width: 22px;
    height: 16px;
    border-top: 4px solid #C4A02E;
}

.sprite-transit {
    width: 24px;
    height: 16px;
    background: #5B8EE0;
    border-bottom: 4px solid #333;
    position: relative;
}

.sprite-transit::before,
.sprite-transit::after {
    content: '';
    position: absolute;
    bottom: -8px;
    width: 6px;
    height: 6px;
    background: #333;
    border-radius: 0;
}

.sprite-transit::before { left: 2px; }
.sprite-transit::after  { right: 2px; }

.sprite-lunch {
    width: 20px;
    height: 8px;
    background: #F0F0E8;
    border-top: 6px solid #E06060;
    border-bottom: 4px solid #F7D358;
}

.sprite-data {
    width: 18px;
    height: 22px;
    background: #1A1A2E;
    border: 2px solid #38B764;
    position: relative;
}

.sprite-data::before {
    content: '';
    position: absolute;
    top: 4px;
    left: 3px;
    width: 8px;
    height: 2px;
    background: #38B764;
    box-shadow: 0 4px 0 #38B764, 0 8px 0 #38B764;
}

.sprite-time {
    width: 22px;
    height: 22px;
    border: 2px solid #F7D358;
    position: relative;
}

.sprite-time::before {
    content: '';
    position: absolute;
    top: 3px;
    left: 50%;
    width: 2px;
    height: 8px;
    background: #F7D358;
    transform: translateX(-50%);
}

.sprite-time::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 6px;
    height: 2px;
    background: #F7D358;
    transform: translate(-50%, -50%);
}

.item-name {
    font-family: 'Silkscreen', cursive;
    font-size: 10px;
    color: #F0F0E8;
    letter-spacing: 0.05em;
}

.item-cost {
    font-family: 'Press Start 2P', cursive;
    font-size: 10px;
    color: #38B764;
    display: flex;
    align-items: center;
    gap: 4px;
}

.coin-icon {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: #F7D358;
    border-left: 1px solid #FFEEBB;
    border-top: 1px solid #FFEEBB;
    border-right: 1px solid #C4A02E;
    border-bottom: 1px solid #C4A02E;
}

.inventory-note {
    font-style: normal;
    color: #5B8EE0;
}

/* --- Worth Grid (Level 4) --- */
.worth-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin: 20px 0;
}

.worth-item {
    border: 2px solid #F7D358;
    padding: 16px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    background: rgba(247, 211, 88, 0.05);
}

.worth-icon {
    width: 32px;
    height: 32px;
    position: relative;
}

/* Pixel art worth icons */
.worth-sunrise {
    background: #F7D358;
    width: 32px;
    height: 16px;
    margin-top: 16px;
    position: relative;
}

.worth-sunrise::before {
    content: '';
    position: absolute;
    top: -12px;
    left: 8px;
    width: 4px;
    height: 12px;
    background: #F7D358;
    box-shadow: -8px 4px 0 #F7D358, 8px 4px 0 #F7D358, -12px 8px 0 #F7D358, 12px 8px 0 #F7D358;
}

.worth-conversation {
    border: 2px solid #5B8EE0;
    width: 28px;
    height: 22px;
    position: relative;
}

.worth-conversation::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 4px;
    width: 8px;
    height: 8px;
    background: #5B8EE0;
    clip-path: polygon(0 0, 100% 0, 0 100%);
}

.worth-walk {
    width: 12px;
    height: 28px;
    background: #38B764;
    position: relative;
}

.worth-walk::before {
    content: '';
    position: absolute;
    top: -10px;
    left: 1px;
    width: 10px;
    height: 10px;
    background: #38B764;
}

.worth-walk::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: -4px;
    width: 8px;
    height: 4px;
    background: #38B764;
    box-shadow: 8px 0 0 #38B764;
}

.worth-knowledge {
    width: 24px;
    height: 20px;
    background: #E06060;
    border-top: 4px solid #E06060;
    position: relative;
}

.worth-knowledge::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -4px;
    width: 32px;
    height: 4px;
    background: #E06060;
}

.worth-knowledge::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 6px;
    width: 12px;
    height: 4px;
    background: #E06060;
}

.worth-label {
    font-family: 'Silkscreen', cursive;
    font-size: 10px;
    color: #F0F0E8;
    letter-spacing: 0.05em;
}

.worth-value {
    font-family: 'Press Start 2P', cursive;
    font-size: 8px;
}

/* --- Sunset Footer --- */
#sunset-footer {
    position: relative;
    overflow: hidden;
    min-height: 80vh;
    justify-content: center;
}

#sunset-gradient {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    z-index: 0;
}

.sunset-band {
    flex: 1;
}

.sunset-band[data-band="0"] { background-color: #1A1A2E; }
.sunset-band[data-band="1"] { background-color: #2E1A3E; }
.sunset-band[data-band="2"] { background-color: #4A1A4A; }
.sunset-band[data-band="3"] { background-color: #6B2040; }
.sunset-band[data-band="4"] { background-color: #8B3030; }
.sunset-band[data-band="5"] { background-color: #C05030; }
.sunset-band[data-band="6"] { background-color: #E06060; }
.sunset-band[data-band="7"] { background-color: #F7D358; }

/* Pixel Stars */
.pixel-star {
    position: absolute;
    width: 4px;
    height: 4px;
    background: #F0F0E8;
    z-index: 1;
    animation: starTwinkle 2s steps(2) infinite;
}

.star-1  { top: 5%;  left: 10%; animation-delay: 0s; }
.star-2  { top: 8%;  left: 30%; animation-delay: 0.3s; }
.star-3  { top: 3%;  left: 55%; animation-delay: 0.7s; }
.star-4  { top: 12%; left: 75%; animation-delay: 1.1s; }
.star-5  { top: 6%;  left: 90%; animation-delay: 0.5s; }
.star-6  { top: 15%; left: 20%; animation-delay: 1.4s; }
.star-7  { top: 2%;  left: 45%; animation-delay: 0.9s; }
.star-8  { top: 18%; left: 65%; animation-delay: 0.2s; }
.star-9  { top: 10%; left: 85%; animation-delay: 1.6s; }
.star-10 { top: 20%; left: 5%;  animation-delay: 0.6s; }
.star-11 { top: 7%;  left: 50%; animation-delay: 1.2s; }
.star-12 { top: 14%; left: 38%; animation-delay: 0.8s; }

@keyframes starTwinkle {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.2; }
}

#footer-content {
    position: relative;
    z-index: 5;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

#footer-content .pixel-display {
    color: #F7D358;
    text-shadow: 4px 4px 0 #1A1A2E;
}

.footer-korean {
    color: #E06060;
    font-size: clamp(12px, 1.8vw, 16px);
}

#footer-ground {
    z-index: 3;
}

/* --- Checkerboard Pattern Background --- */
#level-1,
#level-3 {
    background-image:
        repeating-conic-gradient(
            rgba(240, 240, 232, 0.03) 0% 25%,
            transparent 0% 50%
        );
    background-size: 8px 8px;
}

/* Stripe pattern for level-2, level-4 */
#level-2,
#level-4 {
    background-image:
        repeating-linear-gradient(
            0deg,
            rgba(240, 240, 232, 0.02) 0px,
            rgba(240, 240, 232, 0.02) 2px,
            transparent 2px,
            transparent 4px
        );
}

/* --- Responsive --- */
@media (max-width: 600px) {
    .pixel-inventory {
        grid-template-columns: repeat(2, 1fr);
    }

    .worth-grid {
        grid-template-columns: 1fr;
    }

    .game-window {
        width: 95%;
    }

    #pixel-sun {
        width: 40px;
        height: 40px;
    }

    .sun-body {
        width: 40px;
        height: 40px;
    }

    .ray-top    { top: -16px; left: 16px; width: 6px; height: 14px; }
    .ray-bottom { bottom: -16px; left: 16px; width: 6px; height: 14px; }
    .ray-left   { left: -16px; top: 16px; width: 14px; height: 6px; }
    .ray-right  { right: -16px; top: 16px; width: 14px; height: 6px; }
}
