/* --- src/mobizy.css ---
   Shared design system for every Mobizy page (mobizy.html = voice page,
   mobizy-chat.html = text chat, mobizy-contact.html = Telegram contact form).
   Top bar, buttons, status badge, voice orb, cards, footer.

   Tokens: accent mint #5fd6a4, dark #1b1e1d, base #f6f8f7, greys #636363 /
   #a4a4a4, Oswald (headings) + Roboto (body) - fonts come from the Google Fonts
   <link> in each page. Radius: 20px cards, 12px buttons/inputs.

   Functional contract this file must not break: app.js (bundle.js) looks up
   #startButton/#endButton/#connectionStatus/#orbLabel/#categoryIcon/
   #speakingStatus by id and .avatar by class, and writes the
   --mz-live-accent/--mz-live-accent-dark/--mz-live-accent-rgb custom
   properties + the mz-category-icon/mz-icon-* class names directly onto those
   elements (optional intent accent, see CATEGORY_THEMES in app.js) - keep
   those names in sync with app.js. The defaults on .mz-portal below are what
   a call looks like when no intent accent has been pushed. */

* {
    box-sizing: border-box;
}

:root {
    /* Surfaces / ink */
    --mz-bg: #F6F8F7;
    --mz-surface: #FFFFFF;
    --mz-surface-2: #ECF0EE;
    --mz-ink: #1B1E1D;
    --mz-ink-muted: #636363;
    --mz-border: #DFE5E2;

    /* Brand: dark primary buttons, mint accent */
    --mz-primary: #1B1E1D;
    --mz-primary-hover: #2E3432;
    --mz-primary-soft: #E3F6EE;
    --mz-on-primary: #FFFFFF;
    --mz-accent: #5FD6A4;
    --mz-accent-soft: #E3F6EE;
    --mz-mint: #5FD6A4;
    --mz-mint-dark: #3FB888;

    /* Status */
    --mz-success: #3FB888;
    --mz-warning: #E0B04A;
    --mz-danger: #E5484D;
    --mz-danger-soft: rgba(229, 72, 77, 0.1);
    --mz-success-soft: rgba(63, 184, 136, 0.14);

    /* Dark surfaces (top bar + voice stage) */
    --mz-dark: #1B1E1D;
    --mz-dark-ink: #A4A4A4;
    --mz-dark-active: #272C2A;
    --mz-dark-border: #353B38;

    /* Shape */
    --mz-radius: 12px;
    --mz-radius-card: 20px;
    --mz-radius-pill: 999px;
    --mz-shell-max: 1200px;

    /* Type */
    --mz-font-head: 'Oswald', 'Segoe UI', system-ui, -apple-system, sans-serif;
    --mz-font-body: 'Roboto', 'Segoe UI', system-ui, -apple-system, Helvetica, Arial, sans-serif;
    --mz-font-mono: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
}

.mz-portal {
    margin: 0;
    min-height: 100vh;
    background: var(--mz-bg);
    color: var(--mz-ink);
    font-family: var(--mz-font-body);
    -webkit-font-smoothing: antialiased;
    /* Default accent (Mobizy mint) shown until a live intent guess overrides
       it - see applyCategoryTheme()/resetCategoryTheme() in app.js. */
    --mz-live-accent: #5FD6A4;
    --mz-live-accent-dark: #3FB888;
    --mz-live-accent-rgb: 95, 214, 164;
}

.mz-portal h1,
.mz-portal h2,
.mz-portal h3 {
    font-family: var(--mz-font-head);
    letter-spacing: 0.01em;
    font-weight: 600;
}

.mz-portal a {
    color: inherit;
    text-decoration: none;
}

.mz-portal :focus-visible {
    outline: 2px solid var(--mz-mint-dark);
    outline-offset: 2px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.mz-shell {
    width: min(100% - 32px, var(--mz-shell-max));
    margin-inline: auto;
}

/* Small mono kicker used above headings */
.mz-eyebrow {
    margin: 0;
    font-family: var(--mz-font-mono);
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--mz-ink-muted);
}

/* --- Top bar (dark, full-bleed) ---
   Markup (identical on every page):
   <header class="mz-topbar"><div class="mz-shell mz-topbar-inner">
     <a class="mz-brand">[svg.mz-logo]<span>Mobizy</span></a>
     <nav class="mz-nav">…</nav>
   </div></header> */

.mz-topbar {
    background: var(--mz-dark);
    color: var(--mz-dark-ink);
    border-bottom: 1px solid var(--mz-dark-border);
}

.mz-topbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    padding: 12px 0;
    min-height: 64px;
}

