/* DASHBOARD (dashboard/index, orders, downloads; devise/registrations/edit, delete)
   Layers over main.css, style-page.css and cart.css.
   The style page's skeleton: the sections are tabs on the 20px bar, a green 10% account
   panel hangs from the bar on the left, and the section's content sits on the right. */

/* ---------- account panel ---------- */


.accountPanel {
    grid-column: span 3;
    align-self: start;
    margin-top: -20px;
    background-color: rgba(21, 71, 52, 0.1);
    padding: 20px;
    border-radius: 0 0 10px 10px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.accountWho {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.accountWho p:last-child {
    font-size: 0.875em;
    overflow-wrap: anywhere;
}

.accountDiscount {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-top: 20px;
    border-top: 1px solid rgba(21, 71, 52, 0.35);
}

.accountDiscount .specsLabel {
    margin-bottom: 0;
}

.accountDiscount .amount {
    font-size: 2.25em;
    font-weight: 700;
    line-height: 1;
}

.accountDiscount p:last-child {
    font-size: 0.875em;
}

.accountPanel .cartLinks {
    justify-content: flex-start;
    padding-top: 20px;
    border-top: 1px solid rgba(21, 71, 52, 0.35);
}

/* ---------- content column ---------- */

.dashContent {
    grid-column: span 7;
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-width: 0;
}

.dashCard {
    background-color: #FFF;
    padding: 20px;
    min-width: 0;
}

/* fields on white take the paper ground, as the sample field in the tester bar does */
.dashCard .textField, .dashCard .styleSelect select {
    background-color: #F4F6F2;
}

.dashMessage {
    font-size: 2.25em;
    text-wrap: balance;
    margin-bottom: 20px;
}

.dashEmpty {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.dashEmpty > p:first-child {
    font-size: 1.5em;
}

/* ---------- forms ---------- */

.dashForm {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 20px;
}

.formField {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
}

.formField .specsLabel, .formGroup .specsLabel {
    margin-bottom: 0;
}

.formField.wide {
    grid-column: span 2;
}

.formField.full, .formGroup, .formCheck {
    grid-column: 1 / -1;
}

/* a hint inside a label: lowercase, black, so it reads as a remark, not a heading */
.fieldHint {
    text-transform: none;
    letter-spacing: 0;
    color: #000;
}

.formNote {
    font-size: 0.875em;
}

/* a heading for a group of fields (Billing address): the label, bolder; its hint stays regular */
.specsLabel.groupHeading {
    font-weight: bolder;
}

.specsLabel.groupHeading .fieldHint {
    font-weight: normal;
}

.formGroup {
    padding-top: 20px;
    border-top: 1px solid rgba(21, 71, 52, 0.35);
}

/* a field that opens a group of its own keeps the field width */
.formField.formGroup > .textField {
    max-width: calc((100% - 40px) / 3);
}

.formActions {
    grid-column: 1 / -1;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 20px;
    padding-top: 20px;
    border-top: 1px solid rgba(21, 71, 52, 0.35);
}

.formActions .actionButton {
    width: auto;
}

.dashCard > .cartLinks {
    margin-top: 20px;
    justify-content: flex-start;
}

/* Devise's own error block (devise_error_messages!), styled where it stands: an alert */
#error_explanation {
    grid-column: 1 / -1;
    background-color: #BC004C;
    color: #FFF;
    padding: 16px 30px 16px 24px;
}

#error_explanation h2 {
    grid-column: auto;
    font-size: 1em;
    font-weight: 700;
    margin-bottom: 8px;
}

#error_explanation ul {
    list-style: none;
    font-size: 0.875em;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* ---------- order history: one row per order, opening to its licenses ---------- */

.historyHead, .historyOrder > summary {
    display: grid;
    grid-template-columns: 1.75em minmax(0, 1fr) minmax(0, 1.3fr) minmax(0, 1.5fr) minmax(0, 1.3fr) minmax(0, 2fr);
    column-gap: 20px;
    align-items: baseline;
}

.historyHead {
    padding-bottom: 12px;
}

.historyHead .specsLabel {
    margin-bottom: 0;
}

.historyHead .num, .historyOrder .num {
    text-align: right;
}

.historyOrder {
    border-top: 1px solid rgba(21, 71, 52, 0.35);
}

.historyOrder > summary {
    list-style: none;
    padding: 8px 0;
    cursor: pointer;
    transition: 200ms;
}

.historyOrder > summary::-webkit-details-marker {
    display: none;
}

.historyOrder > summary:hover {
    background-color: rgba(21, 71, 52, 0.1);
}

.historyOrder > summary:focus-visible {
    outline: 2px solid #154734;
    outline-offset: -2px;
}

.historyToggle {
    text-align: center;
    transition: transform 200ms;
}

.historyOrder[open] .historyToggle {
    transform: rotate(90deg);
}

.historyOrder .historyTotal {
    font-weight: 700;
    text-wrap: nowrap;
}

.historyActions {
    display: flex;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 8px 12px;
}

.historyLicense {
    display: grid;
    grid-template-columns: 1.75em 1.75em minmax(0, 3fr) minmax(0, 2.5fr) minmax(0, 1fr);
    column-gap: 20px;
    align-items: baseline;
    padding: 8px 0;
    border-top: 1px solid rgba(21, 71, 52, 0.35);
    font-size: 0.875em;
}

.historyLicense > i {
    grid-column: 2;
    text-align: center;
}

.historyLicense > :last-child {
    text-align: right;
    text-wrap: nowrap;
}

/* ---------- downloads: a card per font, opening to the download options ---------- */

.dashContent .cartItem {
    grid-column: auto;
}

.downloadPanel {
    background-color: rgba(21, 71, 52, 0.1);
    border-top: solid 20px #111;
    border-radius: 0 0 10px 10px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.downloadPanel .lic-title {
    font-size: 1.5rem;
}

.downloadHead {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 20px;
}

.downloadGroup {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-top: 20px;
    border-top: 1px solid rgba(21, 71, 52, 0.35);
}

.downloadGroup .specsLabel {
    margin-bottom: 0;
}

.checkGrid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px 20px;
}

.checkGrid .styleSelect {
    grid-column: span 2;
}

.downloadPanel .formActions {
    padding-top: 20px;
}

/* ---------- widths ---------- */

@media only screen and (max-width: 1410px) {
    .dashContent {
        grid-column: span 5;
    }
    .dashForm, .checkGrid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .formField.wide, .checkGrid .styleSelect {
        grid-column: 1 / -1;
    }
    .historyHead, .historyOrder > summary {
        grid-template-columns: 1.75em minmax(0, 1fr) minmax(0, 1.3fr) minmax(0, 1.3fr);
    }
    /* rows that wrap to a second line keep it clear of the first */
    .historyOrder > summary {
        row-gap: 4px;
    }
    .historyHead > :nth-child(4), .historyHead > :nth-child(6) {
        display: none;
    }
    /* order, date, total on the first line; status and the documents under them */
    .historyOrder > summary > :nth-child(1) { grid-area: 1 / 1; }
    .historyOrder > summary > :nth-child(2) { grid-area: 1 / 2; }
    .historyOrder > summary > :nth-child(3) { grid-area: 1 / 3; }
    .historyOrder .historyTotal { grid-area: 1 / 4; }
    .historyOrder .historyStatus {
        grid-area: 2 / 2;
        font-size: 0.875em;
    }
    .historyActions {
        grid-area: 2 / 3 / auto / span 2;
    }
}

/* 6 columns: the account panel lies across the top */
@media only screen and (max-width: 1150px) {
    .accountPanel {
        grid-column: span 6;
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        column-gap: 40px;
        align-items: start;
    }
    .accountDiscount, .accountPanel .cartLinks {
        padding-top: 0;
        border-top: 0;
    }
    .accountPanel .cartLinks {
        justify-content: flex-end;
    }
    .dashContent {
        grid-column: span 6;
    }
}

@media only screen and (max-width: 880px) {
    .accountPanel, .dashContent {
        grid-column: span 5;
    }
    .accountPanel {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .accountPanel .cartLinks {
        grid-column: 1 / -1;
        justify-content: flex-start;
    }
}

@media only screen and (max-width: 760px) {
    .accountPanel, .dashContent {
        grid-column: span 4;
    }
    .accountPanel {
        display: flex;
    }
    .dashForm, .checkGrid {
        grid-template-columns: minmax(0, 1fr);
    }
    .historyHead {
        display: none;
    }
    .historyOrder > summary {
        grid-template-columns: 1.75em minmax(0, 1fr) auto;
        row-gap: 6px;
    }
    /* order and total; date and status; then the documents */
    .historyOrder > summary > :nth-child(3) {
        grid-area: 2 / 2;
        font-size: 0.875em;
    }
    .historyOrder .historyTotal { grid-area: 1 / 3; }
    .historyOrder .historyStatus { grid-area: 2 / 3; text-align: right; }
    .historyActions {
        grid-area: 3 / 2 / auto / span 2;
        justify-content: flex-start;
    }
    .historyLicense {
        grid-template-columns: 1.75em minmax(0, 1fr) auto;
        grid-template-areas: "icon item price" ".    lic  .";
        row-gap: 2px;
    }
    .historyLicense > i { grid-area: icon; }
    .historyLicense > :nth-child(2) { grid-area: item; }
    .historyLicense > :nth-child(3) { grid-area: lic; }
    .historyLicense > :nth-child(4) { grid-area: price; }
    /* four tabs fit a phone only without their icons */
    .dashTabs .tab, .dashTabs .tab-active {
        padding: 10px 12px;
        font-size: 0.875em;
        text-wrap: nowrap;
    }
    .dashTabs i {
        display: none;
    }
}

/* ---------- order history: one grid for all rows ----------
   Where <details> can be laid out as a grid (Chrome 131, Safari 18.4, Firefox 143: the same
   releases that brought ::details-content), the list is one grid and every row shares its
   columns through subgrid, so each column takes the width of its widest cell, as a table does.
   Elsewhere the fixed proportions above apply. */

@supports selector(::details-content) {
    .historyList {
        display: grid;
        grid-template-columns: 1.75em repeat(5, auto);
        column-gap: 20px;
    }
    .historyHead, .historyOrder, .historyOrder > summary {
        grid-column: 1 / -1;
        display: grid;
        grid-template-columns: subgrid;
    }
    .historyOrder::details-content {
        grid-column: 1 / -1;
    }
    @media only screen and (max-width: 1410px) {
        .historyList {
            grid-template-columns: 1.75em repeat(3, auto);
        }
    }
    @media only screen and (max-width: 760px) {
        .historyList {
            grid-template-columns: 1.75em minmax(0, 1fr) auto;
        }
        .historyHead {
            display: none;
        }
    }
}
