/* ========================================
   ibanabattuta - Etymology Journey
   ======================================== */

:root {
    --bg-primary: #ACD8C9;
    --bg-secondary: #97C8B9;
    --text-primary: #000000;
    --text-secondary: rgba(0, 0, 0, 0.6);
    --text-muted: rgba(0, 0, 0, 0.4);
    --white: #ffffff;
    --black: #000000;
    --error: #dc3545;
    --shadow: 4px 4px 0px 0px rgba(0, 0, 0, 1);
    --shadow-sm: 2px 2px 0px 0px rgba(0, 0, 0, 1);
    --border: 1px solid #000000;
    --font-mono: 'IBM Plex Mono', monospace;
    --font-display: 'Doto', sans-serif;
}

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

html,
body {
    width: 100%;
    height: 100%;
    overflow: hidden;
}

body {
    font-family: var(--font-mono);
    background-color: var(--bg-primary);
    color: var(--text-primary);
}

/* ========================================
   Screen Management
   ======================================== */

.screen {
    display: none;
    width: 100%;
    height: 100%;
}

.screen.active {
    display: flex;
}

/* ========================================
   Password Gate
   ======================================== */

#password-gate {
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
}

.gate-container {
    text-align: center;
    padding: 3rem;
}

.gate-logo,
.signin-logo {
    width: 180px;
    height: 180px;
    object-fit: contain;
    border: 3px solid var(--black);
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
    background: var(--white);
}

.brand-name {
    font-family: var(--font-display);
    font-size: 3rem;
    font-weight: 900;
    letter-spacing: -0.02em;
    margin-bottom: 0.5rem;
    text-transform: lowercase;
}

.tagline {
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--text-secondary);
    background: var(--black);
    color: var(--white);
    padding: 0.25rem 0.75rem;
    display: inline-block;
}

.password-form {
    margin-top: 2.5rem;
}

.input-group {
    display: flex;
    gap: 0.5rem;
    max-width: 400px;
    margin: 0 auto;
}

.input-group input {
    flex: 1;
    padding: 0.75rem 1rem;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border: var(--border);
    background: rgba(255, 255, 255, 0.4);
    outline: none;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s;
}

.input-group input:focus {
    background: var(--white);
}

.input-group input::placeholder {
    color: var(--text-secondary);
}

.btn-primary {
    padding: 0.75rem 1.5rem;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    background: var(--black);
    color: var(--white);
    border: var(--border);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary:hover {
    background: #333;
}

.btn-primary:active {
    transform: translate(2px, 2px);
    box-shadow: none;
}

.error-message {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--error);
    margin-top: 1rem;
    height: 1em;
}

/* ========================================
   Google Sign-In Screen
   ======================================== */

#signin-screen {
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
}

.signin-container {
    text-align: center;
    padding: 3rem;
}

.google-signin-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    width: 100%;
    max-width: 300px;
    margin: 2rem auto 0;
    padding: 0.875rem 1.5rem;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    font-weight: 600;
    background: var(--white);
    border: var(--border);
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: all 0.2s;
}

.google-signin-btn:hover {
    background: #f5f5f5;
}

.google-signin-btn:active {
    transform: translate(4px, 4px);
    box-shadow: none;
}

.google-icon {
    width: 20px;
    height: 20px;
}

.signin-note {
    font-size: 0.65rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-top: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ========================================
   Main Application
   ======================================== */

#main-app {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 100vh;
}

/* Header */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 2rem;
    background: var(--bg-primary);
    border-bottom: var(--border);
    gap: 2rem;
    flex-shrink: 0;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
}

