/**
 * Base CSS for WebsiteBase project.
 *
 * This stylesheet uses CSS custom properties (variables) that can be
 * dynamically set from branding.py values via inline styles in templates,
 * or can be customized per client deployment.
 *
 * The design follows modern, clean principles with responsive layout.
 */

/* Self-hosted heading font: Knockout Bold */
@font-face {
    font-family: "Knockout";
    src: url("/static/fonts/Knockout-Bold.otf") format("opentype");
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

/* Fallback vars; branding in base.html can override. --font-primary always defined here. */
:root {
    --font-heading: 'Knockout', 'Oswald', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-primary: 'Work Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-secondary: 'Work Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    --color-primary: #ff4c3e;
    --color-primary-hover: #e63e30;
    --primary-color: #ff4c3e;
    --secondary-color: #e9967a;
    --background-color: #fafaf9;
    --surface-color: #f5f5f4;
    --text-primary: #1c1917;
    --text-secondary: #78716c;
    --success-color: #059669;
    --error-color: #dc2626;
    --container-max-width: 1200px;
    --border-radius: 10px;
    --header-height: 64px;
    --footer-height: 120px;
}

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-primary);
    color: var(--text-primary);
    background-color: var(--background-color);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Titulares — Knockout Bold, uppercase */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    text-transform: uppercase;
}

/* Container — 1200px max, no side padding/margin; content flush to edges */
.container {
    max-width: var(--container-max-width);
    margin: 0 auto;
    padding: 0;
}

@media (max-width: 767px) {
    .container {
        padding-inline: var(--layout-gutter-mobile, 1rem);
        box-sizing: border-box;
    }

    .header-inner {
        min-width: 0;
        gap: 0.5rem;
    }

    .logo-link {
        min-width: 0;
        flex: 0 1 auto;
    }
}

/* Header — logo left (fixed size), single CTA right */
.site-header {
    background-color: var(--background-color);
    border: none;
    box-shadow: none;
    min-height: var(--header-height);
    display: flex;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
}

.logo-link {
    display: flex;
    align-items: center;
    text-decoration: none;
    color: var(--text-primary);
    font-weight: 700;
    font-size: 1.25rem;
    line-height: 1;
}

.logo-img {
    display: block;
    width: auto;
    object-fit: contain;
    object-position: left center;
    transition: filter 0.25s ease;
}

@media (max-width: 767px) {
    /* Mismo tamaño que .landing-footer__logo (variables.css) */
    .logo-img {
        height: var(--logo-mobile-height, 32px);
        max-width: var(--logo-mobile-max-width, min(160px, calc(100vw - 4rem)));
    }
}

@media (min-width: 768px) {
    .logo-img {
        height: 40px;
        max-width: 180px;
    }
}

.logo-text {
    font-family: var(--font-heading);
    color: var(--primary-color);
    font-size: 1.25rem;
    text-transform: uppercase;
    transition: color 0.25s ease;
}

.nav-cta {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.nav-cta .nav-link {
    margin-right: 1rem;
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 500;
}
.nav-cta .nav-link:hover {
    color: var(--color-primary);
}
.nav-cta .btn-primary {
    white-space: nowrap;
}

/* Hamburger toggle — same position in navbar, toggles open/close icon */
.nav-menu-toggle {
    display: flex;
    align-items: center;
    justify-content: right;
    
    height: 44px;
    margin-left: 1rem;
    padding: 0;
    border: none;
    background: transparent;
    color: var(--text-primary);
    cursor: pointer;
    border-radius: 8px;
    transition: color 0.2s;
}

@media (max-width: 767px) {
    .nav-menu-toggle {
        margin-left: 0.4rem;
    }
}

.nav-menu-toggle:hover {
    color: var(--color-primary);
}
.nav-menu-toggle:focus,
.nav-menu-toggle:focus-visible {
    outline: none;
}
.nav-menu-toggle:focus-visible {
    color: var(--color-primary);
}
.nav-menu-toggle__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}
.nav-menu-toggle__icon--close {
    display: none;
}
body.nav-overlay-open .nav-menu-toggle__icon--open {
    display: none;
}
body.nav-overlay-open .nav-menu-toggle__icon--close {
    display: flex;
    font-size: 1.85rem;
}

