/* ================================================================
   HAWAII ORGANIC CERTIFICATION SURVEY
   Matches Observatory dashboard design system
   ================================================================ */

/* === DARK THEME (Default) === */
:root,
[data-theme="dark"] {
    --bg-deep: #0d0d0d;
    --bg-surface: #161616;
    --bg-elevated: #1e1e1e;
    --bg-panel: #242424;
    --bg-hover: #2a2a2a;
    --accent-terracotta: #E07A5F;
    --accent-ochre: #F4A259;
    --accent-sage: #81B29A;
    --accent-ocean: #3D85C6;
    --text-primary: #FAFAF9;
    --text-secondary: #A8A8A6;
    --text-muted: #6B6B69;
    --text-accent: var(--accent-terracotta);
    --border-subtle: rgba(255, 255, 255, 0.06);
    --border-medium: rgba(255, 255, 255, 0.1);
    --border-glow: rgba(224, 122, 95, 0.3);
    --positive: #81B29A;
    --negative: #E07A5F;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);
    --header-bg: rgba(22, 22, 22, 0.8);
    --input-bg: #1a1a1a;
    --input-border: rgba(255, 255, 255, 0.12);
    --input-focus: var(--accent-terracotta);
    --radio-bg: #2a2a2a;
    --radio-checked: var(--accent-terracotta);
    --orb-opacity: 0.4;
}

[data-theme="light"] {
    --bg-deep: #F8F6F3;
    --bg-surface: #FFFFFF;
    --bg-elevated: #FAFAF8;
    --bg-panel: #F0EDE8;
    --bg-hover: #E8E4DD;
    --accent-terracotta: #D66853;
    --accent-ochre: #E8934A;
    --accent-sage: #6A9B84;
    --accent-ocean: #3574B0;
    --text-primary: #1A1A18;
    --text-secondary: #4A4A48;
    --text-muted: #7A7A78;
    --text-accent: var(--accent-terracotta);
    --border-subtle: rgba(0, 0, 0, 0.06);
    --border-medium: rgba(0, 0, 0, 0.1);
    --border-glow: rgba(214, 104, 83, 0.3);
    --positive: #4A8B6A;
    --negative: #C45A42;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.12);
    --header-bg: rgba(255, 255, 255, 0.9);
    --input-bg: #ffffff;
    --input-border: rgba(0, 0, 0, 0.15);
    --input-focus: var(--accent-terracotta);
    --radio-bg: #f0ede8;
    --radio-checked: var(--accent-terracotta);
    --orb-opacity: 0.2;
}

/* === RESET & BASE === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
    font-family: 'Source Sans 3', sans-serif;
    background: var(--bg-deep);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    overflow-x: hidden;
}

h1, h2, h3 { font-family: 'Sora', sans-serif; }

/* === AMBIENT BG === */
.ambient-bg {
    position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden;
}
.gradient-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(120px);
    opacity: var(--orb-opacity);
}
.orb-1 { width: 600px; height: 600px; top: -200px; right: -100px; background: radial-gradient(circle, var(--accent-terracotta), transparent 70%); }
.orb-2 { width: 500px; height: 500px; bottom: -150px; left: -100px; background: radial-gradient(circle, var(--accent-sage), transparent 70%); }

/* === LAYOUT === */
.survey-layout {
    position: relative;
    z-index: 1;
    max-width: 800px;
    margin: 0 auto;
    padding: 0 1rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* === HEADER === */
.survey-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0;
    border-bottom: 1px solid var(--border-subtle);
    backdrop-filter: blur(20px);
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--header-bg);
    margin: 0 -1rem;
    padding: 1rem;
}
.header-brand { display: flex; align-items: center; gap: 0.75rem; }
.brand-icon { width: 32px; height: 32px; color: var(--accent-terracotta); }
.brand-icon svg { width: 100%; height: 100%; }
.brand-text h1 { font-size: 1.1rem; font-weight: 600; color: var(--text-primary); }
.brand-tagline { font-size: 0.75rem; color: var(--text-muted); }
.header-nav { display: flex; align-items: center; gap: 0.75rem; }
.theme-toggle {
    background: none; border: 1px solid var(--border-medium); border-radius: 8px;
    padding: 0.4rem; cursor: pointer; color: var(--text-secondary);
    display: flex; align-items: center; justify-content: center;
}
.theme-toggle svg { width: 18px; height: 18px; }
[data-theme="dark"] .icon-sun { display: none; }
[data-theme="light"] .icon-moon { display: none; }
.nav-link {
    display: flex; align-items: center; gap: 0.3rem;
    color: var(--text-secondary); text-decoration: none; font-size: 0.85rem;
    padding: 0.4rem 0.75rem; border: 1px solid var(--border-medium); border-radius: 8px;
    transition: all 0.2s;
}
.nav-link:hover { color: var(--text-primary); border-color: var(--accent-terracotta); }
.nav-link svg { width: 14px; height: 14px; }

