@import url("./root.css");

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-light);
    transition: background-color 0.3s ease, color 0.3s ease;
    font-family: 'Inter', sans-serif;
    font-size: 18px;
    line-height: 1.6;
    color: var(--text-dark);
}

.body-dark {
    background-color: var(--bg-dark);
    color: var(--text-light);
}

main {
    max-width: 900px;
    width: 100%;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    flex-direction: column;
}

/* ========== NAVIGATION ========== */
nav {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    padding: 20px 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    margin-bottom: 48px;
    order: 1;
}

.body-dark nav {
    border-bottom-color: rgba(255, 255, 255, 0.1);
}

nav > div:first-child {
    justify-self: start;
}

nav > a {
    justify-self: center;
}

nav > div:last-child {
    justify-self: end;
}

nav img {
    height: 40px;
    width: auto;
    transition: transform 0.2s ease;
}

nav img:hover {
    transform: scale(1.05);
}

/* ========== DARK MODE TOGGLE ========== */
.checkbox {
    opacity: 0;
    position: absolute;
}

.checkbox-label {
    background: linear-gradient(135deg, var(--toggle-bg), rgba(0, 0, 0, 0.8));
    width: 60px;
    height: 32px;
    border-radius: 50px;
    position: relative;
    padding: 6px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
}

.checkbox-label:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.fa-moon {
    color: var(--moon-color);
}

.fa-sun {
    color: var(--sun-color);
}

