/*
 * Draft language on the template form (lang/partials/template-language):
 * three paper tiles, English, Italiano and العربية, each named in its own
 * language with a letter's opening line set in that language, and the note
 * under them that says what the draft will be. Tokens only, so the dark
 * library theme follows; logical properties, so the Arabic page mirrors.
 */
body.hp-ui.hp-templates .hpl { display: grid; gap: 12px; margin-top: 14px; }
body.hp-ui.hp-templates .hpl-set { min-width: 0; margin: 0; padding: 0; border: 0; }
body.hp-ui.hp-templates .hpl-legend {
    margin: 0 0 9px; padding: 0;
    font-size: .72rem; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; color: var(--hx-quill-ink);
}
html[lang="ar"] body.hp-ui.hp-templates .hpl-legend { font-size: .86rem; letter-spacing: 0; }
body.hp-ui.hp-templates .hpl-options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
body.hp-ui.hp-templates .hpl-option { position: relative; display: flex; min-width: 0; cursor: pointer; }
body.hp-ui.hp-templates .hpl-option input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
body.hp-ui.hp-templates .hpl-card {
    position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-areas: "mark name" "hint hint" "sample sample";
    align-items: center; column-gap: 9px; row-gap: 2px; width: 100%; min-width: 0; padding: 12px 14px 13px; border-radius: 16px;
    border: 1px solid var(--hx-line-2); background: var(--hx-paper); color: var(--hx-ink-2);
    transition: border-color .2s ease, background-color .2s ease, box-shadow .2s ease, transform .2s var(--hx-ease, ease);
}
body.hp-ui.hp-templates .hpl-mark {
    grid-area: mark; display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%;
    border: 1px solid color-mix(in srgb, var(--hx-quill) 60%, transparent); color: var(--hx-quill-ink);
    font-size: .62rem; font-weight: 800; letter-spacing: .06em; line-height: 1;
}
body.hp-ui.hp-templates .hpl-option[data-lang-option="ar"] .hpl-mark { font-family: "HP Arabic Display", "HP Arabic", serif; font-size: .95rem; letter-spacing: 0; padding-bottom: 3px; }
body.hp-ui.hp-templates .hpl-name {
    grid-area: name; justify-self: start; max-width: 100%; min-width: 0; font-family: var(--hx-f-display); font-size: 1.32rem; line-height: 1.1; color: var(--hx-ink);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
body.hp-ui.hp-templates .hpl-name:lang(ar) { font-family: "HP Arabic Display", "HP Arabic", serif; font-size: 1.28rem; line-height: 1.35; }
body.hp-ui.hp-templates .hpl-hint { grid-area: hint; margin-top: 6px; font-size: .74rem; font-weight: 700; line-height: 1.35; color: var(--hx-ink-3); }
body.hp-ui.hp-templates .hpl-sample {
    grid-area: sample; justify-self: stretch; margin-top: 7px; padding-top: 7px; border-top: 1px dashed var(--hx-line-2); text-align: start;
    font-family: var(--hx-f-display); font-style: italic; font-size: .92rem; line-height: 1.35; color: var(--hx-ink-2);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
body.hp-ui.hp-templates .hpl-sample:lang(ar) { font-family: "HP Arabic Display", "HP Arabic", serif; font-style: normal; font-size: .95rem; line-height: 1.5; }
/* Each sample keeps to the page's start side, whatever its own direction. */
html:not([dir="rtl"]) body.hp-ui.hp-templates .hpl-sample:lang(ar) { text-align: left; }
html[dir="rtl"] body.hp-ui.hp-templates .hpl-sample:not(:lang(ar)) { text-align: right; }
body.hp-ui.hp-templates .hpl-check {
    position: absolute; inset-block-start: 10px; inset-inline-end: 10px; width: 18px; height: 18px; padding: 3px; border-radius: 50%;
    background: var(--hx-royal); color: #fff; fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round;
    opacity: 0; transform: scale(.6); transition: opacity .18s ease, transform .22s var(--hx-ease, ease);
}
body.hp-ui.hp-templates .hpl-option:hover .hpl-card { border-color: color-mix(in srgb, var(--hx-royal) 55%, var(--hx-line-2)); }
body.hp-ui.hp-templates .hpl-option input:checked + .hpl-card {
    border-color: var(--hx-royal); background: color-mix(in srgb, var(--hx-royal) 6%, var(--hx-surface));
    box-shadow: 0 0 0 1px var(--hx-royal), 0 14px 26px -22px rgba(8, 26, 19, .55);
}
body.hp-ui.hp-templates .hpl-option input:checked + .hpl-card .hpl-check { opacity: 1; transform: none; }
body.hp-ui.hp-templates .hpl-option input:checked + .hpl-card .hpl-mark { background: var(--hx-quill-soft); border-color: var(--hx-quill); }
body.hp-ui.hp-templates .hpl-option input:focus-visible + .hpl-card { outline: 2px solid var(--hx-focus); outline-offset: 3px; }

html[data-hp-theme="dark"] body.hp-ui.hp-templates .hpl-option input:checked + .hpl-card {
    border-color: var(--hx-quill); background: color-mix(in srgb, var(--hx-quill) 9%, var(--hx-surface));
    box-shadow: 0 0 0 1px var(--hx-quill), 0 16px 30px -24px rgba(0, 0, 0, .8);
}
html[data-hp-theme="dark"] body.hp-ui.hp-templates .hpl-check { background: var(--hx-quill); color: #14110b; }

body.hp-ui.hp-templates .hpl-note {
    display: flex; align-items: flex-start; gap: 9px; margin: 0; padding: 10px 14px; border-radius: 14px;
    background: var(--hx-quill-soft); color: var(--hx-quill-ink); font-size: .88rem; font-weight: 600; line-height: 1.55;
}
body.hp-ui.hp-templates .hpl-note p { margin: 0; }
body.hp-ui.hp-templates .hpl-note p[hidden] { display: none; }
body.hp-ui.hp-templates .hpl-note-icon { flex: none; width: 17px; height: 17px; margin-top: 2px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* The draft itself, in its own language and direction (hp-templates.js sets lang and dir from the answer). */
body.hp-ui.hp-templates .hpt-text[dir="rtl"] { text-align: right; font-family: "HP Arabic", var(--hx-f-body); font-size: 1.04rem; line-height: 1.95; }
body.hp-ui.hp-templates .hpt-text[lang="it"] { hyphens: auto; -webkit-hyphens: auto; }

/* Phones: names only, stacked tight; the sample line comes back on wider screens. */
@media (max-width: 560px) {
    body.hp-ui.hp-templates .hpl-options { gap: 8px; }
    body.hp-ui.hp-templates .hpl-card { grid-template-columns: minmax(0, 1fr); grid-template-areas: "mark" "name" "hint"; justify-items: start; padding: 10px 11px 11px; row-gap: 6px; }
    body.hp-ui.hp-templates .hpl-name { font-size: 1.12rem; }
    body.hp-ui.hp-templates .hpl-name:lang(ar) { font-size: 1.1rem; }
    body.hp-ui.hp-templates .hpl-hint { margin-top: 0; font-size: .7rem; }
    body.hp-ui.hp-templates .hpl-sample { display: none; }
    body.hp-ui.hp-templates .hpl-check { inset-block-start: 8px; inset-inline-end: 8px; }
}

@media (prefers-reduced-motion: reduce) {
    body.hp-ui.hp-templates :is(.hpl-card, .hpl-check) { transition: none; }
}
