/* tapas-portal.css — TapasAI Portal sheet styles.
   Mirrors HYPYoga-iOS Features/Reflect/TapasPortalSheet.swift chrome:
   bottom-sheet on mobile, centered modal on desktop, Liquid Glass everywhere.
   Depends on .lg-surface from chat-widget.css / colors_and_type.css. */

body.tp-open { overflow: hidden; }

.tp-overlay {
    position: fixed;
    inset: 0;
    z-index: 99997;       /* one below the chat panel so the panel can replace it */
    background: rgba(20, 22, 28, 0);
    transition: background 0.24s ease;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 0;
}
.tp-overlay.open { background: rgba(20, 22, 28, 0.42); }
.tp-overlay[hidden] { display: none; }

.tp-sheet {
    width: 100%;
    max-width: 560px;
    max-height: 88vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    padding: 0;
    transform: translateY(24px);
    opacity: 0;
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.22s ease;
    --lg-tint: var(--c-tapas, #1e88b4);
    --lg-tint-soft: rgba(30,136,180,0.10);
    --lg-rim-color: rgba(30,136,180,0.30);
    --lg-radius: 22px 22px 0 0;
    border-radius: 22px 22px 0 0;
}
.tp-overlay.open .tp-sheet {
    transform: translateY(0);
    opacity: 1;
}

/* Drag-handle grabber at the top — iOS bottom-sheet idiom */
.tp-grabber {
    width: 44px;
    height: 4px;
    border-radius: 2px;
    background: color-mix(in srgb, var(--c-tapas, #1e88b4) 30%, transparent);
    margin: 0.55rem auto 0.4rem;
    flex-shrink: 0;
}

.tp-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.4rem 1.2rem 0.8rem;
    flex-shrink: 0;
}
.tp-title-wrap {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    flex: 1;
    min-width: 0;
}
.tp-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    overflow: hidden;
    background: rgba(30,136,180,0.12);
    border: 1px solid rgba(30,136,180,0.30);
    flex-shrink: 0;
}
.tp-avatar img { width: 100%; height: 100%; object-fit: cover; }
.tp-title-stack { min-width: 0; }
.tp-title {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 1.2rem;
    font-weight: 600;
    color: #2c2a26;
    line-height: 1.2;
}
.tp-sub {
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 0.78rem;
    color: #6b6560;
    line-height: 1.35;
    margin-top: 1px;
}
.tp-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.35rem;
    color: #6b6560;
    border-radius: 6px;
    transition: background 0.15s ease, color 0.15s ease;
    flex-shrink: 0;
}
.tp-close:hover {
    background: rgba(30,136,180,0.10);
    color: var(--c-tapas, #1e88b4);
}
.tp-close:focus-visible {
    outline: 2px solid var(--c-tapas, #1e88b4);
    outline-offset: 2px;
}

.tp-tabs {
    display: flex;
    gap: 4px;
    padding: 0 1rem 0.5rem;
    border-bottom: 1px solid color-mix(in srgb, var(--c-tapas, #1e88b4) 15%, transparent);
    flex-shrink: 0;
}
.tp-tab {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.55rem 0.6rem;
    border: none;
    background: none;
    cursor: pointer;
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 0.78rem;
    font-weight: 500;
    color: #6b6560;
    border-radius: 8px 8px 0 0;
    transition: color 0.15s ease, background 0.15s ease;
    position: relative;
}
.tp-tab:hover { background: rgba(30,136,180,0.06); color: #2c2a26; }
.tp-tab.active {
    color: var(--c-tapas, #1e88b4);
    font-weight: 600;
    background: rgba(30,136,180,0.08);
}
.tp-tab.active::after {
    content: '';
    position: absolute;
    left: 12%;
    right: 12%;
    bottom: -1px;
    height: 2px;
    background: var(--c-tapas, #1e88b4);
    border-radius: 2px 2px 0 0;
}
.tp-tab svg { flex-shrink: 0; }

.tp-body {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 1.2rem 1.4rem;
    -webkit-overflow-scrolling: touch;
}

/* ── Compose mode ── */
.tp-compose-label {
    display: block;
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--c-tapas, #1e88b4);
    margin-bottom: 0.5rem;
}
.tp-compose-textarea {
    width: 100%;
    min-height: 140px;
    padding: 0.85rem 0.95rem;
    border: 1px solid rgba(30,136,180,0.25);
    border-radius: 12px;
    background: rgba(255,255,255,0.7);
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 1.05rem;
    line-height: 1.55;
    color: #2c2a26;
    resize: vertical;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.tp-compose-textarea::placeholder {
    color: #958e85;
    font-style: italic;
}
.tp-compose-textarea:focus {
    outline: none;
    border-color: var(--c-tapas, #1e88b4);
    box-shadow: 0 0 0 3px rgba(30,136,180,0.12);
}

.tp-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 0.85rem;
}
.tp-compose-send {
    padding: 0.6rem 1.2rem;
    border: none;
    cursor: pointer;
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    color: color-mix(in srgb, var(--c-tapas, #1e88b4) 80%, #2c2a26);
    transition: transform 0.15s ease, filter 0.15s ease;
    --lg-tint: var(--c-tapas, #1e88b4);
    --lg-tint-soft: rgba(30,136,180,0.18);
    --lg-rim-color: rgba(30,136,180,0.40);
    --lg-radius: 999px;
}
.tp-compose-send:hover { transform: translateY(-1px) scale(1.015); filter: brightness(1.04); }
.tp-compose-send:focus-visible { outline: 2px solid var(--c-tapas, #1e88b4); outline-offset: 2px; }

/* ── Voice mode — Web Speech API (Phase 8d) ──
   Three states: idle (tap to start), listening (waveform + live transcript),
   captured (final transcript + "Open in TapasAI"). Unsupported state shown
   when Web Speech API is unavailable (Firefox + some Safari builds). */
.tp-voice {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem 0.5rem;
}
.tp-voice-state {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.85rem;
}
.tp-voice-state[hidden] { display: none; }

.tp-voice-mic {
    width: 84px;
    height: 84px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    background: color-mix(in srgb, var(--c-tapas, #1e88b4) 12%, transparent);
    color: var(--c-tapas, #1e88b4);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s ease, background 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 4px 16px rgba(30,136,180,0.18), inset 0 0 0 2px rgba(30,136,180,0.30);
}
.tp-voice-mic:hover {
    transform: scale(1.04);
    background: color-mix(in srgb, var(--c-tapas, #1e88b4) 18%, transparent);
}
.tp-voice-mic:focus-visible {
    outline: 2px solid var(--c-tapas, #1e88b4);
    outline-offset: 4px;
}
.tp-voice-mic--active {
    background: var(--c-tapas, #1e88b4);
    color: #fff;
    box-shadow: 0 4px 18px rgba(30,136,180,0.40), 0 0 0 0 rgba(30,136,180,0.45);
    animation: tp-voice-pulse 1.4s ease-in-out infinite;
}
@keyframes tp-voice-pulse {
    0%, 100% { box-shadow: 0 4px 18px rgba(30,136,180,0.40), 0 0 0 0 rgba(30,136,180,0.45); }
    50%      { box-shadow: 0 4px 22px rgba(30,136,180,0.55), 0 0 0 16px rgba(30,136,180,0.00); }
}
@media (prefers-reduced-motion: reduce) {
    .tp-voice-mic--active { animation: none; }
}

.tp-voice-prompt {
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 0.92rem;
    color: #6b6560;
    text-align: center;
    line-height: 1.45;
    max-width: 320px;
}

/* Listening waveform — 7 bars, journal-blue tint, audio-meter feel */
.tp-voice-wave {
    display: flex;
    align-items: center;
    gap: 4px;
    height: 28px;
}
.tp-voice-wave i {
    display: block;
    width: 4px;
    height: 16px;
    background: var(--c-tapas, #1e88b4);
    border-radius: 2px;
    transform-origin: center;
    animation: tp-voice-wave 1s ease-in-out infinite;
    opacity: 0.85;
}
.tp-voice-wave i:nth-child(1) { animation-delay: 0.00s; }
.tp-voice-wave i:nth-child(2) { animation-delay: 0.10s; }
.tp-voice-wave i:nth-child(3) { animation-delay: 0.20s; }
.tp-voice-wave i:nth-child(4) { animation-delay: 0.30s; }
.tp-voice-wave i:nth-child(5) { animation-delay: 0.20s; }
.tp-voice-wave i:nth-child(6) { animation-delay: 0.10s; }
.tp-voice-wave i:nth-child(7) { animation-delay: 0.00s; }
@keyframes tp-voice-wave {
    0%, 100% { transform: scaleY(0.4); }
    50%      { transform: scaleY(1.4); }
}
@media (prefers-reduced-motion: reduce) {
    .tp-voice-wave i { animation: none; transform: scaleY(0.8); }
}

/* Live transcript pill */
.tp-voice-transcript {
    width: 100%;
    max-width: 460px;
    padding: 0.7rem 1rem;
    background: rgba(30,136,180,0.08);
    border: 1px solid rgba(30,136,180,0.25);
    border-radius: 999px;
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 0.98rem;
    font-style: italic;
    color: #2c2a26;
    text-align: center;
    line-height: 1.4;
    min-height: 1.6em;
    transition: background 0.2s ease;
}

/* Captured state */
.tp-voice-captured-label {
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: color-mix(in srgb, var(--c-me, #A8AEB8) 70%, #2c2a26);
}
.tp-voice-captured {
    width: 100%;
    padding: 1rem 1.1rem;
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 1.05rem;
    line-height: 1.55;
    color: #2c2a26;
    --lg-tint: var(--c-me, #A8AEB8);
    --lg-tint-soft: var(--c-me-soft, rgba(168,174,184,0.14));
    --lg-rim-color: var(--c-me-rim, rgba(168,174,184,0.45));
    --lg-radius: 12px;
}
.tp-voice-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    margin-top: 0.4rem;
}
.tp-voice-redo {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 0.85rem;
    background: none;
    border: 1px solid color-mix(in srgb, var(--c-tapas, #1e88b4) 25%, transparent);
    border-radius: 999px;
    cursor: pointer;
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 0.78rem;
    font-weight: 500;
    color: #6b6560;
    transition: background 0.15s ease, color 0.15s ease;
}
.tp-voice-redo:hover {
    background: rgba(30,136,180,0.06);
    color: var(--c-tapas, #1e88b4);
}
.tp-voice-send {
    padding: 0.55rem 1.1rem;
    border: none;
    cursor: pointer;
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    color: color-mix(in srgb, var(--c-tapas, #1e88b4) 80%, #2c2a26);
    transition: transform 0.15s ease, filter 0.15s ease;
    --lg-tint: var(--c-tapas, #1e88b4);
    --lg-tint-soft: rgba(30,136,180,0.18);
    --lg-rim-color: rgba(30,136,180,0.40);
    --lg-radius: 999px;
}
.tp-voice-send:hover { transform: translateY(-1px) scale(1.015); filter: brightness(1.04); }
.tp-voice-send:focus-visible { outline: 2px solid var(--c-tapas, #1e88b4); outline-offset: 2px; }

/* Unsupported state (Firefox, some Safari builds) */
.tp-voice-placeholder {
    text-align: center;
    padding: 2rem 1rem 1.5rem;
    color: #6b6560;
}
.tp-voice-placeholder svg {
    color: color-mix(in srgb, var(--c-tapas, #1e88b4) 50%, #958e85);
    margin-bottom: 0.85rem;
}
.tp-voice-placeholder-title {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 1.1rem;
    font-weight: 500;
    color: #2c2a26;
    margin-bottom: 0.4rem;
}
.tp-voice-placeholder-sub {
    font-size: 0.85rem;
    line-height: 1.6;
    max-width: 360px;
    margin: 0 auto;
}

/* ── Lenses mode ── */
.tp-mode--lenses {
    display: grid;
    gap: 0.65rem;
}
.tp-mode--lenses[hidden] { display: none; }
.tp-lens-card {
    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-rows: auto auto auto;
    column-gap: 0.85rem;
    align-items: center;
    padding: 0.95rem 1.05rem;
    border: none;
    cursor: pointer;
    text-align: left;
    text-decoration: none;
    color: inherit;
    transition: transform 0.18s ease, filter 0.18s ease;
    --lg-radius: 14px;
}
.tp-lens-card[data-lens="smriti"] {
    --lg-tint: var(--c-smriti, #8B6914);
    --lg-tint-soft: var(--c-smriti-bg, rgba(139,105,20,0.12));
    --lg-rim-color: rgba(139,105,20,0.40);
}
.tp-lens-card[data-lens="sthiti"] {
    --lg-tint: var(--c-sthiti, var(--c-tapas, #1e88b4));
    --lg-tint-soft: var(--c-sthiti-bg, rgba(30,136,180,0.12));
    --lg-rim-color: rgba(30,136,180,0.40);
}
.tp-lens-card[data-lens="sankalpa"] {
    --lg-tint: var(--c-sankalpa, #4A9E52);
    --lg-tint-soft: var(--c-sankalpa-bg, rgba(74,158,82,0.12));
    --lg-rim-color: rgba(74,158,82,0.40);
}
.tp-lens-card:hover { transform: translateY(-1px) scale(1.005); filter: brightness(1.04); }
.tp-lens-card:focus-visible { outline: 2px solid var(--lg-tint); outline-offset: 2px; }

.tp-lens-sanskrit {
    font-family: 'Noto Sans Devanagari', serif;
    font-size: 1.65rem;
    color: var(--lg-tint);
    line-height: 1;
    grid-column: 1;
    grid-row: 1 / span 3;
    align-self: center;
}
.tp-lens-name {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 1.15rem;
    font-weight: 600;
    color: color-mix(in srgb, var(--lg-tint) 75%, #2c2a26);
    grid-column: 2;
    grid-row: 1;
    align-self: end;
}
.tp-lens-label {
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--lg-tint);
    grid-column: 2;
    grid-row: 2;
    line-height: 1.2;
}
.tp-lens-sub {
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 0.78rem;
    color: #6b6560;
    line-height: 1.4;
    grid-column: 2;
    grid-row: 3;
}

/* ── Desktop — center the sheet, give it some breathing room ── */
@media (min-width: 720px) {
    .tp-overlay { padding: 4vh 1rem; align-items: center; }
    .tp-sheet {
        max-height: 84vh;
        border-radius: 22px;
        --lg-radius: 22px;
        transform: translateY(12px) scale(0.985);
    }
    .tp-overlay.open .tp-sheet { transform: translateY(0) scale(1); }
    .tp-grabber { display: none; }
}