.checkbox-label .ball {
    background-color: var(--text-light);
    width: 26px;
    height: 26px;
    position: absolute;
    left: 3px;
    top: 3px;
    border-radius: 50%;
    transition: transform 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.checkbox:checked + .checkbox-label .ball {
    transform: translateX(28px);
}

/* ========== LANGUAGE DROPDOWN ========== */
.custom-dropdown {
    position: relative;
    display: inline-block;
}

.custom-dropdown-button {
    padding: 8px 12px;
    font-size: 14px;
    text-align: left;
    background-color: transparent;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
    font-weight: 500;
    color: var(--text-dark);
}

.custom-dropdown-button:hover {
    background-color: rgba(0, 0, 0, 0.03);
    border-color: rgba(0, 0, 0, 0.15);
}

.arrow {
    border: solid var(--text-dark);
    border-width: 0 2px 2px 0;
    padding: 2.5px;
    transform: rotate(45deg);
    transition: transform 0.3s ease;
    margin-left: 6px;
}

.custom-dropdown-button.open .arrow {
    transform: rotate(-135deg);
}

.custom-dropdown-content {
    display: none;
    position: absolute;
    background-color: var(--dropdown-bg-light);
    min-width: 150px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    border-radius: 12px;
    z-index: 100;
    max-height: 320px;
    overflow-y: auto;
    padding: 8px;
    margin-top: 8px;
    right: 0;
    animation: dropdownSlide 0.2s ease-out;
}

@keyframes dropdownSlide {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.custom-dropdown-content a {
    text-decoration: none;
    color: var(--text-dark);
    padding: 10px 14px;
    display: block;
    border-radius: 8px;
    transition: background-color 0.2s ease;
    font-weight: 500;
    font-size: 14px;
}

.custom-dropdown-content a:hover {
    background-color: var(--dropdown-hover-light);
}

/* Dark mode dropdown */
.body-dark .custom-dropdown-button {
    color: var(--text-light);
    border-color: rgba(255, 255, 255, 0.2);
}

.body-dark .custom-dropdown-button:hover {
    background-color: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.3);
}

.body-dark .custom-dropdown-content {
    background-color: var(--dropdown-bg-dark);
}

.body-dark .custom-dropdown-content a {
    background-color: var(--dropdown-bg-dark);
    color: var(--text-light);
}

.body-dark .custom-dropdown-content a:hover {
    background-color: var(--dropdown-hover-dark);
}

.body-dark .custom-dropdown .arrow {
    border-color: var(--text-light) !important;
}

/* ========== HERO SECTION ========== */
h1 {
    text-align: center;
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: 16px;
    line-height: 1.2;
    letter-spacing: -0.02em;
    margin-top: 0;
    animation: fadeInUp 0.6s ease-out;
    order: 2;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

p.tag-line {
    text-align: center;
    font-size: 1.25rem;
    color: rgba(0, 0, 0, 0.6);
    font-weight: 400;
    letter-spacing: 0;
    margin-bottom: 48px;
    order: 3;
}

.body-dark p.tag-line {
    color: rgba(255, 255, 255, 0.7);
}

/* ========== MESSAGE BOXES ========== */
.message {
    display: flex;
    align-items: flex-start;
    background-color: var(--message-bg-light);
    margin-top: 16px;
    padding: 20px 24px;
    gap: 16px;
    border-radius: 12px;
    border: 1px solid transparent;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    transition: all 0.3s ease;
    order: 7;
}

.message:nth-of-type(2) {
    order: 8;
}

.message:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    transform: translateY(-2px);
}

.message svg {
    fill: var(--message-icon);
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    margin-top: 2px;
}

.message a {
    text-decoration: none;
    font-weight: 600;
    color: inherit;
    border-bottom: 2px solid var(--message-icon);
    transition: opacity 0.2s ease;
}

.message a:hover {
    opacity: 0.8;
}

.body-dark .message {
    background-color: var(--message-bg-dark);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* ========== SEARCH FORM ========== */
.download-form {
    background-color: var(--search-bg-light);
    border: 1px solid rgba(0, 0, 0, 0.06);
    margin-top: 32px;
    display: flex;
    gap: 12px;
    padding: 32px;
    border-radius: 16px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
    transition: all 0.3s ease;
    order: 5;
    /* Stays reachable while scrolling, on every screen size.
       The background above is opaque in both themes, so page content
       scrolls underneath it cleanly. Mobile narrows the offset below. */
    position: sticky;
    top: 16px;
    z-index: 60;
}

.download-form:focus-within {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
    border-color: rgba(0, 0, 0, 0.1);
}

.download-form input {
    flex: 1;
    font-size: 18px;
    padding: 16px 24px;
    border: 2px solid var(--input-border);
    border-radius: 12px;
    outline: none;
    transition: all 0.2s ease;
    background-color: white;
    font-family: 'Inter', sans-serif;
}

.download-form input:focus {
    border-color: var(--search-button-bg);
    box-shadow: 0 0 0 3px rgba(229, 62, 62, 0.1);
}

.download-form button {
    outline: none;
    border: none;
    background-color: var(--search-button-bg);
    color: var(--text-light);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 32px;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 600;
    font-size: 18px;
    white-space: nowrap;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(229, 62, 62, 0.3);
    font-family: 'Inter', sans-serif;
}

.download-form button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(229, 62, 62, 0.4);
}

.download-form button:active:not(:disabled) {
    transform: translateY(0);
}

.download-form button:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.body-dark .download-form {
    background-color: var(--search-bg-dark);
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.body-dark .download-form input {
    background-color: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.2);
    color: var(--text-light);
}

.body-dark .download-form input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

.body-dark .download-form input:focus {
    border-color: var(--search-button-bg);
    background-color: rgba(255, 255, 255, 0.08);
}

/* ========== SEARCH RESULTS ========== */
#searchResults {
    display: flex;
    flex-direction: column;
    margin: 32px 0;
    order: 6;
}

#searchResults .search-item {
    background-color: var(--search-bg-light);
    border: 1px solid rgba(0, 0, 0, 0.06);
    padding: 24px;
    display: flex;
    justify-content: center;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    margin-bottom: 16px;
    border-radius: 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
    animation: fadeInUp 0.4s ease-out;
}

.search-item:hover {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
    transform: translateY(-4px);
}

.search-item img {
    max-width: 100%;
    width: 100%;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease;
}

.search-item img:hover {
    transform: scale(1.02);
}

.search-item h4 {
    text-align: center;
    font-size: 1.125rem;
    font-weight: 600;
    line-height: 1.4;
    margin: 0;
}

.search-item button {
    min-width: 180px;
    outline: none;
    border: none;
    color: var(--text-light);
    padding: 14px 24px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    font-size: 16px;
    letter-spacing: 0;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    font-family: 'Inter', sans-serif;
}

