/* ============================================
   RESET & BASE STYLES
   ============================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Crombie Color Palette */
    --color-background: #000000;
    --color-foreground: #ffffff;
    --color-primary: #FFD700;
    --color-primary-foreground: #000000;
    --color-secondary: #888888;
    --color-muted: #161616;
    --color-muted-foreground: #888888;
    --color-accent: #33c566;
    --color-success: #33c566;
    --color-destructive: #ef4444;
    --color-warning: #f59e0b;
    --color-border: #333333;
    --color-input: #161616;
    --color-card: #161616;
    
    /* Fonts */
    --font-hanken: 'Hanken Grotesk', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-urbanist: 'Urbanist', sans-serif;

    /* Spacing */
    --radius: 0.5rem;
    --content-max-width: 1200px;
}

body {
    font-family: var(--font-hanken);
    background-color: var(--color-background);
    color: var(--color-foreground);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    background-image: url('../images/crombie-background-rounded.png');
    background-repeat: no-repeat;
    background-position: calc(100% - 120px) top;
    background-size: 25%;
}

/* ============================================
   HEADER STYLES
   ============================================ */
.site-header {
    position: relative;
    z-index: 100;
    padding: 24px 0;
}

.header-container {
    display: flex;
    align-items: center;
}

.logo-link {
    display: inline-flex;
    align-items: center;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.logo-link:hover {
    transform: scale(1.04);
}

.logo-link:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 4px;
}

.site-logo {
    height: 60px;
    width: auto;
}

@media (max-width: 768px) {
    .site-header {
        padding: 16px 0;
    }

    .site-logo {
        height: 44px;
    }
}

/* ============================================
   TOPBAR STYLES
   ============================================ */
.topbar {
    position: absolute;
    top: 16px;
    left: 6rem;
    right: 2rem;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--color-border);
    padding: 16px 0;
}

.topbar-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.brand-link {
    text-decoration: none;
    margin-left: 3rem;
}

.brand-large {
    height: 50px;
    width: auto;
    display: block;
    filter: drop-shadow(0 4px 14px rgba(0,0,0,.45));
}

@media (max-width: 768px) {
    .brand-large {
        height: 40px;
        background-image: url('../images/recurso4.png');
        background-repeat: no-repeat;
        background-position: right 24px bottom 0px;
        background-size: 180px auto;
        min-height: 180px;
        gap: 1rem;
    }
    .hero-title {
        font-size: 2.5rem;
    }
}

.topbar-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--color-muted-foreground);
    text-decoration: none;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 12px 16px;
    font-weight: 500;
    transition: all 0.2s ease;
    background: var(--color-muted);
}

.topbar-link:hover {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: var(--color-primary-foreground);
    transform: translateY(-1px);
}

.back-link {
    margin: 0;
}

/* ============================================
   HERO SECTION
   ============================================ */
.hero-section {
    width: 100%;
    background: none;
    padding: 4rem 0 2rem;
    text-align: left;
    position: relative;
    z-index: 10;
}


.hero-content {
    position: relative;
    z-index: 1;
}


.hero-header {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    justify-items: center;
    gap: 1rem;
    margin-bottom: 2rem;
}

.hero-title {
    font-family: var(--font-urbanist);
    font-size: clamp(32px, 8vw, 64px);
    font-weight: 700;
    color: var(--color-foreground);
    margin-bottom: 1.5rem;
    letter-spacing: -0.02em;
    line-height: 1.1;
}

.hero-subtitle {
    font-size: 1.125rem;
    color: var(--color-secondary);
    font-weight: 500;
    font-family: var(--font-hanken);
    max-width: 800px;
}

/* ============================================
   APPLICATIONS SECTION
   ============================================ */
.applications-section {
    padding: 2rem 1rem;
}

.applications-card {
    background-color: var(--color-card);
    border: 2px solid var(--color-border);
    border-radius: var(--radius);
    padding: 2rem;
    max-width: 750px;
    margin: 0 auto;
    position: relative;
    z-index: 30;
}

.applications-title {
    font-family: var(--font-urbanist);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-foreground);
    margin-bottom: 1.5rem;
    text-align: left;
}

.applications-content {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    text-align: left;
}

.applications-content p {
    color: var(--color-secondary);
    line-height: 1.7;
    font-family: var(--font-hanken);
}

.applications-example {
    margin-top: 1.5rem;
    padding: 1.5rem;
    background: rgba(253, 185, 19, 0.05);
    border: 1px solid rgba(253, 185, 19, 0.2);
    border-radius: 0.75rem;
    border-left: 4px solid var(--color-primary);
    text-align: center;
}

.font-semibold {
    font-weight: 600;
}

/* ============================================
   CONTAINER & MAIN CONTENT
   ============================================ */
