/* BookForge -- main.css -- Neo-Brutalist Design System
   Paleta "Brasa y Miel" (2026-07): calida, inspirada en la forja --
   tinta espresso, papel dorado, brasa terracota, miel ambar y un
   contrapunte de cobre-patina. Los efectos retro se conservan. */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=Space+Mono:ital,wght@0,400;0,700;1,400&display=swap');

/* ── Variables base ── */
:root {
    --bg:            #FBF1E0;   /* papel dorado calido */
    --bg-card:       #FFFCF5;   /* blanco marfil */
    --bg-inset:      #F2E3CB;   /* papel hundido, miel palida */
    --fg:            #2B1D14;   /* tinta espresso (negro calido) */
    --fg-muted:      #7A6450;   /* tinta suave, cuero claro */
    --border-color:  #2B1D14;
    --border:        2px solid #2B1D14;
    --border-thin:   1px solid #2B1D14;
    --shadow:        4px 4px 0 #2B1D14;
    --shadow-lg:     6px 6px 0 #2B1D14;
    --shadow-sm:     2px 2px 0 #2B1D14;
    --font-body:     'Space Grotesk', system-ui, sans-serif;
    --font-mono:     'Space Mono', monospace;
    --font-heading:  'Space Grotesk', system-ui, sans-serif;
    --transition:    0.12s ease;

    /* Accent -- updated by JS theme engine */
    --color-primary:    #E8541E;   /* brasa terracota: botones, precios, focos */
    --color-secondary:  #C62F10;   /* rojo horno: peligro */
    --color-accent:     #0F7A6A;   /* cobre-patina: el unico frio, para enlaces e info */
    --color-accent-fg:  #FFFCF5;

    /* Marca fija -- brasa y miel, no cambia con el tema del libro */
    --brand-yellow:  #FFAF36;   /* miel ambar (antes amarillo acido) */
    --brand-orange:  #E8541E;   /* brasa terracota */
    --brand-stripe:  repeating-linear-gradient(
        135deg,
        var(--brand-yellow) 0px, var(--brand-yellow) 10px,
        var(--brand-orange) 10px, var(--brand-orange) 20px
    );

    /* Legacy dark-mode compat vars -- mapped to light equivalents */
    --bg-deep:      var(--bg);
    --bg-mid:       var(--bg-inset);
    --bg-card:      #FFFFFF;
    --text-bright:  var(--fg);
    --text-muted:   var(--fg-muted);
    --border-legacy: var(--border);
    --glow:         transparent;
    --gradient-bg:  none;
    --gradient-hero: none;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--fg);
    min-height: 100vh;
    overflow-x: hidden;
    font-size: 15px;
    line-height: 1.5;
}

/* ── Aurora -- reemplazado con fondo plano + patron ── */
.bg-aurora {
    position: fixed;
    inset: 0;
    z-index: 0;
    background: var(--bg);
}

.bg-aurora::before,
.bg-aurora::after { display: none; }

/* ── Layout ── */
.page {
    position: relative;
    z-index: 1;
    min-height: 100vh;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 24px;
}

.container-wide {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
}

/* ── Tipografia ── */
h1, h2, h3, h4 {
    font-family: var(--font-heading);
    font-weight: 700;
    line-height: 1.15;
    letter-spacing: -0.02em;
}

h1 { font-size: clamp(2rem, 5vw, 3.5rem); }
h2 { font-size: clamp(1.4rem, 3vw, 2rem); }
h3 { font-size: 1.15rem; }

.display-title {
    font-family: var(--font-heading);
    font-size: clamp(2.5rem, 6vw, 5rem);
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.05;
    color: var(--fg);
    position: relative;
    display: inline-block;
}

/* Efecto VHS / chromatic aberration retro al pasar el cursor */
.display-title:hover {
    text-shadow:
        2px 0 var(--brand-orange),
        -2px 0 var(--color-accent);
    animation: vhs-jitter 0.25s steps(2, end) 1;
}

@keyframes vhs-jitter {
    0%   { transform: translate(0, 0); }
    25%  { transform: translate(-1px, 1px); }
    50%  { transform: translate(1px, 0); }
    75%  { transform: translate(-1px, -1px); }
    100% { transform: translate(0, 0); }
}

.subtitle {
    font-size: 1.05rem;
    color: var(--fg-muted);
    font-weight: 400;
}

/* ── Cards ── */
.card {
    background: var(--bg-card);
    border: var(--border);
    box-shadow: var(--shadow);
    padding: 28px;
    transition: box-shadow var(--transition), transform var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-lg);
    transform: translate(-1px, -1px);
}

.card-sm { padding: 16px 20px; }

/* ── Formularios ── */
.form-group { margin-bottom: 20px; }

