/**
 * Step Calculator Styles - Enhanced Version
 * Modern and responsive CSS for the step-by-step calculator
 * 
 * @package StepCalculator
 * @version 2.1
 */

/* Web Font Imports with Fallbacks */
@font-face {
    font-family: 'Roboto Mono';
    src: url('../fonts/RobotoMono-Regular.woff2') format('woff2'),
         url('../fonts/RobotoMono-Regular.woff') format('woff');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Poppins';
    src: url('../fonts/Poppins-Bold.woff2') format('woff2'),
         url('../fonts/Poppins-Bold.woff') format('woff');
    font-weight: bold;
    font-style: normal;
    font-display: swap;
}

:root {
    /* Color Variables */
    --calc-bg: #222;
    --calc-dark-bg: #111;
    --calc-display: #FFFF66;
    --calc-button-blue: #4a9cff;
    --calc-button-blue-hover: #3180e5;
    --calc-button-green: #4DB84D;
    --calc-button-green-hover: #3da63d;
    --calc-button-yellow: #FFFF66;
    --calc-button-yellow-hover: #080808;
    --calc-text: #fff;
    --calc-text-dark: #333;
    --calc-error: #ff6b6b;
    --calc-cell-red: #FF6B6B;
    --calc-cell-green: #4DB84D;
    --calc-cell-blue: #4a9cff;
    --calc-cell-yellow: #FFFF66;
    
    /* Sizing Variables */
    --calc-border-radius: 12px;
    --calc-button-radius: 8px;
    --calc-shadow: 0 10px 20px rgba(0, 0, 0, 0.19), 0 6px 6px rgba(0, 0, 0, 0.23);
    --calc-inner-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.5);
}

/* Step Calculator Container */
.step-calculator {
    position: relative;
    background: var(--calc-bg);
    color: var(--calc-text);
    border-radius: var(--calc-border-radius);
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
    box-shadow: var(--calc-shadow);
    overflow: hidden;
    min-height: 600px;
    font-family: 'Roboto Mono', monospace, sans-serif;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    touch-action: manipulation;
}

.step-calculator:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.25), 0 10px 10px rgba(0, 0, 0, 0.22);
}

/* Enhanced Display Section */
.step-calc-display {
    background-color: var(--calc-dark-bg);
    color: var(--calc-display);
    text-align: right;
    padding: 16px;
    margin: 16px;
    border-radius: var(--calc-button-radius);
    font-family: 'Roboto Mono', monospace, sans-serif;
    font-size: clamp(20px, 6vw, 32px);
    min-height: clamp(45px, 10vw, 60px);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    overflow: hidden;
    word-break: break-word;
    word-wrap: break-word;
    line-height: 1.2;
    box-shadow: var(--calc-inner-shadow);
    transition: all 0.3s ease;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Main Calculator Area */
.step-calc-area {
    position: relative;
    height: calc(100% - 100px);
    overflow: hidden;
}

/* Keyboard */
.step-calc-keyboard {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--calc-bg);
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    grid-template-rows: repeat(4, 1fr);
    gap: clamp(4px, 1.5vw, 8px);
    padding: clamp(8px, 2vw, 16px);
    transition: top 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Calculator Buttons */
.step-calc-button {
    border: none;
    border-radius: var(--calc-button-radius);
    font-weight: bold;
    font-size: clamp(0.9rem, 3vw, 1.2rem);
    cursor: pointer;
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), 
                background-color 0.3s, 
                box-shadow 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    box-shadow: 0 4px 0 rgba(0, 0, 0, 0.2);
    position: relative;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
    min-height: 60px;
    touch-action: manipulation;
}

.step-calc-button:active {
    transform: translateY(4px) scale(0.95);
    box-shadow: 0 0 0 rgba(0, 0, 0, 0.2);
}

.step-calc-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Button ripple effect */
.step-calc-button::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 5px;
    height: 5px;
    background: rgba(255, 255, 255, 0.5);
    opacity: 0;
    border-radius: 100%;
    transform: scale(1) translate(-50%, -50%);
    transform-origin: 50% 50%;
}