.container {
    max-width: var(--content-max-width);
    margin: 0 auto;
    padding: 0 2rem;
}

@media (max-width: 768px) {
    .container {
        padding: 0 1rem;
    }

    .hero-section {
        padding: 3rem 0 1.5rem;
    }
}

.main-content {
    padding: 2rem 0 4rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* ============================================
   CARD COMPONENTS
   ============================================ */
.card {
    background-color: var(--color-card);
    border: 2px solid var(--color-border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
    border-color: rgba(253, 185, 19, 0.3);
}

.card-header {
    padding: 2rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.02);
}

.card-title {
    font-family: var(--font-urbanist);
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--color-foreground);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.card-description {
    color: var(--color-secondary);
    font-size: 0.95rem;
    font-family: var(--font-hanken);
}

.card-content {
    padding: 2rem;
}

/* ============================================
   FORM STYLES
   ============================================ */
.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    font-weight: 500;
    font-size: 0.95rem;
    color: var(--color-foreground);
    margin-bottom: 0.5rem;
}

.form-input {
    width: 100%;
    padding: 1rem 1.25rem;
    font-size: 1.125rem;
    font-family: monospace;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 0.75rem;
    color: var(--color-foreground);
    transition: all 0.3s ease;
    backdrop-filter: blur(5px);
}

.form-input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(253, 185, 19, 0.2);
    background: rgba(255, 255, 255, 0.08);
    transform: translateY(-1px);
}

.form-input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.form-hint {
    margin-top: 0.5rem;
    font-size: 0.8rem;
    color: var(--color-muted-foreground);
}

/* ============================================
   BUTTONS
   ============================================ */
.btn-primary {
    width: 100%;
    padding: 1.5rem 2rem;
    font-size: 1.125rem;
    font-weight: 600;
    background: linear-gradient(135deg, var(--color-primary) 0%, #e5a610 100%);
    color: var(--color-primary-foreground);
    border: none;
    border-radius: 0.75rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    box-shadow: 0 4px 20px rgba(253, 185, 19, 0.3);
    position: relative;
    overflow: hidden;
}

.btn-primary::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s ease;
}

.btn-primary:hover::before {
    left: 100%;
}

