/* Liitetiedostot block (digitaali/attachments) */
/* Toimii sellaisenaan sivulla: reunaviiva tekee kortin nakyvaksi myos
   valkoisella taustalla, joten group-lohkoa ei tarvita ympärille. */
.dg-attachments {
    margin: 0 0 12px;
    padding: 0 20px;
    background-color: var(--wp--preset--color--white, #fff);
    border: 1px solid var(--wp--preset--color--border-gray, #D9D9D9);
    border-radius: 5px;
}
.dg-attachments:last-child {
    margin-bottom: 0;
}

/* Accordion header - mirrors the details block so groups look alike */
.dg-attachments__summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 0;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--wp--preset--color--secondary, #001020);
    cursor: pointer;
    list-style: none;
}
.dg-attachments__summary::marker,
.dg-attachments__summary::-webkit-details-marker {
    display: none !important;
    content: none !important;
}
.dg-attachments__summary::after {
    content: '›';
    flex-shrink: 0;
    margin-left: 1rem;
    font-size: 1.6rem;
    font-weight: 300;
    line-height: 1;
    color: var(--wp--preset--color--secondary, #001020);
    transition: transform 0.3s ease;
}
.dg-attachments[open] > .dg-attachments__summary {
    padding-bottom: 10px;
}
.dg-attachments[open] > .dg-attachments__summary::after {
    transform: rotate(90deg);
}

.dg-attachments__list {
    margin: 0;
    padding: 0 0 20px;
    list-style: none;
}

.dg-attachments__item {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 20px;
    padding: 14px 0;
    border-bottom: 1px solid var(--wp--preset--color--border-gray, #D9D9D9);
}
.dg-attachments__item:last-child {
    border-bottom: none;
}

/* File name is the primary link - opens the document */
.dg-attachments__name {
    flex: 1 1 260px;
    min-width: 0;
    overflow-wrap: anywhere;
    font-weight: 600;
    line-height: 1.4;
    color: var(--wp--preset--color--secondary, #001020);
    text-decoration: none;
}
.dg-attachments__name:hover,
.dg-attachments__name:focus-visible {
    text-decoration: underline;
}

/* Format, size and the download button travel together on the right */
.dg-attachments__aside {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    gap: 14px;
}

.dg-attachments__meta {
    font-size: 0.85rem;
    line-height: 1.4;
    white-space: nowrap;
    color: var(--wp--preset--color--text-gray, #707070);
}

.dg-attachments__button {
    padding: 7px 18px;
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1.4;
    border-radius: 3px;
    background-color: var(--wp--preset--color--secondary, #001020);
    color: var(--wp--preset--color--white, #fff);
    text-decoration: none;
    transition: background-color 0.2s ease;
}
.dg-attachments__button:hover,
.dg-attachments__button:focus-visible {
    background-color: var(--wp--preset--color--primary-dark, #3d4a1f);
    color: var(--wp--preset--color--white, #fff);
}

/* --- Editor -------------------------------------------------------------
   Everything visible is edited on canvas: group title, row names, order,
   removal and adding files. The sidebar only holds the visibility toggles.
   The canvas reuses the front-end classes, so this section only adds the
   editing affordances on top. */

.dg-attachments-editor {
    padding-bottom: 8px;
}

/* No chevron in the editor - the list is always expanded there, so an
   accordion arrow would suggest a click that does nothing. */
.dg-attachments-editor__title::after {
    content: none;
}
.dg-attachments-editor__title {
    margin: 0;
    cursor: text;
}

/* The download button is a preview in the editor, not a link */
.dg-attachments-editor .dg-attachments__button {
    cursor: default;
    opacity: 0.55;
}

.dg-attachments-editor__controls {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    gap: 2px;
    margin-left: 6px;
    padding-left: 10px;
    border-left: 1px solid var(--wp--preset--color--border-gray, #D9D9D9);
}

.dg-attachments-editor__add {
    padding: 14px 0 6px;
}

.dg-attachments-editor__empty {
    margin: 0 0 8px;
    padding: 32px 20px;
    text-align: center;
    background-color: #f0f0f0;
    border: 2px dashed #ccc;
    border-radius: 4px;
}
.dg-attachments-editor__empty p {
    margin: 0 0 12px;
    color: #757575;
}

/* Row name is a TextControl that should read as plain text, not a form field */
.dg-attachments-editor__namefield {
    flex: 1 1 260px;
    min-width: 0;
    margin: 0 !important;
}
.dg-attachments-editor__namefield .components-base-control__field {
    margin: 0 !important;
}
.dg-attachments-editor__namefield input.components-text-control__input {
    width: 100%;
    min-height: 0;
    padding: 2px 4px;
    margin: 0;
    /* 1rem eikä inherit: Gutenbergin base-control pakottaa kontrolleille 13px,
       ja rivin pitää editorissa nayttaa samalta kuin frontissa. */
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.4;
    color: var(--wp--preset--color--secondary, #001020);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 3px;
    box-shadow: none;
}
.dg-attachments-editor__namefield input.components-text-control__input:hover {
    border-color: var(--wp--preset--color--border-gray, #D9D9D9);
}
.dg-attachments-editor__namefield input.components-text-control__input:focus {
    border-color: var(--wp--preset--color--secondary, #001020);
    box-shadow: none;
}
.dg-attachments-editor__namefield input.components-text-control__input::placeholder {
    color: var(--wp--preset--color--text-gray, #707070);
    font-weight: 400;
    opacity: 1;
}

@media (max-width: 575px) {
    .dg-attachments {
        padding: 0 15px;
    }
    .dg-attachments__summary {
        font-size: 0.95rem;
    }
    .dg-attachments__item {
        justify-content: flex-start;
    }
    .dg-attachments__name {
        flex: 1 1 100%;
    }
}
