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

body {
    min-height: 100vh;
    background: #0c0518;
    font-family: 'Inter', system-ui, sans-serif;
    color: #e2e2e2;
    overflow-x: hidden;
}

/* ========== ANIMATED BACKGROUND ========== */
.bg-orbs {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(100px);
    opacity: 0.35;
    animation: float 20s ease-in-out infinite;
}

.orb-1 {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, #6d28d9, transparent 70%);
    top: -10%;
    left: -5%;
    animation-duration: 22s;
}

.orb-2 {
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, #a21caf, transparent 70%);
    bottom: -10%;
    right: -5%;
    animation-duration: 18s;
    animation-delay: -5s;
}

.orb-3 {
    width: 350px;
    height: 350px;
    background: radial-gradient(circle, #1e40af, transparent 70%);
    top: 40%;
    left: 50%;
    animation-duration: 25s;
    animation-delay: -10s;
}

@keyframes float {

    0%,
    100% {
        transform: translate(0, 0) scale(1);
    }

    25% {
        transform: translate(30px, -40px) scale(1.05);
    }

    50% {
        transform: translate(-20px, 20px) scale(0.95);
    }

    75% {
        transform: translate(40px, 30px) scale(1.02);
    }
}

/* ========== CONTAINER ========== */
.container {
    position: relative;
    z-index: 1;
    max-width: 1100px;
    margin: 0 auto;
    padding: 2rem 1.5rem 4rem;
}

/* ========== HEADER ========== */
header {
    text-align: center;
    margin-bottom: 2.5rem;
}

.logo-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    display: inline-block;
    animation: pulse-glow 3s ease-in-out infinite;
    filter: drop-shadow(0 0 12px rgba(168, 85, 247, 0.5));
}

@keyframes pulse-glow {

    0%,
    100% {
        transform: scale(1);
        opacity: 0.8;
    }

    50% {
        transform: scale(1.15);
        opacity: 1;
    }
}

header h1 {
    font-family: 'Cinzel', serif;
    font-size: clamp(1.6rem, 4vw, 2.8rem);
    font-weight: 700;
    background: linear-gradient(135deg, #e8a87c 0%, #d4a574 40%, #f0c27f 70%, #e8a87c 100%);
    background-size: 200% auto;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: 0.06em;
    animation: shimmer 4s linear infinite;
}

@keyframes shimmer {
    0% {
        background-position: 0% center;
    }

    100% {
        background-position: 200% center;
    }
}

.subtitle {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.1rem;
    color: rgba(255, 255, 255, 0.4);
    letter-spacing: 0.35em;
    text-transform: uppercase;
    margin-top: 0.3rem;
}

/* ========== INPUT SECTION ========== */
.input-section {
    display: flex;
    justify-content: center;
    margin-bottom: 2.5rem;
}

.input-card {
    background: rgba(255, 255, 255, 0.04);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 20px;
    padding: 1.5rem 1.8rem;
    width: 100%;
    max-width: 560px;
    transition: border-color 0.3s;
}

.input-card:focus-within {
    border-color: rgba(139, 92, 246, 0.4);
    box-shadow: 0 0 40px rgba(139, 92, 246, 0.08);
}

.input-card label {
    display: block;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: rgba(255, 255, 255, 0.45);
    margin-bottom: 0.75rem;
    font-weight: 500;
}

.input-wrapper {
    display: flex;
    gap: 0.75rem;
    align-items: stretch;
}

#nameInput {
    flex: 1;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    color: #fff;
    font-size: 1.05rem;
    padding: 0.75rem 1.2rem;
    outline: none;
    font-family: 'Inter', sans-serif;
    transition: border-color 0.25s, box-shadow 0.25s;
}

#nameInput:focus {
    border-color: rgba(139, 92, 246, 0.5);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.12);
}

#nameInput::placeholder {
    color: rgba(255, 255, 255, 0.25);
}

#generateBtn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: linear-gradient(135deg, #7c3aed, #6d28d9);
    color: #fff;
    border: none;
    padding: 0.75rem 1.6rem;
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    transition: all 0.25s ease;
    white-space: nowrap;
}

#generateBtn:hover {
    background: linear-gradient(135deg, #8b5cf6, #7c3aed);
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(124, 58, 237, 0.35);
}

#generateBtn:active {
    transform: translateY(0);
}

.btn-icon {
    transition: transform 0.25s;
    font-size: 1.1rem;
}

#generateBtn:hover .btn-icon {
    transform: translateX(3px);
}

/* ========== TREE ========== */
.tree-container {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 1rem 0 2rem;
    min-height: 0;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: rgba(139, 92, 246, 0.3) transparent;
}

.tree-container::-webkit-scrollbar {
    height: 6px;
}

.tree-container::-webkit-scrollbar-track {
    background: transparent;
}

