/* ============================================================
   main.css
   Platform shell styles and shared component styles.
   Taskbar styles live in taskbar.css.
   ============================================================ */

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

:root {
    --bg:           #0d1117;
    --surface:      #1a2332;
    --surface-2:    #222f42;
    --accent-gold:  #e8a020;
    --accent-blue:  #4aa8d8;
    --text:         #c8d4e0;
    --text-dim:     #6a7f94;
    --border:       #2a3a4a;
    --error:        #e05050;
    --success:      #50c878;
    --top-bar-h:    52px;
    --top-bar-slim-h: 34px;
}

html, body {
    height: 100%;
    margin: 0;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, sans-serif;
    font-size: 15px;
    line-height: 1.5;
}

input, textarea {
    cursor: text;
}

button, .icon-btn, [role="button"] {
    cursor: pointer;
}

.hidden {
    display: none !important;
}

/* --- Login screen ----------------------------------------- */
#login {
    position: fixed;
    inset: 0;
    background: var(--bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3rem;
    padding: 3rem 1rem 4rem;
    overflow-y: auto;
    z-index: 100;
}

/* --- Logo -------------------------------------------------- */
#logo-scene {
    perspective: 600px;
    width: 160px;
    height: 160px;
    flex-shrink: 0;
}

#logo {
    width: 160px;
    height: 160px;
    object-fit: contain;
    display: block;
    animation: logo-breathe 3s ease-in-out infinite;
    will-change: transform, filter;
}

@keyframes logo-breathe {
    0%, 100% { filter: drop-shadow(0 0 12px rgba(232, 160, 32, 0.4)); }
    50%       { filter: drop-shadow(0 0 28px rgba(232, 160, 32, 0.75)); }
}

@media (prefers-reduced-motion: reduce) {
    #logo { animation: none; filter: drop-shadow(0 0 16px rgba(232, 160, 32, 0.5)); }
}

/* --- Auth container --------------------------------------- */
#auth-container {
    width: 100%;
    max-width: 400px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: visible;
}

#auth-container h2 {
    font-size: 1.1rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-dim);
    text-align: center;
    padding: 1.75rem 2rem 0;
}

#auth-container form {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 1.5rem 2rem 2rem;
}

#auth-step-email,
#auth-step-password {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 100%;
}

/* --- Auth committed email --------------------------------- */
.auth-email-committed {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    width: 100%;
    padding: 0.6rem 1rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
}

.auth-email-committed span {
    font-size: 0.95rem;
    color: var(--text-dim);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    caret-color: transparent;
}

.auth-back-link {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 0.8rem;
    white-space: nowrap;
    flex-shrink: 0;
    transition: color 0.2s;
}

.auth-back-link:hover { color: var(--accent-blue); }

/* --- Password mismatch ------------------------------------ */
input.mismatch {
    border-color: var(--error);
}

input.mismatch:focus {
    border-color: var(--error);
}

/* --- Main dashboard --------------------------------------- */
#dashboard {
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* --- View frame ------------------------------------------- */
#view-frame {
    margin-top: var(--top-bar-slim-h);
    flex: 1;
    overflow-y: auto;
    transition: margin-top 0.22s ease;
}

/* Content follows the tray: sits under the slim handle when collapsed, slides
   down to meet the full bar when expanded (same 0.22s as the tray's height). */
#top-bar.expanded ~ #view-frame {
    margin-top: var(--top-bar-h);
}

/* --- Modal layer ------------------------------------------ */
#modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 1rem;
}

/* --- Form elements ---------------------------------------- */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    width: 100%;
}

.form-group label {
    font-size: 0.8rem;
    font-weight: 500;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text-dim);
}

.form-group input {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 0.95rem;
    padding: 0.75rem 1rem;
    outline: none;
    transition: border-color 0.2s;
    width: 100%;
}

.form-group input:focus {
    border-color: var(--accent-blue);
}

.form-error:empty,
.form-success:empty {
    display: none;
}

.form-error {
    font-size: 0.85rem;
    color: var(--error);
    width: 100%;
}

.form-success {
    font-size: 0.85rem;
    color: var(--success);
    width: 100%;
}

.submit-btn {
    padding: 0.65rem 1.4rem;
    background: var(--accent-gold);
    color: #0d1117;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    transition: opacity 0.2s;
    align-self: center;
}

.submit-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.submit-btn:hover  { opacity: 0.85; }
.submit-btn:active { opacity: 0.7; }

.danger-btn {
    background: var(--error);
    color: #fff;
}

/* --- Avatar (shared: account, friends, chat, profile) ----- */
.avatar {
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    vertical-align: middle;
}

.avatar-fallback {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 600;
    line-height: 1;
    flex-shrink: 0;
}

@media (max-width: 600px) {
    .submit-btn {
        align-self: stretch;
        text-align: center;
    }
}

/* --- Toasts (toastManager.js) ---------------------------------------- */
/* App-level ephemeral notifications, stacked bottom-right (bottom, full
   width on mobile). The container never blocks clicks; each toast does
   (click = dismiss). Sits above panels/menus (which top out around 200). */

#toast-container {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: none;
}

.toast {
    pointer-events: auto;
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent-gold);
    border-radius: 6px;
    padding: 0.6rem 0.9rem;
    font-size: 0.85rem;
    max-width: 320px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    cursor: pointer;
    opacity: 0;
    transform: translateY(0.5rem);
    transition: opacity 0.25s ease, transform 0.25s ease;
}
.toast:hover { border-color: var(--accent-blue); }
.toast.visible { opacity: 1; transform: translateY(0); }
.toast.leaving { opacity: 0; transform: translateY(0.5rem); }

@media (max-width: 600px) {
    #toast-container {
        left: 0.5rem;
        right: 0.5rem;
        bottom: 0.75rem;
        align-items: center;
    }
    .toast { max-width: 100%; }
}
