/* Generator (#45): the landing's dark style (tokens, header and footer in
   base-oscura.css). Mobile first; two columns from 1020px, the same
   breakpoint htmlparser-v2.js uses for the templates list. */

button, input, select, textarea { font: inherit; color: inherit; }

.contenido { padding-block: var(--space-s) var(--space-m-xl); }

.form-preview-wrap { display: grid; gap: var(--space-l); }
.form, .preview { min-width: 0; }

.title {
    margin: 0 0 var(--space-s);
    font-size: var(--step-1);
    font-weight: 700;
    letter-spacing: -.01em;
}

.group + .group { margin-top: var(--space-s); }

/* utility classes */
.hidden { display: none !important; }

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* Message language and templates: collapsible card (#19) */
.settings-panel {
    padding: var(--space-m) var(--space-s-l);
    border: 1px solid var(--borde);
    border-radius: 12px;
    background: var(--superficie);
}

.settings-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2xs);
}

.settings-panel-title {
    margin: 0;
    color: var(--texto-suave);
    font-size: var(--step--1);
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
}

.settings-panel-summary {
    color: var(--texto);
    font-weight: normal;
    letter-spacing: 0;
    text-transform: none;
}

.settings-panel-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 8px;
    background: none;
    color: var(--texto-suave);
    cursor: pointer;
}

.settings-panel-toggle:hover { border-color: var(--borde); color: var(--texto); }
.settings-panel-toggle:focus-visible { outline: 2px solid var(--acento); outline-offset: 1px; }
.settings-panel-toggle svg { transition: transform .2s; }
.settings-panel-toggle[aria-expanded="false"] svg { transform: rotate(180deg); }
.settings-panel-body { margin-top: var(--space-xs); }

/* Radios as pills: the chosen one in the accent colour */
.lang-selector, .alignment, .width { display: flex; flex-wrap: wrap; gap: var(--space-3xs); }

.lang-selector label, .alignment label, .width label {
    position: relative;
    display: inline-flex;
    align-items: center;
    padding: var(--space-3xs) var(--space-xs);
    border: 1px solid var(--borde);
    border-radius: 100px;
    color: var(--texto-suave);
    font-size: var(--step--1);
    cursor: pointer;
}

.lang-selector input, .alignment input, .width input {
    position: absolute;
    inset: 0;
    opacity: 0;
    margin: 0;
    cursor: pointer;
}

.lang-selector label:hover, .alignment label:hover, .width label:hover { color: var(--texto); }

/* Format (alignment and width) and the action buttons: one row when it
   fits, the buttons to the right; otherwise the buttons wrap below */
.acciones {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-s);
}

.formato { display: flex; flex-wrap: wrap; gap: var(--space-2xs) var(--space-s); }
.alignment label { padding-inline: var(--space-2xs); }
.alignment svg { display: block; }

.lang-selector label:has(:checked), .alignment label:has(:checked), .width label:has(:checked) {
    border-color: var(--acento);
    color: var(--acento);
}

.lang-selector label:has(:focus-visible), .alignment label:has(:focus-visible), .width label:has(:focus-visible) {
    outline: 2px solid var(--acento);
    outline-offset: 2px;
}

/* Templates (#10): the list takes the full width so long names fit, with
   its buttons underneath */
.template-search > label {
    display: block;
    margin-bottom: var(--space-3xs);
    color: var(--texto-suave);
    font-size: var(--step--1);
}

#template-search, #template-select, textarea {
    width: 100%;
    border: 1px solid var(--borde);
    border-radius: 8px;
    background: var(--superficie-2);
}

#template-search { padding: var(--space-2xs) var(--space-xs); font-size: var(--step--1); }
#template-search::placeholder { color: var(--texto-suave); }

.template-picker { display: grid; gap: var(--space-2xs); margin-top: var(--space-2xs); }

#template-select { padding: var(--space-2xs); font-size: var(--step--1); }
#template-select optgroup { color: var(--texto-suave); font-style: normal; }
#template-select option { padding: 4px 8px; border-radius: 4px; color: var(--texto); }
#template-select option:checked { background: var(--borde); }

.template-actions { display: flex; flex-wrap: wrap; gap: var(--space-2xs); }

/* Touch-sized and sharing the row on narrow screens */
.template-actions button { flex: 1 1 0; min-height: 44px; }

.template-actions button, .toolbar button {
    padding: var(--space-3xs) var(--space-xs);
    border: 1px solid var(--borde);
    border-radius: 8px;
    background: transparent;
    font-size: var(--step--1);
    white-space: nowrap;
    cursor: pointer;
}