label {
    display: block;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--fg);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 6px;
    font-family: var(--font-mono);
}

input[type="text"],
input[type="password"],
input[type="email"],
textarea,
select {
    width: 100%;
    background: var(--bg-card);
    border: var(--border);
    padding: 12px 16px;
    color: var(--fg);
    font-family: var(--font-body);
    font-size: 0.95rem;
    outline: none;
    transition: box-shadow var(--transition);
    appearance: none;
}

input:focus,
textarea:focus,
select:focus {
    box-shadow: var(--shadow);
    outline: 2px solid var(--color-primary);
    outline-offset: 0;
}

input::placeholder,
textarea::placeholder { color: #A98F74; }

textarea { resize: vertical; min-height: 110px; }

/* ── Hero input ── */
.hero-input {
    font-family: var(--font-body);
    font-size: clamp(1rem, 2.5vw, 1.4rem);
    font-weight: 500;
    background: var(--bg-card);
    border: var(--border);
    box-shadow: var(--shadow);
    padding: 20px 24px;
    color: var(--fg);
    width: 100%;
    outline: none;
    transition: box-shadow var(--transition);
    line-height: 1.5;
}

.hero-input:focus {
    box-shadow: var(--shadow-lg);
    outline: 3px solid var(--color-primary);
    outline-offset: 0;
}

/* ── Placeholder animado tipo maquina de escribir ── */
.hero-input-wrap {
    position: relative;
    background: var(--bg-card);
    box-shadow: var(--shadow);
}

.hero-input-wrap .hero-input {
    box-shadow: none;
}

.hero-input-wrap .hero-input:focus {
    box-shadow: none;
}

.typewriter-overlay {
    position: absolute;
    inset: 0;
    padding: 20px 24px;
    font-family: var(--font-body);
    font-size: clamp(1rem, 2.5vw, 1.4rem);
    font-weight: 500;
    line-height: 1.5;
    pointer-events: none;
    color: #A98F74;
    display: flex;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 0.35em;
    transition: opacity 0.15s ease;
}

.typewriter-overlay.hidden {
    opacity: 0;
}

.typewriter-word {
    font-weight: 800;
    font-family: var(--font-heading);
    font-size: 1.15em;
    color: var(--brand-orange);
}

.typewriter-word.alt { color: var(--brand-yellow); text-shadow: 1px 1px 0 var(--fg); }

.typewriter-cursor {
    display: inline-block;
    margin-left: 1px;
    color: var(--brand-orange);
    animation: cursor-blink 1s steps(1) infinite;
}

/* ── Botones ── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    font-family: var(--font-body);
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    border: var(--border);
    text-decoration: none;
    transition: box-shadow var(--transition), transform var(--transition);
    letter-spacing: 0.02em;
    text-transform: uppercase;
    background: var(--bg-card);
    color: var(--fg);
    box-shadow: var(--shadow-sm);
    white-space: nowrap;
}

.btn:hover {
    box-shadow: var(--shadow);
    transform: translate(-1px, -1px);
}

.btn:active {
    box-shadow: none;
    transform: translate(2px, 2px);
}

.btn-primary {
    background: var(--color-primary);
    color: var(--fg);
    border-color: var(--fg);
    box-shadow: var(--shadow);
}

.btn-primary:hover {
    box-shadow: var(--shadow-lg);
    transform: translate(-2px, -2px);
}

.btn-outline {
    background: transparent;
    border-color: var(--fg);
    color: var(--fg);
}

.btn-ghost {
    background: transparent;
    border-color: transparent;
    box-shadow: none;
    color: var(--fg-muted);
    text-transform: none;
    font-weight: 500;
}

.btn-ghost:hover {
    color: var(--fg);
    box-shadow: none;
    transform: none;
    background: var(--bg-inset);
}

.btn-lg {
    padding: 16px 36px;
    font-size: 1rem;
}

.btn-full { width: 100%; justify-content: center; }

.btn-danger {
    background: var(--color-secondary);
    color: #FFFFFF;
    border-color: var(--fg);
}

/* ── Wizard nav ── */
.wizard-nav {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
    margin-bottom: 40px;
}

.wizard-step {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--fg-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    line-height: 1.3;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: var(--bg-card);
    box-shadow: var(--shadow-sm);
    transition: background var(--transition), color var(--transition), border-color var(--transition);
}

.wizard-step.active {
    background: var(--brand-yellow);
    color: var(--fg);
    border-color: var(--fg);
    box-shadow: 3px 3px 0 var(--brand-orange);
}

.wizard-step.done {
    background: var(--bg-inset);
    color: var(--fg);
}

a.wizard-step {
    text-decoration: none;
    cursor: pointer;
}

a.wizard-step.done:hover {
    background: var(--brand-orange);
    border-color: var(--fg);
    color: var(--fg);
}

.wizard-step-num {
    width: 28px; height: 28px;
    border: 2px solid currentColor;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.78rem;
    font-weight: 700;
    flex-shrink: 0;
    font-family: var(--font-mono);
}

.wizard-step.active .wizard-step-num {
    background: var(--fg);
    color: var(--brand-yellow);
    border-color: var(--fg);
}

.wizard-sep {
    display: none;
}

/* ── Badges ── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    border: var(--border-thin);
    font-family: var(--font-mono);
}

.badge-draft    { background: var(--bg-inset); color: var(--fg-muted); }
.badge-progress {
    background: var(--brand-stripe);
    background-size: 28px 28px;
    color: var(--fg);
    text-shadow: 0 1px 0 rgba(255,255,255,0.5);
}
.badge-done     { background: var(--fg); color: var(--brand-yellow); }

/* ── Loader / "VU meter" retro -- evoca un cassette grabando ── */
.loader {
    position: relative;
    display: inline-block;
    width: 22px;
    height: 18px;
    vertical-align: middle;
    border: none;
    background: var(--brand-orange);
    transform-origin: bottom;
    animation: eq-bar 0.9s ease-in-out infinite 0.15s;
}

.loader::before,
.loader::after {
    content: '';
    position: absolute;
    bottom: 0;
    width: 6px;
    height: 100%;
    background: var(--brand-yellow);
    transform-origin: bottom;
    animation: eq-bar 0.9s ease-in-out infinite;
}

.loader::before { left: -10px; animation-delay: 0s; }
.loader::after  { left: 16px;  animation-delay: 0.35s; }

@keyframes eq-bar {
    0%, 100% { transform: scaleY(0.25); }
    50%      { transform: scaleY(1); }
}

.loader-sm { transform: scale(0.65); transform-origin: bottom center; }
.loader-lg { transform: scale(1.9);  transform-origin: bottom center; }

.loading-overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    background: rgba(251, 241, 224, 0.93);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    overflow: hidden;
}