/* === WELCOME/THANKYOU LOGOS === */
.welcome-logos {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 0.25rem;
    padding: 0.5rem 1rem 0;
}
.welcome-logo {
    height: 55px;
    max-width: 280px;
    object-fit: contain;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.92);
    padding: 6px 10px;
}
.welcome-logo-primary {
    height: 90px;
    max-width: none;
}
.welcome-logos-secondary {
    margin-top: -1.25rem;
    margin-bottom: 1rem;
    gap: 1.5rem;
}
[data-theme="light"] .welcome-logo {
    background: rgba(255, 255, 255, 0.5);
}

/* === PROGRESS BAR === */
.progress-container {
    padding: 1rem 0 0.5rem;
    position: sticky;
    top: 58px;
    z-index: 9;
}
.progress-bar {
    height: 4px;
    background: var(--accent-terracotta);
    border-radius: 2px;
    transition: width 0.4s ease;
    width: 0%;
}
.progress-text {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.3rem;
    text-align: right;
}

/* === SURVEY CONTENT === */
.survey-content {
    flex: 1;
    padding: 1.5rem 0;
}
.survey-section {
    display: none;
    animation: fadeIn 0.3s ease;
}
.survey-section.active { display: block; }

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

.section-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 16px;
    padding: 2rem;
    box-shadow: var(--shadow-md);
}
.section-card.welcome { text-align: center; max-width: 600px; margin: 1rem auto; padding: 1.25rem 2rem; }
.section-card.welcome h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, var(--accent-terracotta), var(--accent-ochre));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.section-card.welcome p {
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
    line-height: 1.5;
}
.survey-meta {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin: 0.75rem 0;
}
.meta-item {
    display: flex; align-items: center; gap: 0.5rem;
    color: var(--text-muted); font-size: 0.9rem;
}
.meta-item svg { width: 18px; height: 18px; flex-shrink: 0; }

.section-title {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}
.section-description {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

/* === QUESTION STYLES === */
.question-block {
    margin-bottom: 1.75rem;
    padding-bottom: 1.75rem;
    border-bottom: 1px solid var(--border-subtle);
}
.question-block:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }

.question-label {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
    display: block;
}
.question-label .required {
    color: var(--accent-terracotta);
    margin-left: 0.25rem;
}
.question-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

/* Radio / Single Choice */
.radio-group { display: flex; flex-direction: column; gap: 0.5rem; }
.radio-option {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--radio-bg);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
}
.radio-option:hover { border-color: var(--accent-terracotta); background: var(--bg-hover); }
.radio-option.selected {
    border-color: var(--radio-checked);
    background: rgba(224, 122, 95, 0.08);
}
.radio-option input[type="radio"] { display: none; }
.radio-dot {
    width: 20px; height: 20px; border-radius: 50%;
    border: 2px solid var(--input-border); flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.2s;
}
.radio-option.selected .radio-dot {
    border-color: var(--radio-checked);
}
.radio-option.selected .radio-dot::after {
    content: '';
    width: 10px; height: 10px; border-radius: 50%;
    background: var(--radio-checked);
}
.radio-label { font-size: 0.95rem; color: var(--text-primary); }

/* Checkbox / Multiple Choice */
.checkbox-group { display: flex; flex-direction: column; gap: 0.5rem; }
.checkbox-option {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--radio-bg);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
}
.checkbox-option:hover { border-color: var(--accent-sage); background: var(--bg-hover); }
.checkbox-option.selected {
    border-color: var(--accent-sage);
    background: rgba(129, 178, 154, 0.08);
}
.checkbox-option input[type="checkbox"] { display: none; }
.check-box {
    width: 20px; height: 20px; border-radius: 5px;
    border: 2px solid var(--input-border); flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.2s;
}
.checkbox-option.selected .check-box {
    border-color: var(--accent-sage);
    background: var(--accent-sage);
}
.checkbox-option.selected .check-box::after {
    content: '';
    width: 6px; height: 10px;
    border: solid white; border-width: 0 2px 2px 0;
    transform: rotate(45deg);
    margin-top: -2px;
}