.logo-wrapper {
    width: 40px;
    height: 40px;
    background: var(--black);
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-logo {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.brand-info {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.header-title {
    font-family: var(--font-display);
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.header-subtitle {
    font-size: 0.55rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    background: var(--black);
    color: var(--white);
    padding: 0.125rem 0.5rem;
    width: fit-content;
}

/* Search */
.search-container {
    flex: 1;
    max-width: 600px;
}

.search-form {
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 0.75rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
}

#search-input {
    flex: 1;
    padding: 0.625rem 4rem 0.625rem 2.5rem;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    border: var(--border);
    background: rgba(255, 255, 255, 0.4);
    box-shadow: var(--shadow-sm);
    outline: none;
    transition: all 0.2s;
}

#search-input:focus {
    background: var(--white);
}

#search-input::placeholder {
    color: var(--text-secondary);
}

.btn-search {
    position: absolute;
    right: 4px;
    padding: 0.375rem 0.75rem;
    font-family: var(--font-mono);
    font-size: 0.6rem;
    font-weight: 700;
    background: var(--black);
    color: var(--white);
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-search:hover {
    background: #333;
}

.suggestions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
    overflow-x: auto;
    padding-bottom: 0.25rem;
}

.suggestions::-webkit-scrollbar {
    display: none;
}

.suggestions-label {
    font-size: 0.55rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-secondary);
    white-space: nowrap;
}

.suggestion-btn {
    font-family: var(--font-mono);
    font-size: 0.55rem;
    font-weight: 700;
    text-transform: uppercase;
    padding: 0.25rem 0.5rem;
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(0, 0, 0, 0.1);
    color: var(--text-secondary);
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
}

.suggestion-btn:hover {
    border-color: var(--black);
    color: var(--text-primary);
}

/* Header Right */
.header-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
}

.icon-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: var(--border);
    cursor: pointer;
    transition: all 0.2s;
}

.icon-btn:hover {
    background: var(--black);
    color: var(--white);
}

.user-menu {
    position: relative;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border: var(--border);
    cursor: pointer;
    object-fit: cover;
}

.user-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    background: var(--white);
    border: var(--border);
    box-shadow: var(--shadow);
    min-width: 150px;
    z-index: 100;
}

.user-dropdown.active {
    display: block;
}

.user-name {
    display: block;
    padding: 0.75rem;
    font-size: 0.7rem;
    font-weight: 600;
}

.user-dropdown hr {
    border: none;
    border-top: var(--border);
}

.dropdown-btn {
    display: block;
    width: 100%;
    padding: 0.75rem;
    font-family: var(--font-mono);
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    text-align: left;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}

.dropdown-btn:hover {
    background: var(--black);
    color: var(--white);
}

/* ========================================
   Main Content Area
   ======================================== */

.app-main {
    flex: 1;
    position: relative;
    overflow: hidden;
    min-height: 0;
}

/* Map Container */
.map-container {
    width: 100%;
    height: 100%;
    background: var(--bg-primary);
    position: relative;
}

#world-map {
    width: 100%;
    height: 100%;
    cursor: grab;
}

#world-map:active {
    cursor: grabbing;
}

/* Loading Overlay */
.loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(172, 216, 201, 0.4);
    backdrop-filter: blur(4px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 40;
}

.loading-overlay.hidden {
    display: none;
}

.loading-box {
    width: 80px;
    height: 80px;
    background: var(--black);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: pulse 2s infinite;
}

