/* 
   Shadow Documentation:
   Fisier: proiecte/hamiltonian-dag/style.css
   Descriere: Stilizarea paginii de proiect Drum Hamiltonian in DAG.
   Implementeaza o tema intunecata de inalta calitate cu elemente de sticla (glassmorphism),
   efecte de stralucire (neon glows) pentru graf, design tip terminal pentru consola
   si editor de cod, integrandu-se estetic in portofoliul general.
*/

:root {
    --bg-dark: #050505;
    --bg-card: rgba(18, 18, 24, 0.7);
    --accent: #4f46e5;
    --accent-light: #818cf8;
    --accent-glow: rgba(79, 70, 229, 0.3);
    --success: #10b981;
    --success-glow: rgba(16, 185, 129, 0.4);
    --error: #ef4444;
    --error-glow: rgba(239, 68, 68, 0.4);
    --warning: #f59e0b;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-bg: rgba(255, 255, 255, 0.02);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    line-height: 1.6;
    overflow-x: hidden;
}

h1, h2, h3, h4 {
    font-family: 'Outfit', sans-serif;
}

.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 2rem;
}

/* --- Navigation --- */
nav {
    position: fixed;
    top: 0;
    width: 100%;
    z-index: 1000;
    padding: 1.2rem 0;
    background: rgba(5, 5, 5, 0.92);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--glass-border);
}

nav .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-family: 'Outfit', sans-serif;
    font-weight: 800;
    font-size: 1.5rem;
    background: linear-gradient(to right, var(--accent-light), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-decoration: none;
}

.nav-links {
    display: flex;
    gap: 2rem;
}

.nav-links a {
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    transition: var(--transition);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.nav-links a:hover {
    color: var(--text-primary);
}

/* --- Navigation Mobile Menu --- */
.nav-toggle {
    display: none;
    flex-direction: column;
    justify-content: space-between;
    width: 26px;
    height: 18px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    z-index: 1001;
}

.nav-toggle span {
    width: 100%;
    height: 2px;
    background-color: var(--text-primary);
    border-radius: 2px;
    transition: var(--transition);
    transform-origin: center;
}

.nav-toggle.active span:nth-child(1) {
    transform: translateY(8px) rotate(45deg);
}

.nav-toggle.active span:nth-child(2) {
    opacity: 0;
}

.nav-toggle.active span:nth-child(3) {
    transform: translateY(-8px) rotate(-45deg);
}

@media (max-width: 768px) {
    .nav-toggle {
        display: flex;
    }
    
    .nav-links {
        display: flex;
        flex-direction: column;
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        width: 280px;
        background: rgba(5, 5, 10, 0.96);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        border-left: 1px solid var(--glass-border);
        padding: 6rem 2rem 2rem;
        gap: 1.5rem;
        transform: translateX(100%);
        transition: var(--transition);
        z-index: 1000;
    }
    
    .nav-links.active {
        transform: translateX(0);
    }
}

/* --- Hero Section --- */
.hero {
    padding: 10rem 0 2rem 0;
    text-align: center;
}

.hero h1 {
    font-size: clamp(2.2rem, 6vw, 3.5rem);
    font-weight: 800;
    line-height: 1.2;
    margin-bottom: 1rem;
    letter-spacing: -0.02em;
    background: linear-gradient(to right, #ffffff, var(--accent-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero p {
    font-size: 1.1rem;
    color: var(--text-secondary);
    max-width: 700px;
    margin: 0 auto;
}

/* --- Section Layout --- */
.section-title {
    font-size: 1.8rem;
    font-weight: 600;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.section-title span.badge {
    background: var(--accent);
    color: white;
    font-size: 0.8rem;
    padding: 0.2rem 0.6rem;
    border-radius: 6px;
    font-family: monospace;
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(8px);
    border-radius: 1rem;
    padding: 2rem;
    margin-bottom: 2rem;
    transition: var(--transition);
}

.card:hover {
    border-color: rgba(79, 70, 229, 0.2);
}

/* --- Grid de Lucru --- */
.playground-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
    margin-bottom: 2rem;
}

@media (min-width: 1024px) {
    .playground-grid {
        grid-template-columns: 1fr 1.2fr;
    }
}

/* --- Panou Control & Matrice --- */
.control-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.matrix-container {
    overflow-x: auto;
    margin-bottom: 1.5rem;
    padding: 0.5rem;
    border-radius: 0.5rem;
    background: rgba(0, 0, 0, 0.2);
}

.matrix-table {
    border-collapse: collapse;
    margin: 0 auto;
}

.matrix-table th, .matrix-table td {
    padding: 0.4rem;
    text-align: center;
}

.matrix-table th {
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    color: var(--accent-light);
    width: 2.2rem;
    height: 2.2rem;
    font-size: 0.9rem;
}

.matrix-table td.node-label-col {
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    color: var(--accent-light);
    font-size: 0.9rem;
    padding-right: 0.8rem;
}

.matrix-cell {
    width: 2.2rem;
    height: 2.2rem;
    position: relative;
}

.matrix-cell input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 100%;
    width: 100%;
    z-index: 2;
}

.matrix-cell-visual {
    width: 100%;
    height: 100%;
    border: 1px solid var(--glass-border);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.02);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: monospace;
    font-size: 0.8rem;
    color: var(--text-secondary);
    transition: var(--transition);
}

