/* typography */
:root {
    --md-ref-typeface-brand: 'Google Sans Flex', system-ui, sans-serif;
    --md-ref-typeface-plain: 'Google Sans Flex', system-ui, sans-serif;
}

body {
    font-family: 'Google Sans Flex', system-ui, sans-serif;
    margin: 0;
}

.m3e-typescale-title-medium {
    font-size: var(--md-sys-typescale-title-medium-font-size);
    font-weight: var(--md-sys-typescale-title-medium-font-weight);
    line-height: var(--md-sys-typescale-title-medium-line-height);
    letter-spacing: var(--md-sys-typescale-title-medium-tracking);
}

.m3e-typescale-body-large {
    font-size: var(--md-sys-typescale-body-large-font-size);
    font-weight: var(--md-sys-typescale-body-large-font-weight);
    line-height: var(--md-sys-typescale-body-large-line-height);
    letter-spacing: var(--md-sys-typescale-body-large-tracking);
}

.m3e-typescale-body-medium {
    font-size: var(--md-sys-typescale-body-medium-font-size);
    font-weight: var(--md-sys-typescale-body-medium-font-weight);
    line-height: var(--md-sys-typescale-body-medium-line-height);
    letter-spacing: var(--md-sys-typescale-body-medium-tracking);
}

.m3e-typescale-body-small {
    font-size: var(--md-sys-typescale-body-small-font-size);
    font-weight: var(--md-sys-typescale-body-small-font-weight);
    line-height: var(--md-sys-typescale-body-small-line-height);
    letter-spacing: var(--md-sys-typescale-body-small-tracking);
}

/* global */

m3e-theme {
    display: flex;
    justify-content: center;
    align-items: center;

    min-height: 100vh;
    padding: 24px;
    box-sizing: border-box;
    width: 100%;
}

audio {
    width: 100%;
    height: 40px;
    border-radius: 20px;
}



/* layouts */

.container {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 880px;
    gap: 24px;
}

.content-grid {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.column-stack {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    position: relative;
    z-index: 2;
}

header m3e-heading {
    font-family: 'Google Sans Flex', system-ui, sans-serif !important;
    font-stretch: 135% !important;
    font-weight: 775 !important;
    font-variation-settings: 'opsz' 32, 'ROND' 100 !important;
}

/* containers */

#downloadCard, #optionsCard {
    --m3e-card-padding: 24px;
}

.card-content {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

#buttonContainer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 8px;
}

#buttonContainer:not(:has(> m3e-button:not([style*="display: none"]))) {
    display: none !important;
}

.disabled-card {
    pointer-events: none;
    position: relative;
}

.disabled-card::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: var(--m3e-card-shape, 12px);
    z-index: 2;

    background: var(--md-sys-color-on-surface);
    opacity: 0.12;
}

#downloadCard:has(#downloadArea:empty) {
    display: none;
}

#downloadCard > .card-content {
    margin-top: -12px;
}

#downloadCard {
    opacity: 1;
    transform: translateY(0) scaleY(1);
    transform-origin: top;
    transition: 
        opacity var(--md-sys-motion-spring-slow-effects, 200ms cubic-bezier(0.34, 0.88, 0.34, 1)),
        transform var(--md-sys-motion-spring-slow-effects, 200ms cubic-bezier(0.34, 0.88, 0.34, 1));
}

@starting-style {
    #downloadCard {
        opacity: 0;
        transform: translateY(-8px) scaleY(0.95);
    }
}

#downloadArea > m3e-card {
    --m3e-card-padding: 16px;
    margin-bottom: 16px;
    opacity: 1;
    transform: scale(1);
    transition: 
        opacity var(--md-sys-motion-spring-slow-effects, 200ms cubic-bezier(0.34, 0.88, 0.34, 1)),
        transform var(--md-sys-motion-spring-slow-effects, 200ms cubic-bezier(0.34, 0.88, 0.34, 1));
}

#downloadArea > m3e-card:last-child {
    margin-bottom: 0;
}

#downloadArea > m3e-card .card-content {
    gap: 12px;
}

@starting-style {
    #downloadArea > m3e-card {
        opacity: 0;
        transform: scale(0.95);
    }
}

.result-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 12px;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: -12px;
}

.result-card-title {
    display: flex;
    align-items: center;
    gap: 8px;
}

.result-card-actions {
    display: flex;
    gap: 8px;
}

/* components */

.file-area {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 24px;
    text-align: left;
    position: relative;
    min-height: auto;
    padding: 32px 24px;
    background-color: var(--md-sys-color-surface-container-lowest, #000);
    border: 2px dashed var(--md-sys-color-outline);
    border-radius: 12px;
    transition: all 0.17s ease;
}

.file-area:hover {
    border-color: var(--md-sys-color-primary);
    background-color: var(--md-sys-color-surface-container);
}

.file-area.disabled {
    opacity: 0.5;
    pointer-events: none;
}

.file-area input[type="file"] {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.file-text-wrapper {
    display: flex;
    flex-direction: column;
}

.file-area p {
    color: var(--md-sys-color-on-surface);
    margin: 0;
    font-variation-settings: 'wght' 500;
    transition: font-variation-settings 0.2s ease;
}

.file-area:hover p {
    font-variation-settings: 'wght' 700;
}

.file-area small {
    color: var(--md-sys-color-on-surface-variant);
}

#fileAreaIcon {
    color: var(--md-sys-color-primary);
}

.download-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

.download-filename {
    font-family: 'Google Sans Code', monospace;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--md-sys-color-on-surface);
    flex: 1;
}

