/* base.css - The Physics & Proportions */
:root { --sidebar-width: 300px; }

*, *::before, *::after { box-sizing: border-box; }

body, html {
    margin: 0; padding: 0;
    font-family: 'Inter', sans-serif;
    height: 100vh; width: 100vw;
    overflow: hidden;
}

/* --- IMMUTABLE AUTH OVERLAY --- */
#auth-overlay {
    position: fixed; inset: 0;
    background: radial-gradient(circle at center, #0a1221 0%, #050b18 100%);
    z-index: 3000; display: none; align-items: center; justify-content: center;
}
.auth-card {
    background: rgba(255, 255, 255, 0.03);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 30px; padding: 50px; width: 400px; text-align: center;
}
.auth-input {
    width: 100%; padding: 15px; margin-bottom: 15px; border-radius: 12px;
    background: rgba(0, 0, 0, 0.3); border: 1px solid #1e293b; color: white; outline: none;
}
.auth-btn {
    width: 100%; padding: 15px; border-radius: 12px;
    background: #008080; color: white; font-weight: 900; border: none; cursor: pointer; transition: 0.3s;
}
.auth-btn:hover { background: #ff007f; transform: scale(1.02); }
.auth-toggle { margin-top: 20px; font-size: 0.8rem; cursor: pointer; color: #008080; }

/* --- IMMUTABLE SPLASH SCREEN --- */
#splash-screen {
    position: fixed; inset: 0;
    --font-size: 10rem;
    --cap-height: 7.27rem;
    font-family: 'Inter', sans-serif;
    background: linear-gradient(135deg, #007c85 0%, #335c81 40%, #7d337d 75%, #d11c7a 100%);
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    z-index: 2000; text-align: center;
}

.word-container {
    display: flex;
    align-items: flex-end; /* Keeps I, F, and P bottoms flush */
    gap: 12px;
    opacity: 0;
    transform: scale(0.9);
}

.letter {
    font-size: var(--font-size);
    color: #fff;
    font-family: 'Inter', sans-serif;
    font-weight: 900;
    line-height: 0.73;
    margin: 0;
    padding: 0;
}

/* This container is the same height as the letters */
.i-column {
    position: relative;
    width: 2.2rem;
    height: var(--cap-height);
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
}

.globe-dot {
    position: absolute;
    width: 3.3rem;
    height: auto;
    top: 0;
    object-fit: contain;
    opacity: 0;
    z-index: 10;
}

.squash-i {
    display: block;
    font-size: var(--font-size);
    color: #fff;
    font-family: 'Inter', sans-serif;
    font-weight: 900;
    line-height: 0.73;
    transform-origin: bottom;
}

.zing-flare {
    position: absolute;
    top: 0;
    width: 4px;
    height: 4px;
    background: #fff;
    border-radius: 50%;
    opacity: 0;
}

#splash-actions {
    margin-top: 50px;
    opacity: 0;
    text-align: center;
    display: flex;
    gap: 20px;
    align-items: center;
}

#splash-screen.splash-animate .word-container {
    animation: mainZoom 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

#splash-screen.splash-animate .globe-dot {
    animation: gravityJiggle 1.4s linear forwards 0.9s;
}

#splash-screen.splash-animate .squash-i {
    animation: jiggleSquash 1.2s ease-out forwards 1.08s;
}

#splash-screen.splash-animate .zing-flare {
    animation: magicZing 0.4s ease-out forwards 1.08s;
}

#splash-screen.splash-animate #splash-actions {
    animation: fadeIn 0.5s ease-out forwards 2.5s;
}

#ui-splash-btn {
    padding: 25px 80px; font-size: 1.5rem; font-weight: 700; color: white;
    background: rgba(255, 255, 255, 0.1); border: 4px solid white; border-radius: 60px; cursor: pointer; transition: 0.3s;
}
#ui-splash-btn:hover { background: white; color: #ff007f; transform: scale(1.1); }
#ui-splash-lang-btn {
    padding: 12px 25px; font-size: 1rem; font-weight: 700; color: white;
    background: rgba(255, 255, 255, 0.05); border: 2px solid rgba(255, 255, 255, 0.5); border-radius: 40px; cursor: pointer;
}

/* --- APP SHELL PHYSICS --- */
#app-shell { height: 100vh; display: flex; flex-direction: column; }
header { height: 70px; display: flex; align-items: center; justify-content: space-between; padding: 0 30px; z-index: 10; }
#courses-staff-portal-btn {
    margin-left: 16px;
    padding: 6px 14px;
    border-radius: 10px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    text-decoration: none;
    white-space: nowrap;
    border: 1px solid var(--pink);
    color: var(--pink);
}
#courses-staff-portal-btn:hover,
#courses-staff-portal-btn:focus-visible {
    background: var(--pink);
    color: #fff;
    outline: none;
}
#ui-logout-btn { margin-left: 16px; }
#main-workspace { display: flex; flex: 1; overflow: hidden; position: relative; }
#nav-pane { width: var(--sidebar-width); display: flex; flex-direction: column; padding: 20px; }
#view-port { flex: 1; padding: 40px 80px; overflow-y: auto; transition: margin-right 0.5s cubic-bezier(0.19, 1, 0.22, 1); margin-right: 0; }
.fifi-open-layout #view-port { margin-right: 420px; }