.matrix-cell input[type="checkbox"]:checked ~ .matrix-cell-visual {
    background: rgba(79, 70, 229, 0.2);
    border-color: var(--accent);
    color: var(--accent-light);
    box-shadow: inset 0 0 8px rgba(79, 70, 229, 0.3);
}

.matrix-cell input[type="checkbox"]:hover ~ .matrix-cell-visual {
    border-color: var(--accent-light);
    background: rgba(255, 255, 255, 0.05);
}

.matrix-cell.diagonal .matrix-cell-visual {
    background: rgba(255, 255, 255, 0.05);
    border-color: transparent;
    color: rgba(255, 255, 255, 0.15);
    cursor: not-allowed;
}

.matrix-cell.diagonal input[type="checkbox"] {
    pointer-events: none;
}

/* --- Butoane --- */
.btn-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.btn-small {
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    border-radius: 8px;
    font-size: 0.85rem;
    cursor: pointer;
    font-weight: 500;
    transition: var(--transition);
}

.btn-small:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--text-secondary);
}

.btn-accent {
    background: var(--accent);
    border-color: rgba(255, 255, 255, 0.1);
}

.btn-accent:hover {
    background: var(--accent-light);
    box-shadow: 0 4px 15px rgba(79, 70, 229, 0.3);
}

.btn-success {
    background: var(--success);
    border-color: rgba(255, 255, 255, 0.1);
}

.btn-success:hover {
    background: #34d399;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
}

/* --- SVG Graph Container --- */
.graph-container {
    position: relative;
    width: 100%;
    aspect-ratio: 1.2 / 1;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--glass-border);
    border-radius: 0.75rem;
    overflow: hidden;
}

@media (max-width: 640px) {
    .graph-container {
        aspect-ratio: 1 / 1;
    }
}

@media (max-width: 1024px) {
    nav, .nav-links, .card, .console-card {
        -webkit-backdrop-filter: none !important;
        backdrop-filter: none !important;
    }
    nav { background: rgba(5, 5, 5, 0.98) !important; }
    .card { background: rgba(18, 18, 24, 0.98) !important; }
    .nav-links { background: rgba(5, 5, 10, 0.98) !important; }
}

.graph-svg {
    width: 100%;
    height: 100%;
    /* Previne conflictele intre touch scroll si drag pe SVG */
    touch-action: none;
}

.graph-node {
    cursor: grab;
    transition: transform 0.1s ease;
    touch-action: none;
}

.graph-node:active,
.graph-node.dragging {
    cursor: grabbing;
    transition: none !important;
}

.graph-node circle {
    fill: #111116;
    stroke: var(--accent-light);
    stroke-width: 2.5;
    transition: var(--transition);
    touch-action: none;
}

.graph-node:hover circle {
    fill: rgba(79, 70, 229, 0.15);
    stroke-width: 3.5;
}

@media (min-width: 1025px) {
    .graph-node:hover circle {
        filter: drop-shadow(0 0 6px var(--accent-light));
    }
}

.graph-node text {
    fill: var(--text-primary);
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    font-size: 14px;
    text-anchor: middle;
    dominant-baseline: central;
    pointer-events: none;
    user-select: none;
}

.graph-edge {
    fill: none;
    stroke: var(--text-secondary);
    stroke-width: 2;
    stroke-opacity: 0.4;
    transition: var(--transition);
}

.graph-edge-label {
    fill: var(--text-secondary);
    font-size: 10px;
    font-family: monospace;
}

/* Evidentieri pentru Drumul Hamiltonian */
/* Nota: folosim animatii GPU-friendly (opacity, transform) in loc de filter: drop-shadow
   care cauzeaza lag pe mobile din cauza rasterizarii software */
@keyframes pulse-success {
    0% { stroke-opacity: 0.8; stroke-width: 3; }
    50% { stroke-opacity: 1; stroke-width: 4.5; }
    100% { stroke-opacity: 0.8; stroke-width: 3; }
}

@keyframes pulse-error {
    0% { stroke-opacity: 0.7; stroke-width: 3; }
    50% { stroke-opacity: 1; stroke-width: 4.5; }
    100% { stroke-opacity: 0.7; stroke-width: 3; }
}

@keyframes pulse-glow-success {
    0% { r: 20; fill-opacity: 0.1; }
    50% { r: 22; fill-opacity: 0.25; }
    100% { r: 20; fill-opacity: 0.1; }
}

.graph-node.in-path circle {
    stroke: var(--success);
    fill: rgba(16, 185, 129, 0.15);
    stroke-width: 3.5;
    will-change: stroke-width, stroke-opacity;
}

.graph-node.in-cycle circle {
    stroke: var(--error);
    fill: rgba(239, 68, 68, 0.15);
    stroke-width: 3.5;
    will-change: stroke-width, stroke-opacity;
}