.search-item button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.search-item button:active:not(:disabled) {
    transform: translateY(0);
}

.body-dark .search-item {
    background-color: var(--message-bg-dark) !important;
    border-color: rgba(255, 255, 255, 0.1) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3) !important;
}

/* Button colors */
.download-now-button {
    background-color: var(--download-now-button-bg) !important;
}

.body-dark .download-now-button {
    background-color: #3b82f6 !important;
}

.convert-another-button {
    background-color: var(--convert-another-button-bg) !important;
}

.follow-us-button {
    background-color: var(--follow-us-button-bg) !important;
}

.mp3-button {
    background-color: var(--mp3-button-bg) !important;
}

.mp4-button {
    background-color: var(--mp4-button-bg) !important;
}

/* ========== PAGE CONTENT ========== */
.page-content {
    line-height: 1.8;
    letter-spacing: 0;
    margin: 64px 0 32px;
    order: 10;
}

.page-content * {
    letter-spacing: 0;
    line-height: 1.8;
    color: inherit;
}

.page-content p {
    font-size: 16px;
    font-weight: 400;
    text-align: left;
    margin: 24px 0 !important;
    color: rgba(0, 0, 0, 0.8);
}

.body-dark .page-content p {
    color: rgba(255, 255, 255, 0.85);
}

.page-content h1,
.page-content h2,
.page-content h3,
.page-content h4 {
    margin: 32px 0 16px;
    font-weight: 600;
    line-height: 1.3;
}

.page-content ul,
.page-content ol {
    padding-left: 32px !important;
    margin: 16px 0 !important;
}

.page-content > p:first-of-type {
    margin-top: 0 !important;
}

/* ========== FOOTER ========== */
footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 0;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    margin-top: 64px;
    font-size: 14px;
    order: 11;
}

.body-dark footer {
    border-top-color: rgba(255, 255, 255, 0.1);
}

footer div {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

footer div a {
    text-decoration: none;
    color: inherit;
    opacity: 0.8;
    transition: opacity 0.2s ease;
    font-weight: 500;
}

footer div a:hover {
    opacity: 1;
}

/* ========== ELEMENT ORDERING ========== */
main > *:nth-child(4) {
    order: 4;
}

main > *:nth-child(8) {
    order: 9;
}

/* ========== RESPONSIVE DESIGN ========== */
@media (max-width: 768px) {
    main {
        padding: 0 16px;
    }

    nav {
        order: 1;
        grid-template-columns: auto 1fr auto;
        gap: 16px;
    }

    h1 {
        order: 2;
        font-size: 2rem;
    }

    p.tag-line {
        order: 3;
        font-size: 1.125rem;
    }

    main > *:nth-child(4) {
        order: 4;
    }

    .download-form {
        order: 5;
        flex-direction: column;
        padding: 24px;
    }

    #searchResults {
        order: 6;
    }

    main > .message:nth-of-type(1) {
        order: 7;
    }

    main > .message:nth-of-type(2) {
        order: 8;
    }

    main > *:nth-child(8) {
        order: 9;
    }

    .page-content {
        order: 10;
    }

    footer {
        order: 11;
    }

    .download-form button {
        justify-content: center;
        width: 100%;
    }

    .message {
        flex-direction: column;
        text-align: center;
        align-items: center;
        max-width: 90%;
        margin-left: auto;
        margin-right: auto;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }

    .search-item button {
        min-width: 0;
        width: 100%;
    }
}

@media (max-width: 458px) {
    footer {
        flex-direction: column;
        gap: 16px;
        text-align: center;
    }

    nav img {
        height: 32px;
    }

    h1 {
        font-size: 1.75rem;
    }

    .search-item button {
        font-size: 15px;
        padding: 12px 20px;
    }
}

/* Reduced motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}
/* ========== HOW IT WORKS - 3 STEPS ========== */
.how-steps {
    order: 6;
    list-style: none;
    margin: 48px 0 8px;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    counter-reset: how;
}

