/* ── Persona sidebar (PoC mock) ─────────────────────────────────────────
   Slide-in left rail showing the 4-persona V1 cast (Carlos, Anna, Mei,
   Yuki) with per-persona minute quotas + a tier card. Mock data only —
   no backend wiring yet. Visual proof-of-concept for the multi-tutor
   differentiation surface and the at-cost metered overage strategy. */

:root {
    --sidebar-width: 360px;
}

/* Toggle button lives in the app header */
.tutors-toggle {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--ink-soft);
    font-family: var(--sans);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.04em;
    padding: 7px 14px 7px 10px;
    border-radius: 999px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: background 160ms ease, border-color 160ms ease, color 160ms ease;
}
.tutors-toggle:hover {
    background: var(--surface-2);
    border-color: var(--border-strong);
    color: var(--ink);
}
.tutors-toggle .dots {
    display: inline-grid;
    grid-template-columns: 1fr 1fr;
    grid-gap: 2px;
    width: 14px;
    height: 14px;
}
.tutors-toggle .dots span {
    display: block;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--accent);
    opacity: 0.8;
}

/* Backdrop */
.persona-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(45, 26, 16, 0.32);
    backdrop-filter: blur(2px);
    z-index: 90;
    opacity: 0;
    pointer-events: none;
    transition: opacity 220ms ease;
}
.persona-backdrop.open {
    opacity: 1;
    pointer-events: auto;
}

/* Sidebar
   The whole sidebar is the scroll container — header, language row,
   persona list, gem progression, and tier card all scroll together as a
   single window. (Previously only the .persona-list scrolled, which
   pinned the gem + tier blocks at the bottom and made the persona
   section feel cramped.) The header is sticky so the close button stays
   reachable during scroll. */
.persona-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--surface-2);
    border-right: 1px solid var(--border);
    box-shadow: 4px 0 24px rgba(45, 26, 16, 0.12);
    z-index: 100;
    transform: translateX(calc(-1 * var(--sidebar-width) - 32px));
    transition: transform 280ms cubic-bezier(0.22, 1, 0.36, 1);
    display: flex;
    flex-direction: column;
    font-family: var(--sans);
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
}
.persona-sidebar.open {
    transform: translateX(0);
}

.persona-sidebar header.sidebar-head {
    padding: 22px 24px 14px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 5;
}
.persona-sidebar .sidebar-title {
    font-family: var(--serif);
    font-size: 22px;
    font-weight: 600;
    letter-spacing: -0.015em;
    color: var(--ink);
    margin: 0;
}
.persona-sidebar .sidebar-sub {
    font-family: var(--serif);
    font-style: italic;
    font-size: 12px;
    color: var(--muted);
    margin: 2px 0 0;
}
.persona-sidebar .close-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--muted);
    font-size: 22px;
    line-height: 1;
    padding: 4px 8px;
    border-radius: 6px;
}
.persona-sidebar .close-btn:hover {
    background: var(--surface-2);
    color: var(--ink);
}

/* ── Language row (dropdown selector) ─────────────────────────────── */
.lang-row {
    padding: 12px 18px 10px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}
.lang-row-label {
    font-family: var(--sans);
    font-size: 11px;
    color: var(--muted);
    font-style: italic;
    margin: 0 0 8px;
    letter-spacing: 0.01em;
    text-align: right;
}
.lang-row-count { color: var(--muted); }

.lang-dropdown {
    position: relative;
    transition: transform 200ms ease;
}
.lang-dropdown.pulse {
    animation: lang-dropdown-pulse 700ms ease;
}
@keyframes lang-dropdown-pulse {
    0%   { transform: scale(1);     box-shadow: 0 0 0 0 var(--accent-soft); }
    35%  { transform: scale(1.025); box-shadow: 0 0 0 6px var(--accent-subtle); }
    100% { transform: scale(1);     box-shadow: 0 0 0 0 var(--accent-soft); }
}