.step-calc-button:active::after {
    animation: ripple 0.8s ease-out;
}

@keyframes ripple {
    0% {
        transform: scale(0) translate(-50%, -50%);
        opacity: 0.5;
    }
    100% {
        transform: scale(40) translate(-50%, -50%);
        opacity: 0;
    }
}

/* Button Types */
.step-calc-blue {
    background-color: var(--calc-button-blue);
    color: var(--calc-text);
    animation: bounceIn 0.5s ease-out;
    animation-delay: 0.1s;
    animation-fill-mode: backwards;
}

.step-calc-blue:hover {
    background-color: var(--calc-button-blue-hover);
}

.step-calc-green {
    background-color: var(--calc-button-green);
    color: var(--calc-text);
    animation: bounceIn 0.5s ease-out;
    animation-delay: 0.2s;
    animation-fill-mode: backwards;
}

.step-calc-green:hover {
    background-color: var(--calc-button-green-hover);
}

.step-calc-yellow {
    background-color: var(--calc-button-yellow);
    color: var(--calc-text-dark);
    animation: bounceIn 0.5s ease-out;
    animation-delay: 0.3s;
    animation-fill-mode: backwards;
}

.step-calc-yellow:hover {
    background-color: var(--calc-button-yellow-hover);
}

/* Special Button Sizes */
.step-calc-button:nth-child(1) {
    grid-column: 1 / 3;
}

.step-calc-button:nth-child(2) {
    grid-column: 3 / 6;
}

.step-calc-double {
    grid-column: span 2;
}

/* Output Area */
.step-calc-output {
    position: absolute;
    top: -100%;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--calc-dark-bg);
    padding: 16px;
    transition: top 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #444 #222;
}

#step-calc-result-area {
    flex: 1;
    overflow-y: auto;
    margin-bottom: 16px;
    scrollbar-width: thin;
    scrollbar-color: #444 #222;
    padding-right: 8px;
}

#step-calc-result-area::-webkit-scrollbar {
    width: 8px;
}

#step-calc-result-area::-webkit-scrollbar-track {
    background: #222;
    border-radius: 4px;
}

#step-calc-result-area::-webkit-scrollbar-thumb {
    background-color: #444;
    border-radius: 4px;
    border: 2px solid #222;
}

/* Animate result area elements */
#step-calc-result-area > * {
    animation: slideUp 0.3s ease-out forwards;
}

/* Control Buttons */
.step-calc-controls {
    display: flex;
    justify-content: space-between;
    margin-top: auto;
}

.step-calc-control-button {
    background-color: #333;
    color: #ddd;
    border: none;
    border-radius: var(--calc-button-radius);
    padding: 12px 20px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
}

.step-calc-control-button:hover {
    background-color: #444;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.step-calc-control-button:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

#step-calc-extended, #step-calc-normal {
    display: none;
}

