/*
Theme Name: Fluency Mode
Theme URI: https://fluencymode.com.br
Description: Premium dark theme for the Fluency Mode English learning platform.
Version: 1.0.3
Author: Fluency Mode Team
License: GPL-2.0-or-later
Text Domain: fluency-mode-theme
*/

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
}
body {
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
    background: #07091a;
    color: #edf0ff;
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

/* v1.0.2 — Force minimum 16px font-size on text inputs and textareas
 * to prevent iOS Safari's automatic zoom-on-focus behavior.
 *
 * The bug: iOS Safari zooms into any input or textarea whose computed
 * font-size is below 16px because the OS decides the text is "too small
 * to read" and "helpfully" magnifies the field. The result is that the
 * viewport jumps when a student touches a field — exactly the "balança
 * quando vai escrever" sensation Kawe described in writing exercises.
 *
 * The fix: Setting the font-size to 16px (the threshold) tells iOS that
 * the field is already large enough, so it doesn't intervene. This
 * works WITH the browser's behavior instead of trying to override it,
 * which is why it has zero side effects. The visual size of the field
 * is unchanged in practice because the plugin's existing inputs are
 * already styled with their own font-size — this rule only matters in
 * the rare case where an input has no explicit font-size or one below
 * 16px.
 *
 * This is the ONLY change in v1.0.2. A previous v1.0.2 attempt also
 * included viewport user-scalable=no, touch-action:manipulation, and
 * overscroll-behavior:none, but those were reverted because they were
 * either ineffective (iOS Safari ignores user-scalable=no) or caused
 * the duplo-scroll keyboard bug. This release is intentionally minimal
 * — one line of CSS, one bug fixed, zero side effects expected. */
@media (max-width: 768px) {
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="search"],
    input[type="tel"],
    input[type="url"],
    input[type="number"],
    textarea,
    select {
        font-size: 16px !important;
    }
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; height: auto; }

/* Kill WP / BuddyBoss default spacing in content area */
.fm-site-content article { margin: 0; padding: 0; }
.fm-site-content article > p:empty { display: none; }
.fm-site-content article > .fm-lib-root,
.fm-site-content article > .fm-dash-root,
.fm-site-content article > .fm-adapt-root,
.fm-site-content article > .fm-teacher-root,
.fm-site-content article > .fm-quiz-root { margin: 0; }

/* ═══════════════════════════════════════════
 * PREMIUM HEADER
 * ═══════════════════════════════════════════ */
.fm-header {
    position: sticky;
    top: 0;
    z-index: 99999;
    background: rgba(7,9,26,0.92);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(255,255,255,0.06);
}
/* Subtle glow line at bottom */
.fm-header::after {
    content: "";
    position: absolute;
    bottom: -1px;
    left: 10%;
    right: 10%;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(124,92,252,0.3) 30%, rgba(103,232,249,0.2) 70%, transparent);
    pointer-events: none;
}

.fm-header-inner {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 28px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

/* ── Logo ── */
.fm-header-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}
.fm-header-logo img {
    height: 28px;
    width: auto;
    display: block;
}
.fm-header-logo-text {
    font-family: 'Sora', sans-serif;
    font-size: 16px;
    font-weight: 700;
    color: #fff;
    white-space: nowrap;
}

/* ── Nav Tabs ── */
.fm-header-nav {
    display: flex;
    gap: 4px;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 14px;
    padding: 4px;
}
.fm-header-tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 500;
    color: #8b99c2;
    transition: all 0.2s;
    white-space: nowrap;
}
.fm-header-tab:hover {
    background: rgba(255,255,255,0.05);
    color: #edf0ff;
}
.fm-header-tab-active {
    background: rgba(124,92,252,0.15) !important;
    color: #c4b5fd !important;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(124,92,252,0.15);
}
.fm-header-tab-icon {
    font-size: 14px;
    line-height: 1;
}

/* ── User ── */
.fm-header-user {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}
/* v1.0.1 — User dropdown rules. Migrated from an inline <style> block
 * that lived in header.php after the <header> markup, which caused a
 * brief FOUC on every page load: the avatar/dropdown rendered with
 * browser defaults until the parser reached the inline <style> tag.
 * Moving these rules into style.css means they're parsed in <head>
 * before the <body> renders, eliminating the flash. */
.fm-user-wrap {
    position: relative;
    display: flex;
    align-items: center;
}
.fm-user-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    border-radius: 28px;
    transition: opacity .2s;
}
.fm-user-btn:hover { opacity: .85; }
.fm-user-name {
    font-family: "Outfit", sans-serif;
    font-size: 14px;
    font-weight: 500;
    color: #edf0ff;
}
.fm-user-pic {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.12);
    object-fit: cover;
}
.fm-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: 260px;
    background: rgba(10,14,32,0.98);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 16px;
    padding: 8px;
    box-shadow: 0 20px 48px rgba(0,0,0,0.55);
    z-index: 10000;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}