.lang-trigger {
    width: 100%;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 14px 11px;
    font-family: var(--sans);
    cursor: pointer;
    display: flex;
    align-items: baseline;
    gap: 10px;
    transition: background 140ms ease, border-color 140ms ease;
}
.lang-trigger:hover {
    background: var(--surface);
    border-color: var(--border-strong);
}
.lang-trigger-eyebrow {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--muted);
    flex-shrink: 0;
}
.lang-trigger-name {
    font-family: var(--serif);
    font-size: 16px;
    font-weight: 600;
    color: var(--ink);
    flex: 1 1 auto;
    text-align: left;
    letter-spacing: -0.005em;
}
.lang-trigger-caret {
    font-size: 12px;
    color: var(--ink-soft);
    transition: transform 180ms ease;
}
.lang-dropdown.open .lang-trigger {
    border-color: var(--accent);
    background: var(--surface);
}
.lang-dropdown.open .lang-trigger-caret {
    transform: rotate(180deg);
}

.lang-menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: 12px;
    box-shadow: 0 12px 28px rgba(45, 26, 16, 0.18);
    padding: 6px;
    z-index: 110;
    opacity: 0;
    transform: translateY(-4px);
    pointer-events: none;
    transition: opacity 180ms ease, transform 180ms ease;
}
.lang-dropdown.open .lang-menu {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.lang-option {
    width: 100%;
    background: transparent;
    border: none;
    border-radius: 8px;
    padding: 9px 12px;
    font-family: var(--sans);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    color: var(--ink);
    text-align: left;
    transition: background 120ms ease;
}
.lang-option:hover {
    background: var(--surface-2);
}
.lang-option.active {
    background: var(--accent-subtle);
    color: var(--accent-deep);
}
.lang-option-name {
    font-family: var(--serif);
    font-size: 15px;
    font-weight: 500;
    letter-spacing: -0.005em;
}
.lang-option.active .lang-option-name {
    font-weight: 700;
}
.lang-option-count {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    background: var(--surface-2);
    border: 1px solid var(--border);
    padding: 2px 7px;
    border-radius: 4px;
    flex-shrink: 0;
}
.lang-option.active .lang-option-count {
    color: var(--accent-deep);
    background: var(--surface);
    border-color: var(--accent-soft);
}
.lang-option-check {
    font-size: 13px;
    font-weight: 700;
    color: var(--accent);
    margin-left: -4px;
}
.lang-menu-foot {
    padding: 8px 12px 4px;
    margin-top: 4px;
    border-top: 1px solid var(--border);
    font-family: var(--sans);
    font-size: 10.5px;
    font-style: italic;
    color: var(--muted);
    line-height: 1.5;
}

.persona-list {
    /* No internal scroll — height is intrinsic to the cards rendered.
       Sidebar-level scroll handles overflow when gem + tier blocks push
       content past viewport. Tutors for the active language sit at the
       top of the scrollable area, directly below the language picker. */
    flex: 0 0 auto;
    padding: 14px 14px 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.persona-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 14px 16px;
    cursor: pointer;
    transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
    position: relative;
}
.persona-card:hover {
    border-color: var(--border-strong);
    box-shadow: 0 4px 14px rgba(45, 26, 16, 0.08);
    transform: translateY(-1px);
}
.persona-card.active {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-subtle), 0 4px 14px rgba(107, 63, 160, 0.14);
}
.persona-card.active::after {
    content: "Active";
    position: absolute;
    top: 12px;
    right: 14px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--accent-deep);
    background: var(--accent-subtle);
    border: 1px solid var(--accent-soft);
    padding: 2px 8px;
    border-radius: 999px;
}

/* Locked persona card — visible but inert. The lock icon + helper note
   point at the language switcher as the only unlock action. */
.persona-card.locked {
    cursor: default;
    background: var(--surface-2);
    opacity: 0.78;
}
.persona-card.locked:hover {
    transform: none;
    box-shadow: none;
    border-color: var(--border);
}
.persona-card.locked .persona-avatar {
    filter: grayscale(0.6);
    opacity: 0.7;
}
.persona-card.locked .persona-name,
.persona-card.locked .persona-tagline {
    color: var(--muted);
}
.persona-card.locked .persona-stack {
    opacity: 0.6;
}
.persona-card .lock-icon {
    font-size: 14px;
    color: var(--muted);
    flex-shrink: 0;
    margin-left: 4px;
    align-self: flex-start;
}
.persona-card .locked-note {
    margin: 8px 0 0;
    font-family: var(--serif);
    font-style: italic;
    font-size: 12px;
    line-height: 1.45;
    color: var(--muted);
}
.persona-card .locked-note strong {
    color: var(--ink-soft);
    font-style: normal;
    font-weight: 700;
}

