/* Data Format Converter (/data-format-converter): only what is the app's own (the two panes side by side with Swap
   between them, the editors with line numbers and the marked error line, the notes). Panels, fields, buttons, tags,
   messages and colours come from the app kit (css/app-kit, docs/app-kit.md). Loaded only on this app's page
   (StylePaths in its demo catalog entry). */

/* On a phone the site's photo-app rule sets align-items: start on every stage, which beats the kit's stretch. */
.dfc-landing-app > .ak-stage > * {
    align-self: stretch;
    min-width: 0;
}

/* --- The panes: stacked, side by side once there is room ---------------------------------------------------------- */

.dfc-landing-app .dfc-wrap {
    container-type: inline-size;
    min-width: 0;
}

.dfc-landing-app .dfc-panes {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--ak-space-2);
    align-items: stretch;
}

@container (min-width: 46rem) {
    .dfc-landing-app .dfc-panes {
        grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    }
}

.dfc-landing-app .dfc-pane {
    gap: var(--ak-space-2);
    min-width: 0;
}

.dfc-landing-app .dfc-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--ak-space-2);
    min-width: 0;
}

.dfc-landing-app .dfc-format {
    flex: 0 1 auto;
    width: auto;
    min-width: 7.5rem;
    font-weight: 600;
}

.dfc-landing-app .dfc-detected {
    font-family: var(--ak-font-mono);
    font-weight: 700;
}

.dfc-landing-app .dfc-tools {
    display: inline-flex;
    gap: var(--ak-space-1);
    margin-inline-start: auto;
}

/* Swap: a round button between the panes (turned a quarter while they are stacked). */
.dfc-landing-app .dfc-swap-cell {
    display: flex;
    align-items: center;
    justify-content: center;
}

.dfc-landing-app .dfc-swap {
    border-radius: 999px;
}

.dfc-landing-app .dfc-swap .ak-icon {
    transform: rotate(90deg);
}

@container (min-width: 46rem) {
    .dfc-landing-app .dfc-swap .ak-icon {
        transform: none;
    }
}

/* --- The editors: line numbers beside a borderless text area, in the frame of a kit field ------------------------- */

.dfc-landing-app .dfc-editor {
    position: relative;
    display: flex;
    height: clamp(16rem, 66vh, 40rem);
    overflow: hidden;
    border: 1px solid var(--ak-border);
    border-radius: var(--ak-radius-sm);
    background: var(--ak-field);
    direction: ltr;
}

.dfc-landing-app .dfc-editor--out {
    background: color-mix(in srgb, var(--ak-panel) 55%, var(--ak-field));
}

.dfc-landing-app .dfc-editor:focus-within {
    outline: 2px solid var(--ak-accent);
    outline-offset: 1px;
    border-color: var(--ak-accent);
}

.dfc-landing-app .dfc-editor.is-invalid {
    border-color: var(--ak-danger);
}

.dfc-landing-app .dfc-editor.is-drop {
    border-color: var(--ak-accent);
    box-shadow: 0 0 0 2px var(--ak-accent) inset;
}

.dfc-landing-app .dfc-gutter,
.dfc-landing-app .dfc-text {
    font-family: var(--ak-font-mono);
    font-size: var(--ak-fs-sm);
    line-height: 1.5;
}

.dfc-landing-app .dfc-gutter {
    flex: 0 0 auto;
    min-width: 2.75rem;
    padding: 0.5rem 0.45rem 2rem;
    overflow: hidden;
    border-inline-end: 1px solid var(--ak-border);
    background: var(--ak-panel);
    color: var(--ak-muted);
    text-align: right;
    white-space: pre;
    user-select: none;
}

.dfc-landing-app .dfc-gutter-err {
    display: block;
    margin: 0 -0.45rem;
    padding: 0 0.45rem;
    background: var(--ak-danger);
    color: var(--ak-bg);
    font-weight: 700;
}

.dfc-landing-app .dfc-area {
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
}

/* The marked error line, behind the (transparent) text area; the script moves it with the scroll. */
.dfc-landing-app .dfc-hl {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    background: color-mix(in srgb, var(--ak-danger) 16%, transparent);
    border-block: 1px solid color-mix(in srgb, var(--ak-danger) 45%, transparent);
    pointer-events: none;
}

.dfc-landing-app .dfc-text {
    position: relative;
    display: block;
    box-sizing: border-box;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0.5rem 0.6rem;
    overflow: auto;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--ak-text);
    box-shadow: none;
    resize: none;
    tab-size: 4;
    white-space: pre;
    text-align: left;
}

.dfc-landing-app .dfc-text:focus {
    outline: none;
    box-shadow: none;
}

.dfc-landing-app .dfc-text::placeholder {
    color: var(--ak-muted);
    white-space: pre-wrap;
}

/* --- The error and the notes ---------------------------------------------------------------------------------------- */

.dfc-landing-app .dfc-error {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--ak-space-2);
}

.dfc-landing-app .dfc-error[hidden],
.dfc-landing-app .dfc-notes[hidden] {
    display: none;
}

.dfc-landing-app .dfc-error-text {
    flex: 1 1 12rem;
    min-width: 0;
    overflow-wrap: anywhere;
}

.dfc-landing-app .dfc-notes {
    margin: 0;
    padding-inline-start: 1.1rem;
    color: var(--ak-muted);
    font-size: var(--ak-fs-sm);
}

@media (max-width: 640px) {
    .dfc-landing-app .dfc-editor {
        height: 12rem;
    }
}