.tree-container::-webkit-scrollbar-thumb {
    background: rgba(139, 92, 246, 0.3);
    border-radius: 3px;
}

.tree-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    min-width: fit-content;
    padding: 0 1rem;
    margin: 0 auto;
}

.tree-row {
    display: flex;
    justify-content: center;
    gap: var(--cell-gap, 3px);
    opacity: 0;
    animation: row-enter 0.45s ease forwards;
    animation-delay: var(--row-delay, 0ms);
    white-space: nowrap;
}

@keyframes row-enter {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.tree-cell {
    width: var(--cell-size, 40px);
    height: var(--cell-size, 40px);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    font-weight: 600;
    font-size: var(--cell-font, 0.95rem);
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
    position: relative;
}

.tree-cell:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
    transform: scale(1.08);
    z-index: 2;
}

/* Letter cells */
.tree-cell.letter {
    background: transparent;
    border-color: transparent;
    color: #e8a87c;
    font-family: 'Cinzel', serif;
    font-weight: 700;
    font-size: var(--letter-font, 1.05rem);
}

.tree-cell.letter:hover {
    background: rgba(232, 168, 124, 0.08);
}

/* First number row */
.tree-cell.first-row {
    background: rgba(139, 92, 246, 0.12);
    border-color: rgba(139, 92, 246, 0.25);
    color: #c4b5fd;
}

/* Highlight (negative energy triplets) */
.tree-cell.highlight {
    background: rgba(220, 38, 38, 0.2);
    border-color: rgba(239, 68, 68, 0.5);
    color: #fca5a5;
    box-shadow: 0 0 18px rgba(239, 68, 68, 0.2), inset 0 0 12px rgba(239, 68, 68, 0.08);
    animation: row-enter 0.45s ease forwards, pulse-red 2.5s ease-in-out infinite 0.6s;
}

@keyframes pulse-red {

    0%,
    100% {
        box-shadow: 0 0 18px rgba(239, 68, 68, 0.2), inset 0 0 12px rgba(239, 68, 68, 0.08);
    }

    50% {
        box-shadow: 0 0 28px rgba(239, 68, 68, 0.35), inset 0 0 16px rgba(239, 68, 68, 0.15);
    }
}

/* Final single cell */
.tree-cell.final-cell {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.25), rgba(168, 85, 247, 0.15));
    border-color: rgba(168, 85, 247, 0.5);
    color: #e9d5ff;
    font-weight: 700;
    font-size: calc(var(--cell-font, 0.95rem) * 1.15);
    box-shadow: 0 0 24px rgba(168, 85, 247, 0.2);
}

/* ========== SUMMARY CARDS ========== */
.summary-container {
    display: flex;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
    padding: 0.5rem 0 1.5rem;
    max-width: 600px;
    margin: 0 auto;
}

.summary-container:empty {
    display: none;
}

.summary-card {
    flex: 1 1 150px;
    max-width: 180px;
    background: rgba(255, 255, 255, 0.04);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    padding: 1.1rem 1rem;
    text-align: center;
    opacity: 0;
    animation: row-enter 0.5s ease forwards;
}

.summary-card .card-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: rgba(255, 255, 255, 0.45);
    margin-bottom: 0.4rem;
    font-weight: 500;
}

.summary-card .card-value {
    font-family: 'Cinzel', serif;
    font-size: 2rem;
    font-weight: 700;
    line-height: 1;
}

.summary-card.expressao {
    border-color: rgba(168, 85, 247, 0.3);
    animation-delay: 200ms;
}

.summary-card.expressao .card-value {
    color: #c4b5fd;
}

.summary-card.motivacao {
    border-color: rgba(232, 168, 124, 0.3);
    animation-delay: 350ms;
}

.summary-card.motivacao .card-value {
    color: #e8a87c;
}

.summary-card.impressao {
    border-color: rgba(96, 165, 250, 0.3);
    animation-delay: 500ms;
}

.summary-card.impressao .card-value {
    color: #93c5fd;
}

@media (max-width: 600px) {
    .summary-container {
        gap: 0.6rem;
        padding: 0.3rem 0.5rem 1rem;
    }

    .summary-card {
        padding: 0.8rem 0.6rem;
        border-radius: 12px;
    }

    .summary-card .card-value {
        font-size: 1.6rem;
    }

    .summary-card .card-label {
        font-size: 0.65rem;
    }
}

/* ========== CONNECTOR LINES ========== */
.connector-row {
    display: flex;
    justify-content: center;
    gap: var(--cell-gap, 3px);
    height: 8px;
    opacity: 0;
    animation: row-enter 0.3s ease forwards;
    animation-delay: var(--row-delay, 0ms);
}

.connector {
    width: var(--cell-size, 40px);
    height: 8px;
    position: relative;
}