/* queue items */

.queue-item {
    --m3e-list-item-container-height: 64px;
    opacity: 1;
    transform: scale(1);
    transition: 
        opacity var(--md-sys-motion-spring-slow-effects, 200ms cubic-bezier(0.34, 0.88, 0.34, 1)),
        transform var(--md-sys-motion-spring-slow-effects, 200ms cubic-bezier(0.34, 0.88, 0.34, 1));
}

@starting-style {
    .queue-item {
        opacity: 0;
        transform: scale(0.95);
    }
}

.queue-item m3e-circular-progress-indicator {
    --m3e-circular-wavy-progress-indicator-diameter: 24px;
}

.queue-filename {
    font-family: 'Google Sans Code', monospace;
    font-size: 14px;
    font-weight: 500;
    color: var(--md-sys-color-on-surface);
}

.queue-trailing {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: center;
    text-align: right;
    line-height: 1.3;
}

.queue-status {
    font-size: 13px;
    font-weight: 500;
    color: var(--md-sys-color-on-surface);
}

.queue-frames {
    font-size: 11px;
    font-weight: 400;
    color: var(--md-sys-color-on-surface-variant);
    margin-top: 2px;
}

.queue-item.error-state {
    --m3e-list-item-label-text-color: var(--md-sys-color-error);
}

.queue-item.error-state .queue-status,
.queue-item.error-state .queue-frames {
    color: var(--md-sys-color-error);
}

/* forms */

.advanced-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    padding: 16px;
}

m3e-form-field {
    width: 100%;
}

.switch-wrapper {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
}

#cicpSelect m3e-option,
#drcEffect m3e-option {
    --m3e-option-container-height: 52px;
}

#cicpSelect m3e-option .option-title,
#drcEffect m3e-option .option-title {
    display: block;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.2;
    white-space: normal;
}

#cicpSelect m3e-option option-desc,
#drcEffect m3e-option option-desc {
    display: block;
    white-space: normal;
}

input[type=number]::-webkit-outer-spin-button,
input[type=number]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type=number] {
    appearance: textfield;
}

/* misc */

.error-btn {
    --m3e-button-container-color: var(--md-sys-color-error);
    --m3e-button-label-text-color: var(--md-sys-color-on-error);
    --m3e-button-icon-color: var(--md-sys-color-on-error);
    --m3e-button-hover-state-layer-color: var(--md-sys-color-on-error);
    --m3e-button-pressed-state-layer-color: var(--md-sys-color-on-error);
}

#startBtn, #cancelBtn {
    display: flex;
    overflow: hidden;
    opacity: 1;
    transform: translateY(0);
    transition: 
        opacity var(--md-sys-motion-spring-slow-effects, 200ms cubic-bezier(0.34, 0.88, 0.34, 1)),
        transform var(--md-sys-motion-spring-slow-effects, 200ms cubic-bezier(0.34, 0.88, 0.34, 1)),
        display var(--md-sys-motion-spring-slow-effects, 200ms cubic-bezier(0.34, 0.88, 0.34, 1)) allow-discrete;
}

@starting-style {
    #startBtn, #cancelBtn {
        opacity: 0;
        transform: translateY(-8px);
    }
}

#statusArea {
    overflow: hidden;
}

.status-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    color: var(--md-sys-color-on-surface);
}

.perfbox-widget {
    display: flex;
    align-items: center;
    gap: 12px;

    background-color: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
    padding: 8px 16px;
    border-radius: 12px;

    opacity: 1;
    transform: translateY(0);
    transition: 
        opacity var(--md-sys-motion-spring-slow-effects, 200ms cubic-bezier(0.34, 0.88, 0.34, 1)),
        transform var(--md-sys-motion-spring-slow-effects, 200ms cubic-bezier(0.34, 0.88, 0.34, 1)),
        display var(--md-sys-motion-spring-slow-effects, 200ms cubic-bezier(0.34, 0.88, 0.34, 1)) allow-discrete;
}

@starting-style {
    .perfbox-widget {
        opacity: 0;
        transform: translateY(-16px);
    }
}

.perfbox-primary {
    font-weight: bold;
    font-family: 'Google Sans Code', monospace;
}

.perfbox-secondary {
    font-size: 0.8em;
    opacity: 0.8;
}

/* media */

@media (max-width: 600px) {
    header {
        flex-direction: column;
        justify-content: center;
        text-align: center;
    }

    .perfbox-widget {
        margin-top: 0px;
        z-index: 1;
    }

    .advanced-grid {
        grid-template-columns: 1fr;
    }

    .download-header {
        flex-direction: column;
        align-items: stretch;
    }

    .download-header m3e-button {
        align-self: center;
    }
}
