/* ============================================================
   Eco — Hojas de estilo
   Estética mediterránea: cream, terracota y verde basílico.
   Sin frameworks, solo CSS plano.
   ============================================================ */

:root {
    --cream-50:        #faf6ee;
    --cream-100:       #f5ede0;
    --cream-200:       #ede2cf;
    --cream-300:       #e4d5b8;
    --terracotta:      #c8423d;
    --terracotta-dark: #a8332e;
    --terracotta-deep: #8b2722;
    --basilico:        #2d5f3f;
    --basilico-dark:   #1a3325;
    --azzurro:         #2c5e8f;
    --azzurro-dark:    #1c3f60;
    --gold:            #c89b3c;
    --gold-dark:       #8a6a25;
    --aubergine:       #7a3a52;
    --aubergine-dark:  #4f2336;
    --ink:             #1a1612;
    --ink-soft:        #2a221c;
    --warm-muted:      #8a6f5a;
    --warm-mid:        #6b5544;
    --warm-light:      #b8a48d;

    --font-display: 'Fraunces', Georgia, 'Times New Roman', serif;
    --font-body:    'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
}

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

html {
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

button {
    font: inherit;
    color: inherit;
    background: none;
    border: none;
    cursor: pointer;
}

a {
    color: inherit;
    text-decoration: none;
}

input {
    font: inherit;
    color: inherit;
}

/* ---------- Cuerpo y fondo ---------- */
body {
    min-height: 100vh;
    min-height: 100dvh;
    font-family: var(--font-body);
    color: var(--ink);
    background:
        radial-gradient(ellipse at top,
            var(--cream-100) 0%,
            var(--cream-200) 50%,
            var(--cream-300) 100%);
    background-attachment: fixed;
    position: relative;
    overflow-x: hidden;
    padding:
        env(safe-area-inset-top)
        env(safe-area-inset-right)
        env(safe-area-inset-bottom)
        env(safe-area-inset-left);
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/%3E%3CfeColorMatrix values='0 0 0 0 0.4 0 0 0 0 0.3 0 0 0 0 0.2 0 0 0 0.08 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    opacity: 0.6;
    mix-blend-mode: multiply;
    z-index: 0;
}

/* ---------- Contenedor ---------- */
.app {
    position: relative;
    z-index: 1;
    max-width: 480px;
    margin: 0 auto;
    padding: 1rem;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

.app--auth {
    justify-content: center;
}

/* ---------- Cabecera ---------- */
.hero {
    text-align: center;
    padding: 1.5rem 0 2rem;
}

.rule {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.25rem;
}

.rule-line {
    display: block;
    width: 2rem;
    height: 1px;
}

.rule-line--red   { background: var(--terracotta); }
.rule-line--green { background: var(--basilico); }

.rule-text {
    font-size: 0.625rem;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    color: var(--warm-muted);
    font-weight: 500;
}

.title {
    font-family: var(--font-display);
    font-size: 4rem;
    font-weight: 300;
    font-style: italic;
    color: var(--ink);
    letter-spacing: -0.04em;
    line-height: 1;
}

.subtitle {
    margin-top: 0.5rem;
    font-size: 0.875rem;
    color: var(--warm-mid);
}

/* ---------- Selector de idiomas (dropdowns + swap) ---------- */
.direction {
    display: flex;
    align-items: end;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.direction__field {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.direction__hint {
    font-size: 0.5625rem;
    letter-spacing: 0.25em;
    text-transform: uppercase;
    color: var(--warm-muted);
    font-weight: 600;
    text-align: center;
}

.direction__select {
    appearance: none;
    -webkit-appearance: none;
    padding: 0.625rem 2rem 0.625rem 1rem;
    border: 1px solid rgba(26, 22, 18, 0.12);
    border-radius: 9999px;
    background-color: rgba(255, 250, 242, 0.85);
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%231a1612' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    font-family: var(--font-body);
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--ink);
    cursor: pointer;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.8),
        0 2px 8px -4px rgba(120, 80, 50, 0.2);
    transition: background 0.2s, transform 0.15s;
    min-width: 7rem;
}

.direction__select:hover:not(:disabled) {
    background-color: rgba(255, 250, 242, 1);
}

.direction__select:active { transform: scale(0.98); }
.direction__select:disabled { opacity: 0.5; cursor: not-allowed; }

.direction__swap {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    background: var(--ink);
    color: var(--cream-100);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px -4px rgba(26, 22, 18, 0.4);
    transition: background 0.2s, transform 0.15s;
    align-self: end;
    margin-bottom: 0; /* alineado con los selects */
}

.direction__swap:hover:not(:disabled) { background: var(--ink-soft); }
.direction__swap:active { transform: scale(0.92) rotate(15deg); }
.direction__swap:disabled { opacity: 0.4; cursor: not-allowed; }


/* ---------- Barra de usuario (en home) ---------- */
.user-bar {
    margin-top: 1.5rem;
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.375rem 0.875rem;
    background: rgba(255, 250, 242, 0.65);
    border: 1px solid rgba(26, 22, 18, 0.08);
    border-radius: 9999px;
    font-size: 0.6875rem;
    color: var(--warm-mid);
}

.user-bar__email {
    font-weight: 500;
}

.user-bar__logout {
    color: var(--terracotta);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    font-weight: 600;
    border-left: 1px solid rgba(26, 22, 18, 0.12);
    padding-left: 0.75rem;
    transition: opacity 0.2s;
}

.user-bar__logout:hover { opacity: 0.6; }

/* ---------- Paneles del traductor ---------- */
.panels {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.panel {
    border-radius: 1.5rem;
    padding: 1.5rem;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.panel--source {
    background: rgba(255, 250, 242, 0.65);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.8),
        0 8px 24px -12px rgba(120, 80, 50, 0.2);
}

.panel--target {
    background: rgba(247, 243, 232, 0.85);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.8),
        0 8px 24px -12px rgba(45, 95, 63, 0.2);
}

/* Modificadores de color según el idioma actual del panel.
   Las clases se aplican vía JS al cambiar de dirección. */
.panel--accent-red {
    border: 1px solid rgba(200, 66, 61, 0.15);
}

.panel--accent-green {
    border: 1px solid rgba(45, 95, 63, 0.18);
}

.panel--accent-blue {
    border: 1px solid rgba(44, 94, 143, 0.2);
}

.panel--accent-gold {
    border: 1px solid rgba(200, 155, 60, 0.22);
}

.panel--accent-aubergine {
    border: 1px solid rgba(122, 58, 82, 0.2);
}

.panel--target.panel--accent-green {
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.8),
        0 8px 24px -12px rgba(45, 95, 63, 0.25);
}
.panel--target.panel--accent-red {
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.8),
        0 8px 24px -12px rgba(200, 66, 61, 0.25);
}
.panel--target.panel--accent-blue {
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.8),
        0 8px 24px -12px rgba(44, 94, 143, 0.25);
}
.panel--target.panel--accent-gold {
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.8),
        0 8px 24px -12px rgba(200, 155, 60, 0.25);
}
.panel--target.panel--accent-aubergine {
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.8),
        0 8px 24px -12px rgba(122, 58, 82, 0.25);
}

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
    min-height: 1rem;
}