.template-actions button:hover, .toolbar button:hover { border-color: var(--texto-suave); }
.template-actions button:focus-visible, .toolbar button:focus-visible { outline: 2px solid var(--acento); outline-offset: 1px; }

button.danger { color: #ff8a80; }

/* Short labels on narrow screens, long ones from 1020px */
.label-long { display: none; }
.label-short { display: inline; }

.template-transfer {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3xs);
    align-items: baseline;
    margin-top: var(--space-xs);
    color: var(--texto-suave);
    font-size: var(--step--1);
}

.template-transfer .hint { display: none; font-size: var(--step--2); }
.template-transfer .link-button { padding: 10px 0; }

.link-button {
    padding: 0;
    border: 0;
    background: none;
    color: var(--acento);
    text-decoration: underline;
    cursor: pointer;
}

/* without storage: hide what needs it (save, delete, import) */
.no-storage .needs-storage,
.no-storage #delete-template-button {
    display: none !important;
}

/* Toolbar: compact chips, rows must not touch */
.toolbar { display: flex; flex-wrap: wrap; gap: var(--space-3xs); }
.toolbar button { padding: 2px var(--space-2xs); color: var(--texto-suave); font-size: var(--step--2); }
.toolbar button:hover { color: var(--texto); }

/* The message is plain text: monospace, like the landing's plain card */
#message {
    height: 24rem;
    padding: var(--space-m) var(--space-s-l);
    font-family: var(--mono);
    font-size: var(--step--1);
    line-height: 1.7;
    resize: vertical;
}

#message:focus, #template-search:focus, #template-select:focus { outline: 2px solid var(--acento); outline-offset: 1px; }

/* Actions: copying the message is the call to action */
.btn-msg-wrap {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    /* buttons + notices must wrap, or a long notice widens the column (#19) */
    gap: var(--space-2xs);
}

/* Clear, copy title and copy message look alike: mixing filled and
   outlined pills made them read as different sizes */
.heg-button {
    padding: var(--space-2xs) var(--space-s);
    border: 1px solid var(--acento);
    border-radius: 100px;
    background: transparent;
    color: var(--acento);
    font-size: var(--step--1);
    font-weight: 600;
    cursor: pointer;
}

.heg-button:hover { background: rgb(243 146 0 / .12); }
.heg-button:focus-visible { outline: 2px solid var(--texto); outline-offset: 2px; }

.msg { flex-basis: 100%; margin: 0; color: var(--texto-suave); font-size: var(--step--1); }
.msg:empty { display: none; }
.msg.msg-warning { color: var(--acento); }
.preview .msg-warning { margin-bottom: var(--space-xs); }

/* "Ready to send?" panel (#49), above the preview */
.listo {
    margin: 0 0 var(--space-s);
    border: 1px solid var(--borde);
    border-left: 3px solid var(--acento);
    border-radius: 10px;
    background: var(--superficie);
    font-size: var(--step--1);
}

.listo summary, .listo-ok {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-3xs) var(--space-2xs);
    padding: var(--space-2xs) var(--space-s);
    color: var(--texto);
    font-weight: 600;
}

.listo summary { cursor: pointer; list-style: none; }
.listo summary::-webkit-details-marker { display: none; }
.listo summary:focus-visible { outline: 2px solid var(--acento); outline-offset: 2px; border-radius: 10px; }

/* chevron: down when closed, up when open */
.listo summary::after {
    content: "";
    margin-left: auto;
    width: .5em;
    height: .5em;
    border-right: 2px solid var(--texto-suave);
    border-bottom: 2px solid var(--texto-suave);
    transform: rotate(45deg) translateY(-2px);
}

.listo[open] summary::after { transform: rotate(-135deg); }

.listo-cuenta { color: var(--acento); }

/* The box spans the column, but its text keeps the default email width:
   longer lines are hard to read */
.listo ul {
    box-sizing: border-box;
    max-width: 620px;
    margin: 0;
    padding: 0 var(--space-s) var(--space-s) calc(var(--space-s) + 1.1em);
    color: var(--texto-suave);
    line-height: 1.5;
    overflow-wrap: anywhere;
}

.listo li + li { margin-top: var(--space-3xs); }
.listo li strong { color: var(--texto); font-weight: 600; }

.listo-ok { border-left-color: var(--ok); }
.listo-ok .listo-cuenta { color: var(--ok); }

/* Off-screen: only the copy code reads it */
.form-to-copy-wrap { position: absolute; left: -9999px; opacity: 0; }

/* Help, shown while the message is empty */
ul.help {
    display: grid;
    gap: var(--space-xs);
    margin: 0;
    padding: var(--space-m) var(--space-s-l);
    border: 1px solid var(--borde);
    border-radius: 14px;
    background: var(--superficie);
    color: var(--texto-suave);
    line-height: 1.55;
    list-style: none;
}

