/* Reset and base */
*, *::before, *::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Avenir, Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    background-color: #f8fafc;
    color: #1f2937;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a {
    color: #2563eb;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.container {
    max-width: 900px;
    width: 100%;
    margin: 0 auto;
    padding: 0 1rem;
}

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

/* Header */
.site-header {
    padding: 1.5rem 0 0.5rem;
}

.site-header .container {
    text-align: center;
}

.site-logo img {
    width: 5rem;
    height: auto;
    display: block;
    margin: 0 auto 1rem;
}

.site-nav {
    margin-bottom: 0.5rem;
}

.site-nav__link {
    font-weight: bold;
    color: #2c3e50;
    text-decoration: none;
}

.site-nav__link:hover,
.site-nav__link--active {
    color: #2563eb;
}

.site-nav__sep {
    margin: 0 0.5rem;
    color: #9ca3af;
}

/* Hero */
.hero {
    text-align: center;
    margin: 1.5rem 0 2rem;
}

.hero h1 {
    font-size: clamp(2rem, 6vw, 3.5rem);
    font-weight: bold;
    margin: 0 0 0.5rem;
}

.hero__subtitle {
    color: #6b7280;
    font-size: 1.1rem;
    margin: 0;
}

.hero__subtitle a {
    color: inherit;
    font-weight: bold;
}

/* Calculator */
.calculator-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 3rem;
}

.mode-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
    margin-bottom: 1.5rem;
}

.mode-btn {
    padding: 0.5rem 1rem;
    font-size: 0.95rem;
    font-weight: 600;
    background: white;
    color: #374151;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s, color 0.2s;
}

.mode-btn:hover {
    background-color: #f3f4f6;
}

.mode-btn:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

.mode-btn--active {
    background-color: #1f2937;
    color: white;
    border-color: #1f2937;
}

.mode-btn--active:hover {
    background-color: #374151;
}

.calculator__form {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.calculator__row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-size: 1.25rem;
    font-weight: bold;
    padding: 1rem 0;
}

.calculator__prefix,
.calculator__connector,
.calculator__suffix {
    white-space: nowrap;
}

.calculator__label {
    display: inline-block;
}

.input {
    padding: 0.5rem;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    font-size: 1.25rem;
    width: 100px;
    text-align: center;
    transition: border-color 0.2s;
    font-weight: bold;
}

.input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.25);
}

.input:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 1px;
}

.validation-message {
    min-height: 1.25rem;
    margin: 0 0 0.5rem;
    font-size: 0.9rem;
    font-weight: normal;
    color: #dc2626;
    text-align: center;
}

.calculate-btn {
    margin: 0.5rem 0 1.5rem;
    padding: 0.75rem 1.5rem;
    font-size: 1.25rem;
    font-weight: bold;
    background-color: #1f2937;
    color: white;
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: background-color 0.2s;
}

.calculate-btn:hover:not(:disabled) {
    background-color: #374151;
}

.calculate-btn:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

.calculate-btn:disabled {
    background-color: #9ca3af;
    cursor: not-allowed;
}

.calculator__answer {
    text-align: center;
    min-height: 1.2em;
}

#answerDisplay {
    font-size: clamp(3rem, 12vw, 7rem);
    font-weight: bold;
    color: #1f2937;
    margin: 0;
    line-height: 1.1;
    word-break: break-word;
}

.controls {
    margin-top: 1rem;
}

.control-btn {
    padding: 0.5rem 1.5rem;
    font-size: 1rem;
    color: #6b7280;
    background-color: transparent;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: background-color 0.2s;
}

.control-btn:hover {
    background-color: #e5e7eb;
}

.control-btn:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

.control-btn[hidden] {
    display: none;
}

/* Content sections */
.section-divider {
    border: none;
    border-top: 1px solid #e5e7eb;
    margin: 2rem 0;
}

.content-section {
    margin-bottom: 2.5rem;
}

.content-section__title {
    text-align: center;
    font-size: clamp(1.5rem, 4vw, 2rem);
    margin: 0 0 1.5rem;
}

.content {
    line-height: 1.7;
    color: #374151;
}

.content p {
    margin: 0 0 1rem;
}

.content ol,
.content ul {
    margin: 0 0 1rem;
    padding-left: 1.5rem;
}

.content li {
    margin-bottom: 0.5rem;
}

.content li p {
    margin: 0;
}

/* Footer */
.site-footer {
    margin-top: auto;
    padding: 2rem 0;
    border-top: 1px solid #ececec;
    text-align: center;
    color: #6b7280;
    font-size: 0.95rem;
}

.site-footer p {
    margin: 0;
    line-height: 1.6;
}

.heart-icon {
    height: 0.8rem;
    vertical-align: middle;
}

main {
    flex: 1;
}

/* Mobile */
@media (max-width: 600px) {
    .calculator__row {
        flex-direction: column;
        font-size: 1rem;
        gap: 0.75rem;
    }

    .input {
        width: 140px;
        font-size: 1rem;
    }

    .mode-btn {
        font-size: 0.85rem;
        padding: 0.4rem 0.75rem;
    }
}
