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

:root {
    --primary-color: #f5f5f7;
    --text-primary: #1d1d1f;
    --text-secondary: #515154;
    --background-light: #ffffff;
    --glow-shadow: rgba(0, 132, 255, 0.2);
    --accent-color: #0071e3;
    --border-color: rgba(0, 0, 0, 0.1);
    --highlight-color: #e6f2ff;  /* Colore di sfondo per evidenziare */
    --highlight-border: #0071e3; /* Bordo per le risposte selezionate */
    --selected-text: #0071e3;    /* Colore del testo per le risposte selezionate */
}

* {
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    scroll-behavior: smooth;
    margin: 0;
    padding: 0;
}

body {
    min-height: 100vh;
    font-family: 'Poppins', sans-serif;
    background: var(--primary-color);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
}

#bgCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

.bg-element {
    position: fixed;
    width: 100%;
    height: 100%;
    max-width: 44em;
    opacity: 0.6;
    pointer-events: none;
    z-index: 2;
}

.bg-element::before,
.bg-element::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 100em;
    box-shadow: 
        inset 0 0 4em 3em var(--glow-shadow),
        inset 0 0 2em 0.4em var(--glow-shadow),
        0 0 0.1em 0.1em var(--glow-shadow),
        0 0 1em 0.4em rgba(0, 132, 255, 0.3);
}

.bg-element::before {
    top: -64%;
    animation: onloadbgt 1s ease-in-out forwards;
}

.bg-element::after {
    bottom: -64%;
    animation: onloadbgb 1s ease-in-out forwards;
}

.filters {
    height: 0;
    width: 0;
    position: absolute;
    z-index: -1;
}

main {
    position: relative;
    z-index: 3;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

.intro-page {
    display: none;
    min-height: 100vh;
    padding-top: 120px;
}

.intro-page.active {
    display: block;
}

.questionnaire-page {
    display: none;
    padding-top: 120px;
}

.questionnaire-page.active {
    display: block;
}

.intro-content {
    padding: 4rem 0;
    text-align: center;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.5s ease;
}

.intro-content h1 {
    font-size: 3em;
    line-height: 1.0625;
    letter-spacing: -0.009em;
    position: relative;
    display: inline-block;
    animation: onloadscale 1s ease-out forwards;
    color: var(--text-primary);
}

.intro-content h1::before {
    content: attr(data-text);
    position: absolute;
    inset: 0;
    background: linear-gradient(0deg, var(--text-primary) 0%, var(--accent-color) 50%);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: url(#glow-4);
    opacity: 0;
    animation: onloadopacity 1s ease-out forwards;
}

.intro-description {
    color: var(--text-secondary);
    font-weight: 600;
    margin: 2rem 0;
}

.progress-container {
  position: sticky;
  top: 0;
  z-index: 10;
  background-color: var(--background-light);
  padding: 1rem;
  margin-bottom: 2rem;
  border-radius: 10px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
  width: 100%;
}

.progress-text {
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

.progress-bar {
  width: 100%;
  height: 8px;
  background-color: rgba(0, 0, 0, 0.1);
  border-radius: 10px;
  margin: 10px 0;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background-color: var(--accent-color);
  border-radius: 10px;
  transition: width 0.5s ease;
}

.progress-steps {
  display: flex;
  justify-content: space-between;
  width: 100%;
  margin-top: 5px;
}

.progress-step {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--border-color);
  background-color: var(--background-light);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 14px;
  transition: all 0.3s ease;
  position: relative;
}

.progress-step.active {
  border-color: var(--accent-color);
  background-color: var(--accent-color);
  color: white;
  box-shadow: 0 0 8px var(--glow-shadow);
}

.progress-step.completed {
  border-color: var(--accent-color);
  background-color: var(--accent-color);
  color: white;
}

.question-container {
    background: var(--background-light);
    border-radius: 18px;
    padding: 2rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    margin-bottom: 2rem;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.5s ease;
}

.question-container.active {
    opacity: 1;
    transform: translateY(0);
}

.question h1 {
    font-size: 1.6em;
    margin-bottom: 1.5rem;
    position: relative;
    display: inline-block;
}

.question h1::before {
    content: attr(data-text);
    position: absolute;
    inset: 0;
    background: linear-gradient(0deg, var(--text-primary) 0%, var(--accent-color) 50%);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: url(#glow-4);
    opacity: 0;
    animation: onloadopacity 1s ease-out forwards;
}

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

.option {
    background-color: var(--background-light);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    opacity: 0;
    transform: translateY(20px);
    display: flex;
    align-items: center;
}

.option:hover {
    background-color: rgba(0, 113, 227, 0.05);
    border-color: var(--accent-color);
    box-shadow: 0 2px 6px var(--glow-shadow);
    transform: translateY(-2px);
}

.option.selected {
    background-color: var(--highlight-color);
    border: 2px solid var(--highlight-border);
    color: var(--selected-text);
    font-weight: 600;
    box-shadow: 0 2px 12px var(--glow-shadow);
}

.option.selected::after {
    content: "✓";
    position: absolute;
    right: 15px;
    font-size: 1.2em;
    color: var(--accent-color);
    font-weight: bold;
}

.option-checkbox {
    margin-right: 10px;
}

.other-input-container {
    margin-top: 0.5rem;
    width: 100%;
}

.other-input {
    width: 100%;
    padding: 0.8rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-family: 'Poppins', sans-serif;
    transition: all 0.3s ease;
}

.other-input:focus {
    border: 2px solid var(--highlight-border);
    box-shadow: 0 0 8px var(--glow-shadow);
    outline: none;
}

.navigation {
    display: flex;
    justify-content: space-between;
    margin-top: 2rem;
}

.glow-button {
    background-color: var(--accent-color);
    color: white;
    border: none;
    padding: 1rem 2rem;
    border-radius: 8px;
    cursor: pointer;
    font-family: 'Poppins', sans-serif;
    font-weight: 600;
    transition: all 0.3s ease;
}

.glow-button:hover:not(:disabled) {
    background-color: #005bb3;
    box-shadow: 0 4px 12px var(--glow-shadow);
    transform: translateY(-2px);
}

.glow-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.completion-message {
    text-align: center;
}

.completion-message h1 {
    font-size: 2.5em;
    margin-bottom: 1rem;
}

.completion-message p {
    font-size: 1.2em;
    color: var(--text-secondary);
    margin-top: 2rem;
}

@keyframes onloadscale {
    24% { transform: scale(1); }
    100% { transform: scale(1.02); }
}

@keyframes onloadopacity {
    24% { opacity: 0; }
    100% { opacity: 1; }
}

@keyframes onloadbgt {
    0% { transform: translateY(-70%); opacity: 0.3; }
    100% { transform: translateY(-64%); opacity: 0.8; }
}

@keyframes onloadbgb {
    0% { transform: translateY(70%); opacity: 0.3; }
    100% { transform: translateY(64%); opacity: 0.8; }
}

/* Stili per la domanda audio */
.audio-question {
    margin-top: 2rem;
}

.question-hint {
    background-color: #f8f9fa;
    border-left: 4px solid var(--accent-color);
    padding: 1rem;
    margin: 1rem 0;
    font-size: 0.95rem;
    line-height: 1.6;
}

.question-hint strong {
    font-weight: 600;
}

.recorder-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 2rem;
    width: 100%;
}

.controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 1rem;
    width: 100%;
}

.record-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 80px;
    height: 80px;
    background-color: var(--accent-color);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    margin-bottom: 1rem;
}