ul.help li { display: flex; gap: var(--space-xs); }
ul.help li::before { content: "✓"; flex: none; color: var(--acento); font-weight: 700; }

/* Preview drawn as the message window of an email client (#18): white,
   like the landing's example but straight */
.mail-window {
    /* the email is seen as on a light client, whatever the page around it */
    color-scheme: light;
    overflow: hidden;
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 40px 80px -30px rgba(0, 0, 0, .9), 0 0 0 1px rgba(255, 255, 255, .06);
    color: #1f1f1f;
}

.mail-window-bar {
    display: grid;
    grid-template-columns: 46px minmax(0, 1fr) 46px;
    align-items: center;
    gap: var(--space-xs);
    padding: 10px 14px;
    border-bottom: 1px solid #e3e3e3;
    background: #f1f1f1;
    color: #333;
    font-family: Arial, sans-serif;
    font-size: var(--step--1);
}

/* decorative: three dots and a close mark only suggest a window */
.mail-window-bar::before {
    content: "";
    height: 10px;
    background: radial-gradient(circle 5px at 5px 5px, #d4d4d4 98%, transparent) 0 0 / 18px 10px repeat-x;
}

.mail-window-subject {
    text-align: center;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mail-window-subject em { color: #666; font-weight: normal; }

.mail-window-heading {
    display: grid;
    min-width: 0;
    line-height: 1.35;
}

/* Preheader (#48): as an inbox shows it, under the subject */
.mail-window-preheader {
    text-align: center;
    color: #6b6b6b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mail-window-close {
    justify-self: end;
    color: #777;
    font-size: 1.2rem;
    line-height: 1;
    cursor: default;
    user-select: none;
}

.mail-window-body { padding: var(--space-m); }

/* lists inside the email render as in a mail client */
.mail-window-body ul { padding-left: 40px; list-style-type: disc; margin-bottom: 8px; }
.mail-window-body ol { margin-top: 0; }

/* same rule the copied email carries in its <head> */
@media (pointer: coarse) {
    .mail-window-body .tel-enllac { text-decoration: underline; }
}

/* Toasts: bottom-right corner, newest at the bottom; full width minus the
   gutter on narrow screens */
.toasts {
    position: fixed;
    right: var(--space-s-l);
    bottom: var(--space-s-l);
    left: var(--space-s-l);
    z-index: 20;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: var(--space-2xs);
    pointer-events: none;
}

.toast {
    max-width: min(24rem, 100%);
    padding: var(--space-xs) var(--space-s);
    border: 1px solid var(--borde);
    border-left: 3px solid var(--acento);
    border-radius: 10px;
    background: var(--superficie);
    box-shadow: 0 16px 32px -12px rgba(0, 0, 0, .8);
    color: var(--texto);
    font-size: var(--step--1);
    pointer-events: auto;
    cursor: pointer;
    animation: toast-in .25s ease-out;
    transition: opacity .3s, transform .3s;
}

.toast-warning { border-left-color: #ff8a80; }
.toast-out { opacity: 0; transform: translateY(.5rem); }

@keyframes toast-in {
    from { opacity: 0; transform: translateY(.5rem); }
}

@media (prefers-reduced-motion: reduce) {
    .toast { animation: none; transition: none; }
}

@media (min-width: 1020px) {
    /* Nearly even columns, the preview a bit wider; never narrower than
       the wide email (700px plus the window padding) while it can */
    .form-preview-wrap {
        grid-template-columns: minmax(0, 1fr) minmax(min(47.5rem, 62%), 1.1fr);
        align-items: start;
    }

    /* The message fills what the screen has left: with the templates box
       collapsed, everything down to the buttons fits without scrolling */
    #message { height: max(16rem, 100dvh - 28.5rem); }

    /* The preview window is at least as tall as the left column down to
       the message box (templates box collapsed), so both sides line up */
    .mail-window { min-height: max(26rem, 100dvh - 17.875rem); }

    /* Just under the fixed header, never above its natural place */
    .preview { position: sticky; top: calc(4rem + var(--space-2xs)); }

    .settings-panel-toggle { width: 32px; height: 32px; }
    ul.help { padding-inline: var(--space-l-2xl); }
    .template-actions button { flex: none; min-height: 0; }
    .label-long { display: inline; }
    .label-short { display: none; }
    .template-transfer .hint { display: inline; }
    .template-transfer .link-button { padding: 0; }
}

/* From 1600px format and buttons share one row: one row less to leave */
@media (min-width: 100rem) {
    #message { height: max(16rem, 100dvh - 25rem); }
    .mail-window { min-height: max(26rem, 100dvh - 14.375rem); }
}