.how-step {
    position: relative;
    background-color: var(--search-bg-light);
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 16px;
    padding: 28px 20px 24px;
    text-align: center;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.how-step:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
}

.how-step-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background-color: var(--message-bg-light);
    color: var(--message-icon);
    font-size: 20px;
    margin-bottom: 14px;
}

.how-step-num {
    position: absolute;
    top: 14px;
    inset-inline-end: 16px;
    font-size: 13px;
    font-weight: 700;
    line-height: 1;
    color: var(--message-icon);
    opacity: 0.55;
}

.how-step h3 {
    font-size: 1rem;
    font-weight: 700;
    margin: 0 0 6px;
    color: var(--text-dark);
}

.how-step p {
    font-size: 14px;
    line-height: 1.6;
    margin: 0;
    color: rgba(0, 0, 0, 0.65);
}

.body-dark .how-step {
    background-color: var(--search-bg-dark);
    border-color: var(--border-dark);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

.body-dark .how-step-icon { background-color: var(--message-bg-dark); }
.body-dark .how-step h3 { color: var(--text-light); }
.body-dark .how-step p { color: rgba(255, 255, 255, 0.7); }

/* ========== RECENT DOWNLOAD PROOF TOAST ========== */
.proof-toast {
    position: fixed;
    inset-inline-end: 24px;
    bottom: 24px;
    z-index: 900;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    width: 320px;
    max-width: calc(100vw - 32px);
    padding: 14px 16px;
    background-color: var(--search-bg-light);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 14px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.16);
    opacity: 0;
    transform: translateY(14px);
    transition: opacity 0.35s ease, transform 0.35s ease;
    pointer-events: none;
}

.proof-toast.is-visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.proof-icon {
    flex: 0 0 auto;
    color: var(--message-icon);
    font-size: 18px;
    line-height: 1.2;
    margin-top: 1px;
}

.proof-body { flex: 1 1 auto; min-width: 0; }

.proof-toast p { margin: 0; text-align: start; }

.proof-line {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-dark);
}

.proof-title {
    font-size: 13px;
    color: rgba(0, 0, 0, 0.7);
    margin-top: 2px !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.proof-meta {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: rgba(0, 0, 0, 0.45);
    margin-top: 4px !important;
}

.proof-close {
    flex: 0 0 auto;
    background: none;
    border: 0;
    padding: 2px;
    cursor: pointer;
    font-size: 13px;
    line-height: 1;
    color: rgba(0, 0, 0, 0.35);
}

.proof-close:hover { color: rgba(0, 0, 0, 0.7); }

.body-dark .proof-toast {
    background-color: var(--search-bg-dark);
    border-color: var(--border-dark);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.body-dark .proof-line { color: var(--text-light); }
.body-dark .proof-title { color: rgba(255, 255, 255, 0.72); }
.body-dark .proof-meta { color: rgba(255, 255, 255, 0.45); }
.body-dark .proof-close { color: rgba(255, 255, 255, 0.4); }
.body-dark .proof-close:hover { color: rgba(255, 255, 255, 0.8); }

@media (max-width: 768px) {
    .how-steps {
        grid-template-columns: 1fr;
        gap: 12px;
        margin: 32px 0 8px;
    }

    .how-step {
        display: grid;
        grid-template-columns: auto 1fr;
        grid-template-areas: "icon title" "icon text";
        column-gap: 16px;
        row-gap: 2px;
        text-align: start;
        padding: 18px 20px;
        align-items: center;
    }

    .how-step-icon { grid-area: icon; margin-bottom: 0; }
    .how-step h3 { grid-area: title; }
    .how-step p { grid-area: text; }

    /* Sticky itself is set in the base rule now - only the phone-specific
       tweaks live here. Tighter offset because vertical space is scarcer. */
    .download-form {
        top: 12px;
        margin-top: 16px;
        border-radius: 14px;
    }

    .proof-toast {
        inset-inline: 12px;
        inset-inline-end: 12px;
        bottom: 12px;
        width: auto;
    }
}

@media (prefers-reduced-motion: reduce) {
    .how-step, .proof-toast { transition: none; }
    .how-step:hover { transform: none; }
}
