@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Outfit:wght@500;700&display=swap');

:root {
    --primary: #0E2A36;
    --primary-light: #1c4252;
    --primary-dark: #061218;
    --accent: #8BAE9A;
    --accent-light: #a9c8b6;
    --accent-dark: #6e937d;
    --bg: #f9fbfb;
    --card-bg: #ffffff;
    --text: #2f3e46;
    --text-muted: #6b7c85;
    --error: #d9534f;
    --success: #5cb85c;
    --border: #e1e7ea;
    --shadow: 0 4px 20px rgba(14, 42, 54, 0.05);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    margin: 0;
    padding: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
}

header {
    background: #ffffff;
    color: var(--primary);
    padding: 24px 0;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.header-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nunavoice-brand {
    display: flex;
    align-items: center;
    gap: 15px;
}

.nunavoice-brand__mark {
    width: 58px;
    height: 58px;
    flex: 0 0 58px;
    display: block;
    position: relative;
    top: -1.5px;
}

.nunavoice-brand__content {
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.nunavoice-brand__title-row {
    display: flex;
    align-items: center;
    line-height: 1;
}

.nunavoice-brand__name {
    color: var(--primary);
    font-size: 1.65rem;
    font-weight: 700;
    line-height: 1;
    letter-spacing: -0.02em;
}

.brand-nuna {
    font-weight: 700;
}

.brand-voice {
    font-weight: 400;
}

.nunavoice-brand__badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.45rem;
    border-radius: 999px;
    background: var(--accent);
    color: var(--primary);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    line-height: 1.2;
    margin-left: 10px;
}

.nunavoice-brand__descriptor {
    margin-top: 2px;
    color: #526873;
    font-size: 0.88rem;
    font-weight: 500;
    white-space: nowrap;
}

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

    .nunavoice-brand {
        gap: 12px;
    }

    .nunavoice-brand__mark {
        width: 48px;
        height: 48px;
        flex: 0 0 48px;
    }

    .nunavoice-brand__name {
        font-size: 1.35rem;
    }

    .nunavoice-brand__descriptor {
        font-size: 0.82rem;
        white-space: normal;
        line-height: 1.3;
    }
}

.save-status {
    font-size: 13px;
    color: #668B78;
    display: flex;
    align-items: center;
    gap: 5px;
}

.save-spinner {
    width: 10px;
    height: 10px;
    border: 2px solid #e2ece7;
    border-top: 2px solid #668B78;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    display: none;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

main {
    flex: 1;
    max-width: 900px;
    width: 100%;
    margin: 40px auto;
    padding: 0 20px;
    box-sizing: border-box;
}

.progress-bar-container {
    background: var(--border);
    height: 8px;
    border-radius: 4px;
    margin-bottom: 40px;
    overflow: hidden;
}

.progress-bar-fill {
    background: var(--accent);
    height: 100%;
    width: 0%;
    transition: width 0.3s ease;
}

.card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 40px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    display: none; /* Controlled by survey.js */
}

.card.active {
    display: block;
    animation: fadeIn 0.4s ease;
}

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

h2 {
    color: var(--primary);
    font-size: 24px;
    margin-top: 0;
    margin-bottom: 15px;
}

.description {
    color: var(--text-muted);
    font-size: 15px;
    line-height: 1.6;
    margin-bottom: 30px;
}

