/* ============================================
   moral.quest — Neomorphic Ethical Interface
   ============================================ */

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

:root {
    --deep-charcoal: #2A2A3A;
    --medium-charcoal: #4A4A5A;
    --silver-grey: #7A7A8A;
    --neomorph-surface: #E4E8EE;
    --shadow-dark: #C0C4D0;
    --highlight-light: #FFFFFF;
    --ethics-blue: #5060A0;
    --moral-gold: #B0A070;

    --neo-shadow: 8px 8px 16px var(--shadow-dark), -8px -8px 16px var(--highlight-light);
    --neo-shadow-sm: 4px 4px 8px var(--shadow-dark), -4px -4px 8px var(--highlight-light);
    --neo-inset: inset 4px 4px 8px var(--shadow-dark), inset -4px -4px 8px var(--highlight-light);
    --neo-inset-sm: inset 2px 2px 5px var(--shadow-dark), inset -2px -2px 5px var(--highlight-light);

    --morph-transition: all 400ms cubic-bezier(0.4, 0, 0.2, 1);
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', sans-serif;
    font-weight: 400;
    font-size: clamp(0.95rem, 1.2vw, 1.1rem);
    line-height: 1.9;
    color: var(--medium-charcoal);
    background-color: var(--neomorph-surface);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* --- Typography --- */
h1, h2, h3 {
    font-family: 'DM Serif Display', serif;
    font-weight: 400;
    color: var(--deep-charcoal);
}

.detail-annotation,
.thinker-era,
.perspective-fw {
    font-family: 'Source Serif 4', serif;
    font-style: italic;
    color: var(--silver-grey);
}

/* --- SVG Connections Layer --- */
.connections-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 1;
}

.flow-curve {
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    transition: stroke-dashoffset 2s ease;
}

.flow-curve.animated {
    stroke-dashoffset: 0;
}

/* --- Hero Surface --- */
.hero-surface {
    position: relative;
    width: 100%;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    overflow: hidden;
}

.hero-inner {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hero-title-container {
    text-align: center;
    padding: 3rem 4rem;
    border-radius: 24px;
    box-shadow: var(--neo-inset);
    background: var(--neomorph-surface);
    opacity: 0;
    transform: scale(0.95);
    animation: heroReveal 1.2s cubic-bezier(0.4, 0, 0.2, 1) 0.3s forwards;
    position: relative;
    z-index: 5;
}

@keyframes heroReveal {
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.hero-title {
    font-size: clamp(2.2rem, 5vw, 4rem);
    letter-spacing: 0.15em;
    color: var(--deep-charcoal);
    text-shadow: 2px 2px 4px var(--shadow-dark), -1px -1px 2px var(--highlight-light);
    margin-bottom: 0.5rem;
}

.hero-subtitle {
    font-family: 'Source Serif 4', serif;
    font-style: italic;
    font-size: clamp(0.9rem, 1.5vw, 1.15rem);
    color: var(--silver-grey);
    letter-spacing: 0.05em;
}

/* --- Hero Ethics Icons --- */
.hero-icons {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 3;
}

.ethics-icon {
    position: absolute;
    width: 80px;
    height: 80px;
    opacity: 0;
    animation: iconDraw 1.5s ease forwards;
}

.ethics-icon path,
.ethics-icon line,
.ethics-icon circle,
.ethics-icon polygon,
.ethics-icon rect {
    stroke-dasharray: 200;
    stroke-dashoffset: 200;
    animation: drawStroke 2s ease forwards;
}

@keyframes drawStroke {
    to {
        stroke-dashoffset: 0;
    }
}

@keyframes iconDraw {
    to {
        opacity: 0.7;
    }
}

.icon-scales {
    top: 18%;
    left: 12%;
    animation-delay: 0.6s;
}
.icon-scales path,
.icon-scales line,
.icon-scales circle {
    animation-delay: 0.8s;
}

.icon-compass {
    top: 22%;
    right: 14%;
    animation-delay: 0.9s;
}
.icon-compass path,
.icon-compass line,
.icon-compass circle,
.icon-compass polygon {
    animation-delay: 1.1s;
}

.icon-paths {
    bottom: 24%;
    left: 50%;
    transform: translateX(-50%);
    animation-delay: 1.2s;
}
.icon-paths path,
.icon-paths line,
.icon-paths circle {
    animation-delay: 1.4s;
}

/* --- HUD Panels --- */
.hud-panel {
    position: fixed;
    z-index: 10;
    background: var(--neomorph-surface);
    border-radius: 16px;
    padding: 1.25rem;
    transition: var(--morph-transition);
    opacity: 0;
    animation: panelExtrude 0.8s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.neo-panel {
    box-shadow: var(--neo-shadow);
}

.neo-panel-large {
    box-shadow: var(--neo-shadow);
}

@keyframes panelExtrude {
    from {
        opacity: 0;
        transform: scale(0.92) translateY(10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.hud-top-left {
    top: 24px;
    left: 24px;
    width: 220px;
    animation-delay: 0.8s;
}

.hud-top-right {
    top: 24px;
    right: 24px;
    width: 240px;
    animation-delay: 1s;
}

.hud-bottom-left {
    bottom: 24px;
    left: 24px;
    width: 200px;
    animation-delay: 1.2s;
}

.hud-bottom-right {
    bottom: 24px;
    right: 24px;
    width: 320px;
    animation-delay: 1.4s;
}

/* --- Panel Header --- */
.panel-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--shadow-dark);
}

.panel-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.panel-label {
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--silver-grey);
}

/* --- Framework Navigator --- */
.framework-list {
    list-style: none;
}

.framework-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 0.6rem;
    border-radius: 10px;
    cursor: pointer;
    transition: var(--morph-transition);
    margin-bottom: 0.2rem;
}

.framework-item:hover {
    background: var(--neomorph-surface);
    box-shadow: var(--neo-inset-sm);
}

.framework-item.active {
    background: var(--neomorph-surface);
    box-shadow: var(--neo-inset-sm);
}

.fw-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--shadow-dark);
    transition: var(--morph-transition);
    flex-shrink: 0;
}

