/* ============================================================
   components/file.css — Majestic V2 file field & dropzone
   ------------------------------------------------------------
   Track C. Two opt-in shapes, both keeping the native
   <input type="file"> as the submitted source:

     • .majestic-file      compact field — a browse button plus a
                           file name / count and a clear action.
     • .majestic-filedrop  a keyboard/click/drag/drop zone. Paste is
                           accepted only while the zone itself is
                           focused; it never captures page-wide paste.

   Namespaced away from the legacy .majestic-dropzone system so both
   can coexist until the legacy sweep in Phase 10.
   ============================================================ */

/* ==========================================================================
   COMPACT FILE FIELD
   ========================================================================== */

.majestic-file {
    display: grid;
    gap: 6px;
    min-width: 0;
    font-family: var(--font-input);
}
.majestic-file__legend {
    color: var(--text-muted-color);
    font-size: 0.6875rem;
    font-weight: 500;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
.majestic-file--required .majestic-file__legend::after { content: " *"; color: var(--danger-color); }

.majestic-file__control {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: var(--control-height);
    padding: 4px 6px 4px 4px;
    background: var(--input-background);
    border: 1px solid var(--input-border-color);
    border-radius: var(--radius-control);
    box-shadow: var(--control-inset-shadow);
    transition: border-color var(--motion-default) var(--ease-out), background-color var(--motion-default) var(--ease-out);
}
.majestic-file__control:hover { border-color: var(--border-color-strong); }
.majestic-file:has(.majestic-file__input:focus-visible) .majestic-file__control {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-focus);
}

/* Native input stays for form submission but is visually removed. */
.majestic-file[data-file-init] .majestic-file__input {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
.majestic-file__browse { flex: 0 0 auto; }
.majestic-file__name {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    color: var(--text-color);
    font-size: 0.875rem;
}
.majestic-file__name--empty { color: var(--text-subtle-color); }
.majestic-file__clear {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    padding: 0;
    color: var(--text-muted-color);
    background: transparent;
    border: 0;
    border-radius: 50%;
    cursor: pointer;
}
.majestic-file__clear[hidden] { display: none; }
.majestic-file__clear:hover { color: var(--danger-color); background: var(--surface-hover); }
.majestic-file__clear:focus-visible { outline: 2px solid var(--primary-color); outline-offset: 1px; }
.majestic-file__clear .majestic-icon { width: 0.95rem; height: 0.95rem; }

.majestic-file__message { margin: 0; color: var(--text-muted-color); font-size: 0.75rem; line-height: 1.4; }
.majestic-file__message:empty { display: none; }
.majestic-file--invalid .majestic-file__control { border-color: var(--danger-border-color); background: var(--danger-background); }
.majestic-file--invalid .majestic-file__message { color: var(--danger-color); }

/* ==========================================================================
   DROPZONE
   ========================================================================== */

.majestic-filedrop {
    display: grid;
    gap: 6px;
    min-width: 0;
    font-family: var(--font-input);
}
.majestic-filedrop__legend {
    color: var(--text-muted-color);
    font-size: 0.6875rem;
    font-weight: 500;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.majestic-filedrop__zone {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 148px;
    padding: 24px;
    text-align: center;
    color: var(--text-muted-color);
    background: var(--inner-card-background);
    border: 1.5px dashed var(--border-color-strong);
    border-radius: var(--radius-control);
    cursor: pointer;
    transition: border-color var(--motion-default) var(--ease-out), background-color var(--motion-default) var(--ease-out), color var(--motion-default) var(--ease-out);
}
.majestic-filedrop__zone:hover { border-color: var(--primary-color); color: var(--text-color); }
.majestic-filedrop__zone:focus-visible { outline: none; border-color: var(--primary-color); box-shadow: var(--shadow-focus); }
.majestic-filedrop--dragging .majestic-filedrop__zone {
    border-color: var(--primary-color);
    background: color-mix(in srgb, var(--primary-color) 10%, var(--inner-card-background));
    color: var(--text-color);
}

.majestic-filedrop[data-filedrop-init] .majestic-filedrop__input {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
.majestic-filedrop__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    color: var(--primary-color);
    background: color-mix(in srgb, var(--primary-color) 12%, transparent);
    border-radius: var(--radius-inner);
}
.majestic-filedrop__icon .majestic-icon { width: 22px; height: 22px; }
.majestic-filedrop__prompt { color: var(--text-color); font-size: 0.875rem; font-weight: 500; }
.majestic-filedrop__prompt strong { color: var(--primary-color); font-weight: 600; }
.majestic-filedrop__hint { font-size: 0.75rem; }

/* Selected files list */
.majestic-filedrop__files { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.majestic-filedrop__files:empty { display: none; }
.majestic-filedrop__file {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    background: var(--inner-card-background);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-inner);
}
.majestic-filedrop__thumb {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    overflow: hidden;
    color: var(--text-muted-color);
    background: var(--surface-3);
    border-radius: var(--radius-control);
}
.majestic-filedrop__thumb .majestic-icon { width: 1.05rem; height: 1.05rem; }
.majestic-filedrop__file-meta { flex: 1 1 auto; min-width: 0; display: grid; gap: 1px; }
.majestic-filedrop__file-name { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: var(--text-color); font-size: 0.8125rem; }
.majestic-filedrop__file-size { color: var(--text-subtle-color); font-size: 0.6875rem; font-variant-numeric: tabular-nums; }
.majestic-filedrop__file-remove {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    padding: 0;
    color: var(--text-muted-color);
    background: transparent;
    border: 0;
    border-radius: 50%;
    cursor: pointer;
}
.majestic-filedrop__file-remove:hover { color: var(--danger-color); background: var(--surface-hover); }
.majestic-filedrop__file-remove:focus-visible { outline: 2px solid var(--primary-color); outline-offset: 1px; }
.majestic-filedrop__file-remove .majestic-icon { width: 0.9rem; height: 0.9rem; }
.majestic-filedrop__message { margin: 0; color: var(--text-muted-color); font-size: 0.75rem; line-height: 1.4; }
.majestic-filedrop__message:empty { display: none; }
.majestic-filedrop--invalid .majestic-filedrop__zone { border-color: var(--danger-border-color); background: var(--danger-background); }
.majestic-filedrop--invalid .majestic-filedrop__message { color: var(--danger-color); }
.majestic-file[data-disabled],
.majestic-filedrop[data-disabled] { opacity: 0.55; }
.majestic-filedrop[data-disabled] .majestic-filedrop__zone { cursor: not-allowed; }

@media (prefers-reduced-motion: reduce) {
    .majestic-filedrop__zone,
    .majestic-file__control { transition-duration: 0.01ms; }
}

@media (forced-colors: active) {
    .majestic-file__control,
    .majestic-filedrop__zone { border-color: ButtonText; }
    .majestic-filedrop--dragging .majestic-filedrop__zone,
    .majestic-filedrop__zone:focus-visible { border-color: Highlight; }
}