.mz-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: var(--mz-font-head);
    font-weight: 700;
    font-size: 17px;
    letter-spacing: -0.01em;
    color: #FFFFFF;
}

/* Mobizy wordmark stand-in (plain text, no site logo) */
.mz-brand span {
    font-family: var(--mz-font-head);
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.mz-logo {
    width: 32px;
    height: 32px;
    flex: none;
    display: block;
}

.mz-nav {
    display: flex;
    align-items: center;
    gap: 4px;
}

.mz-nav-link {
    padding: 8px 14px;
    border-radius: var(--mz-radius);
    font-size: 14px;
    font-weight: 500;
    color: var(--mz-dark-ink);
    transition: background 0.15s ease, color 0.15s ease;
}

.mz-nav-link:hover {
    color: #FFFFFF;
    background: rgba(255, 255, 255, 0.06);
}

.mz-nav-link.is-active {
    background: var(--mz-dark-active);
    color: #FFFFFF;
}

@media (max-width: 720px) {
    .mz-topbar-inner {
        justify-content: space-between;
    }

    .mz-nav {
        order: 3;
        width: 100%;
        overflow-x: auto;
    }
}

/* --- Buttons --- */

.mz-portal .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 1px solid transparent;
    border-radius: var(--mz-radius);
    font-family: inherit;
    font-size: 14.5px;
    font-weight: 600;
    cursor: pointer;
    padding: 12px 20px;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.mz-portal .btn:active:not(:disabled) {
    transform: translateY(1px);
}

.mz-portal .btn svg {
    width: 18px;
    height: 18px;
    flex: none;
}

.mz-portal .btn:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

.mz-portal .btn-primary {
    background: var(--mz-primary);
    color: var(--mz-on-primary);
}

.mz-portal .btn-primary:hover:not(:disabled) {
    background: var(--mz-primary-hover);
}

/* Mint call-to-action: dark text (white on mint fails contrast). */
.mz-portal .btn-accent {
    background: var(--mz-mint);
    color: #1B1E1D;
}

.mz-portal .btn-accent:hover:not(:disabled) {
    background: #4CC595;
}

.mz-portal .btn-secondary {
    background: var(--mz-surface);
    color: var(--mz-ink);
    border-color: var(--mz-border);
}

.mz-portal .btn-outline {
    background: transparent;
    color: var(--mz-ink);
    border-color: var(--mz-border);
}

.mz-portal .btn-secondary:hover:not(:disabled),
.mz-portal .btn-outline:hover:not(:disabled) {
    border-color: var(--mz-mint-dark);
    color: var(--mz-ink);
    background: var(--mz-primary-soft);
}

/* Ghost button for dark surfaces (voice stage) */
.mz-portal .btn-glass {
    background: transparent;
    color: var(--mz-dark-ink);
    border-color: var(--mz-dark-border);
}

.mz-portal .btn-glass:hover:not(:disabled) {
    background: var(--mz-dark-active);
    color: #FFFFFF;
}

/* Active call: the start button doubles as the timer readout */
.mz-portal #startButton:disabled {
    background: var(--mz-dark-active);
    color: var(--mz-live-accent);
}

.mz-portal #endButton {
    border-color: var(--mz-danger);
}

/* --- Status badge (idle / connecting / live) - voice stage --- */

.mz-portal .status-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: var(--mz-font-mono);
    font-size: 11.5px;
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 6px 12px;
    border-radius: var(--mz-radius-pill);
    color: var(--mz-dark-ink);
    background: var(--mz-dark-active);
    border: 1px solid var(--mz-dark-border);
}

.mz-portal .status-badge::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.mz-portal .status-badge.is-connecting {
    color: var(--mz-warning);
    border-color: rgba(224, 176, 74, 0.45);
    background: rgba(224, 176, 74, 0.1);
}

.mz-portal .status-badge.is-connecting::before {
    animation: mzBlink 1s ease-in-out infinite;
}

.mz-portal .status-badge.is-live {
    color: var(--mz-live-accent);
    border-color: rgba(var(--mz-live-accent-rgb), 0.5);
    background: rgba(var(--mz-live-accent-rgb), 0.12);
}

.mz-portal .status-badge.is-live::before {
    animation: mzBlink 1.4s ease-in-out infinite;
}

@keyframes mzBlink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.25;
    }
}

/* --- Voice orb / avatar (ringed mic button) --- */