.panel-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.dot {
    width: 0.375rem;
    height: 0.375rem;
    border-radius: 50%;
    display: inline-block;
}

.dot--red       { background: var(--terracotta); }
.dot--green     { background: var(--basilico); }
.dot--blue      { background: var(--azzurro); }
.dot--gold      { background: var(--gold); }
.dot--aubergine { background: var(--aubergine); }

.label {
    font-size: 0.625rem;
    letter-spacing: 0.25em;
    text-transform: uppercase;
    font-weight: 600;
}

.label--red       { color: var(--terracotta); }
.label--green     { color: var(--basilico); }
.label--blue      { color: var(--azzurro); }
.label--gold      { color: var(--gold-dark); }
.label--aubergine { color: var(--aubergine); }

.panel-body {
    font-family: var(--font-display);
    font-size: 1.35rem;
    line-height: 1.4;
    color: var(--ink);
    min-height: 4rem;
    font-weight: 400;
}

.panel-body--target {
    color: var(--basilico-dark);
    font-style: italic;
}

.placeholder {
    color: var(--warm-light);
    font-style: italic;
    font-weight: 300;
}

.panel-body--target .placeholder {
    color: #a8b8ac;
    font-style: normal;
    font-weight: 300;
}

/* ---------- Estado y "repetir" ---------- */
.status {
    font-size: 0.625rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    font-weight: 600;
    color: var(--warm-muted);
}

.status--shimmer {
    background: linear-gradient(90deg,
        var(--warm-mid) 0%,
        var(--gold) 50%,
        var(--warm-mid) 100%);
    background-size: 200% 100%;
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    animation: shimmer 2.5s linear infinite;
}