.framework-item.active .fw-indicator {
    background: var(--ethics-blue);
    box-shadow: 0 0 8px rgba(80, 96, 160, 0.5);
}

.fw-name {
    font-size: 0.85rem;
    font-weight: 400;
    color: var(--medium-charcoal);
    transition: color 300ms ease;
}

.framework-item.active .fw-name {
    font-weight: 500;
    color: var(--deep-charcoal);
}

/* --- Status Panel --- */
.status-content {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.status-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.5rem;
}

.status-key {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--silver-grey);
    flex-shrink: 0;
}

.status-value {
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--deep-charcoal);
    text-align: right;
    transition: var(--morph-transition);
}

/* --- Main Framework Detail Panel --- */
.framework-detail-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(680px, 88vw);
    max-height: 70vh;
    overflow-y: auto;
    border-radius: 24px;
    padding: 2.5rem;
    z-index: 8;
    background: var(--neomorph-surface);
    opacity: 0;
    animation: mainPanelReveal 1s cubic-bezier(0.4, 0, 0.2, 1) 1.6s forwards;
}

/* Custom scrollbar for detail panel */
.framework-detail-panel::-webkit-scrollbar {
    width: 6px;
}

.framework-detail-panel::-webkit-scrollbar-track {
    background: var(--neomorph-surface);
    border-radius: 3px;
}

.framework-detail-panel::-webkit-scrollbar-thumb {
    background: var(--shadow-dark);
    border-radius: 3px;
}

@keyframes mainPanelReveal {
    from {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

.detail-header {
    margin-bottom: 2rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--shadow-dark);
}

.detail-title {
    font-size: clamp(1.8rem, 3.5vw, 2.6rem);
    color: var(--deep-charcoal);
    margin-bottom: 0.3rem;
    transition: var(--morph-transition);
}

.detail-annotation {
    font-size: 0.9rem;
    transition: var(--morph-transition);
}

/* --- Detail Sections --- */
.detail-section {
    margin-bottom: 1.8rem;
}

.section-heading {
    font-size: 1.1rem;
    color: var(--deep-charcoal);
    margin-bottom: 0.6rem;
    position: relative;
    padding-left: 1rem;
}

.section-heading::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 70%;
    background: var(--ethics-blue);
    border-radius: 2px;
}

.section-text {
    color: var(--medium-charcoal);
    transition: var(--morph-transition);
}

.critique-text {
    padding: 1rem 1.25rem;
    border-radius: 12px;
    box-shadow: var(--neo-inset-sm);
    background: var(--neomorph-surface);
}

/* --- Thinkers Grid --- */
.thinkers-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.75rem;
}

.thinker-card {
    padding: 0.8rem 1rem;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    transition: var(--morph-transition);
}

.neo-inset-sm {
    box-shadow: var(--neo-inset-sm);
    background: var(--neomorph-surface);
}

.thinker-name {
    font-weight: 500;
    font-size: 0.88rem;
    color: var(--deep-charcoal);
}

.thinker-era {
    font-size: 0.78rem;
}

/* --- Principles List --- */
.principles-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.principle-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.principle-marker {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--ethics-blue);
    flex-shrink: 0;
    margin-top: 0.55rem;
    box-shadow: 0 0 6px rgba(80, 96, 160, 0.4);
}

.principle-text {
    font-size: 0.92rem;
    color: var(--medium-charcoal);
    line-height: 1.7;
}

