/* ethica.dev - Pixel-Art Ethical Adventure RPG */

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

:root {
    --deep-cartridge-blue: #0B1D3A;
    --dark-bg: #111827;
    --parchment: #E8E4DC;
    --muted-steel: #5B6E7A;
    --near-black: #1C1C1E;
    --virtue-purple: #9B59B6;
    --consequence-red: #E74C3C;
    --pixel-gold: #FFD866;
    --growth-green: #4CAF50;
    --parchment-warm: #F5E6C8;
}

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--deep-cartridge-blue);
    color: var(--parchment);
    font-family: 'Lora', Georgia, serif;
    overflow-x: hidden;
    line-height: 1.6;
}

/* === Scanline Overlay === */
#scanline-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    opacity: 0;
    background: repeating-linear-gradient(
        to bottom,
        transparent 0px,
        transparent 2px,
        rgba(0, 0, 0, 0.15) 2px,
        rgba(0, 0, 0, 0.15) 4px
    );
    transition: opacity 400ms ease;
}

#scanline-overlay.visible {
    opacity: 0.12;
}

/* === Pixel Border Frame === */
.pixel-border-frame {
    border: 8px solid transparent;
    border-image: repeating-linear-gradient(
        90deg,
        var(--pixel-gold) 0px,
        var(--pixel-gold) 8px,
        var(--deep-cartridge-blue) 8px,
        var(--deep-cartridge-blue) 16px
    ) 8;
    padding: clamp(1rem, 3vw, 2.5rem);
    margin: clamp(0.5rem, 2vw, 1.5rem);
    position: relative;
    clip-path: inset(0);
    animation: frameDraw 1.2s steps(4) forwards;
}

@keyframes frameDraw {
    0% { clip-path: inset(0 100% 100% 0); }
    25% { clip-path: inset(0 0 100% 0); }
    50% { clip-path: inset(0 0 0 0); }
    100% { clip-path: inset(0); }
}

/* === Game Sections === */
.game-section {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: clamp(1rem, 3vw, 2rem);
    position: relative;
}

/* === Title Screen === */
#title-screen {
    background-color: var(--deep-cartridge-blue);
}

.title-content {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: clamp(1.5rem, 4vw, 3rem);
}

.game-title {
    font-family: 'Press Start 2P', monospace;
    font-size: clamp(2rem, 6vw, 5rem);
    color: var(--pixel-gold);
    text-shadow: 4px 4px 0 var(--near-black);
    letter-spacing: 0.1em;
    animation: titleFlicker 3s infinite;
}

@keyframes titleFlicker {
    0%, 95%, 100% { opacity: 1; }
    96% { opacity: 0.8; }
    97% { opacity: 1; }
    98% { opacity: 0.7; }
}

.subtitle {
    font-family: 'IBM Plex Mono', monospace;
    font-size: clamp(0.8rem, 2vw, 1.2rem);
    color: var(--muted-steel);
    text-transform: uppercase;
    letter-spacing: 0.3em;
}

/* === Game Menu === */
.game-menu ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.menu-item {
    font-family: 'Press Start 2P', monospace;
    font-size: clamp(0.7rem, 1.5vw, 1rem);
    color: var(--parchment);
    cursor: pointer;
    padding: 0.5rem 1rem;
    transition: color 200ms, transform 100ms;
    text-align: left;
}

.menu-item:hover {
    color: var(--pixel-gold);
    transform: translateX(8px);
}

.menu-item.active {
    color: var(--pixel-gold);
}

.menu-arrow {
    display: inline-block;
    margin-right: 0.5rem;
    opacity: 0;
    transition: opacity 200ms;
}

.menu-item:hover .menu-arrow,
.menu-item.active .menu-arrow {
    opacity: 1;
}

/* === Scroll Arrow === */
.scroll-arrow {
    position: absolute;
    bottom: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    animation: bounce 1.5s infinite;
}