.loading-box svg {
    color: var(--white);
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

.loading-message {
    margin-top: 1.5rem;
    padding: 0.75rem 1.5rem;
    background: var(--white);
    border: var(--border);
    box-shadow: var(--shadow);
    font-size: 0.7rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: -0.02em;
}

/* Empty State */
.empty-state {
    position: absolute;
    bottom: 5rem;
    left: 2rem;
    pointer-events: none;
}

.empty-content {
    max-width: 280px;
}

.empty-text {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    line-height: 1.4;
    padding-left: 1rem;
    border-left: 4px solid var(--black);
    margin-bottom: 1rem;
}

.legend {
    display: flex;
    gap: 1rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.25rem 0.5rem;
    background: rgba(255, 255, 255, 0.5);
    border: var(--border);
}

.legend-box {
    width: 8px;
    height: 8px;
}

.legend-box.filled {
    background: var(--black);
}

.legend-box.outline {
    border: var(--border);
    background: transparent;
}

.legend-item span:last-child {
    font-size: 0.55rem;
    font-weight: 900;
    text-transform: uppercase;
}

/* Playback Controls */
.playback-controls {
    position: absolute;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    z-index: 20;
}

.playback-controls.hidden {
    display: none;
}

.controls-bar {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.5rem;
    background: rgba(255, 255, 255, 0.9);
    border: var(--border);
    box-shadow: var(--shadow);
}

.control-btn {
    padding: 0.375rem;
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.control-btn:hover {
    background: var(--black);
    color: var(--white);
}

.control-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.control-btn:disabled:hover {
    background: transparent;
    color: inherit;
}

.play-btn {
    padding: 0.5rem;
    background: var(--black);
    color: var(--white);
}

.play-btn:hover {
    background: #333;
}

.speed-controls {
    display: flex;
    gap: 0.25rem;
    padding-left: 0.75rem;
    border-left: 1px solid rgba(0, 0, 0, 0.2);
}

.speed-btn {
    padding: 0.25rem 0.5rem;
    font-family: var(--font-mono);
    font-size: 0.55rem;
    font-weight: 900;
    background: transparent;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
}

.speed-btn:hover {
    border-color: var(--black);
}

.speed-btn.active {
    background: var(--black);
    color: var(--white);
    border-color: var(--black);
}

.progress-bar {
    width: 256px;
    height: 4px;
    background: var(--white);
    border: var(--border);
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--black);
    width: 0%;
    transition: width 0.3s;
}

/* ========================================
   Info Panel
   ======================================== */

.info-panel {
    position: absolute;
    right: 0;
    top: 0;
    height: 100%;
    width: 400px;
    max-width: 100%;
    background: rgba(172, 216, 201, 0.95);
    border-left: var(--border);
    backdrop-filter: blur(20px);
    z-index: 30;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.3s ease;
}

.info-panel.active {
    transform: translateX(0);
}

.info-panel.hidden {
    display: none;
}

.panel-header {
    padding: 1.5rem;
    border-bottom: var(--border);
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.panel-word {
    font-family: var(--font-display);
    font-size: 2rem;
    font-weight: 700;
    text-transform: capitalize;
    margin-bottom: 0.25rem;
}

.panel-meaning {
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.panel-close {
    padding: 0.25rem;
    background: transparent;
    border: var(--border);
    cursor: pointer;
    transition: all 0.2s;
}

.panel-close:hover {
    background: var(--black);
    color: var(--white);
}

.panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}

.panel-content::-webkit-scrollbar {
    width: 6px;
}

.panel-content::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

.panel-content::-webkit-scrollbar-thumb {
    background: var(--black);
}

.panel-section {
    margin-bottom: 2rem;
}

.section-label {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    background: var(--black);
    color: var(--white);
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    margin-bottom: 1rem;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.route-badge {
    font-size: 0.55rem;
    font-weight: 900;
    text-transform: uppercase;
    padding: 0.25rem 0.5rem;
    border: var(--border);
    letter-spacing: -0.02em;
}

.origin-box {
    padding: 1rem;
    border: var(--border);
    background: rgba(255, 255, 255, 0.2);
}

.origin-word {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 700;
}

.origin-meta {
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.origin-meaning {
    font-size: 0.7rem;
    padding-top: 0.5rem;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    margin-top: 0.5rem;
}

.origin-location {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-top: 0.75rem;
}

.narrative-text {
    font-size: 0.7rem;
    line-height: 1.6;
    padding: 1rem;
    border: var(--border);
    background: rgba(0, 0, 0, 0.05);
}

/* Journey Timeline */
.journey-timeline {
    position: relative;
    padding-left: 1.5rem;
}

.journey-timeline::before {
    content: '';
    position: absolute;
    left: 3px;
    top: 0.5rem;
    bottom: 0.5rem;
    width: 1px;
    background: var(--black);
}

.journey-step {
    position: relative;
    margin-bottom: 1.5rem;
    transition: opacity 0.3s;
}

.journey-step.inactive {
    opacity: 0.2;
}

.journey-step::before {
    content: '';
    position: absolute;
    left: -27px;
    top: 0.25rem;
    width: 8px;
    height: 8px;
    border: var(--border);
    background: transparent;
    transition: background 0.3s;
}

.journey-step.active::before {
    background: var(--black);
}

.journey-step.current {
    opacity: 1;
}

.journey-step.current::before {
    background: var(--black);
}

.step-content {
    padding: 1rem;
    border: 1px solid rgba(0, 0, 0, 0.2);
    transition: all 0.3s;
}

.journey-step.current .step-content {
    background: var(--white);
    border-color: var(--black);
    box-shadow: var(--shadow);
}

.step-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.25rem;
}

.step-word {
    font-family: var(--font-display);
    font-size: 1.125rem;
    font-weight: 700;
}

.step-meta {
    font-size: 0.55rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.step-pronunciation {
    font-size: 0.6rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.step-notes {
    font-size: 0.6rem;
    line-height: 1.5;
    color: var(--text-secondary);
}

/* Fun Fact */
.fun-fact {
    padding: 1rem;
    border: 1px dashed var(--black);
}

.fun-fact.hidden {
    display: none;
}

.fun-fact-label {
    font-size: 0.55rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 0.25rem;
}

.fun-fact-text {
    font-size: 0.65rem;
    font-style: italic;
    color: var(--text-secondary);
}

/* ========================================
   History Panel
   ======================================== */

.history-panel {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 320px;
    max-width: 100%;
    background: rgba(172, 216, 201, 0.95);
    border-right: var(--border);
    backdrop-filter: blur(20px);
    z-index: 30;
    display: flex;
    flex-direction: column;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
}

.history-panel.active {
    transform: translateX(0);
}

.history-panel.hidden {
    display: none;
}

.history-header {
    padding: 1rem 1.25rem;
    border-bottom: var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.history-header h3 {
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
}

.history-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.text-btn {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-secondary);
    background: transparent;
    border: none;
    cursor: pointer;
    transition: color 0.2s;
}

.text-btn:hover {
    color: var(--error);
}

.history-list {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

.history-empty {
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-align: center;
    padding: 2rem;
}

.history-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    background: rgba(255, 255, 255, 0.3);
    border: 1px solid rgba(0, 0, 0, 0.1);
    cursor: pointer;
    transition: all 0.2s;
}

.history-item:hover {
    background: var(--white);
    border-color: var(--black);
}

.history-item-info {
    flex: 1;
    min-width: 0;
}

.history-item-word {
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: capitalize;
    margin-bottom: 0.125rem;
}

.history-item-date {
    font-size: 0.55rem;
    color: var(--text-muted);
}

.history-item-delete {
    padding: 0.25rem;
    background: transparent;
    border: none;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s;
    color: var(--text-muted);
}

.history-item:hover .history-item-delete {
    opacity: 1;
}

.history-item-delete:hover {
    color: var(--error);
}

/* ========================================
   Utilities
   ======================================== */

.hidden {
    display: none !important;
}

/* ========================================
   Responsive
   ======================================== */

@media (max-width: 768px) {
    .app-header {
        flex-wrap: wrap;
        padding: 1rem;
        gap: 1rem;
    }

    .header-left {
        order: 1;
    }

    .header-right {
        order: 2;
    }

    .search-container {
        order: 3;
        width: 100%;
        max-width: none;
    }

    .brand-info {
        display: none;
    }

    .info-panel,
    .history-panel {
        width: 100%;
    }

    .gate-logo,
    .signin-logo {
        width: 120px;
        height: 120px;
    }

    .brand-name {
        font-size: 2rem;
    }

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

    .input-group input,
    .btn-primary {
        width: 100%;
    }

    .playback-controls {
        bottom: 1rem;
        left: 1rem;
        right: 1rem;
        transform: none;
    }

    .controls-bar {
        width: 100%;
        justify-content: center;
    }

    .progress-bar {
        width: 100%;
    }

    .empty-state {
        display: none;
    }
}