/* The workbench: the shell, the app bar, the toolbar, the two panes and the status bar,
   one section per part of the page. Only the shell pages (the workbench and /not-found)
   load this. */

/* ==== Shell ================================================================= */

:root {
    --ff-statusbar-h: 1.5rem;
    --ff-mono: 'JetBrains Mono', 'Cascadia Mono', 'Cascadia Code', 'Consolas', ui-monospace, monospace;
    --ff-sans: 'Inter', 'Segoe UI Variable Text', 'Segoe UI', system-ui, -apple-system, sans-serif;
}

.ff-shell {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--ff-bg);
    color: var(--ff-text);
    font-family: var(--ff-sans);
    font-size: 0.875rem;
}

/* ==== App bar =============================================================== */

.appbar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: none;
    height: 2.75rem;
    padding: 0 0.625rem;
    background: var(--ff-chrome);
    border-bottom: 1px solid var(--ff-border);
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.4375rem;
    flex: none;
}

.brand-mark {
    width: 1.375rem;
    height: 1.375rem;
}

.brand-name {
    color: var(--ff-text);
    font-size: 0.9375rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.brand-name-accent {
    color: var(--ff-accent);
}

.appbar-tagline {
    padding-left: 0.75rem;
    border-left: 1px solid var(--ff-border);
    color: var(--ff-faint);
    font-size: 0.75rem;
    white-space: nowrap;
}

.appbar-spacer {
    flex: 1;
}

@media (max-width: 1228.78px) {
    .appbar {
        gap: 0.5rem;
    }
}

/* ==== Theme switch ========================================================== */

.theme-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    flex: none;
    padding: 0.25rem 0.5rem;
    border: 1px solid var(--ff-border);
    border-radius: 999px;
    background: transparent;
    color: var(--ff-muted);
    font: inherit;
    font-size: 0.75rem;
    cursor: pointer;
}

.theme-btn:hover:not(:disabled) {
    background: var(--ff-chrome-hover);
    color: var(--ff-text);
}

.theme-btn:disabled {
    cursor: default;
    opacity: 0.6;
}

/* The label is the first thing to go when the chrome tightens - the glyph on its
   own still says which way the switch will move. */
@media (max-width: 1228.78px) {
    .theme-btn-label {
        display: none;
    }
}

/* ==== Toolbar =============================================================== */

.ff-tools {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    flex: none;
    padding: 0.3125rem 0.625rem;
    background: var(--ff-chrome-2);
    border-bottom: 1px solid var(--ff-border);
    color: var(--ff-muted);
    font-size: 0.75rem;
}

.tools-label {
    margin-right: 0.125rem;
    color: var(--ff-faint);
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.tools-sep {
    flex: none;
    width: 1px;
    height: 1.125rem;
    margin: 0 0.375rem;
    background: var(--ff-border);
}

.tools-spacer {
    flex: 1;
    min-width: 0.5rem;
}

/* A switch drawn as one joined strip. Pressed rather than one-shot - the state is how
   the text is being read. */
.seg {
    display: inline-flex;
    flex: none;
    overflow: hidden;
    border: 1px solid var(--ff-border);
    border-radius: 5px;
}

.seg > button {
    position: relative;
    padding: 0.1875rem 0.5625rem;
    border: 0;
    background: transparent;
    color: var(--ff-muted);
    font: inherit;
    font-size: 0.75rem;
    white-space: nowrap;
    cursor: pointer;
}

.seg > button + button {
    border-left: 1px solid var(--ff-border);
}

.seg > button:hover:not(.is-on):not(:disabled) {
    background: var(--ff-chrome-hover);
    color: var(--ff-text);
}

.seg > button.is-on {
    background: var(--ff-accent-wash);
    color: var(--ff-accent);
    font-weight: 600;
}

.seg > button:disabled {
    cursor: default;
    opacity: 0.45;
}

/* Under Auto, the language it found: picked out with a rule under it rather than
   pressed, because Auto is what is pressed. */
.seg > button.is-detected {
    color: var(--ff-text);
}

.seg > button.is-detected::after {
    content: "";
    position: absolute;
    left: 0.5rem;
    right: 0.5rem;
    bottom: 0.125rem;
    height: 2px;
    border-radius: 1px;
    background: var(--ff-accent);
}

/* A one-shot action: an icon, and a label the narrower layouts drop. */
.tool-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.3125rem;
    flex: none;
    padding: 0.1875rem 0.5rem 0.1875rem 0.375rem;
    border: 1px solid transparent;
    border-radius: 5px;
    background: transparent;
    color: var(--ff-muted);
    font: inherit;
    font-size: 0.75rem;
    white-space: nowrap;
    cursor: pointer;
}