/* Grid & Staggered Succession Physics */
.card-grid { display: flex; flex-wrap: wrap; gap: 20px; width: 100%; justify-content: center; }

.chunky-card, .cat-level, .cat-series, .cat-course {
    opacity: 0;
    animation: cardEntrance 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.chunky-card, .cat-series, .cat-course { flex: 1; min-width: 220px; max-width: 320px; height: 180px; padding: 25px; display: flex; flex-direction: column; justify-content: center; align-items: center; cursor: pointer; transition: 0.3s; text-align: center; }

.cat-level { flex: 1; min-width: 150px; max-width: 220px; height: 75vh !important; padding: 30px 15px !important; display: flex; flex-direction: column; align-items: center; justify-content: space-between; transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275); position: relative; overflow: hidden; }

/* Fixed Spine Layout for vertical alignment */
.spine-top { display: flex; flex-direction: column; height: 60px; justify-content: flex-start; }
.spine-mid { flex: 1; display: flex; align-items: center; justify-content: center; }
.spine-bottom { height: 40px; display: flex; align-items: center; justify-content: center; text-align: center; font-size: 0.7rem; font-weight: 700; max-width: 120px; line-height: 1.2; text-transform: uppercase; }
.spine-logo { height: 55px; display: flex; align-items: center; justify-content: center; }
.spine-logo img { object-fit: contain; }

.dynamic-group-label { width: 100%; font-size: 0.7rem; margin: 30px 0 10px 10px; text-transform: uppercase; letter-spacing: 2px; font-weight: 700; }

/* FIFI HUB PHYSICS */
#fifi-hub { position: fixed; bottom: 30px; right: 30px; width: 180px; height: 55px; z-index: 1000; transition: all 0.5s cubic-bezier(0.19, 1, 0.22, 1); display: flex; flex-direction: column; overflow: hidden; }
#fifi-hub.expanded { bottom: 0; right: 20px; width: 90vw; max-width: 400px; height: 65vh; }
#fifi-header { height: 55px; padding: 0 15px; display: none; align-items: center; justify-content: space-between; z-index: 100; position: relative; }
#fifi-hub.expanded #fifi-header { display: flex; }
#chat-log { flex: 1; padding: 15px; overflow-y: auto; display: none; flex-direction: column; gap: 8px; }
#fifi-hub.expanded #chat-log { display: flex; }
#speech-overlay { position: absolute; inset: 55px 0 0 0; display: none; flex-direction: column; align-items: center; justify-content: center; z-index: 10; }
#fifi-mouth-img { width: 80%; max-height: 40vh; object-fit: contain; }
#ui-fifi-tap-btn { width: 80%; padding: 15px; border: none; cursor: pointer; text-transform: uppercase; font-weight: 900; }
.pulse-ring { width: 60px; height: 60px; border-radius: 50%; animation: pulse 1.5s infinite; margin: 15px 0; border-width: 4px; border-style: solid; }

.msg { position: relative; padding: 12px 18px; max-width: 85%; word-wrap: break-word; line-height: 1.4; }
.session-break { display: flex; align-items: center; text-align: center; margin: 30px 0; width: 100%; }
.session-break::before, .session-break::after { content: ''; flex: 1; border-bottom: 1px solid; opacity: 0.1; }
.session-label { font-size: 0.65rem; text-transform: uppercase; letter-spacing: 1px; font-weight: 700; }
#history-loader { text-align: center; padding: 15px; font-size: 0.65rem; width: 100%; cursor: pointer; border-bottom: 1px solid; margin-bottom: 20px; text-transform: uppercase; letter-spacing: 1px; }

/* METRICS LOGIC (Full Restoration to Requested Physics) */
#metrics-tab { position: fixed; right: 0; top: 150px; width: 40px; height: 180px; cursor: pointer; z-index: 500; display: flex; align-items: center; justify-content: center; transition: width 0.4s cubic-bezier(0.19, 1, 0.22, 1); overflow: hidden; }
#metrics-tab.open { width: 300px; height: 350px; padding: 25px; }
.metrics-handle { writing-mode: vertical-rl; font-weight: 700; letter-spacing: 2px; }
#metrics-tab.open .metrics-handle { display: none; }
#metrics-content { display: none; width: 100%; height: 100%; flex-direction: column; }
#metrics-tab.open #metrics-content { display: flex; }