/* Lineas de escaneo CRT sobre el overlay de carga */
.loading-overlay::before {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: repeating-linear-gradient(
        to bottom,
        rgba(43,29,20,0.05) 0px,
        rgba(43,29,20,0.05) 1px,
        transparent 1px,
        transparent 3px
    );
    animation: scan-move 7s linear infinite;
}

@keyframes scan-move {
    from { transform: translateY(0); }
    to   { transform: translateY(120px); }
}

.loading-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.loading-overlay p {
    font-family: var(--font-mono);
    font-size: 0.9rem;
    color: var(--fg);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    position: relative;
    z-index: 1;
}

/* Cursor parpadeante estilo terminal retro junto al mensaje de carga */
.loading-overlay p::after {
    content: '\2588';
    display: inline-block;
    margin-left: 6px;
    color: var(--brand-orange);
    animation: cursor-blink 1s steps(1) infinite;
}

@keyframes cursor-blink {
    50% { opacity: 0; }
}

/* ── Pilares y capitulos ── */
.pillar-card {
    border-left: 4px solid var(--fg);
    padding-left: 20px;
    margin-bottom: 28px;
}

.pillar-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--fg);
    font-weight: 700;
    margin-bottom: 6px;
    font-family: var(--font-mono);
}

.chapter-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    background: var(--bg-card);
    border: var(--border);
    margin-bottom: 8px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition), transform var(--transition);
}

.chapter-item:hover {
    box-shadow: var(--shadow);
    transform: translate(-1px, -1px);
}

.chapter-num {
    width: 32px; height: 32px;
    background: var(--fg);
    border: none;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--bg);
    flex-shrink: 0;
    font-family: var(--font-mono);
}

/* ── Ilustraciones ── */
.illus-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 14px;
}

.illus-option {
    position: relative;
    aspect-ratio: 3/4;
    overflow: hidden;
    border: var(--border);
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition), transform var(--transition);
}

.illus-option:hover {
    box-shadow: var(--shadow);
    transform: translate(-1px, -1px);
}

.illus-option.selected {
    border-color: var(--fg);
    box-shadow: var(--shadow-lg);
    outline: 3px solid var(--color-primary);
}

.illus-option img {
    width: 100%; height: 100%;
    object-fit: cover;
}

.illus-check {
    position: absolute;
    top: 6px; right: 6px;
    width: 22px; height: 22px;
    background: var(--fg);
    display: none;
    align-items: center; justify-content: center;
    font-size: 11px;
    color: var(--color-primary);
    font-weight: 700;
    font-family: var(--font-mono);
}

.illus-option.selected .illus-check { display: flex; }

/* ── Alertas ── */
.alert {
    padding: 12px 16px;
    font-size: 0.88rem;
    margin-bottom: 16px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    border: var(--border);
    font-weight: 500;
}