.tool-btn svg {
    width: 0.875rem;
    height: 0.875rem;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.tool-btn:hover:not(:disabled) {
    background: var(--ff-chrome-hover);
    border-color: var(--ff-border);
    color: var(--ff-text);
}

.tool-btn:disabled {
    cursor: default;
    opacity: 0.45;
}

@media (max-width: 1228.78px) {
    .ff-tools {
        gap: 0.25rem;
    }

    .tool-label {
        display: none;
    }

    .tool-btn {
        padding-right: 0.375rem;
    }
}

/* ==== Workbench ============================================================= */

/* One grid, input | handle | output. Track sizes are bare `fr` values so a drag just moves
   budget between neighbours; js/panes.js rewrites these custom properties during a drag.
   They must stay free of any `minmax()` floor - with a floor in the track, grid
   subtracts the floors before distributing the remainder, so sizes stop being
   proportional to the custom properties and the arithmetic in panes.js no longer holds.
   The minimum pane size is clamped in JS instead.

   The starting proportions are `var()` fallbacks rather than declarations on this
   element, because a remembered layout is applied to <html> before first paint (see the
   inline script in the page head) and a declaration here would shadow what it inherits. */
.ff {
    position: relative;
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: var(--ff-size-input, 2fr) auto var(--ff-size-output, 3fr);
    grid-template-rows: minmax(0, 1fr);
    background: var(--ff-bg);
}

.pane-input { grid-area: 1 / 1; }
.pane-output { grid-area: 1 / 3; }

/* The handle: a gutter in the shell colour, hairlined on both sides, with a short grip
   in the middle. Its axis is read from its box by panes.js, so the same handle works
   when the narrow layout stacks the panes. */
.ff-split {
    position: relative;
    z-index: 1;
    display: grid;
    place-items: center;
    grid-column: 2;
    grid-row: 1;
    width: 9px;
    background: var(--ff-bg);
    border-inline: 1px solid var(--ff-border);
    cursor: col-resize;
    touch-action: none;
}

.ff-split::after {
    content: "";
    display: block;
    width: 3px;
    height: 2rem;
    border-radius: 999px;
    background: var(--ff-faint);
    opacity: 0.5;
}

.ff-split:hover,
.ff-split:focus-visible {
    background: var(--ff-accent-wash);
    border-color: var(--ff-accent-dim);
    outline: none;
}

.ff-split:hover::after,
.ff-split:focus-visible::after,
.ff-split.is-dragging::after {
    background: var(--ff-accent);
    opacity: 1;
}

.ff-split.is-dragging {
    background: var(--ff-accent-wash);
    border-color: var(--ff-accent);
}

@media (pointer: coarse) {
    .ff-split {
        width: 17px;
    }
}

/* ==== Panes ================================================================= */

.pane {
    position: relative;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    background: var(--ff-pane);
}

/* A file is being dragged over the workbench. */
.pane.is-drop-target {
    box-shadow: inset 0 0 0 2px var(--ff-accent-dim);
    background: color-mix(in srgb, var(--ff-accent-wash) 60%, var(--ff-pane));
}

.pane-head {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: none;
    min-height: 1.9375rem;
    box-sizing: border-box;
    padding: 0.25rem 0.5rem 0.25rem 0.625rem;
    background: var(--ff-pane-alt);
    border-bottom: 1px solid var(--ff-border-soft);
}

.pane-title {
    margin: 0;
    color: var(--ff-text);
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.11em;
    text-transform: uppercase;
}

.pane-meta {
    color: var(--ff-muted);
    font-size: 0.6875rem;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* The name of the file the input was opened from. It gives way first when the header is
   short of room. */
.pane-file {
    min-width: 0;
    overflow: hidden;
    color: var(--ff-text);
    font-family: var(--ff-mono);
    font-size: 0.6875rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pane-head-spacer {
    flex: 1;
    min-width: 0.5rem;
}

.pane-actions {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex: none;
}

/* Small ghost buttons in the pane header bars. */
.pane-btn {
    padding: 0.1875rem 0.4375rem;
    border: 1px solid transparent;
    border-radius: 4px;
    background: transparent;
    color: var(--ff-muted);
    font: inherit;
    font-size: 0.75rem;
    white-space: nowrap;
    cursor: pointer;
}

.pane-btn:hover:not(:disabled) {
    background: var(--ff-chrome-hover);
    border-color: var(--ff-border);
    color: var(--ff-text);
}

.pane-btn:disabled {
    cursor: default;
    opacity: 0.55;
}

/* What the text is being read as. */
.lang-badge {
    padding: 0.0625rem 0.4375rem;
    border: 1px solid var(--ff-accent-dim);
    border-radius: 999px;
    background: var(--ff-accent-wash);
    color: var(--ff-accent);
    font-size: 0.6875rem;
    font-weight: 600;
    white-space: nowrap;
}

/* Detected rather than chosen: the same badge, with a dot that says "found it". */
.lang-badge.is-detected::before {
    content: "";
    display: inline-block;
    width: 0.375rem;
    height: 0.375rem;
    margin-right: 0.3125rem;
    border-radius: 50%;
    background: currentColor;
    vertical-align: 0.0625rem;
}

.pane-editor {
    flex: 1;
    min-height: 0;
    min-width: 0;
    padding: 0.5rem 0.75rem;
    border: 0;
    outline: 0;
    resize: none;
    background: transparent;
    color: var(--ff-text);
    font-family: var(--ff-mono);
    font-size: 0.8125rem;
    line-height: 1.55;
    tab-size: 4;
    white-space: pre;
    overflow: auto;
}

.pane-editor::placeholder {
    color: var(--ff-faint);
}

.pane-editor:focus-visible {
    box-shadow: inset 2px 0 0 var(--ff-accent);
}

/* ==== The formatted text ==================================================== */

.ff-view {
    flex: 1;
    min-height: 0;
    min-width: 0;
    overflow: auto;
    outline: 0;
    font-family: var(--ff-mono);
    font-size: 0.8125rem;
    line-height: 1.55;
}

.ff-view[hidden] {
    display: none;
}

.ff-view:focus-visible {
    box-shadow: inset 2px 0 0 var(--ff-accent);
}

/* Line numbers and text side by side, as wide as the longest line, so the numbers can
   stick to the left edge while the text scrolls sideways under them. */
.ff-lines {
    display: flex;
    width: max-content;
    min-width: 100%;
    min-height: 100%;
}

.ff-gutter,
.ff-code {
    margin: 0;
    padding: 0.5rem 0;
    font: inherit;
    line-height: inherit;
    white-space: pre;
}

.ff-gutter {
    position: sticky;
    left: 0;
    z-index: 1;
    flex: none;
    box-sizing: content-box;
    min-width: calc(var(--ff-gutter-ch, 2) * 1ch);
    padding-inline: 0.75rem 0.625rem;
    background: var(--ff-pane-alt);
    border-right: 1px solid var(--ff-border-soft);
    color: var(--ff-faint);
    text-align: right;
    user-select: none;
}

.ff-code {
    flex: 1;
    padding-inline: 0.875rem 1.5rem;
    color: var(--ff-text);
    tab-size: 4;
}

.ff-code code {
    font: inherit;
}

.ff-code ::selection {
    background: var(--ff-accent-dim);
}

/* What each kind of token looks like. Names cool, values warm, comments quiet. */
.t-key { color: var(--ff-syn-key); }
.t-str { color: var(--ff-syn-str); }
.t-num { color: var(--ff-syn-num); }
.t-lit { color: var(--ff-syn-lit); }
.t-kw { color: var(--ff-syn-kw); }
.t-type { color: var(--ff-syn-type); }
.t-fn { color: var(--ff-syn-fn); }
.t-com { color: var(--ff-syn-com); font-style: italic; }
.t-tag { color: var(--ff-syn-tag); }
.t-attr { color: var(--ff-syn-attr); }
.t-punc { color: var(--ff-syn-punc); }
.t-op { color: var(--ff-syn-punc); }
.t-meta { color: var(--ff-syn-meta); }
.t-err {
    color: var(--ff-danger);
    text-decoration: underline wavy var(--ff-danger);
    text-underline-offset: 3px;
}

/* ==== Nothing pasted yet ==================================================== */

.ff-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    text-align: center;
}

.ff-empty[hidden] {
    display: none;
}

.ff-empty-mark {
    width: 3.25rem;
    height: 3.25rem;
    margin-bottom: 1rem;
    fill: none;
    stroke-width: 2.2;
    stroke-linecap: round;
    stroke-linejoin: round;
    opacity: 0.9;
}

.ff-empty-title {
    margin: 0 0 0.375rem;
    color: var(--ff-text);
    font-size: 1.0625rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.ff-empty-text {
    max-width: 24rem;
    margin: 0 0 1.5rem;
    color: var(--ff-muted);
    font-size: 0.8125rem;
    line-height: 1.55;
}

.ff-empty-label {
    margin: 0 0 0.5rem;
    color: var(--ff-faint);
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.ff-samples {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.375rem;
    max-width: 26rem;
}

.chip {
    padding: 0.25rem 0.75rem;
    border: 1px solid var(--ff-border);
    border-radius: 999px;
    background: var(--ff-pane-alt);
    color: var(--ff-muted);
    font: inherit;
    font-size: 0.75rem;
    cursor: pointer;
}

.chip:hover,
.chip:focus-visible {
    border-color: var(--ff-accent-dim);
    background: var(--ff-accent-wash);
    color: var(--ff-accent);
    outline: none;
}

/* ==== Status bar ============================================================ */

.statusbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex: none;
    box-sizing: border-box;
    /* Fixed, so the privacy sheet can sit exactly on top of it. */
    height: var(--ff-statusbar-h);
    padding: 0 0.75rem;
    background: var(--ff-chrome);
    border-top: 1px solid var(--ff-border);
    color: var(--ff-muted);
    font-size: 0.6875rem;
}

.statusbar-item {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.statusbar-item:empty {
    display: none;
}

/* The verdict: what the text was read as, and whether it read cleanly. */
.statusbar-summary {
    color: var(--ff-text);
}

.statusbar-summary.is-ok {
    color: var(--ff-ok);
}

.statusbar-summary.is-error {
    color: var(--ff-danger);
}

.statusbar-summary.is-unknown {
    color: var(--ff-muted);
}

/* The first problem in the input, as a link to it. */
.statusbar-error {
    min-width: 0;
    overflow: hidden;
    padding: 0 0.4375rem;
    border: 0;
    border-radius: 3px;
    background: var(--ff-danger-wash);
    color: var(--ff-danger);
    font: inherit;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
}

.statusbar-error:hover,
.statusbar-error:focus-visible {
    text-decoration: underline;
}

.statusbar-error[hidden] {
    display: none;
}

.statusbar-spacer {
    flex: 1;
}

/* Something the user asked for did, or did not, happen. */
.statusbar-warn {
    min-width: 0;
    overflow: hidden;
    color: var(--ff-text);
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Feedback, Privacy and the privacy sheet are css/privacy-sheet.css and css/feedback.css,
   copies of shared/feedback-and-privacy/. */

/* ==== Narrow screens ======================================================== */

/* Below tablet width the panes stack: input above, formatted text below, the handle
   between them now dragging up and down. The toolbar scrolls sideways rather than
   wrapping, and the chrome sheds what it can do without. */
@media (max-width: 921.58px) {
    .ff {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: var(--ff-size-input, 2fr) auto var(--ff-size-output, 3fr);
    }

    .pane-input { grid-area: 1 / 1; }
    .pane-output { grid-area: 3 / 1; }

    .ff-split {
        grid-column: 1;
        grid-row: 2;
        width: auto;
        height: 9px;
        border-inline: 0;
        border-block: 1px solid var(--ff-border);
        cursor: row-resize;
    }

    .ff-split::after {
        width: 2rem;
        height: 3px;
    }

    .appbar-tagline,
    .statusbar-item:not(.statusbar-summary) {
        display: none;
    }

    .ff-tools {
        overflow-x: auto;
        scrollbar-width: none;
    }

    .statusbar {
        gap: 0.625rem;
    }
}

@media (max-width: 921.58px) and (pointer: coarse) {
    .ff-split {
        width: auto;
        height: 17px;
    }
}

/* ==== Not found ============================================================= */

.missing {
    flex: 1;
    display: grid;
    place-items: center;
    padding: 2rem;
    text-align: center;
}

.missing h1 {
    margin: 0 0 0.5rem;
    font-size: 1.125rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.missing p {
    margin: 0 0 1rem;
    color: var(--ff-muted);
}

.missing a {
    color: var(--ff-accent);
}