.fm-dropdown.open { display: block; }
.fm-dd-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 10px 10px;
}
.fm-dd-pic {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    flex-shrink: 0;
    object-fit: cover;
}
.fm-dd-name {
    font-family: "Sora", sans-serif;
    font-size: 14px;
    font-weight: 700;
    color: #edf0ff;
}
.fm-dd-email {
    font-size: 12px;
    color: #8b99c2;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 170px;
    white-space: nowrap;
}
.fm-dd-sep {
    height: 1px;
    background: rgba(255,255,255,0.06);
    margin: 6px 0;
}
.fm-dd-link {
    display: block;
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 14px;
    color: #edf0ff;
    text-decoration: none;
    font-family: "Outfit", sans-serif;
    transition: background .15s;
}
.fm-dd-link:hover { background: rgba(124,92,252,0.1); }
.fm-dd-teacher { color: #a78bfa; font-weight: 600; }
.fm-dd-teacher:hover { background: rgba(167,139,250,0.12); }
.fm-dd-logout { color: #ff6b6b; }
.fm-dd-logout:hover { background: rgba(255,107,107,0.08); }

.fm-header-login {
    font-size: 13px;
    font-weight: 600;
    color: #a78bfa;
    padding: 6px 16px;
    border-radius: 10px;
    border: 1px solid rgba(124,92,252,0.3);
    transition: all 0.2s;
}
.fm-header-login:hover {
    background: rgba(124,92,252,0.1);
}

/* ── Content ── */
.fm-site-content {
    width: 100%;
    max-width: 100vw;
    min-height: calc(100vh - 57px - 48px);
    overflow-x: hidden;
}
/* Prevent body horizontal scroll on all devices */
html, body { overflow-x: hidden; max-width: 100vw; }

/* All shortcode roots: prevent overflow + kill BuddyBoss margins */
.fm-lib-root, .fm-dash-root, .fm-teacher-root, .fm-adapt-root {
    overflow-x: hidden;
    max-width: 100vw;
}

/* ── Footer ── */
.fm-site-footer {
    text-align: center;
    padding: 16px 28px;
    font-size: 12px;
    color: #485070;
    border-top: 1px solid rgba(255,255,255,0.04);
}

/* ── WP admin bar fix ── */
body.admin-bar .fm-header { top: 32px; }
@media (max-width: 782px) {
    body.admin-bar .fm-header { top: 46px; }
}

/* ═══════════════════════════════════════════
 * MOBILE
 * ═══════════════════════════════════════════ */
@media (max-width: 768px) {
    .fm-header-inner {
        padding: 0 12px;
        height: 48px;
        gap: 8px;
    }
    .fm-header-logo img { height: 22px; }
    .fm-header-logo-text { font-size: 13px; }

    /* Compact nav pills */
    .fm-header-nav {
        padding: 3px;
        gap: 2px;
        border-radius: 12px;
    }
    .fm-header-tab {
        padding: 6px 12px;
        font-size: 11px;
        gap: 4px;
        border-radius: 9px;
    }
    .fm-header-tab-icon { font-size: 12px; }
    .fm-header-tab-label { display: none; }

    /* Show only icons on very small screens */
    .fm-user-name { display: none; }
    .fm-user-pic  { width: 32px; height: 32px; }
    .fm-header-login { padding: 5px 12px; font-size: 12px; }
}

/* On very small screens, show labels again but shorter */
@media (min-width: 480px) and (max-width: 768px) {
    .fm-header-tab-label { display: inline; }
}

/* ═══════════════════════════════════════════
 * NARROW MOBILE (≤420px) — iPhone 13 mini, SE,
 * iPhone 13/14/15 regular, and other ~375-430px
 * viewports. Without this pass, 5 nav tabs + logo
 * + avatar + gaps = ~370px which barely fits in
 * 375px, causing the user avatar to be silently
 * cropped by `body { overflow-x: hidden }`.
 *
 * Strategy: tighten padding, shrink icons/avatar,
 * reduce gaps. Every element stays visible and
 * functional, just more compact. Logo text is
 * hidden (the image logo is kept; only the text
 * fallback 🌐 FluencyMode is suppressed).
 * ═══════════════════════════════════════════ */
@media (max-width: 420px) {
    .fm-header-inner {
        padding: 0 8px;
        gap: 6px;
        height: 46px;
    }
    /* Logo: keep image, hide text fallback to save width */
    .fm-header-logo img { height: 20px; }
    .fm-header-logo-text { display: none; }

    /* Nav pills even tighter */
    .fm-header-nav {
        padding: 2px;
        gap: 1px;
        border-radius: 11px;
        flex-shrink: 1;
        min-width: 0;
    }
    .fm-header-tab {
        padding: 5px 9px;
        gap: 0;
        border-radius: 8px;
    }
    .fm-header-tab-icon { font-size: 14px; }

    /* Smaller avatar + tighter login button */
    .fm-user-btn { padding: 2px; }
    .fm-user-pic {
        width: 30px;
        height: 30px;
        border-width: 1.5px;
    }
    .fm-header-login {
        padding: 5px 10px;
        font-size: 11px;
    }
}

/* ═══════════════════════════════════════════
 * ULTRA-NARROW (≤360px) — iPhone SE 1st gen,
 * Galaxy Fold closed, older Android phones.
 * Last-resort compression. Everything still
 * functional but at minimum comfortable size.
 * ═══════════════════════════════════════════ */
@media (max-width: 360px) {
    .fm-header-inner {
        padding: 0 6px;
        gap: 4px;
    }
    .fm-header-logo img { height: 18px; }
    .fm-header-nav { padding: 2px; }
    .fm-header-tab { padding: 4px 7px; }
    .fm-header-tab-icon { font-size: 13px; }
    .fm-user-pic { width: 28px; height: 28px; }
}