body.nav-overlay-open .nav-menu-toggle {
    color: #fff;
}
body.nav-overlay-open .nav-menu-toggle:hover {
    color: var(--color-primary);
}
body.nav-overlay-open .nav-menu-toggle:focus-visible {
    color: var(--color-primary);
}

/* Navbar logo legible sobre el overlay oscuro — misma caja que siempre */
body.nav-overlay-open .logo-img {
    filter: brightness(0) invert(1);
}
body.nav-overlay-open .logo-text {
    color: #fff;
}

/* Full-screen nav overlay — fondo oscuro, debajo del header (header z-index encima) */
.nav-overlay {
    position: fixed;
    inset: 0;
    z-index: 999;
    background-color: #131313;
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}
.nav-overlay--open {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
}
body.nav-overlay-open {
    overflow: hidden;
}

.nav-overlay__inner {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100svh;
    padding: calc(var(--header-height) + 1rem) 0 0;
    padding-left: var(--layout-gutter-mobile, 1rem);
    padding-right: 0;
    padding-bottom: max(1.5rem, env(safe-area-inset-bottom, 0px));
}

/* Ocupa el espacio entre header y redes; centra el bloque de enlaces en ese área (independiente del footer social) */
.nav-overlay__links {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    align-self: stretch;
    gap: 0;
    min-height: 0;
    width: 100%;
    max-width: min(22rem, 100%);
    margin: 0 auto;
}

.nav-overlay__link {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    width: 100%;
    padding: 1.1rem 0;
    margin: 0;
    background: transparent;
    color: #fff;
    font-family: var(--font-heading);
    font-size: clamp(1.65rem, 5.5vw, 2.65rem);
    font-weight: 700;
    text-transform: uppercase;
    text-decoration: none;
    letter-spacing: -0.02em;
    border: none;
    border-radius: 0;
    border-bottom: 3px solid rgba(255, 255, 255, 0.14);
    transition: color 0.2s ease, border-color 0.2s ease, opacity 0.2s ease;
}
.nav-overlay__link:last-child {
    border-bottom: none;
}
.nav-overlay__link:hover {
    color: rgba(255, 255, 255, 0.92);
    border-bottom-color: rgba(255, 255, 255, 0.28);
}
.nav-overlay__num {
    color: rgba(255, 255, 255, 0.88);
    font-size: clamp(0.95rem, 2.8vw, 1.35rem);
    font-weight: 700;
    min-width: 2ch;
    text-align: right;
}
.nav-overlay__inner > .nav-overlay__social {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    flex-shrink: 0;
    gap: 0.75rem;
    width: 100%;
    max-width: var(--container-max-width);
    margin-left: auto;
    margin-right: auto;
    padding-top: 0.5rem;
    padding-bottom: 0.25rem;
}

.nav-overlay__social-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--surface-secondary);
    border: 1px solid rgba(255, 255, 255, 0.06);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 1.125rem;
    transition: background 0.2s, color 0.2s, transform 0.15s ease;
}
.nav-overlay__social-link:hover {
    background: #2e2e2e;
    color: #e7e5e4;
    transform: translateY(-1px);
}

/* Messages */
.messages-container {
    padding: 1rem 0;
}

/* Honeypot field: visually hidden (no display:none) */
.hp-field {
    position: absolute;
    left: -9999px;
    opacity: 0;
    height: 1px;
    width: 1px;
    pointer-events: none;
}

.alert {
    padding: 1rem;
    border-radius: var(--border-radius);
    margin-bottom: 1rem;
}

.alert-success {
    background-color: #d1fae5;
    color: #065f46;
    border: 1px solid var(--success-color);
}

.alert-error {
    background-color: #fee2e2;
    color: #991b1b;
    border: 1px solid var(--error-color);
}