.mz-orb {
    position: relative;
    flex: none;
    width: 220px;
    height: 220px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mz-orb-ring {
    position: absolute;
    width: 200px;
    height: 200px;
    border-radius: 50%;
    border: 1px solid rgba(var(--mz-live-accent-rgb), 0.55);
    animation: mzPulseRing 3.2s ease-out infinite;
}

.mz-orb-ring--2 {
    border-color: rgba(var(--mz-live-accent-rgb), 0.3);
    animation-delay: 1.6s;
}

@keyframes mzPulseRing {
    0% {
        transform: scale(0.9);
        opacity: 0.6;
    }

    70%,
    100% {
        transform: scale(1.18);
        opacity: 0;
    }
}

.mz-portal .avatar {
    position: relative;
    width: 168px;
    height: 168px;
    border-radius: 50%;
    background: radial-gradient(circle at 50% 30%, rgba(var(--mz-live-accent-rgb), 0.22), var(--mz-dark-active) 70%);
    border: 3px solid var(--mz-live-accent);
    box-shadow: 0 0 0 6px rgba(var(--mz-live-accent-rgb), 0.12), 0 0 60px rgba(var(--mz-live-accent-rgb), 0.22);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px;
    animation: mzBreathe 4.5s ease-in-out infinite;
    transition: box-shadow 0.4s ease, border-color 0.4s ease;
}

.mz-portal .avatar.speaking-mode {
    box-shadow: 0 0 0 10px rgba(var(--mz-live-accent-rgb), 0.2), 0 0 90px rgba(var(--mz-live-accent-rgb), 0.4);
}

@keyframes mzBreathe {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.03);
    }
}

.mz-orb-label {
    font-family: var(--mz-font-mono);
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--mz-dark-ink);
    text-align: center;
    line-height: 1.5;
}

/* Intent icon shown inside the orb (see CATEGORY_THEMES in app.js; the
   animation names below match its `anim` values: pulse, flicker, spin, sway). */
.mz-category-icon {
    width: 40px;
    height: 40px;
    color: var(--mz-live-accent);
    opacity: 1;
    transform: scale(1);
    transition: color 0.4s ease, width 0.3s ease, height 0.3s ease, opacity 0.3s ease, transform 0.3s ease, margin 0.3s ease;
}

.mz-category-icon:empty {
    width: 0;
    height: 0;
    margin: 0;
    opacity: 0;
    transform: scale(0.4);
}

.mz-category-icon svg {
    width: 100%;
    height: 100%;
    display: block;
}

.mz-icon-flicker {
    animation: mzIconFlicker 1.1s steps(1, end) infinite;
}

@keyframes mzIconFlicker {

    0%,
    19%,
    21%,
    54%,
    56%,
    100% {
        opacity: 1;
    }

    20%,
    55% {
        opacity: 0.3;
    }
}

.mz-icon-spin {
    animation: mzIconSpin 3.5s linear infinite;
}

@keyframes mzIconSpin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.mz-icon-sway {
    animation: mzIconSway 2.4s ease-in-out infinite;
    transform-origin: 50% 85%;
}

@keyframes mzIconSway {

    0%,
    100% {
        transform: rotate(-9deg);
    }

    50% {
        transform: rotate(9deg);
    }
}

.mz-icon-pulse {
    animation: mzIconPulse 1.8s ease-in-out infinite;
}

@keyframes mzIconPulse {

    0%,
    100% {
        transform: scale(1);
        opacity: 0.85;
    }

    50% {
        transform: scale(1.12);
        opacity: 1;
    }
}

@media (prefers-reduced-motion: reduce) {

    .mz-orb-ring,
    .mz-portal .avatar,
    .mz-icon-flicker,
    .mz-icon-spin,
    .mz-icon-sway,
    .mz-icon-pulse {
        animation: none;
    }
}

/* --- Generic panels --- */

.mz-card {
    border-radius: var(--mz-radius-card);
    border: 1px solid var(--mz-border);
    background: var(--mz-surface);
    padding: 24px;
}

/* --- Back link --- */

.mz-back-row {
    padding: 20px 0 0;
}

.mz-back-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--mz-ink-muted);
}

.mz-back-link:hover {
    color: var(--mz-ink);
}

/* --- Footer --- */

.mz-footer {
    border-top: 1px solid var(--mz-border);
    padding: 22px 0 32px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    font-size: 13px;
    color: var(--mz-ink-muted);
}

.mz-footer a:hover {
    color: var(--mz-ink);
    text-decoration: underline;
}

/* --- Consent / privacy note (shown on the voice, chat and contact pages) --- */

.mz-consent {
    margin: 0;
    font-size: 12.5px;
    line-height: 1.5;
    color: var(--mz-ink-muted);
}