.persona-row-1 {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}
.persona-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    /* Initial letter (M/Y/C/A) stays in the markup for fallback /
       debug-via-source, but is visually hidden since the portrait + the
       per-persona gradient now carry the recognition load. */
    font-family: var(--serif);
    font-size: 18px;
    font-weight: 600;
    color: transparent;
    flex-shrink: 0;
    border: 1.5px solid rgba(255, 255, 255, 0.6);
    box-shadow: 0 1px 4px rgba(45, 26, 16, 0.16);
    /* Portrait + gradient stacking. background-size/position/repeat set
       once on the base class; per-persona rules below stack the portrait
       PNG on top of the gradient. If the PNG ever 404s the gradient
       still renders, so the circle never goes blank. */
    background-size: cover;
    background-position: center 22%;
    background-repeat: no-repeat;
}
/* Avatars use the DALL-E portraits in /static/tutors/<id>.png as the top
   layer with the persona's signature gradient as a fallback below. The
   gradients are pulled from each portrait so the circle still reads as
   that tutor even if the PNG fails to load. Regenerate via
   `python scripts/generate_tutor_portraits.py` if styling shifts. */
.persona-avatar.mei {
    background-image: url("/static/tutors/mei.png"),
                      linear-gradient(135deg, #B89DC9, #6E4F8C);
}
.persona-avatar.yuki {
    background-image: url("/static/tutors/yuki.png"),
                      linear-gradient(135deg, #C36E3A, #2F4A36);
}
.persona-avatar.carlos {
    background-image: url("/static/tutors/carlos.png"),
                      linear-gradient(135deg, #D4905A, #7A3F1F);
}
.persona-avatar.anna {
    background-image: url("/static/tutors/anna.png"),
                      linear-gradient(135deg, #7A99B8, #2C3E5A);
}

.persona-meta {
    flex: 1 1 auto;
    min-width: 0;
}
.persona-name {
    font-family: var(--serif);
    font-size: 17px;
    font-weight: 600;
    color: var(--ink);
    margin: 0;
    line-height: 1.2;
}
.persona-tagline {
    font-size: 11px;
    color: var(--muted);
    margin: 1px 0 0;
    letter-spacing: 0.02em;
}

.persona-stack {
    font-family: var(--sans);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
    background: var(--surface-2);
    border: 1px solid var(--border);
    padding: 2px 7px;
    border-radius: 4px;
    display: inline-block;
    margin-bottom: 8px;
}
.persona-stack.premium {
    color: var(--accent-deep);
    background: var(--accent-subtle);
    border-color: var(--accent-soft);
}

.persona-quota {
    margin-bottom: 10px;
}
.quota-foot {
    margin: 5px 0 0;
    font-family: var(--sans);
    font-size: 10px;
    font-style: italic;
    color: var(--muted);
    letter-spacing: 0.01em;
    line-height: 1.5;
}
.add-time-link {
    color: var(--accent-deep);
    text-decoration: none;
    font-style: normal;
    font-weight: 600;
    border-bottom: 1px dotted var(--accent-soft);
    transition: color 140ms ease, border-color 140ms ease;
    white-space: nowrap;
}
.add-time-link:hover {
    color: var(--ink);
    border-bottom-color: var(--ink-soft);
}
.quota-label-row {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--ink-soft);
    margin-bottom: 4px;
    font-variant-numeric: tabular-nums;
}
.quota-label-row .used {
    font-weight: 600;
    color: var(--ink);
}
.quota-bar {
    height: 5px;
    background: var(--surface-2);
    border-radius: 3px;
    overflow: hidden;
    border: 1px solid var(--border);
}
.quota-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--accent-deep));
    border-radius: 3px 0 0 3px;
    transition: width 240ms ease;
}
.quota-fill.warn {
    background: linear-gradient(90deg, #C9A578, #7A3A1C);
}

.persona-actions {
    display: flex;
    gap: 8px;
}
.persona-action {
    flex: 1;
    text-align: center;
    font-family: var(--sans);
    font-size: 12px;
    font-weight: 600;
    padding: 7px 0;
    border-radius: 8px;
    text-decoration: none;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--ink);
    cursor: pointer;
    transition: background 140ms ease, border-color 140ms ease;
}
.persona-action:hover {
    background: var(--surface-2);
    border-color: var(--border-strong);
}
.persona-action.primary {
    background: var(--ink);
    color: var(--surface);
    border-color: var(--ink);
}
.persona-action.primary:hover {
    background: var(--accent-deep);
    border-color: var(--accent-deep);
}