.pixel-arrow {
    font-family: 'Press Start 2P', monospace;
    font-size: 1.2rem;
    color: var(--pixel-gold);
}

.scroll-text {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.65rem;
    color: var(--muted-steel);
    text-transform: uppercase;
    letter-spacing: 0.15em;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(8px); }
}

/* === Bento Grid === */
.bento-grid {
    display: grid;
    gap: clamp(0.5rem, 1.5vw, 1rem);
    width: 100%;
    max-width: 1100px;
}

.dilemma-grid {
    grid-template-columns: 2fr 1fr;
    grid-template-rows: auto auto;
}

.dilemma-grid .scenario-panel {
    grid-column: 1;
    grid-row: 1 / 3;
}

.dilemma-grid .consequence-panel {
    grid-column: 2;
    grid-row: 1;
}

.dilemma-grid .stats-panel {
    grid-column: 2;
    grid-row: 2;
}

.philosopher-grid {
    grid-template-columns: repeat(4, 1fr);
    max-width: 900px;
    margin: 0 auto;
}

.inventory-grid {
    grid-template-columns: repeat(3, 1fr);
    max-width: 900px;
    margin: 0 auto;
}

/* === Bento Cell === */
.bento-cell {
    background: rgba(17, 24, 39, 0.85);
    border: 2px solid var(--muted-steel);
    padding: clamp(0.75rem, 2vw, 1.5rem);
    position: relative;
}

/* === Section Heading === */
.section-heading {
    font-family: 'Press Start 2P', monospace;
    font-size: clamp(0.9rem, 2.5vw, 1.6rem);
    color: var(--pixel-gold);
    text-shadow: 2px 2px 0 var(--near-black);
    margin-bottom: clamp(1rem, 2vw, 1.5rem);
    text-align: center;
}

.panel-label {
    font-family: 'Press Start 2P', monospace;
    font-size: clamp(0.55rem, 1.2vw, 0.75rem);
    color: var(--pixel-gold);
    margin-bottom: 0.75rem;
    text-transform: uppercase;
}

/* === Dialogue Box === */
.dialogue-box {
    background: var(--near-black);
    border: 3px solid var(--parchment);
    padding: clamp(1rem, 2vw, 1.5rem);
    margin-bottom: 1.5rem;
    position: relative;
}

.dialogue-box::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 20px;
    width: 0;
    height: 0;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-top: 10px solid var(--parchment);
}

.dialogue-text {
    font-family: 'IBM Plex Mono', monospace;
    font-size: clamp(0.75rem, 1.5vw, 0.95rem);
    color: var(--parchment);
    line-height: 1.7;
}

/* === Choice Buttons === */
.choice-buttons {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.pixel-btn {
    font-family: 'Press Start 2P', monospace;
    font-size: clamp(0.55rem, 1.2vw, 0.75rem);
    background: var(--deep-cartridge-blue);
    color: var(--parchment);
    border: 3px solid var(--pixel-gold);
    padding: 0.75rem 1.5rem;
    cursor: pointer;
    transition: background 150ms, color 150ms, transform 100ms;
    text-transform: uppercase;
}

.pixel-btn:hover {
    background: var(--pixel-gold);
    color: var(--near-black);
    transform: scale(1.05);
}

.pixel-btn:active {
    transform: scale(0.95);
}

.pixel-btn.selected {
    background: var(--virtue-purple);
    border-color: var(--virtue-purple);
    color: #fff;
}

/* === Consequence Log === */
.consequence-log {
    font-family: 'IBM Plex Mono', monospace;
    font-size: clamp(0.6rem, 1.1vw, 0.8rem);
    color: var(--muted-steel);
    max-height: 200px;
    overflow-y: auto;
}

.log-entry {
    padding: 0.3rem 0;
    border-bottom: 1px solid rgba(91, 110, 122, 0.3);
}

.log-entry.consequence-good {
    color: var(--growth-green);
}

.log-entry.consequence-bad {
    color: var(--consequence-red);
}

.log-entry.consequence-neutral {
    color: var(--virtue-purple);
}

/* === Stat Bars === */
.stat-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.stat-label {
    font-family: 'Press Start 2P', monospace;
    font-size: clamp(0.4rem, 0.8vw, 0.55rem);
    color: var(--parchment);
    width: 110px;
    flex-shrink: 0;
}

.stat-bar {
    flex: 1;
    height: 12px;
    background: var(--near-black);
    border: 2px solid var(--muted-steel);
    overflow: hidden;
}

.stat-fill {
    height: 100%;
    transition: width 600ms ease;
}

#stat-util .stat-fill,
#stat-util {
    background: var(--consequence-red);
}