/* --- Legend Panel --- */
.legend-items {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.legend-line {
    width: 24px;
    height: 2px;
    border-radius: 1px;
}

.legend-line.influence {
    background: var(--ethics-blue);
}

.legend-line.opposition {
    background: var(--moral-gold);
}

.legend-line.synthesis {
    background: linear-gradient(90deg, var(--ethics-blue), var(--moral-gold));
}

.legend-text {
    font-size: 0.78rem;
    color: var(--silver-grey);
}

/* --- Inquiry Panel --- */
.inquiry-question {
    font-family: 'DM Serif Display', serif;
    font-size: 1rem;
    color: var(--deep-charcoal);
    margin-bottom: 1rem;
    line-height: 1.5;
}

.inquiry-perspectives {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.perspective {
    padding: 0.75rem 1rem;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    transition: var(--morph-transition);
}

.perspective-fw {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.perspective-answer {
    font-size: 0.82rem;
    color: var(--medium-charcoal);
    line-height: 1.6;
}

/* --- Concept Nodes --- */
.concept-nodes-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 6;
}

.concept-node {
    position: absolute;
    left: var(--node-x);
    top: var(--node-y);
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
    pointer-events: auto;
    cursor: default;
    opacity: 0;
    animation: nodeAppear 0.6s ease forwards;
}

.concept-node:nth-child(1) { animation-delay: 1.8s; }
.concept-node:nth-child(2) { animation-delay: 2.0s; }
.concept-node:nth-child(3) { animation-delay: 2.2s; }
.concept-node:nth-child(4) { animation-delay: 2.4s; }
.concept-node:nth-child(5) { animation-delay: 2.6s; }

@keyframes nodeAppear {
    from {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.6);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

.neo-circle {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: var(--neomorph-surface);
    box-shadow: var(--neo-shadow-sm);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: var(--morph-transition);
}

.neo-circle:hover {
    box-shadow: var(--neo-inset-sm);
}

.concept-node svg {
    width: 32px;
    height: 32px;
}

.node-label {
    font-size: 0.65rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--silver-grey);
    position: absolute;
    bottom: -18px;
    white-space: nowrap;
}

/* --- Neo Inset Utility --- */
.neo-inset {
    box-shadow: var(--neo-inset);
    background: var(--neomorph-surface);
}

/* --- Panel Morphing States --- */
.hud-panel.collapsed {
    padding: 0.75rem 1rem;
    overflow: hidden;
}

.hud-panel.collapsed .framework-list,
.hud-panel.collapsed .status-content,
.hud-panel.collapsed .legend-items,
.hud-panel.collapsed .inquiry-content {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    margin: 0;
}

/* --- Framework Detail Morph --- */
.framework-detail-panel.morphing {
    transition: var(--morph-transition);
}

.framework-detail-panel.morphing .detail-title,
.framework-detail-panel.morphing .detail-annotation,
.framework-detail-panel.morphing .section-text,
.framework-detail-panel.morphing .thinkers-grid,
.framework-detail-panel.morphing .principles-list,
.framework-detail-panel.morphing .critique-text {
    opacity: 0;
    transform: translateY(8px);
}

.detail-title,
.detail-annotation,
.section-text,
.thinkers-grid,
.principles-list,
.critique-text {
    transition: opacity 350ms ease, transform 350ms ease;
}

/* --- Responsive --- */
@media (max-width: 900px) {
    .hud-top-left,
    .hud-top-right,
    .hud-bottom-left,
    .hud-bottom-right {
        position: relative;
        top: auto;
        left: auto;
        right: auto;
        bottom: auto;
        width: 100%;
        margin: 0.5rem 0;
    }

    .framework-detail-panel {
        position: relative;
        top: auto;
        left: auto;
        transform: none;
        width: 100%;
        max-height: none;
        margin: 1rem 0;
        animation: none;
        opacity: 1;
    }

    .hero-surface {
        height: auto;
        min-height: 60vh;
        padding: 4rem 1rem;
    }

    .concept-nodes-layer {
        position: relative;
        height: auto;
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 1.5rem;
        padding: 2rem 1rem;
    }

    .concept-node {
        position: relative;
        left: auto;
        top: auto;
        transform: none;
        animation: none;
        opacity: 1;
    }

    @keyframes nodeAppear {
        to {
            opacity: 1;
            transform: none;
        }
    }

    .connections-layer {
        display: none;
    }

    body {
        display: flex;
        flex-direction: column;
        padding: 1rem;
    }

    .hud-panel {
        position: relative;
        animation: none;
        opacity: 1;
    }

    @keyframes mainPanelReveal {
        to {
            opacity: 1;
            transform: none;
        }
    }
}

@media (max-width: 480px) {
    .hero-title {
        font-size: 1.8rem;
        letter-spacing: 0.08em;
    }

    .hero-title-container {
        padding: 2rem;
    }

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

    .framework-detail-panel {
        padding: 1.5rem;
    }

    .hud-panel {
        padding: 1rem;
    }
}

/* --- Moral Gold Accent for selected emphasis --- */
.gold-accent {
    color: var(--moral-gold);
}

/* --- Pulse animation for active concepts --- */
@keyframes subtlePulse {
    0%, 100% {
        box-shadow: var(--neo-shadow-sm);
    }
    50% {
        box-shadow: 6px 6px 12px var(--shadow-dark), -6px -6px 12px var(--highlight-light), 0 0 20px rgba(80, 96, 160, 0.15);
    }
}

.concept-node.active .neo-circle,
.concept-node:hover .neo-circle {
    animation: subtlePulse 2s ease-in-out infinite;
}

/* Make sure concept node wrapper doesn't interfere with circle styling */
.concept-node {
    width: auto;
    height: auto;
    border-radius: 0;
    background: none;
    box-shadow: none;
    padding: 0;
}