/* Likert Scale */
.likert-group {
    display: flex; gap: 0; width: 100%;
}
.likert-option {
    flex: 1;
    display: flex; flex-direction: column; align-items: center;
    padding: 0.75rem 0.25rem;
    cursor: pointer;
    border: 1px solid var(--border-subtle);
    margin-right: -1px;
    transition: all 0.2s;
    background: var(--radio-bg);
}
.likert-option:first-child { border-radius: 10px 0 0 10px; }
.likert-option:last-child { border-radius: 0 10px 10px 0; margin-right: 0; }
.likert-option:hover { background: var(--bg-hover); z-index: 1; }
.likert-option.selected {
    background: rgba(224, 122, 95, 0.12);
    border-color: var(--accent-terracotta);
    z-index: 2;
}
.likert-option input[type="radio"] { display: none; }
.likert-number {
    font-size: 1.1rem; font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}
.likert-option.selected .likert-number { color: var(--accent-terracotta); }
.likert-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-align: center;
    line-height: 1.2;
}

/* Likert Matrix */
.likert-matrix {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 0;
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    overflow: hidden;
}
.likert-matrix-header {
    display: grid;
    grid-template-columns: 1fr repeat(5, 60px);
    align-items: end;
    padding: 0.5rem 1rem;
    background: var(--bg-hover);
    border-bottom: 1px solid var(--border-subtle);
    gap: 0;
}
.likert-matrix-col {
    text-align: center;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    line-height: 1.2;
}
.likert-matrix-col-label {
    font-size: 0.65rem;
    font-weight: 400;
    display: block;
    margin-top: 0.15rem;
}
.likert-matrix-row {
    display: grid;
    grid-template-columns: 1fr repeat(5, 60px);
    align-items: center;
    padding: 0.6rem 1rem;
    border-bottom: 1px solid var(--border-subtle);
    transition: background 0.15s;
}
.likert-matrix-row:last-child { border-bottom: none; }
.likert-matrix-row:hover { background: var(--bg-hover); }
.likert-matrix-label {
    font-size: 0.9rem;
    color: var(--text-primary);
    padding-right: 0.5rem;
}
.likert-matrix-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0.25rem;
}
.likert-matrix-cell input[type="radio"] { display: none; }
.likert-matrix-dot {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid var(--input-border);
    transition: all 0.2s;
}
.likert-matrix-cell:hover .likert-matrix-dot {
    border-color: var(--accent-terracotta);
}
.likert-matrix-cell.selected .likert-matrix-dot {
    background: var(--accent-terracotta);
    border-color: var(--accent-terracotta);
    box-shadow: 0 0 0 3px rgba(224, 122, 95, 0.15);
}
.question-block.error .likert-matrix {
    border-color: var(--negative);
}

/* Ranking */
.ranking-group { display: flex; flex-direction: column; gap: 0.5rem; }
.ranking-option {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--radio-bg);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
}
.ranking-option:hover { border-color: var(--accent-ocean); }
.ranking-badge {
    width: 28px; height: 28px; border-radius: 50%;
    border: 2px solid var(--input-border);
    display: flex; align-items: center; justify-content: center;
    font-size: 0.85rem; font-weight: 600; color: var(--text-muted);
    flex-shrink: 0; transition: all 0.2s;
}
.ranking-option.ranked .ranking-badge {
    background: var(--accent-ocean);
    border-color: var(--accent-ocean);
    color: white;
}
.ranking-option.ranked {
    border-color: var(--accent-ocean);
    background: rgba(61, 133, 198, 0.08);
}

/* Open-ended */
.text-input {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 10px;
    color: var(--text-primary);
    font-family: 'Source Sans 3', sans-serif;
    font-size: 0.95rem;
    resize: vertical;
    min-height: 80px;
    transition: border-color 0.2s;
}
.text-input:focus {
    outline: none;
    border-color: var(--input-focus);
    box-shadow: 0 0 0 3px rgba(224, 122, 95, 0.15);
}

/* Validation error */
.question-block.error .question-label { color: var(--negative); }
.question-block.error .radio-option,
.question-block.error .checkbox-option,
.question-block.error .likert-option,
.question-block.error .ranking-option,
.question-block.error .text-input { border-color: var(--negative); }
.error-message {
    font-size: 0.8rem;
    color: var(--negative);
    margin-top: 0.5rem;
    display: none;
}
.question-block.error .error-message { display: block; }