#stat-deont .stat-fill,
#stat-deont {
    background: var(--pixel-gold);
}

#stat-virtue .stat-fill,
#stat-virtue {
    background: var(--virtue-purple);
}

#stat-care .stat-fill,
#stat-care {
    background: var(--growth-green);
}

/* === Philosopher Cards === */
.philosopher-card {
    text-align: center;
    cursor: pointer;
    transition: transform 200ms, border-color 200ms;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.philosopher-card:hover {
    transform: translateY(-4px);
    border-color: var(--pixel-gold);
}

.philosopher-card.selected {
    border-color: var(--pixel-gold);
    box-shadow: 0 0 20px rgba(255, 216, 102, 0.3);
}

.pixel-avatar {
    width: 64px;
    height: 64px;
    image-rendering: pixelated;
}

.avatar-kant {
    background:
        linear-gradient(var(--parchment) 16px, transparent 16px),
        linear-gradient(90deg, transparent 16px, var(--dark-bg) 16px, var(--dark-bg) 48px, transparent 48px),
        linear-gradient(transparent 16px, var(--parchment-warm) 16px, var(--parchment-warm) 48px, transparent 48px),
        linear-gradient(transparent 48px, var(--muted-steel) 48px);
    background-size: 64px 64px;
}

.avatar-mill {
    background:
        linear-gradient(var(--consequence-red) 16px, transparent 16px),
        linear-gradient(90deg, transparent 16px, var(--dark-bg) 16px, var(--dark-bg) 48px, transparent 48px),
        linear-gradient(transparent 16px, var(--parchment-warm) 16px, var(--parchment-warm) 48px, transparent 48px),
        linear-gradient(transparent 48px, var(--consequence-red) 48px);
    background-size: 64px 64px;
}

.avatar-aristotle {
    background:
        linear-gradient(var(--virtue-purple) 16px, transparent 16px),
        linear-gradient(90deg, transparent 16px, var(--dark-bg) 16px, var(--dark-bg) 48px, transparent 48px),
        linear-gradient(transparent 16px, var(--parchment-warm) 16px, var(--parchment-warm) 48px, transparent 48px),
        linear-gradient(transparent 48px, var(--virtue-purple) 48px);
    background-size: 64px 64px;
}

.avatar-noddings {
    background:
        linear-gradient(var(--growth-green) 16px, transparent 16px),
        linear-gradient(90deg, transparent 16px, var(--dark-bg) 16px, var(--dark-bg) 48px, transparent 48px),
        linear-gradient(transparent 16px, var(--parchment-warm) 16px, var(--parchment-warm) 48px, transparent 48px),
        linear-gradient(transparent 48px, var(--growth-green) 48px);
    background-size: 64px 64px;
}

.philosopher-name {
    font-family: 'Press Start 2P', monospace;
    font-size: clamp(0.55rem, 1.2vw, 0.8rem);
    color: var(--pixel-gold);
}

.philosopher-school {
    font-family: 'IBM Plex Mono', monospace;
    font-size: clamp(0.5rem, 1vw, 0.7rem);
    color: var(--muted-steel);
}

.mini-stats {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: center;
}

.mini-stat {
    font-family: 'Press Start 2P', monospace;
    font-size: 0.4rem;
    color: var(--growth-green);
    background: var(--near-black);
    padding: 0.2rem 0.4rem;
    border: 1px solid var(--muted-steel);
}

/* === Alignment Map === */
.alignment-container {
    position: relative;
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    padding: 2.5rem;
}

.alignment-axis-label {
    font-family: 'Press Start 2P', monospace;
    font-size: clamp(0.4rem, 0.9vw, 0.6rem);
    color: var(--muted-steel);
    position: absolute;
    text-transform: uppercase;
}

.axis-top { top: 0; left: 50%; transform: translateX(-50%); }
.axis-bottom { bottom: 0; left: 50%; transform: translateX(-50%); }
.axis-left { left: 0; top: 50%; transform: translateY(-50%) rotate(-90deg); }
.axis-right { right: 0; top: 50%; transform: translateY(-50%) rotate(90deg); }

.alignment-grid-visual {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    width: 100%;
    aspect-ratio: 1;
    border: 2px solid var(--muted-steel);
    position: relative;
}

.alignment-quadrant {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    transition: background 300ms;
}

.q-tl { background: rgba(255, 216, 102, 0.1); border-right: 1px solid var(--muted-steel); border-bottom: 1px solid var(--muted-steel); }
.q-tr { background: rgba(231, 76, 60, 0.1); border-bottom: 1px solid var(--muted-steel); }
.q-bl { background: rgba(155, 89, 182, 0.1); border-right: 1px solid var(--muted-steel); }
.q-br { background: rgba(76, 175, 80, 0.1); }

.quadrant-label {
    font-family: 'Press Start 2P', monospace;
    font-size: clamp(0.4rem, 1vw, 0.65rem);
    color: var(--parchment);
    text-align: center;
}

.player-marker {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    transition: top 600ms ease, left 600ms ease;
    z-index: 10;
}

.marker-icon {
    font-size: 1.5rem;
    color: var(--pixel-gold);
    text-shadow: 0 0 10px var(--pixel-gold);
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

/* === Inventory === */
.inventory-slot {
    text-align: center;
    cursor: pointer;
    transition: transform 200ms, border-color 200ms;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.inventory-slot:hover {
    transform: scale(1.03);
    border-color: var(--pixel-gold);
}

.item-icon {
    font-size: 2rem;
    color: var(--pixel-gold);
}

.item-name {
    font-family: 'Press Start 2P', monospace;
    font-size: clamp(0.4rem, 0.9vw, 0.6rem);
    color: var(--pixel-gold);
}

.item-desc {
    font-family: 'Lora', serif;
    font-size: clamp(0.65rem, 1.1vw, 0.8rem);
    color: var(--muted-steel);
    font-style: italic;
}

/* === Game Over Text === */
.game-over-text {
    text-align: center;
    margin-top: clamp(1.5rem, 3vw, 2.5rem);
    font-family: 'Lora', serif;
    font-size: clamp(0.8rem, 1.5vw, 1rem);
    color: var(--parchment);
}

.blink-text {
    font-family: 'Press Start 2P', monospace;
    font-size: clamp(0.6rem, 1.2vw, 0.85rem);
    color: var(--pixel-gold);
    margin-top: 1rem;
    animation: blink 1.2s step-end infinite;
}

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

/* === Responsive === */
@media (max-width: 768px) {
    .dilemma-grid {
        grid-template-columns: 1fr;
    }

    .dilemma-grid .scenario-panel {
        grid-column: 1;
        grid-row: auto;
    }

    .dilemma-grid .consequence-panel,
    .dilemma-grid .stats-panel {
        grid-column: 1;
        grid-row: auto;
    }

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

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

    .alignment-container {
        padding: 2rem 1rem;
    }
}

@media (max-width: 480px) {
    .philosopher-grid {
        grid-template-columns: 1fr;
    }

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

    .choice-buttons {
        flex-direction: column;
    }
}
