/**
 * Equinest Horse Age Calculator - Frontend Styles
 * Supports light mode (default) and dark mode via CSS media query
 */

/* CSS Custom Properties for theming */
:root {
    --ehac-bg: #ffffff;
    --ehac-bg-secondary: #f0faf6;
    --ehac-bg-faq: #fafafa;
    --ehac-text: #333333;
    --ehac-text-secondary: #555555;
    --ehac-text-muted: #666666;
    --ehac-border: #dddddd;
    --ehac-border-light: #eeeeee;
    --ehac-primary: #27AE7E;
    --ehac-primary-hover: #229e71;
    --ehac-shadow: rgba(0, 0, 0, 0.08);
}

/* Dark mode - triggered by system preference or WordPress theme */
@media (prefers-color-scheme: dark) {
    :root {
        --ehac-bg: #1e1e1e;
        --ehac-bg-secondary: #2d3a35;
        --ehac-bg-faq: #2a2a2a;
        --ehac-text: #e4e4e4;
        --ehac-text-secondary: #c0c0c0;
        --ehac-text-muted: #a0a0a0;
        --ehac-border: #444444;
        --ehac-border-light: #3a3a3a;
        --ehac-primary: #3cc98f;
        --ehac-primary-hover: #2fb87e;
        --ehac-shadow: rgba(0, 0, 0, 0.3);
    }
}

/* Support for WordPress themes that use a .dark-mode or similar class */
.dark-mode,
.is-dark-theme,
[data-theme="dark"],
[data-color-scheme="dark"] {
    --ehac-bg: #1e1e1e;
    --ehac-bg-secondary: #2d3a35;
    --ehac-bg-faq: #2a2a2a;
    --ehac-text: #e4e4e4;
    --ehac-text-secondary: #c0c0c0;
    --ehac-text-muted: #a0a0a0;
    --ehac-border: #444444;
    --ehac-border-light: #3a3a3a;
    --ehac-primary: #3cc98f;
    --ehac-primary-hover: #2fb87e;
    --ehac-shadow: rgba(0, 0, 0, 0.3);
}

/* Calculator container */
.ehac-calculator {
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    max-width: 520px;
    margin: 20px auto;
    padding: 56px 48px;
    background: var(--ehac-bg);
    border-radius: 16px;
    box-shadow: 0 4px 20px var(--ehac-shadow);
}

.ehac-calculator *,
.ehac-calculator *::before,
.ehac-calculator *::after {
    box-sizing: border-box;
}

/* Logo (inline SVG) */
.ehac-logo {
    display: block;
    width: 200px;
    height: auto;
    margin: 0 auto 32px;
    color: #000000;
}

/* Logo text paths use currentColor, green path stays green */
.ehac-logo-text {
    fill: currentColor;
}

.ehac-logo-green {
    fill: #27AE7E;
}

/* Dark mode logo - change text color to white, keep green */
@media (prefers-color-scheme: dark) {
    .ehac-logo {
        color: #ffffff;
    }
}

.dark-mode .ehac-logo,
.is-dark-theme .ehac-logo,
[data-theme="dark"] .ehac-logo,
[data-color-scheme="dark"] .ehac-logo {
    color: #ffffff;
}

/* Title */
.ehac-title {
    margin: 0 0 24px;
    padding: 0;
    font-size: 24px;
    font-weight: 700;
    text-align: center;
    color: var(--ehac-text);
    border: none;
    background: none;
}

/* Label */
.ehac-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    font-size: 14px;
    color: var(--ehac-text-secondary);
}

/* Input */
.ehac-input {
    width: 100%;
    padding: 16px 20px;
    font-size: 16px;
    color: var(--ehac-text);
    background: var(--ehac-bg);
    border: 1px solid var(--ehac-border);
    border-radius: 8px;
    margin-bottom: 8px;
    transition: border-color 0.2s ease;
    -webkit-appearance: none;
    -moz-appearance: textfield;
}

.ehac-input::placeholder {
    color: var(--ehac-text-muted);
}

.ehac-input:focus {
    outline: none;
    border-color: var(--ehac-primary);
}

/* Remove spinner buttons on number input for better mobile UX */
.ehac-input::-webkit-inner-spin-button,
.ehac-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Error message */
.ehac-error {
    display: none;
    padding: 12px 16px;
    margin-bottom: 12px;
    background: #fee;
    border: 1px solid #fcc;
    border-radius: 6px;
    color: #c33;
    font-size: 14px;
    text-align: center;
}

@media (prefers-color-scheme: dark) {
    .ehac-error {
        background: #4a2020;
        border-color: #662020;
        color: #ffb3b3;
    }
}

.dark-mode .ehac-error,
.is-dark-theme .ehac-error,
[data-theme="dark"] .ehac-error,
[data-color-scheme="dark"] .ehac-error {
    background: #4a2020;
    border-color: #662020;
    color: #ffb3b3;
}

/* Button */
.ehac-button {
    width: 100%;
    padding: 16px 20px;
    min-height: 48px;
    font-size: 16px;
    font-weight: 500;
    background: var(--ehac-primary);
    color: #ffffff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
    touch-action: manipulation;
}

.ehac-button:hover {
    background: var(--ehac-primary-hover);
}