.replay {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.625rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    font-weight: 600;
    color: var(--warm-mid);
    transition: opacity 0.2s;
}

.replay:hover  { opacity: 0.6; }
.replay:active { opacity: 0.4; }

/* ---------- Errores ---------- */
.error {
    text-align: center;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--terracotta);
    animation: fade-in-up 0.4s ease-out;
}

.error--inline {
    background: rgba(200, 66, 61, 0.08);
    border: 1px solid rgba(200, 66, 61, 0.2);
    border-radius: 0.75rem;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    font-size: 0.8125rem;
    text-align: left;
}

/* ---------- Controles del micrófono ---------- */
.controls {
    padding-bottom: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.25rem;
}

.controls--dual {
    flex-direction: row;
    align-items: flex-start;
    justify-content: center;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.controls--dual .hint {
    flex-basis: 100%;
    text-align: center;
    margin-top: 0.25rem;
}

.mic-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.625rem;
}

.mic-lang {
    font-size: 0.625rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    font-weight: 600;
    transition: color 0.2s;
}

.mic {
    position: relative;
    width: 6rem;
    height: 6rem;
    border-radius: 50%;
    color: var(--cream-100);
    background: radial-gradient(circle at 30% 30%,
        var(--ink-soft) 0%,
        var(--ink) 70%,
        #0f0c08 100%);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.1),
        inset 0 0 0 1px rgba(255, 255, 255, 0.05),
        0 12px 32px -8px rgba(26, 22, 18, 0.45);
    transition: transform 0.3s ease, background 0.3s ease, box-shadow 0.3s ease;
    animation: breathe 2.5s ease-in-out infinite;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mic:active   { transform: scale(0.95); }
.mic:disabled { opacity: 0.4; cursor: not-allowed; animation: none; }

.mic--active {
    background: radial-gradient(circle at 30% 30%,
        #d65349 0%,
        var(--terracotta-dark) 70%,
        var(--terracotta-deep) 100%);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.15),
        inset 0 0 0 1px rgba(200, 66, 61, 0.3),
        0 12px 32px -8px rgba(200, 66, 61, 0.5);
    animation: none;
}

.mic-ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2px solid var(--terracotta);
    opacity: 0;
    pointer-events: none;
}

.mic--active .mic-ring {
    animation: pulse-ring 1.8s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.mic--active .mic-ring--delay {
    animation-delay: 0.6s;
}

.mic-icon   { position: relative; z-index: 1; }
.mic-loader { display: none; position: relative; z-index: 1; animation: spin 1s linear infinite; }

.mic--loading             { animation: none; }
.mic--loading .mic-icon   { display: none; }
.mic--loading .mic-loader { display: block; }

.hint {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    font-size: 0.6875rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--warm-muted);
    font-weight: 500;
}

.reset {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    color: var(--warm-muted);
    transition: opacity 0.2s;
}

.reset:hover { opacity: 0.6; }

/* ============================================================
   Pantallas de autenticación
   ============================================================ */

.auth-panel {
    background: rgba(255, 250, 242, 0.85);
    border: 1px solid rgba(26, 22, 18, 0.08);
    border-radius: 1.5rem;
    padding: 2rem 1.75rem;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.8),
        0 8px 24px -12px rgba(120, 80, 50, 0.2);
}

.auth-title {
    font-family: var(--font-display);
    font-size: 1.75rem;
    font-weight: 400;
    font-style: italic;
    color: var(--ink);
    margin-bottom: 0.5rem;
    letter-spacing: -0.02em;
}