.btn-primary:hover:not(:disabled) {
    background: linear-gradient(135deg, #e5a610 0%, var(--color-primary) 100%);
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(253, 185, 19, 0.4);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    background-color: var(--color-muted);
    color: var(--color-foreground);
    border: 1px solid var(--color-border);
    border-radius: calc(var(--radius) - 0.25rem);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background-color: var(--color-border);
}

/* ============================================
   ICONS
   ============================================ */
.icon {
    width: 1.25rem;
    height: 1.25rem;
    color: var(--color-primary);
}

.icon-large {
    width: 3rem;
    height: 3rem;
}

/* ============================================
   LOADING STATE
   ============================================ */
.loading-card {
    border-color: var(--color-border);
    background-color: var(--color-card);
}

.loading-content {
    display: flex;
    align-items: flex-start;
    gap: 1.5rem;
    padding: 1rem 0;
}

.loading-spinner-wrapper {
    position: relative;
    width: 4rem;
    height: 4rem;
}

.loading-spinner {
    position: absolute;
    width: 4rem;
    height: 4rem;
    border: 4px solid rgba(255, 215, 0, 0.2);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading-spinner .icon-large {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

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

.loading-text {
    flex: 1;
}

.loading-title {
    font-family: var(--font-urbanist);
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--color-primary);
    margin-bottom: 0.5rem;
}

.loading-subtitle {
    color: var(--color-secondary);
    font-size: 0.95rem;
    font-family: var(--font-hanken);
}

.spinner {
    width: 1.25rem;
    height: 1.25rem;
    animation: spin 1s linear infinite;
}

/* ============================================
   RESULTS DISPLAY
   ============================================ */
.result-content {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.result-main {
    text-align: left;
}

.result-name {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--color-foreground);
    margin-bottom: 0.5rem;
}

.result-question {
    color: var(--color-muted-foreground);
    font-weight: 500;
    font-size: 1.5rem;
    margin-bottom: 1rem;
    line-height: 1.4;
}

.result-cuil-label {
    color: var(--color-muted-foreground);
    font-size: 0.95rem;
    margin-bottom: 1rem;
}

.result-decision {
    font-family: var(--font-urbanist);
    font-size: 2.5rem;
    font-weight: 800;
    margin-top: 0.5rem;
}

.result-decision.success {
    color: var(--color-success);
}

.result-decision.error {
    color: var(--color-destructive);
}

.result-score-section {
    text-align: left;
}

.result-score-label {
    color: var(--color-muted-foreground);
    font-size: 0.95rem;
    margin-bottom: 0.5rem;
}

/* ============================================
   RISK PROGRESS BAR
   ============================================ */
.risk-progress-container {
    margin-top: 2rem;
    width: 100%;
}

.risk-progress-bar {
    position: relative;
    width: 100%;
    height: 2rem;
    background-color: var(--color-muted);
    border-radius: 1rem;
    overflow: hidden;
    border: 2px solid var(--color-border);
}

.risk-progress-sectors {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    z-index: 1;
}

.sector {
    height: 100%;
    opacity: 0.3;
}

.sector-safe {
    width: 30%;
    background: linear-gradient(90deg, #27ae60 0%, #2ecc71 80%, #52c97a 100%);
}

.sector-caution {
    width: 30%;
    background: linear-gradient(90deg, #52c97a 0%, #f39c12 50%, #e67e22 100%);
}

.sector-danger {
    width: 40%;
    background: linear-gradient(90deg, #e67e22 0%, #e74c3c 100%);
}

.risk-progress-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 0%;
    background-color: transparent;
    border-radius: 1rem;
    transition: width 1.5s cubic-bezier(0.65, 0, 0.35, 1), background-color 0.3s ease;
    z-index: 2;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.2);
}

/* Dynamic background based on score - will be set via JS */
.risk-progress-fill.fill-safe {
    background: linear-gradient(90deg, #27ae60 0%, #2ecc71 100%);
    box-shadow: 0 0 15px rgba(39, 174, 96, 0.5);
}

.risk-progress-fill.fill-caution {
    background: linear-gradient(90deg, #27ae60 0%, #2ecc71 30%, #f39c12 60%, #e67e22 100%);
    box-shadow: 0 0 15px rgba(243, 156, 18, 0.5);
}

.risk-progress-fill.fill-danger {
    background: linear-gradient(90deg, #27ae60 0%, #2ecc71 20%, #f39c12 40%, #e67e22 60%, #e74c3c 100%);
    box-shadow: 0 0 15px rgba(231, 76, 60, 0.5);
}

.risk-progress-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.label-safe {
    color: #27ae60;
    width: 30%;
    text-align: left;
}

.label-caution {
    color: #f39c12;
    width: 30%;
    text-align: center;
}

.label-danger {
    color: #e74c3c;
    width: 40%;
    text-align: right;
}

.risk-progress-markers {
    display: flex;
    justify-content: space-between;
    margin-top: 0.25rem;
    font-size: 0.7rem;
    color: var(--color-muted-foreground);
    font-family: monospace;
}

.marker {
    width: 25%;
    text-align: left;
}

.marker:last-child {
    text-align: right;
    padding-left: 1.5rem;
}

.marker:nth-child(2),
.marker:nth-child(3) {
    text-align: center;
}

/* Animation for progress fill */
@keyframes fillProgress {
    from {
        width: 0%;
    }
}

.risk-progress-fill.animating {
    animation: fillProgress 1.5s cubic-bezier(0.65, 0, 0.35, 1);
}

.result-score {
    font-family: var(--font-urbanist);
    font-size: 3.75rem;
    font-weight: 800;
    color: var(--color-primary);
    line-height: 1;
    transition: color 0.5s ease;
}

/* Dynamic color based on score value */
.result-score.score-very-low {
    color: #27ae60; /* Verde oscuro: 0-15% */
}

.result-score.score-low {
    color: #2ecc71; /* Verde claro: 15-30% */
}

.result-score.score-medium {
    color: #f39c12; /* Amarillo: 30-50% */
}

.result-score.score-high {
    color: #e67e22; /* Naranja: 50-70% */
}

.result-score.score-critical {
    color: #e74c3c; /* Rojo: 70-100% */
}

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

.metric-card {
    padding: 1rem;
    background-color: var(--color-card);
    border: 1px solid var(--color-border);
    border-radius: calc(var(--radius) - 0.25rem);
    text-align: left;
}

.metric-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-foreground);
    font-family: var(--font-urbanist);
}

.metric-label {
    font-size: 0.875rem;
    color: var(--color-muted-foreground);
    margin-top: 0.25rem;
}

/* ============================================
   ERROR STATE
   ============================================ */
.error-card {
    border-color: var(--color-border);
    background-color: var(--color-card);
}

.error-content {
    text-align: center;
    padding: 2rem 1rem;
}

.error-icon {
    color: var(--color-destructive);
    margin: 0 auto 1rem;
}

.error-title {
    font-family: var(--font-urbanist);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-destructive);
    margin-bottom: 0.5rem;
}

.error-message {
    color: var(--color-secondary);
    margin-bottom: 1.5rem;
    font-family: var(--font-hanken);
}

/* ============================================
   DISCLAIMER SECTION
   ============================================ */
.disclaimer-section {
    padding: 2rem 1rem;
    background-color: var(--color-background);
    margin-top: 2rem;
    position: relative; /* allow absolute positioning inside footer */
}

.disclaimer-card {
    padding: 1.5rem;
    background-color: transparent;
    border: none;
    border-radius: var(--radius);
}

.disclaimer-text {
    font-style: italic;
    color: var(--color-foreground);
    line-height: 1.7;
    text-align: left;
    font-size: 0.875rem;
    font-family: var(--font-hanken);
}

/* Footer bottom meta row */
.footer-bottom {
    background-image: url('../images/recurso4.png');
    background-repeat: no-repeat;
    background-position: right 24px bottom 0px;
    background-size: 180px auto;
    min-height: 180px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1rem;
    font-size: 0.9rem;
    color: var(--color-foreground);
}

.footer-links {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.footer-links a {
    color: var(--color-foreground);
    text-decoration: none;
    padding: 0 0.125rem;
}

.footer-links a + a::before {
    content: "";
    margin: 0;
}

.footer-links a:hover {
    text-decoration: underline;
}

/* ============================================
   DECORATIVE ASSETS
   ============================================ */
.decorative-area {
    /* occupies the vertical gap between content and footer */
    height: 4rem; /* give vertical room so images can be at different heights */
    position: relative;
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 24px;
    pointer-events: none; /* decorative only */
}

.decorative {
    position: absolute;
    width: clamp(48px, 6vw, 110px);
    height: auto;
    opacity: 0.95;
    transform-origin: center;
    filter: drop-shadow(0 6px 18px rgba(0,0,0,0.35));
}

/* Positions: spaced across the gap, avoid overlapping main content or footer */
.dec-1 { left: 6%; top: -20px; transform: rotate(-18deg); z-index: 5; }
.dec-2 { right: 6%; top: -4px; transform: rotate(10deg); z-index: 5; }
.dec-3 { left: 50%; top: 20px; transform: translateX(-50%) rotate(12deg); z-index: 5; }

/* dec-footer sits inside the footer */
.dec-footer {
    position: absolute;
    bottom: 12px;
    right: 6%;
    /* increased 100%: doubled min/viewport/max to make image 2x larger */
    width: clamp(96px, 12vw, 240px);
    height: auto;
    opacity: 0.95;
    transform: rotate(-6deg);
    pointer-events: none;
    z-index: 25;
}

/* Make sure decorative items never cover interactive content */
.applications-card, .card { position: relative; z-index: 30; }

@media (max-width: 768px) {
    .decorative-area { height: 2rem; padding: 0 12px; }
    .decorative { width: clamp(36px, 10vw, 72px); }
    .dec-3 { top: -3%; }
}

/* Mid-page decorative shapes */
.mid-decorative {
    position: absolute;
    left: 0;
    right: 0;
    top: 45%; /* roughly middle of page */
    height: 0;
    pointer-events: none;
    z-index: 8; /* below cards (30) but above background */
}

.mid {
    position: absolute;
    width: clamp(64px, 8vw, 140px);
    height: auto;
    opacity: 0.95;
    filter: drop-shadow(0 10px 20px rgba(0,0,0,0.28));
}

.decorative-mid-1 { left: 6%; top: -12%; transform: translateY(-50%) rotate(-8deg); }
.decorative-mid-2 { right: 6%; transform: translateY(-30%) rotate(14deg); }

@media (max-width: 768px) {
    .mid { width: clamp(42px, 18vw, 80px); }
    .decorative-mid-1 { left: 8%; top: -6%; }
    .decorative-mid-2 { right: 8%; }
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */
@media (min-width: 769px) {
    .desktop-only {
        display: block !important;
    }
}

@media (max-width: 768px) {
    .desktop-only {
        display: none !important;
    }
    
    .hero-title {
        font-size: clamp(28px, 8vw, 48px);
    }

    .hero-subtitle {
        font-size: 1rem;
    }

    .applications-card {
        padding: 1.5rem;
    }

    .applications-title {
        font-size: 1.25rem;
    }

    .result-question {
        font-size: 1.125rem;
    }

    .result-score {
        font-size: 2.5rem;
    }

    .result-decision {
        font-size: 1.75rem;
    }

    .metrics-grid {
        grid-template-columns: 1fr;
    }

    .risk-progress-labels {
        font-size: 0.65rem;
    }

    .risk-progress-markers {
        font-size: 0.6rem;
    }

    /* Reduce footer gap on small screens */
    .disclaimer-section {
        margin-top: 1rem;
    }
}

/* ============================================
   ANIMATIONS
   ============================================ */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

.card {
    animation: fadeIn 0.3s ease-out;
}

.result-score.animating {
    animation: pulse 0.3s ease-in-out;
}

/* ============================================
   UTILITY CLASSES
   ============================================ */
.text-center {
    text-align: center;
}

.text-left {
    text-align: left;
}

.hidden {
    display: none !important;
}