.ehac-button:active {
    background: var(--ehac-primary-hover);
    transform: scale(0.98);
}

.ehac-button:focus {
    outline: 2px solid var(--ehac-primary);
    outline-offset: 2px;
}

/* Result container */
.ehac-result {
    margin-top: 24px;
    padding: 24px;
    background: var(--ehac-bg-secondary);
    border-radius: 8px;
    text-align: center;
    display: none;
}

.ehac-result.ehac-show {
    display: block;
}

/* Human age display */
.ehac-human-age {
    font-size: 36px;
    font-weight: bold;
    color: var(--ehac-primary);
}

.ehac-human-age-label {
    color: var(--ehac-text-muted);
    margin-top: 5px;
    font-size: 14px;
}

/* FAQ Section */
.ehac-faq-section {
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--ehac-border-light);
}

.ehac-faq-title {
    margin: 0 0 16px;
    padding: 0;
    font-size: 18px;
    font-weight: 700;
    text-align: center;
    color: var(--ehac-text);
    border: none;
    background: none;
}

.ehac-faq-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ehac-faq-item {
    border: 1px solid var(--ehac-border-light);
    border-radius: 8px;
    overflow: hidden;
}

.ehac-faq-question {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    min-height: 48px;
    margin: 0;
    background: var(--ehac-bg-faq);
    border: none;
    border-radius: 0;
    cursor: pointer;
    text-align: left;
    font-size: 15px;
    font-weight: 600;
    color: var(--ehac-text);
    transition: background-color 0.2s ease;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.05);
    touch-action: manipulation;
}

.ehac-faq-question:hover {
    background: #f5f5f5;
}

/* Dark mode FAQ hover */
@media (prefers-color-scheme: dark) {
    .ehac-faq-question:hover {
        background: #363636;
    }
}

.dark-mode .ehac-faq-question:hover,
.is-dark-theme .ehac-faq-question:hover,
[data-theme="dark"] .ehac-faq-question:hover,
[data-color-scheme="dark"] .ehac-faq-question:hover {
    background: #363636;
}

.ehac-faq-question:focus {
    outline: 2px solid var(--ehac-primary);
    outline-offset: -2px;
}

.ehac-faq-question span:first-child {
    flex: 1;
    padding-right: 16px;
}

/* FAQ Icon (plus that rotates to X) */
.ehac-faq-icon {
    position: relative;
    width: 12px;
    height: 12px;
    flex-shrink: 0;
    transition: transform 0.3s ease-out;
}

.ehac-faq-icon::before,
.ehac-faq-icon::after {
    content: '';
    position: absolute;
    background-color: var(--ehac-primary);
    border-radius: 1px;
}

/* Horizontal line */
.ehac-faq-icon::before {
    top: 50%;
    left: 0;
    width: 100%;
    height: 2px;
    transform: translateY(-50%);
}

/* Vertical line */
.ehac-faq-icon::after {
    top: 0;
    left: 50%;
    width: 2px;
    height: 100%;
    transform: translateX(-50%);
}

/* Rotate entire icon 45 degrees to become X when open */
.ehac-faq-item.ehac-faq-open .ehac-faq-icon {
    transform: rotate(45deg);
}

/* FAQ Answer */
.ehac-faq-answer {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    background: var(--ehac-bg);
}

.ehac-faq-item.ehac-faq-open .ehac-faq-answer {
    max-height: 500px;
}

.ehac-faq-answer p {
    margin: 0;
    padding: 16px;
    font-size: 14px;
    line-height: 1.6;
    color: var(--ehac-text-secondary);
}

/* Responsive adjustments for tablets */
@media (max-width: 768px) {
    .ehac-calculator {
        margin: 15px auto;
        padding: 40px 32px;
        max-width: 100%;
    }

    .ehac-input,
    .ehac-button {
        font-size: 16px;
    }
}

/* Responsive adjustments for mobile phones */
@media (max-width: 600px) {
    .ehac-calculator {
        margin: 10px;
        padding: 32px 20px;
        border-radius: 12px;
    }

    .ehac-logo {
        width: 160px;
        margin-bottom: 24px;
    }

    .ehac-title {
        font-size: 20px;
        margin-bottom: 20px;
    }

    .ehac-input {
        padding: 14px 16px;
        font-size: 16px;
    }

    .ehac-button {
        padding: 14px 16px;
        min-height: 48px;
        font-size: 16px;
    }

    .ehac-result {
        padding: 20px;
        margin-top: 20px;
    }

    .ehac-human-age {
        font-size: 32px;
    }

    .ehac-faq-section {
        margin-top: 28px;
        padding-top: 20px;
    }

    .ehac-faq-title {
        font-size: 16px;
        margin-bottom: 12px;
    }

    .ehac-faq-question {
        padding: 14px 12px;
        min-height: 48px;
        font-size: 14px;
    }

    .ehac-faq-question span:first-child {
        padding-right: 12px;
    }

    .ehac-faq-answer p {
        padding: 14px 12px;
        font-size: 13px;
        line-height: 1.5;
    }
}

/* Extra small screens */
@media (max-width: 360px) {
    .ehac-calculator {
        margin: 5px;
        padding: 24px 16px;
    }

    .ehac-logo {
        width: 140px;
    }

    .ehac-title {
        font-size: 18px;
    }
}