.alert-info    { background: #E4F0EC; border-left: 4px solid var(--color-accent); }
.alert-warning { background: #FCEFD3; border-left: 4px solid var(--brand-orange); }
.alert-error   { background: #FBE4DB; border-left: 4px solid #C62F10; }
.alert-success { background: #E9F1E0; border-left: 4px solid #55803B; }

/* ── Input con boton de accion ── */
.input-with-action { position: relative; }
.input-with-action input { padding-right: 48px; }

.input-action-btn {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--fg-muted);
    cursor: pointer;
    padding: 4px;
    font-size: 1rem;
    transition: color var(--transition);
}

.input-action-btn:hover { color: var(--fg); }

/* ── Header ── */
.app-header {
    padding: 16px 0;
    border-bottom: var(--border);
    margin-bottom: 40px;
    background: var(--bg-card);
    box-shadow: 0 2px 0 var(--border-color);
}

.app-header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.app-logo {
    font-family: var(--font-mono);
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--fg);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
    text-transform: uppercase;
    letter-spacing: -0.01em;
}

.app-logo span {
    background: linear-gradient(135deg, var(--brand-yellow) 0%, var(--brand-yellow) 50%, var(--brand-orange) 50%, var(--brand-orange) 100%);
    color: var(--fg);
    padding: 2px 6px;
    font-weight: 700;
}

/* ── Toast / Notificaciones ── */
.toast {
    position: fixed;
    bottom: 24px;
    left: 24px;
    z-index: 200;
    background: var(--fg);
    color: var(--bg);
    padding: 12px 20px;
    border: var(--border);
    border-left: 6px solid var(--brand-orange);
    box-shadow: var(--shadow);
    font-size: 0.875rem;
    font-weight: 600;
    font-family: var(--font-mono);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    max-width: 320px;
    animation: toast-in 0.15s ease;
}

.toast.toast-error {
    background: #C62F10;
    color: #FFFCF5;
    border-left-color: var(--brand-yellow);
}

.toast.toast-success {
    background: #55803B;
    color: #FFFCF5;
    border-left-color: var(--brand-yellow);
}

@keyframes toast-in {
    from { transform: translateY(12px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}

/* ── Icono "VU meter" -- mini ecualizador retro, usado como logo / marcador ── */
.eq-icon {
    display: inline-flex;
    align-items: flex-end;
    gap: 2px;
    height: 1em;
    width: 1.1em;
    vertical-align: -0.15em;
}
.eq-icon i {
    display: block;
    width: 3px;
    flex: 1;
    background: var(--brand-orange);
    animation: eq-bar 1.1s ease-in-out infinite;
}
.eq-icon i:nth-child(1) { height: 40%; background: var(--brand-yellow); animation-delay: 0s; }
.eq-icon i:nth-child(2) { height: 100%; animation-delay: 0.2s; }
.eq-icon i:nth-child(3) { height: 65%; background: var(--brand-yellow); animation-delay: 0.4s; }

/* ── Utilidades ── */
.text-primary  { color: var(--fg); }
.text-muted    { color: var(--fg-muted); }
.text-accent   { color: var(--color-accent); }
.text-orange   { color: var(--brand-orange); }
.text-yellow   { color: var(--brand-yellow); }
.mt-4  { margin-top: 16px; }
.mt-6  { margin-top: 24px; }
.mt-8  { margin-top: 32px; }
.mt-12 { margin-top: 48px; }
.mb-4  { margin-bottom: 16px; }
.mb-6  { margin-bottom: 24px; }
.mb-8  { margin-bottom: 32px; }
.flex  { display: flex; }
.items-center    { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.gap-6 { gap: 24px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.text-center { text-align: center; }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.font-bold { font-weight: 700; }
.opacity-60 { opacity: 0.6; }
.hidden { display: none !important; }

/* ── Divisor -- franja retro amarillo/naranja ── */
.divider {
    height: 4px;
    background: var(--brand-stripe);
    background-size: 24px 24px;
    margin: 28px 0;
    border: var(--border-thin);
}

/* ── Progress bar ── */
.progress-bar {
    height: 8px;
    background: var(--bg-inset);
    border: var(--border-thin);
    overflow: hidden;
    margin-bottom: 6px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--brand-yellow), var(--brand-orange));
    transition: width 0.4s ease;
}

/* ── Responsive ── */
@media (max-width: 640px) {
    .container, .container-wide { padding: 0 16px; }
    .card { padding: 16px; }
    .grid-2 { grid-template-columns: 1fr; }
    .illus-grid { grid-template-columns: repeat(2, 1fr); }
    .btn-lg { padding: 14px 20px; }
    .wizard-nav { grid-template-columns: repeat(2, 1fr); }
}