/* Tier card pinned at the bottom */
.tier-card {
    margin: 14px 14px 18px;
    padding: 16px 18px 14px;
    background: linear-gradient(180deg, var(--accent-subtle), var(--surface));
    border: 1px solid var(--accent-soft);
    border-radius: 14px;
}
.tier-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}
.tier-name {
    font-family: var(--serif);
    font-size: 15px;
    font-weight: 600;
    color: var(--ink);
    margin: 0;
}
.tier-name .tier-icon {
    color: var(--accent);
    margin-right: 5px;
}
.tier-price {
    font-family: var(--sans);
    font-size: 13px;
    font-weight: 600;
    color: var(--accent-deep);
}

.tier-pool {
    margin-bottom: 9px;
}
.tier-pool:last-of-type {
    margin-bottom: 14px;
}
.pool-row {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    margin-bottom: 4px;
    color: var(--ink-soft);
    font-variant-numeric: tabular-nums;
}
.pool-row .pool-name {
    font-weight: 600;
    color: var(--ink);
}
.pool-bar {
    height: 5px;
    background: var(--surface-2);
    border-radius: 3px;
    overflow: hidden;
    border: 1px solid var(--border);
}
.pool-fill {
    height: 100%;
    border-radius: 3px 0 0 3px;
}
/* Pool fill colors. premium-tutor follows the gem accent (so it
   shifts with the user's level — emerald/sapphire/ruby palettes all
   inherit). standard-tutor stays a warm amber so the two tiers read
   as distinct categories regardless of gem level. Chat is a calm
   teal-green for separation from the tutor-minute pools. */
.pool-fill.premium-tutor  { background: linear-gradient(90deg, var(--accent), var(--accent-deep)); }
.pool-fill.standard-tutor { background: linear-gradient(90deg, #E0A050, #7A3A1C); }
.pool-fill.chat           { background: linear-gradient(90deg, #6FB29E, #0E5A48); }
/* Legacy aliases retained for any older markup still referencing
   these class names. */
.pool-fill.realtime { background: linear-gradient(90deg, var(--accent), var(--accent-deep)); }
.pool-fill.composed { background: linear-gradient(90deg, #E0A050, #7A3A1C); }
.pool-fill.tutor    { background: linear-gradient(90deg, var(--accent), var(--accent-deep)); }

.tier-overage {
    font-size: 11px;
    color: var(--muted);
    font-style: italic;
    margin: 4px 0 12px;
    line-height: 1.4;
}
.tier-overage strong {
    color: var(--ink-soft);
    font-style: normal;
}

/* Buy-extra-time block — reads as an upgrade affordance, not a
   penalty. Sits between the pool bars and the manage-subscription
   CTA, lightly framed so it feels offered, not warning. */
.extra-time {
    margin: 14px 0 12px;
    padding: 12px 14px 10px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 10px;
}
.extra-time-head {
    font-family: var(--serif);
    font-size: 14px;
    font-weight: 600;
    color: var(--ink);
    margin: 0 0 4px;
    letter-spacing: -0.005em;
}
.extra-time-body {
    font-family: var(--sans);
    font-size: 11px;
    line-height: 1.5;
    color: var(--ink-soft);
    margin: 0 0 8px;
}
.extra-time-cta {
    display: inline-block;
    font-family: var(--sans);
    font-size: 12px;
    font-weight: 600;
    color: var(--accent-deep);
    text-decoration: none;
    padding: 4px 0;
    transition: color 140ms ease, transform 140ms ease;
}
.extra-time-cta:hover {
    color: var(--ink);
    transform: translateX(2px);
}

.tier-cta {
    display: block;
    text-align: center;
    font-family: var(--sans);
    font-size: 12px;
    font-weight: 600;
    padding: 8px 0;
    border-radius: 8px;
    background: var(--surface);
    color: var(--ink);
    border: 1px solid var(--border-strong);
    text-decoration: none;
    cursor: pointer;
}
.tier-cta:hover {
    background: var(--surface-2);
    border-color: var(--ink-soft);
}

/* Mobile fallback */
@media (max-width: 640px) {
    :root { --sidebar-width: 92vw; }
}