.auth-blurb {
    font-size: 0.875rem;
    color: var(--warm-mid);
    line-height: 1.5;
    margin-bottom: 1.5rem;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.field__label {
    font-size: 0.625rem;
    letter-spacing: 0.25em;
    text-transform: uppercase;
    font-weight: 600;
    color: var(--warm-mid);
}

.field__input {
    padding: 0.875rem 1rem;
    border: 1px solid rgba(26, 22, 18, 0.15);
    border-radius: 0.75rem;
    background: rgba(255, 255, 255, 0.6);
    font-size: 1rem;
    transition: border-color 0.2s, background 0.2s;
}

.field__input:focus {
    outline: none;
    border-color: var(--basilico);
    background: rgba(255, 255, 255, 0.95);
}

.field__hint {
    font-size: 0.6875rem;
    color: var(--warm-muted);
    margin-top: 0.125rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.875rem 1.5rem;
    border-radius: 9999px;
    font-size: 0.875rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    transition: transform 0.2s, opacity 0.2s, box-shadow 0.2s;
    text-align: center;
}

.btn:active { transform: scale(0.97); }

.btn--primary {
    background: var(--ink);
    color: var(--cream-100);
    box-shadow: 0 4px 12px -4px rgba(26, 22, 18, 0.4);
    margin-top: 0.5rem;
}

.btn--primary:hover { background: var(--ink-soft); }

.btn--secondary {
    background: transparent;
    color: var(--ink);
    border: 1px solid rgba(26, 22, 18, 0.2);
}

.btn--secondary:hover {
    background: rgba(26, 22, 18, 0.04);
}

.auth-footer {
    margin-top: 1.5rem;
    text-align: center;
    font-size: 0.875rem;
    color: var(--warm-mid);
}

.auth-link {
    color: var(--terracotta);
    font-weight: 600;
    transition: opacity 0.2s;
}

.auth-link:hover { opacity: 0.7; }

/* ---------- Animaciones ---------- */
.fade-in        { animation: fade-in-up 0.5s ease-out; }
.loading-shimmer {
    background: linear-gradient(90deg,
        var(--warm-mid) 0%,
        var(--gold) 50%,
        var(--warm-mid) 100%);
    background-size: 200% 100%;
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    animation: shimmer 2.5s linear infinite;
    font-style: normal;
    font-weight: 500;
}

@keyframes breathe {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.04); }
}

@keyframes pulse-ring {
    0%   { transform: scale(1);   opacity: 0.5; }
    100% { transform: scale(1.6); opacity: 0;   }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes shimmer {
    0%   { background-position: -200% 0; }
    100% { background-position:  200% 0; }
}

@keyframes fade-in-up {
    0%   { opacity: 0; transform: translateY(8px); }
    100% { opacity: 1; transform: translateY(0); }
}

/* ---------- Pantallas grandes ---------- */
@media (min-width: 600px) {
    .title { font-size: 5rem; }
    .app   { padding: 2rem; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}


/* ============================================================
   Footer del sitio (copyright)
   ============================================================ */

body {
    display: flex;
    flex-direction: column;
}

.app {
    flex: 1;
}

.site-footer {
    position: relative;
    z-index: 1;
    text-align: center;
    padding: 1rem 1rem 1.25rem;
    font-size: 0.6875rem;
    color: var(--warm-muted);
    letter-spacing: 0.02em;
}

.site-footer a {
    color: var(--basilico);
    text-decoration: none;
    font-weight: 600;
    transition: opacity 0.2s;
}

.site-footer a:hover {
    opacity: 0.7;
    text-decoration: underline;
}


/* ---------- Modo conversación: dos micros más pequeños ---------- */
.controls--dual .mic {
    width: 4.75rem;
    height: 4.75rem;
}

/* Cuando un micro está activo, lo tintamos con el color de su idioma */
.mic--active.mic--red       { background: radial-gradient(circle at 30% 30%, #d65953, var(--terracotta) 70%, #8c2622); }
.mic--active.mic--green     { background: radial-gradient(circle at 30% 30%, #3f7a52, var(--basilico) 70%, #1a3325); }
.mic--active.mic--blue      { background: radial-gradient(circle at 30% 30%, #4179a8, var(--azzurro) 70%, var(--azzurro-dark)); }
.mic--active.mic--gold      { background: radial-gradient(circle at 30% 30%, #dab256, var(--gold) 70%, var(--gold-dark)); }
.mic--active.mic--aubergine { background: radial-gradient(circle at 30% 30%, #985368, var(--aubergine) 70%, var(--aubergine-dark)); }

/* Disabled state for the inactive mic during recording */
.mic:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}


/* ---------- Toast / notificación de estado ---------- */
.toast {
    position: fixed;
    top: max(1rem, env(safe-area-inset-top, 1rem));
    left: 50%;
    transform: translate(-50%, -200%);
    padding: 0.625rem 1.25rem;
    border-radius: 9999px;
    background: var(--ink);
    color: var(--cream-100);
    font-family: var(--font-body);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    box-shadow:
        0 4px 16px rgba(26, 22, 18, 0.25),
        0 1px 3px rgba(26, 22, 18, 0.15);
    transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 1000;
    pointer-events: none;
    white-space: nowrap;
}

.toast--visible {
    transform: translate(-50%, 0);
}