/* Error Messages */
.step-calc-error {
    color: var(--calc-error);
    font-weight: bold;
    padding: 16px;
    text-align: center;
    border: 1px solid var(--calc-error);
    border-radius: var(--calc-button-radius);
    margin: 20px 0;
    animation: shake 0.5s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

@keyframes shake {
    10%, 90% { transform: translateX(-1px); }
    20%, 80% { transform: translateX(2px); }
    30%, 50%, 70% { transform: translateX(-3px); }
    40%, 60% { transform: translateX(3px); }
}

/* Calculation Display Elements */
.step-calc-cell {
    position: absolute;
    text-align: center;
    font-family: 'Roboto Mono', monospace, sans-serif;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.5s ease-out;
}

.step-calc-cell-red {
    color: var(--calc-cell-red);
}

.step-calc-cell-green {
    color: var(--calc-cell-green);
}

.step-calc-cell-blue {
    color: var(--calc-cell-blue);
}

.step-calc-cell-yellow {
    color: var(--calc-cell-yellow);
}

/* Factorization Display */
.step-calc-factorization {
    margin: 20px 0;
    animation: scaleIn 0.5s ease-out;
}

.step-calc-result {
    text-align: center;
    font-size: 1.2em;
    margin-bottom: 20px;
    color: var(--calc-display);
}

.step-calc-steps {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.step-calc-factor-step {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    animation: slideUp 0.3s ease-out;
    animation-delay: calc(0.1s * var(--item-index, 1));
    animation-fill-mode: backwards;
}

.step-calc-number {
    color: var(--calc-cell-blue);
}

.step-calc-divider {
    color: #ddd;
}

.step-calc-factor {
    color: var(--calc-cell-red);
}

.step-calc-equals {
    color: #ddd;
}

/* Square Root Display */
.step-calc-sqrt {
    margin: 20px auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    animation: scaleIn 0.5s ease-out;
}

.step-calc-sqrt-symbol {
    font-size: 2em;
    color: var(--calc-cell-blue);
}

.step-calc-sqrt-number {
    font-size: 1.5em;
    color: var(--calc-display);
    margin-bottom: 10px;
}

.step-calc-sqrt-result {
    font-size: 1.8em;
    color: var(--calc-cell-green);
}

.step-calc-note {
    font-style: italic;
    color: #ddd;
    margin-bottom: 10px;
    font-size: 0.9em;
}

/* Math Quiz Styles */
.math-quiz-container {
    background: var(--calc-bg);
    color: var(--calc-text);
    border-radius: var(--calc-border-radius);
    padding: 20px;
    margin: 20px 0;
    box-shadow: var(--calc-shadow);
    font-family: 'Roboto Mono', monospace, sans-serif;
    animation: scaleIn 0.5s ease-out;
}

.calculator-section, .quiz-section {
    margin-bottom: 30px;
    padding: 15px;
    background: #333;
    border-radius: var(--calc-button-radius);
    transition: transform 0.3s ease;
}

.calculator-section:hover, .quiz-section:hover {
    transform: translateY(-3px);
}

.calculator-inputs {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.calculator-inputs input {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 4px;
    background: var(--calc-dark-bg);
    color: var(--calc-display);
    font-family: 'Roboto Mono', monospace, sans-serif;
    transition: all 0.3s ease;
}

.calculator-inputs input:focus {
    outline: 2px solid var(--calc-button-blue);
    box-shadow: 0 0 10px rgba(74, 156, 255, 0.5);
}

.calculator-buttons {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    margin-bottom: 15px;
}

.calculator-button, 
#boton-limpiar, 
#boton-generar-cuestionario,
#boton-verificar-respuestas, 
#boton-reiniciar-cuestionario {
    padding: 10px;
    border: none;
    border-radius: var(--calc-button-radius);
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
}

.calculator-button {
    background-color: var(--calc-button-blue);
    color: white;
}

.calculator-button:hover {
    background-color: var(--calc-button-blue-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.calculator-button:active {
    transform: translateY(2px);
    box-shadow: none;
}

#boton-limpiar {
    background-color: var(--calc-error);
    color: white;
}

#boton-limpiar:hover {
    background-color: #ff5252;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

#boton-generar-cuestionario {
    background-color: var(--calc-button-green);
    color: white;
    padding: 12px;
    margin-bottom: 15px;
    width: 100%;
    font-size: 1.1em;
    transition: all 0.3s;
}

#boton-generar-cuestionario:hover {
    background-color: var(--calc-button-green-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.quiz-controls {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

#boton-verificar-respuestas {
    background-color: var(--calc-button-green);
    color: white;
    flex: 1;
}

#boton-verificar-respuestas:hover {
    background-color: var(--calc-button-green-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

#boton-reiniciar-cuestionario {
    background-color: var(--calc-error);
    color: white;
    flex: 1;
}

#boton-reiniciar-cuestionario:hover {
    background-color: #ff5252;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.oculto {
    display: none !important;
}

.pregunta-cuestionario {
    background: #444;
    padding: 15px;
    border-radius: var(--calc-button-radius);
    margin-bottom: Supplements, Herbs & Vitamins to Improve Your Health - Part 3 of 3 - The Whole Journey10px;
    display: flex;
    align-items: center;
    transition: transform 0.3s ease;
    animation: slideUp 0.3s ease-out;
    animation-delay: calc(0.1s * var(--item-index, 1));
    animation-fill-mode: backwards;
}

.pregunta-cuestionario:hover {
    transform: translateX(5px);
    background: #4a4a4a;
}

.question-content {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
}

.texto-pregunta {
    font-size: 1.2em;
    min-width: 100px;
}

.respuesta-cuestionario {
    padding: 8px;
    border: none;
    border-radius: 4px;
    background: var(--calc-dark-bg);
    color: var(--calc-display);
    font-family: 'Roboto Mono', monospace, sans-serif;
    width: 80px;
    transition: all 0.3s ease;
}

.respuesta-cuestionario:focus {
    outline: 2px solid var(--calc-button-blue);
    box-shadow: 0 0 10px rgba(74, 156, 255, 0.5);
}

.mensaje-resultado {
    margin-left: 10px;
    font-size: 0.9em;
    transition: all 0.3s ease;
}

.sin-respuesta {
    color: #ffcc80;
}

.respuesta-correcta {
    color: #a5d6a7;
    animation: pulse 1s;
}

.respuesta-incorrecta {
    color: #ef9a9a;
    animation: shake 0.5s;
}

.score-container {
    background: #333;
    padding: 15px;
    border-radius: var(--calc-button-radius);
    margin-top: 20px;
    text-align: center;
    animation: fadeIn 0.5s;
}

/* Responsive Adjustments */
@media only screen and (max-width: 768px) {
    .step-calculator {
        min-height: 500px;
    }

    .step-calc-button {
        font-size: clamp(0.9rem, 2.5vw, 1.1rem);
    }
    
    .step-calc-display {
        font-size: clamp(18px, 5vw, 28px);
        padding: clamp(10px, 2vw, 12px);
        min-height: clamp(40px, 8vw, 55px);
    }
    
    .step-calc-control-button {
        padding: clamp(8px, 2vw, 10px) clamp(15px, 3vw, 18px);
        font-size: clamp(12px, 2.5vw, 13px);
    }
    
    .calculator-buttons {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .calculator-inputs {
        flex-direction: column;
    }
}

@media only screen and (max-width: 500px) {
    .step-calculator {
        min-height: 450px;
    }

    .step-calc-button {
        font-size: clamp(0.8rem, 2vw, 1rem);
        min-height: 50px;
    }
    
    .step-calc-display {
        font-size: clamp(16px, 4vw, 24px);
        padding: clamp(8px, 1.5vw, 10px);
        min-height: clamp(35px, 7vw, 50px);
        margin: 10px;
    }
    
    .step-calc-control-button {
        padding: clamp(8px, 1.5vw, 10px) clamp(12px, 2.5vw, 15px);
        font-size: clamp(11px, 2vw, 12px);
    }
    
    .step-calc-keyboard {
        gap: clamp(3px, 1vw, 6px);
        padding: clamp(6px, 1.5vw, 10px);
    }
    
    .pregunta-cuestionario {
        padding: 10px;
    }
    
    .question-content {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .texto-pregunta {
        margin-bottom: 8px;
    }
}

@media only screen and (max-width: 350px) {
    .step-calculator {
        min-height: 400px;
    }

    .step-calc-button {
        font-size: clamp(0.7rem, 1.5vw, 0.9rem);
        min-height: 45px;
    }
    
    .step-calc-keyboard {
        gap: clamp(2px, 1vw, 4px);
        padding: clamp(5px, 1vw, 8px);
    }
    
    .step-calc-display {
        font-size: clamp(14px, 3vw, 20px);
        padding: clamp(6px, 1vw, 8px);
        margin: 8px;
        min-height: clamp(30px, 6vw, 45px);
    }
    
    .calculator-buttons {
        grid-template-columns: repeat(3, 1fr);
        gap: clamp(3px, 1vw, 5px);
    }
}

/* Landscape mode adjustments */
@media (max-width: 768px) and (orientation: landscape) {
    .step-calculator {
        min-height: 350px;
        max-height: 400px;
    }
    
    .step-calc-display {
        min-height: clamp(30px, 6vw, 40px);
        font-size: clamp(16px, 4vw, 22px);
        margin: 10px;
        padding: clamp(6px, 1.5vw, 8px);
    }
    
    .step-calc-area {
        height: calc(100% - 70px);
    }
    
    .step-calc-keyboard {
        gap: clamp(3px, 1vw, 5px);
        padding: clamp(6px, 1.5vw, 10px);
    }
    
    .step-calc-button {
        font-size: clamp(0.7rem, 2vw, 0.9rem);
    }
    
    .calculator-section, .quiz-section {
        padding: 10px;
    }
    
    .calculator-inputs input, .respuesta-cuestionario {
        padding: 6px;
    }
}

/* Improved Touchscreen Support */
@media (hover: none) {
    .step-calc-button:hover,
    .calculator-button:hover,
    #boton-limpiar:hover,
    #boton-generar-cuestionario:hover,
    #boton-verificar-respuestas:hover,
    #boton-reiniciar-cuestionario:hover {
        transform: none;
        box-shadow: none;
    }
    
    .step-calc-button:active,
    .calculator-button:active,
    #boton-limpiar:active,
    #boton-generar-cuestionario:active,
    #boton-verificar-respuestas:active,
    #boton-reiniciar-cuestionario:active {
        transform: scale(0.95);
        opacity: 0.8;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    :root {
        --calc-bg: #181818;
        --calc-dark-bg: #0a0a0a;
    }
}

/* Animation Keyframes */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes scaleIn {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

@keyframes glow {
    0% { box-shadow: 0 0 5px rgba(255, 255, 102, 0.5); }
    50% { box-shadow: 0 0 20px rgba(255, 255, 102, 0.8); }
    100% { box-shadow: 0 0 5px rgba(255, 255, 102, 0.5); }
}

@keyframes bounceIn {
    0% { transform: scale(0.3); opacity: 0; }
    50% { transform: scale(1.05); opacity: 0.9; }
    70% { transform: scale(0.9); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

/* WordPress Specific Adjustments */
.wp-block-step-calculator {
    margin: 24px 0;
}

.step-calculator-container {
    aspect-ratio: 1/1.5;
    max-height: 800px;
}

/* Editor Styles */
.wp-block-step-calculator-editor {
    background: #f0f0f0;
    border-radius: 8px;
    padding: 24px;
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.editor-placeholder {
    text-align: center;
}

.editor-placeholder .dashicons {
    font-size: 48px;
    width: 48px;
    height: 48px;
    margin-bottom: 16px;
    color: #333;
}

.editor-placeholder h3 {
    margin: 0 0 16px;
    color: #333;
}

.editor-placeholder p {
    margin: 8px 0;
    color: #555;
}

/* Accessibility Improvements */
.step-calc-button:focus,
.step-calc-control-button:focus,
.calculator-button:focus,
#boton-limpiar:focus,
#boton-generar-cuestionario:focus,
#boton-verificar-respuestas:focus,
#boton-reiniciar-cuestionario:focus {
    outline: 2px solid var(--calc-button-blue);
    box-shadow: 0 0 10px rgba(74, 156, 255, 0.5);
    position: relative;
    z-index: 1;
}

/* Print styles */
@media print {
    .step-calculator,
    .math-quiz-container {
        box-shadow: none;
        border: 1px solid #ccc;
    }
    
    .step-calc-button,
    .calculator-button,
    #boton-limpiar,
    #boton-generar-cuestionario,
    #boton-verificar-respuestas,
    #boton-reiniciar-cuestionario {
        background-color: #eee !important;
        color: #333 !important;
        box-shadow: none !important;
    }
    
    .step-calc-display {
        border: 1px solid #ccc;
        box-shadow: none;
    }
}