/* Landing page uses landing.css for .landing-hero, .landing-section, hero-* */

.section-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 3rem;
    align-items: start;
}

@media (max-width: 768px) {
    .section-content {
        grid-template-columns: 1fr;
    }
}

.content-column h2 {
    font-size: 2rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.feature-list {
    list-style: none;
    margin-top: 1.5rem;
}

.feature-list li {
    padding: 0.5rem 0;
    color: var(--text-secondary);
}

/* Form Styles */
.form-card {
    background: var(--surface-color);
    padding: 2rem;
    border-radius: var(--border-radius);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.form-card h3 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.form-subtitle {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

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

.form-group {
    display: flex;
    flex-direction: column;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

@media (max-width: 480px) {
    .form-row {
        grid-template-columns: 1fr;
    }
}

.form-group label {
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.form-input,
.form-textarea {
    padding: 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: var(--border-radius);
    font-family: var(--font-primary);
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-input:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.15);
}

.form-textarea {
    resize: vertical;
    min-height: 100px;
}

.form-error {
    color: var(--error-color);
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

.form-help {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

.form-actions {
    margin-top: 1rem;
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--border-radius);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
}

.btn-primary {
    background-color: var(--primary-color);
    color: #fafaf9;
}

.btn-primary:hover {
    background-color: var(--color-primary-hover);
    color: #fafaf9;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.btn-primary:active {
    transform: translateY(0);
}

/* HTMX Indicator */
.htmx-indicator {
    display: none;
}

.htmx-request .htmx-indicator {
    display: inline-block;
}

.spinner {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

/* Form Success */
.form-success {
    text-align: center;
    padding: 2rem;
}

.success-icon {
    width: 64px;
    height: 64px;
    background-color: var(--success-color);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    margin: 0 auto 1rem;
}

.form-success h3 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.form-success p {
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.success-email {
    margin-top: 1rem;
    font-weight: 500;
}

.success-note {
    font-size: 0.875rem;
    margin-top: 1rem;
    color: var(--text-secondary);
}

/* Features Grid */
.landing-features {
    padding: 4rem 0;
    background-color: var(--surface-color);
}

.section-title {
    text-align: center;
    font-size: 2rem;
    margin-bottom: 3rem;
    color: var(--text-primary);
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
}

.feature-card {
    background: var(--background-color);
    padding: 2rem;
    border-radius: var(--border-radius);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.feature-card h3 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
    color: var(--primary-color);
}

.feature-card p {
    color: var(--text-secondary);
}

/* Footer */
.site-footer {
    background-color: var(--text-primary);
    color: white;
    padding: 3rem 0 1.5rem;
    margin-top: 4rem;
}

.footer-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

.footer-section h3,
.footer-section h4 {
    margin-bottom: 1rem;
}

.footer-section p {
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: 0.5rem;
}

.footer-section a {
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    transition: color 0.2s;
}

.footer-section a:hover {
    color: white;
}

.social-links {
    display: flex;
    gap: 1rem;
}

.footer-bottom {
    text-align: center;
    padding-top: 2rem;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.6);
}

/* Responsive Design */
@media (max-width: 768px) {
    .form-card {
        padding: 1.5rem;
    }
}

/* Newsletter success modal — shown after subscribe via HTMX (no redirect) */
.newsletter-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    visibility: hidden;
    opacity: 0;
    transition: visibility 0.2s, opacity 0.2s;
}

.newsletter-modal.newsletter-modal--open {
    visibility: visible;
    opacity: 1;
}

.newsletter-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    cursor: pointer;
}

.newsletter-modal__box {
    position: relative;
    background: var(--surface-color);
    color: var(--text-primary);
    padding: 2rem;
    border-radius: var(--border-radius);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    max-width: 420px;
    width: 100%;
    text-align: center;
}

.newsletter-modal__title {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    margin-bottom: 0.75rem;
    text-transform: uppercase;
}

.newsletter-modal__text {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.newsletter-modal__close {
    cursor: pointer;
}