#metrics-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 15px;
    flex: 1;
    margin-top: 20px;
}
.metric-unit {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}
.metric-unit label { font-size: 0.7rem; font-weight: 900; margin-bottom: 5px; opacity: 0.8; }
.metric-num { font-size: 0.8rem; font-weight: 900; margin-top: 5px; }

/* TF Rail */
.rail-container { width: 100%; height: 12px; background: rgba(0,0,0,0.1); border-radius: 6px; overflow: hidden; }
.rail-fill { height: 100%; width: 0%; transition: width 1s ease-out; }

/* ER Pillar */
.pillar-container { width: 15px; height: 60px; background: rgba(0,0,0,0.1); border-radius: 4px; display: flex; align-items: flex-end; overflow: hidden; }
.pillar-fill { width: 100%; height: 0%; transition: height 1s ease-out; }

/* SVG Gauges */
.speedo-svg, .heart-svg { width: 60px; height: 60px; }
.speedo-bg { opacity: 0.1; stroke: currentColor; }
.speedo-fill { stroke: currentColor; transition: stroke-dashoffset 1s ease-out; stroke-linecap: round; }
.heart-outline { stroke: currentColor; opacity: 0.3; }
.heart-shape { transition: all 1s ease-out; }

/* ANIMATIONS */
@keyframes cardEntrance { from { opacity: 0; transform: translateY(40px) scale(0.95); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes mainZoom {
    0% { opacity: 0; transform: scale(0.7); filter: blur(10px); }
    100% { opacity: 1; transform: scale(1); filter: blur(0); }
}
@keyframes gravityJiggle {
    0%   { opacity: 0; transform: translateY(-150px); }
    5%   { opacity: 1; }
    12%  { opacity: 1; transform: translateY(0); }
    25%  { transform: translateY(-30px); }
    38%  { transform: translateY(0); }
    52%  { transform: translateY(-12px); }
    66%  { transform: translateY(0); }
    78%  { transform: translateY(-4px); }
    88%  { transform: translateY(0); }
    95%  { transform: translateY(-1px); }
    100% { opacity: 1; transform: translateY(0); }
}
@keyframes jiggleSquash {
    0%   { transform: scaleY(1); }
    8%   { transform: scaleY(0.4); }
    20%  { transform: scaleY(0.62); }
    35%  { transform: scaleY(0.46); }
    50%  { transform: scaleY(0.54); }
    65%  { transform: scaleY(0.49); }
    100% { transform: scaleY(0.5); }
}
@keyframes magicZing {
    0%   { opacity: 0; transform: scale(1); box-shadow: 0 0 0 #fff; }
    30%  { opacity: 1; transform: scale(2); box-shadow: 0 0 40px 20px #fff; }
    100% { opacity: 0; transform: scale(8); box-shadow: 0 0 80px 40px transparent; }
}
@keyframes fadeIn { to { opacity: 1; } }
@keyframes pulse { 0% { transform: scale(0.9); opacity: 1; } 100% { transform: scale(1.3); opacity: 0; } }
@media (max-width: 1000px) { .fifi-open-layout #view-port { margin-right: 0; } }
@media (max-width: 768px) {
    #splash-screen {
        --font-size: 5rem;
        --cap-height: 3.63rem;
    }

    .i-column {
        width: 1.1rem;
    }

    .globe-dot {
        width: 1.6rem;
    }
}

/* --- FIFI GENERAL AI OVERRIDE --- */
/* This ensures that when source is 'general', the bubble transforms */
.msg.fifi-msg.general-ai {
    background: rgba(240, 173, 78, 0.2) !important; /* Amber/Gold Transparent */
    border: 2px solid #f0ad4e !important;           /* Solid Amber Border */
    color: #f0ad4e !important;                      /* Amber Text */
    box-shadow: 0 0 15px rgba(240, 173, 78, 0.4) !important; /* Gold Glow */
    backdrop-filter: blur(10px);
}

/* --- LANGUAGE MENU DESIGN (TOP LAYER BREAK-OUT) --- */
.lang-mega-menu {
    display: none;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    position: fixed; /* Fixed to viewport to break out of all parent containers */
    width: 280px;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    padding: 15px;
    z-index: 9999; /* Highest priority layer */
    box-shadow: 0 20px 50px rgba(0,0,0,0.6);
}

/* Centered positioning for Splash Screen */
#splash-lang-grid {
    bottom: 120px;
    left: 50%;
    transform: translateX(-50%);
}

/* Relative fixed positioning for Main Workspace Sidebar */
#lang-grid {
    top: 130px;
    left: 20px;
}

.lang-mega-menu span {
    color: white;
    font-size: 0.85rem;
    padding: 8px 12px;
    cursor: pointer;
    border-radius: 10px;
    transition: 0.2s;
    text-align: left;
}

.lang-mega-menu span:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #ff007f; 
}

/* Specific positioning for Splash Button container */
#splash-actions > div {
    position: relative;
}