/* The settings of the user: their own navigation next to cards of settings, the list of devices and their dialogs. */

.settings {
    display: flex;
    flex-wrap: wrap;
    gap: 2rem;
    align-items: flex-start;
}

.settings-nav {
    display: flex;
    flex: 0 1 13.75rem;
    flex-direction: column;
    gap: 2px;
}

.settings-main {
    display: flex;
    flex: 1 1 32.5rem;
    flex-direction: column;
    gap: 1.5rem;
    min-width: 0;
    max-width: 47.5rem;
}

/* --- Cards ------------------------------------------------------------------
 * A group of settings (or a form of them) on paper.
 */

.card {
    display: flex;
    flex-direction: column;
    gap: 1.125rem;
    padding: 1.5rem;
    border: 1px solid var(--thread);
    border-radius: var(--radius-card);
    background: var(--paper);
}

.card h2 {
    font-size: 1.375rem;
}

.card-header {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    align-items: flex-start;
}

.card-header-text {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.card-header p {
    color: var(--bark);
    font-size: 0.8125rem;
    line-height: 1.5;
}

.card-footer {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
    padding-top: 1.125rem;
    border-top: 1px solid var(--thread);
}

/* One setting with its action on the right, e.g. the password and the button changing it. */
.card-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
    justify-content: space-between;
}

.card-row-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.card-row-title {
    font-size: 0.875rem;
    font-weight: 600;
}

.card-row-note,
.account-since {
    color: var(--bark);
    font-size: 0.8125rem;
}

.field-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(15rem, 100%), 1fr));
    gap: 1rem;
}

.sender-address {
    color: var(--ink-soft);
    font-weight: 600;
    overflow-wrap: anywhere;
}

/* --- The account --------------------------------------------------------------- */

.account-identity {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.account-identity-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.account-name {
    font-size: 0.875rem;
    font-weight: 600;
}

.avatar-large {
    width: 3.5rem;
    height: 3.5rem;
    font-size: 1.125rem;
}

/* Something to know about the settings as they are, e.g. an address waiting for confirmation. */
.notice {
    display: flex;
    gap: 0.625rem;
    align-items: flex-start;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-control);
    background: var(--moss-haze);
    color: var(--ink-soft);
    font-size: 0.8125rem;
    line-height: 1.5;
}

.notice .icon {
    margin-top: 0.125rem;
    color: var(--moss);
}

/* A button that reads as a link, in the middle of a sentence. */
.link-button {
    padding: 0;
    border: 0;
    background: none;
    color: var(--moss);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

.link-button:hover {
    color: var(--moss-dark);
    text-decoration: underline;
}

/* --- Devices --------------------------------------------------------------------- */

.device-list {
    display: flex;
    flex-direction: column;
    padding: 0;
    list-style: none;
}

.device {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 0.875rem;
    align-items: center;
    padding: 0.875rem 0;
    border-top: 1px solid var(--thread);
}

.device-icon {
    display: inline-flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: var(--radius-control);
    background: var(--linen);
    color: var(--moss);
}

/* A device nothing was sent to yet. */
.device-icon-idle {
    color: var(--bark-light);
}

.device-text {
    display: flex;
    flex: 1 1 12rem;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.device-name {
    font-size: 0.875rem;
    font-weight: 600;
}

.device-email {
    overflow: hidden;
    color: var(--bark);
    font-size: 0.8125rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.device-delivery {
    flex: 0 0 9.5rem;
    color: var(--bark);
    font-size: 0.8125rem;
}

/* The star marking the default device (a filled one) and the ones making another device the default. */
.device-default {
    color: var(--honey);
}

.device-default .icon {
    fill: currentColor;
}

.device-default-toggle {
    color: var(--bark-light);
}

.device-default-toggle:hover {
    color: var(--honey);
}

.device-actions {
    display: flex;
    gap: 0.25rem;
}

.device-actions .icon-button {
    color: var(--moss);
}

.icon-button-danger {
    color: var(--ember) !important;
}

.icon-button-danger:hover {
    background: var(--ember-mist);
}

/* --- The OPDS catalog ------------------------------------------------------------------
 * The address and the password of the catalog are secrets the user copies to a device.
 */

/* A row of settings below another one. */
.card-row-divided {
    padding-top: 0.875rem;
    border-top: 1px solid var(--thread);
}

.card-row-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.secret {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.secret-label {
    color: var(--ink-soft);
    font-size: 0.8125rem;
    font-weight: 600;
}

.secret-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem 0.5rem;
    align-items: center;
}

/* A click selects the whole value: enough to copy it without the button. */
.secret-value {
    display: inline-block;
    padding: 0.375rem 0.625rem;
    border: 1px solid var(--thread);
    border-radius: var(--radius-small);
    background: var(--linen);
    color: var(--ink);
    font-family: var(--font-sans);
    font-size: 0.8125rem;
    font-weight: 600;
    overflow-wrap: anywhere;
    user-select: all;
}

/* Copying is the job of copy.js: the button has nothing to do without it. */
.copy-button {
    display: none;
    color: var(--moss);
}

.js .copy-button {
    display: inline-flex;
}

.copy-button.is-copied {
    background: var(--moss-mist);
    color: var(--moss-deep);
}

/* How to set a device up for the catalog, one device at a time; <details> opens without JavaScript. */
.catalog-instructions details {
    border-top: 1px solid var(--thread);
}

.catalog-instructions summary {
    padding: 0.875rem 0;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
}

.catalog-instructions ol {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0 0 1rem 1.25rem;
    font-size: 0.875rem;
    line-height: 1.55;
}

.catalog-instructions li {
    padding-left: 0.375rem;
}

.catalog-instructions .secret-value {
    margin-top: 0.375rem;
}

/* --- Dialogs of the settings ---------------------------------------------------------- */

.modal-form {
    display: flex;
    flex-direction: column;
    gap: 1.375rem;
}

/* A line with a label in the middle, between parts of a dialog. */
.separator {
    display: flex;
    gap: 0.875rem;
    align-items: center;
    color: var(--bark);
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.separator span {
    display: inline-flex;
    gap: 0.5rem;
    align-items: center;
}

.separator::before,
.separator::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--thread);
}

/* How to set a device of the kind up: shown for the kind chosen in the form (see the rules below), one at a time. */
.instructions {
    display: none;
    flex-direction: column;
    gap: 0.625rem;
    padding: 1.125rem 1.25rem;
    border: 1px solid var(--moss-pale);
    border-radius: var(--radius-card);
    background: var(--moss-haze);
}

.instructions h3 {
    font-size: 1.25rem;
}

.instructions ol {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding-left: 1.25rem;
    font-size: 0.875rem;
    line-height: 1.55;
}

.instructions li {
    padding-left: 0.375rem;
}

.instructions-hint {
    display: none;
}

.device-form:has(option[value='']:checked) .instructions-hint {
    display: block;
}

.device-form:has(option[value='kindle']:checked) .instructions[data-kind='kindle'],
.device-form:has(option[value='pocketbook']:checked) .instructions[data-kind='pocketbook'],
.device-form:has(option[value='kobo']:checked) .instructions[data-kind='kobo'],
.device-form:has(option[value='other']:checked) .instructions[data-kind='other'] {
    display: flex;
}

@media (max-width: 48rem) {
    .settings-nav {
        flex: 1 1 100%;
        flex-direction: row;
        flex-wrap: wrap;
    }

    .card {
        padding: 1.125rem;
    }

    /* The device on one line, what is known about it and the actions on the next. */
    .device-text {
        flex-basis: calc(100% - 3.5rem);
    }

    .device-delivery {
        flex: 1 1 auto;
    }
}