/* Card choices grid */
.grid-choices {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.choice-card {
    border: 2px solid var(--border);
    border-radius: 8px;
    padding: 24px;
    text-align: center;
    cursor: pointer;
    background: white;
    transition: all 0.2s ease;
    user-select: none;
    outline: none;
    position: relative;
}

.choice-card:hover {
    border-color: var(--primary-light);
    transform: translateY(-2px);
}

.choice-card:focus-visible {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}

.choice-card.selected {
    border-color: var(--accent);
    background-color: #f3faf7;
}

.choice-card.selected::after {
    content: "✓";
    position: absolute;
    top: 12px;
    right: 12px;
    width: 20px;
    height: 20px;
    background: var(--accent);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.choice-card__header {
    display: block;
    font-size: 14px;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.region-badge {
    display: inline-block;
    padding: 2px 8px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 11px;
    font-weight: 800;
    color: var(--text-muted);
    margin-top: 4px;
    margin-bottom: 10px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.choice-card .emoji {
    font-size: 32px;
    margin-bottom: 8px;
    display: block;
}

.choice-card .title {
    font-weight: 700;
    font-size: 16px;
    color: var(--primary);
    margin-bottom: 6px;
    display: block;
}

.choice-card .desc {
    font-size: 13px;
    display: block;
    color: var(--text-muted);
}

/* Button Navigation */
.nav-buttons {
    display: flex;
    justify-content: space-between;
    margin-top: 40px;
    gap: 20px;
}

.btn {
    padding: 14px 28px;
    border-radius: 6px;
    font-weight: bold;
    font-size: 15px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    outline: none;
}

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

.btn-primary:hover {
    background-color: var(--primary-light);
}

.btn-accent {
    background-color: var(--accent);
    color: white;
}

.btn-accent:hover {
    background-color: var(--accent-dark);
}

.btn-secondary {
    background-color: transparent;
    color: var(--primary);
    border: 2px solid var(--primary);
}

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

.btn:disabled {
    background-color: var(--border);
    color: var(--text-muted);
    border-color: var(--border);
    cursor: not-allowed;
}

/* Form Controls */
.form-group {
    margin-bottom: 25px;
}

label {
    display: block;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 10px;
    font-size: 15px;
}

.help-text {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: -6px;
    margin-bottom: 12px;
    line-height: 1.4;
}

select, textarea, input[type="text"] {
    width: 100%;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 6px;
    box-sizing: border-box;
    font-size: 15px;
    background: white;
    color: var(--text);
    transition: border-color 0.2s;
}

select:focus, textarea:focus, input[type="text"]:focus {
    outline: none;
    border-color: var(--primary-light);
}

/* Custom Checklist Grid */
.check-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 25px;
}

.check-item {
    display: flex;
    align-items: center;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    background: white;
    user-select: none;
    transition: background 0.2s;
}

.check-item:hover {
    background: #f1f5f7;
}

.check-item.selected {
    border-color: var(--accent);
    background: #f3faf7;
}

.check-item input {
    margin-right: 12px;
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
}

/* Grid Matrix */
.matrix-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 30px;
}

.matrix-table th, .matrix-table td {
    padding: 12px;
    border-bottom: 1px solid var(--border);
    text-align: left;
}

.matrix-table th {
    color: var(--primary);
    font-weight: 700;
}

.matrix-table td select {
    padding: 8px;
    font-size: 14px;
}

/* Ranking Items */
.ranking-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 25px;
}

.ranking-item {
    background: white;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: grab;
    user-select: none;
}

.ranking-item:active {
    cursor: grabbing;
}

.ranking-item .rank-controls {
    display: flex;
    gap: 8px;
}

.rank-btn {
    border: 1px solid var(--border);
    background: #f1f5f7;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 4px;
    font-weight: bold;
    user-select: none;
}

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

/* Alert Boxes */
.alert {
    padding: 16px;
    border-radius: 6px;
    margin-bottom: 25px;
    font-size: 14px;
    line-height: 1.5;
}

.alert-info {
    background: #eef7f4;
    color: var(--accent-dark);
    border: 1px solid #d8ede6;
}

.alert-warning {
    background: #fdf8e2;
    color: #8a6d3b;
    border: 1px solid #faebcc;
}

.alert-danger {
    background: #fdf2f2;
    color: var(--error);
    border: 1px solid #fbd5d5;
}

/* Responsive fixes */
@media(max-width: 600px) {
    main {
        margin: 20px auto;
    }
    .card {
        padding: 20px;
    }
    .grid-choices {
        grid-template-columns: 1fr;
    }
    .matrix-table {
        display: block;
        overflow-x: auto;
    }
}

.region-code-large {
    display: block;
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--primary);
    margin: 8px 0 12px 0;
    line-height: 1;
    letter-spacing: -0.01em;
}

.is-invalid {
    border-color: var(--error) !important;
    background-color: #fff9f9 !important;
    box-shadow: 0 0 0 2px rgba(224, 86, 86, 0.2) !important;
}