.record-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.25);
}

.record-btn.recording {
    background-color: #e74c3c;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(231, 76, 60, 0.5);
    }
    70% {
        box-shadow: 0 0 0 12px rgba(231, 76, 60, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(231, 76, 60, 0);
    }
}

.record-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background-color: white;
}

.btn-text {
    display: block;
    margin-top: 0.5rem;
    text-align: center;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.timer {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-top: 0.5rem;
    text-align: center;
}

.status-container {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: 100%;
    text-align: center;
    margin-top: 1rem;
}

.status {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.status.error {
    color: #e74c3c;
}

.status.success {
    color: #2ecc71;
}

.status.processing {
    color: var(--accent-color);
}

.audio-preview {
    width: 100%;
    margin-top: 1rem;
    display: flex;
    justify-content: center;
}

audio {
    width: 100%;
    border-radius: 8px;
}

.transcription-container {
    background-color: var(--highlight-color);
    padding: 1rem;
    border-radius: 8px;
    margin-top: 1rem;
}

.transcription-container h2 {
    font-size: 1rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

/* Logo Ordine degli Attuari */
.logo-header {
    text-align: center;
    margin-bottom: 2rem;
}

.logo-img {
    max-width: 320px;
    width: 80%;
    height: auto;
    display: block;
    margin: 0 auto;
}

/* Disclaimer page */
.disclaimer-page {
    display: none;
    min-height: 100vh;
    padding-top: 80px;
    padding-bottom: 3rem;
}

.disclaimer-page.active {
    display: block;
}

.disclaimer-content {
    max-width: 760px;
    margin: 0 auto;
    background: var(--background-light);
    border-radius: 18px;
    padding: 2.5rem 3rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.disclaimer-content h2 {
    font-size: 1.8em;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}

.disclaimer-text {
    max-height: 380px;
    overflow-y: auto;
    padding: 1.25rem 1.5rem;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
    line-height: 1.7;
}

.disclaimer-text h3 {
    color: var(--accent-color);
    font-size: 0.95rem;
    margin: 1rem 0 0.4rem;
}

.disclaimer-text h3:first-child {
    margin-top: 0;
}

.disclaimer-text p {
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
}

.disclaimer-text a {
    color: var(--accent-color);
    text-decoration: none;
}

.disclaimer-consent {
    margin: 1.5rem 0;
}

.consent-label {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    cursor: pointer;
    font-size: 0.95rem;
    line-height: 1.5;
    color: var(--text-primary);
}

.consent-label input[type="checkbox"] {
    margin-top: 3px;
    width: 18px;
    height: 18px;
    accent-color: var(--accent-color);
    flex-shrink: 0;
    cursor: pointer;
}

/* Audio tabs */
.audio-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid var(--border-color);
}

.audio-tab {
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    padding: 0.75rem 1.5rem;
    cursor: pointer;
    font-family: 'Poppins', sans-serif;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-secondary);
    transition: all 0.2s ease;
    margin-bottom: -2px;
}

.audio-tab:hover {
    color: var(--accent-color);
}

.audio-tab.active {
    color: var(--accent-color);
    border-bottom-color: var(--accent-color);
}

.audio-tab-content {
    width: 100%;
}

/* Tab testo scritto */
.text-input-container {
    padding: 1rem 0;
}

.text-input-hint {
    color: var(--text-secondary);
    margin-bottom: 1rem;
    font-size: 0.95rem;
}

.text-input-area {
    width: 100%;
    min-height: 160px;
    padding: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-family: 'Poppins', sans-serif;
    font-size: 0.9rem;
    line-height: 1.6;
    resize: vertical;
    transition: border 0.3s ease, box-shadow 0.3s ease;
}

.text-input-area:focus {
    border: 2px solid var(--accent-color);
    box-shadow: 0 0 8px var(--glow-shadow);
    outline: none;
}

/* Transcription box — ora è una textarea editabile */
.transcription-box {
    width: 100%;
    background-color: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    min-height: 100px;
    font-size: 0.9rem;
    font-family: 'Poppins', sans-serif;
    line-height: 1.6;
    resize: vertical;
    transition: border 0.3s ease, box-shadow 0.3s ease;
}

.transcription-box:focus {
    border: 2px solid var(--accent-color);
    box-shadow: 0 0 8px var(--glow-shadow);
    outline: none;
}

/* ===== MOBILE RESPONSIVE ===== */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }

    .intro-page,
    .questionnaire-page {
        padding-top: 60px;
    }

    .intro-content {
        padding: 2rem 0;
    }

    .intro-content h1 {
        font-size: 1.8em;
        letter-spacing: -0.005em;
    }

    .intro-description {
        margin: 1.2rem 0;
        font-size: 0.95rem;
    }

    .question h1 {
        font-size: 1.2em;
        margin-bottom: 1rem;
    }

    .question-container {
        padding: 1.2rem;
        margin-bottom: 1rem;
    }

    .options {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .option {
        padding: 0.9rem 1rem;
        font-size: 0.95rem;
        min-height: 48px;
    }

    .navigation {
        flex-direction: column;
        gap: 0.75rem;
        margin-top: 1.2rem;
    }

    .navigation .glow-button {
        width: 100%;
        text-align: center;
        padding: 0.9rem 1rem;
        font-size: 1rem;
        min-height: 48px;
    }

    .start-btn.glow-button {
        width: 100%;
        max-width: 320px;
        padding: 0.9rem 1.5rem;
        font-size: 1rem;
        min-height: 48px;
    }

    .progress-container {
        padding: 0.75rem;
        margin-bottom: 1rem;
    }

    .progress-step {
        width: 24px;
        height: 24px;
        font-size: 12px;
    }

    .completion-message h1 {
        font-size: 1.6em;
    }

    .completion-message p {
        font-size: 1rem;
    }

    .record-btn {
        width: 72px;
        height: 72px;
    }

    .question-hint {
        font-size: 0.85rem;
        padding: 0.75rem;
    }

    .transcription-box {
        min-height: 80px;
        font-size: 0.85rem;
    }

    .logo-img {
        max-width: 200px;
    }

    .logo-header {
        padding: 0.9rem 1rem;
    }

    .disclaimer-content {
        padding: 1.5rem 1.2rem;
    }

    .disclaimer-text {
        max-height: 280px;
        font-size: 0.85rem;
    }

    .audio-tab {
        padding: 0.6rem 1rem;
        font-size: 0.88rem;
    }

    .text-input-area {
        min-height: 130px;
        font-size: 0.88rem;
    }
}