/* === BUTTONS === */
.btn-primary {
    display: inline-flex; align-items: center; gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background: linear-gradient(135deg, var(--accent-terracotta), #c46a50);
    color: white; border: none; border-radius: 10px;
    font-family: 'Sora', sans-serif; font-size: 0.95rem; font-weight: 500;
    cursor: pointer; transition: all 0.2s;
    box-shadow: var(--shadow-sm);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-primary svg { width: 18px; height: 18px; }

.btn-secondary {
    display: inline-flex; align-items: center; gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background: var(--bg-panel);
    color: var(--text-secondary);
    border: 1px solid var(--border-medium); border-radius: 10px;
    font-family: 'Sora', sans-serif; font-size: 0.95rem; font-weight: 500;
    cursor: pointer; transition: all 0.2s; text-decoration: none;
}
.btn-secondary:hover { color: var(--text-primary); border-color: var(--accent-terracotta); }
.btn-secondary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-secondary svg { width: 18px; height: 18px; }

.submit-btn {
    background: linear-gradient(135deg, var(--accent-sage), #5a8b74);
}

/* === NAVIGATION === */
.survey-nav {
    display: flex;
    justify-content: space-between;
    padding: 1rem 0 2rem;
    border-top: 1px solid var(--border-subtle);
    position: sticky;
    bottom: 0;
    background: var(--bg-deep);
    z-index: 10;
}

/* === THANK YOU === */
.thankyou-actions {
    display: flex; gap: 1rem; justify-content: center; margin-top: 1.5rem; flex-wrap: wrap;
}

/* === LOADING === */
.survey-loading {
    text-align: center; padding: 3rem;
    color: var(--text-muted);
}

/* === RESPONSIVE === */
@media (max-width: 640px) {
    /* Header: compact, hide nav links */
    .survey-header {
        flex-direction: row; align-items: center;
        padding: 0.75rem 1rem;
        position: sticky; top: 0;
    }
    .header-nav .nav-link { display: none; }
    .brand-text h1 { font-size: 0.95rem; }
    /* Welcome/thankyou logos: smaller on mobile */
    .welcome-logos { gap: 1rem; padding: 0.75rem 0.5rem; margin-bottom: 1rem; }
    .welcome-logo { height: 42px; max-width: 140px; }

    /* Progress: inline under header, not sticky */
    .progress-container { top: auto; position: relative; padding: 0.75rem 0 0.25rem; }

    /* Cards */
    .section-card { padding: 1.25rem; border-radius: 12px; }
    .section-title { font-size: 1.15rem; }

    /* Welcome */
    .section-card.welcome { margin: 1rem auto; }
    .section-card.welcome h2 { font-size: 1.4rem; }
    .survey-meta { flex-direction: column; gap: 0.75rem; }

    /* Question spacing */
    .question-block { margin-bottom: 1.5rem; padding-bottom: 1.5rem; }
    .question-label { font-size: 0.95rem; }

    /* Touch targets: 48px minimum */
    .radio-option, .checkbox-option, .ranking-option {
        padding: 0.875rem 1rem; min-height: 48px;
    }

    /* Likert: stack vertically */
    .likert-group { flex-direction: column; }
    .likert-option {
        flex-direction: row; gap: 0.75rem; border-radius: 10px !important;
        margin-right: 0; margin-bottom: -1px; padding: 0.875rem 1rem;
        min-height: 48px;
    }
    .likert-option:last-child { margin-bottom: 0; }

    /* Likert matrix: stacked rows with labels */
    .likert-matrix-header { display: none; }
    .likert-matrix-row {
        display: flex; flex-direction: column; gap: 0.25rem;
        padding: 0.75rem 1rem;
    }
    .likert-matrix-label { font-weight: 600; margin-bottom: 0.25rem; }
    .likert-matrix-row .likert-matrix-cell {
        justify-content: flex-start; gap: 0.75rem;
        padding: 0.6rem 0.5rem; min-height: 44px;
        border-radius: 8px;
    }
    .likert-matrix-row .likert-matrix-cell:active {
        background: var(--bg-hover);
    }
    .likert-matrix-row .likert-matrix-cell::before {
        content: attr(data-value) " – " attr(data-label);
        font-size: 0.85rem; color: var(--text-muted);
    }
    .likert-matrix-row .likert-matrix-cell.selected::before {
        color: var(--text-primary);
    }
    .likert-matrix-dot { width: 24px; height: 24px; }

    /* Text inputs: prevent iOS zoom, reduce height */
    .text-input { font-size: 16px; min-height: 60px; }
    input.email-input { min-height: auto; }

    /* Bottom nav: safe area for home indicator */
    .survey-nav {
        padding: 0.75rem 1rem calc(0.75rem + env(safe-area-inset-bottom, 0px));
        margin: 0 -1rem;
        gap: 0.5rem;
    }
    .btn-primary, .btn-secondary {
        padding: 0.85rem 1.25rem; font-size: 0.9rem;
        flex: 1; justify-content: center;
    }

    /* Thank you */
    .thankyou-actions { flex-direction: column; }
}