.connector::before,
.connector::after {
    content: '';
    position: absolute;
    bottom: 0;
    width: 50%;
    height: 100%;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.connector::before {
    left: 0;
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    border-bottom-right-radius: 4px;
}

.connector::after {
    right: 0;
    border-left: 1px solid rgba(255, 255, 255, 0.08);
    border-bottom-left-radius: 4px;
}

/* ========== REFERENCE TABLE ========== */
.reference-table {
    margin-top: 2rem;
    max-width: 560px;
    margin-left: auto;
    margin-right: auto;
}

.reference-table summary {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.45);
    padding: 0.8rem 1.2rem;
    border-radius: 12px;
    transition: all 0.25s;
    user-select: none;
    list-style: none;
}

.reference-table summary::-webkit-details-marker {
    display: none;
}

.reference-table summary::after {
    content: '▾';
    margin-left: auto;
    transition: transform 0.3s;
}

.reference-table[open] summary::after {
    transform: rotate(180deg);
}

.reference-table summary:hover {
    color: rgba(255, 255, 255, 0.65);
    background: rgba(255, 255, 255, 0.04);
}

.table-content {
    margin-top: 0.5rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 14px;
    padding: 1.2rem;
    animation: row-enter 0.3s ease;
}

.table-content table {
    width: 100%;
    border-collapse: collapse;
    text-align: center;
    font-size: 0.9rem;
}

.table-content th {
    background: rgba(139, 92, 246, 0.15);
    color: #c4b5fd;
    padding: 0.5rem;
    font-weight: 700;
    font-family: 'Cinzel', serif;
}

.table-content th:first-child {
    border-radius: 8px 0 0 0;
}

.table-content th:last-child {
    border-radius: 0 8px 0 0;
}

.table-content td {
    padding: 0.45rem;
    border: 1px solid rgba(255, 255, 255, 0.06);
    color: rgba(255, 255, 255, 0.7);
}

.diacritics-ref {
    margin-top: 1rem;
}

.diacritics-ref h4 {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: rgba(255, 255, 255, 0.4);
    margin-bottom: 0.5rem;
}

.diacritics-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1.2rem;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.6);
}

/* ========== RESPONSIVE ========== */

/* Scroll hint when tree overflows */
.scroll-hint {
    display: none;
    text-align: center;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.35);
    padding: 0.3rem 0;
    letter-spacing: 0.05em;
}

.scroll-hint.visible {
    display: block;
}

@media (max-width: 768px) {
    .container {
        padding: 1.5rem 1rem 3rem;
    }

    header {
        margin-bottom: 1.8rem;
    }

    .subtitle {
        font-size: 0.95rem;
        letter-spacing: 0.25em;
    }

    .input-card {
        padding: 1.2rem 1.4rem;
        border-radius: 16px;
    }

    #nameInput {
        font-size: 1rem;
        padding: 0.7rem 1rem;
    }

    #generateBtn {
        padding: 0.7rem 1.4rem;
        font-size: 0.9rem;
    }
}

@media (max-width: 600px) {
    .container {
        padding: 1.2rem 0.6rem 2.5rem;
    }

    header h1 {
        font-size: 1.5rem;
    }

    header {
        margin-bottom: 1.5rem;
    }

    .subtitle {
        font-size: 0.85rem;
        letter-spacing: 0.2em;
    }

    .input-card {
        padding: 1rem;
        max-width: 100%;
    }

    .input-wrapper {
        flex-direction: column;
    }

    #nameInput {
        font-size: 1rem;
        padding: 0.85rem 1rem;
        border-radius: 10px;
        min-height: 48px;
        /* touch target */
    }

    #generateBtn {
        justify-content: center;
        padding: 0.85rem 1.2rem;
        border-radius: 10px;
        min-height: 48px;
        /* touch target */
        font-size: 1rem;
    }

    /* Tree adjustments for mobile */
    .tree-container {
        padding: 0.5rem 0 1.5rem;
    }

    .tree-inner {
        padding: 0 0.5rem;
    }

    .reference-table {
        margin-top: 1.5rem;
    }

    .reference-table summary {
        font-size: 0.82rem;
        padding: 0.6rem 0.8rem;
    }

    .table-content {
        padding: 0.8rem;
    }

    .table-content table {
        font-size: 0.8rem;
    }

    .table-content td,
    .table-content th {
        padding: 0.35rem;
    }
}

@media (max-width: 380px) {
    .container {
        padding: 1rem 0.4rem 2rem;
    }

    header h1 {
        font-size: 1.3rem;
        letter-spacing: 0.03em;
    }

    .subtitle {
        font-size: 0.75rem;
    }

    .logo-icon {
        font-size: 1.5rem;
    }

    .input-card {
        padding: 0.8rem;
        border-radius: 14px;
    }

    .input-card label {
        font-size: 0.7rem;
        margin-bottom: 0.5rem;
    }
}

/* ========== REDUCED MOTION ========== */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}