/* Activam animatia pulse DOAR pe desktop-uri puternice (nu pe tablete/mobile) */
@media (min-width: 1025px) {
    .graph-node.in-path circle {
        animation: pulse-success 2s infinite ease-in-out;
    }
    .graph-node.in-cycle circle {
        animation: pulse-error 1.5s infinite ease-in-out;
    }
}

.graph-edge.in-path {
    stroke: var(--success);
    stroke-width: 4;
    stroke-opacity: 1;
    /* Pe mobile/tablete: fara filter drop-shadow, fara stroke-dasharray animat */
    stroke-dasharray: 8 4;
    will-change: stroke-dashoffset;
}

/* Animatia de dash optimizata doar pe desktop */
@media (min-width: 1025px) {
    .graph-edge.in-path {
        filter: drop-shadow(0 0 4px rgba(16, 185, 129, 0.5));
        animation: dash 0.8s linear infinite;
    }
}

@keyframes dash {
    to {
        stroke-dashoffset: -24;
    }
}

.graph-edge.in-cycle {
    stroke: var(--error);
    stroke-width: 3.5;
    stroke-opacity: 0.9;
}

@media (min-width: 1025px) {
    .graph-edge.in-cycle {
        filter: drop-shadow(0 0 4px rgba(239, 68, 68, 0.5));
    }
}

/* Respectam preferinta utilizatorului pentru animatii reduse */
@media (prefers-reduced-motion: reduce) {
    .graph-node.in-path circle,
    .graph-node.in-cycle circle {
        animation: none !important;
    }
    .graph-edge.in-path {
        animation: none !important;
    }
}

/* Markers pentru sageti */
svg marker {
    fill: var(--text-secondary);
    opacity: 0.5;
}

svg marker#arrow-path {
    fill: var(--success);
    opacity: 1;
}

svg marker#arrow-cycle {
    fill: var(--error);
    opacity: 1;
}

/* --- Consola Output --- */
.console-card {
    background: #09090e;
    border: 1px solid var(--glass-border);
    border-radius: 0.75rem;
    padding: 1.2rem;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 0.85rem;
    margin-bottom: 2rem;
}

.console-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 0.5rem;
    margin-bottom: 0.8rem;
    color: var(--text-secondary);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.console-body {
    max-height: 250px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.console-line {
    word-break: break-all;
    line-height: 1.4;
}

.console-line.info {
    color: var(--text-secondary);
}

.console-line.success {
    color: var(--success);
    font-weight: 500;
}

.console-line.error {
    color: var(--error);
    font-weight: 500;
}

.console-line.warning {
    color: var(--warning);
}

.console-line.log {
    color: #e2e8f0;
    border-left: 2px solid var(--glass-border);
    padding-left: 0.5rem;
}

/* --- Sandbox Cod --- */
.editor-container {
    border: 1px solid var(--glass-border);
    border-radius: 0.75rem;
    overflow: hidden;
    background: #0d0e15;
    margin-bottom: 1.5rem;
}

.editor-header {
    background: #131520;
    padding: 0.75rem 1.2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--glass-border);
}

.editor-title {
    font-family: 'Outfit', sans-serif;
    font-size: 0.9rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.editor-title::before {
    content: "";
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #f59e0b; /* File indicator dot */
}

.editor-wrapper {
    display: flex;
    position: relative;
    height: 380px;
}

.editor-line-numbers {
    padding: 1rem 0.5rem 1rem 1rem;
    text-align: right;
    color: rgba(255, 255, 255, 0.15);
    background: #090a0f;
    font-family: monospace;
    font-size: 0.85rem;
    user-select: none;
    line-height: 1.5;
    min-width: 2.8rem;
    border-right: 1px solid rgba(255, 255, 255, 0.03);
}

.editor-textarea {
    flex-grow: 1;
    background: transparent;
    border: none;
    outline: none;
    color: #e2e8f0;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 0.85rem;
    padding: 1rem;
    line-height: 1.5;
    resize: none;
    white-space: pre;
    overflow-x: auto;
    overflow-y: auto;
    tab-size: 4;
}

/* --- Documentatie Teoretica --- */
.doc-section {
    line-height: 1.8;
}

.doc-section h3 {
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
    color: var(--accent-light);
}

.doc-section p {
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.doc-section ul, .doc-section ol {
    margin-bottom: 1rem;
    padding-left: 1.5rem;
    color: var(--text-secondary);
}

.doc-section li {
    margin-bottom: 0.5rem;
}

.math-block {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 1rem;
    font-family: 'Outfit', sans-serif;
    font-style: italic;
    text-align: center;
    margin: 1.5rem 0;
    color: var(--text-primary);
}

code.inline-code {
    background: rgba(255, 255, 255, 0.08);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.9em;
    color: var(--accent-light);
}

/* --- Sub-Footer Back Button --- */
.back-btn-container {
    margin: 3rem 0;
    text-align: center;
}

/* --- Resetare si Scrollbar global --- */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-dark);
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}
