/*
 * Wax seals: the brass seal component (components/hp-seal.blade.php), its
 * stamp, the "Active" seal on Billing, the "Paid" seal on invoices and the
 * word milestones on the dashboard (dashboard/partials/seals.blade.php).
 * The stamp runs once, from hp-seal.js; reduced motion and print get the
 * settled seal.
 */

/* ---------- The seal ---------- */
.hp-seal { display: inline-block; position: relative; flex: none; line-height: 0; vertical-align: middle; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.hp-seal-svg { display: block; overflow: visible; }
.hp-seal :is(.hp-seal-art, .hp-seal-wax, .hp-seal-shadow) { transform-box: view-box; transform-origin: 100px 100px; }
.hp-seal-shadow-shape { opacity: .75; }
html[data-hp-theme="dark"] .hp-seal-shadow-shape { opacity: 1; }

.hp-seal-legend { font-family: var(--hx-f-display); font-size: 17px; letter-spacing: .14em; text-transform: uppercase; }
.hp-seal-legend.is-word { font-size: 16px; letter-spacing: .24em; }
html[lang="ar"] .hp-seal-legend.is-word { font-size: 18px; letter-spacing: 0; }
.hp-seal-figure { font-family: var(--hx-f-display); font-size: 37px; letter-spacing: -.01em; }
.hp-seal:not(.has-ring) .hp-seal-figure { font-size: 50px; }
html[lang="ar"] .hp-seal-figure { font-size: 27px; }
html[lang="ar"] .hp-seal:not(.has-ring) .hp-seal-figure { font-size: 34px; }

/* Locked: a faint outline with its target */
.hp-seal-outline { fill: var(--hx-surface); stroke: var(--hx-line-2); stroke-width: 1.6; stroke-dasharray: 3 6; stroke-linecap: round; }
.hp-seal-outline-well { fill: var(--hx-surface-2); fill-opacity: .6; stroke: var(--hx-line-2); stroke-width: 1.2; }
.hp-seal-figure-ghost { fill: var(--hx-ink-3); font-family: var(--hx-f-display); font-size: 42px; opacity: .8; }
html[lang="ar"] .hp-seal-figure-ghost { font-size: 30px; }

/* ---------- The stamp: pressed in once, when it first comes into view ---------- */
@media screen and (prefers-reduced-motion: no-preference) {
    /* Waiting for its moment (hp-seal.js); shown anyway after a few seconds if the script never runs */
    .hp-seal[data-hp-seal-stamp]:not(.is-stamping) :is(.hp-seal-art, .hp-seal-shadow) { opacity: 0; animation: hpSealReveal .2s 4s both; }

    .hp-seal.is-stamping .hp-seal-art { animation: hpSealPress .92s var(--hp-seal-delay, 0s) both; }
    .hp-seal.is-stamping .hp-seal-wax { animation: hpSealSpread .92s var(--hp-seal-delay, 0s) both; }
    .hp-seal.is-stamping .hp-seal-shadow { animation: hpSealShadow .92s var(--hp-seal-delay, 0s) both; }
}
@keyframes hpSealReveal { to { opacity: 1; } }
/* The die comes down tilted, presses, and the seal settles with a small spring */
@keyframes hpSealPress {
    0% { opacity: 0; transform: translateY(-16px) scale(1.45) rotate(-17deg); animation-timing-function: cubic-bezier(.55, 0, .85, .35); }
    16% { opacity: 1; }
    36% { transform: scale(.93) rotate(2.4deg); animation-timing-function: cubic-bezier(.25, .7, .35, 1); }
    56% { transform: scale(1.028) rotate(-.9deg); }
    76% { transform: scale(.994) rotate(.25deg); }
    100% { opacity: 1; transform: none; }
}
/* The wax under the die spreads a little, then draws back: the bump */
@keyframes hpSealSpread {
    0%, 33% { transform: scale(.84); }
    48% { transform: scale(1.065); animation-timing-function: cubic-bezier(.3, .6, .3, 1); }
    68% { transform: scale(.985); }
    100% { transform: none; }
}
@keyframes hpSealShadow {
    0% { opacity: 0; transform: translate(12px, 20px) scale(1.3); animation-timing-function: cubic-bezier(.55, 0, .85, .35); }
    36% { opacity: 1; transform: scale(.9); animation-timing-function: ease-out; }
    100% { opacity: 1; transform: none; }
}

/* ---------- Billing: the "Active" seal on the current plan ---------- */
body.hp-ui.billing-page .hpb-plan-seal { order: 1; margin-inline-start: auto; margin-block: -12px -20px; }
body.hp-ui.billing-page .hpb-plan-card .hpb-card-head > .hpb-pill { order: 2; }
body.hp-ui.billing-page .hpb-plan-seal .hp-seal-svg { width: 96px; height: 96px; }
@media (max-width: 560px) {
    body.hp-ui.billing-page .hpb-plan-card .hpb-card-head { flex-wrap: nowrap; align-items: center; }
    body.hp-ui.billing-page .hpb-plan-seal { margin-block: -8px -12px; }
    body.hp-ui.billing-page .hpb-plan-seal .hp-seal-svg { width: 78px; height: 78px; }
    body.hp-ui.billing-page .hpb-plan-card .hpb-card-head > .hpb-pill { align-self: flex-start; }
}

/* ---------- Invoices: the "Paid" seal where the ink stamp was ---------- */
body.hp-ui .hpi-seal { justify-self: center; display: inline-grid; justify-items: center; gap: 2px; }
body.hp-ui .hpi-seal-date {
    color: var(--hpi-brass, var(--hx-quill-ink)); font-size: .66rem; font-weight: 800; letter-spacing: .18em; text-transform: uppercase;
}
html[lang="ar"] body.hp-ui .hpi-seal-date { font-size: .8rem; letter-spacing: 0; }
@media (max-width: 720px) {
    body.hp-ui .hpi-seal { grid-row: 2; margin-top: 4px; }
    body.hp-ui .hpi-seal .hp-seal-svg { width: 116px; height: 116px; }
}
@media print {
    body.hp-ui .hpi-seal .hp-seal-svg { width: 118px; height: 118px; }
}

/* ---------- Dashboard: seals for words rewritten ---------- */
body.hp-ui .hp-seals { margin-top: 20px; overflow: hidden; }
body.hp-ui .hp-seals-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 8px 20px; }
body.hp-ui .hp-seals-total { display: flex; align-items: baseline; gap: 8px; margin: 0; color: var(--hx-ink-2); font-size: .9rem; }
body.hp-ui .hp-seals-total-figure { color: var(--hx-ink); font-family: var(--hx-f-display); font-size: 1.9rem; font-weight: 400; line-height: 1; font-variant-numeric: tabular-nums; }

body.hp-ui .hp-seals-list {
    --hp-seal-size: 104px;
    position: relative; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr));
    margin: 22px 0 0; padding: 0; list-style: none;
}
/* The rail: from the start to the last seal, gilded as far as the words reach */
body.hp-ui .hp-seals-list::before,
body.hp-ui .hp-seals-list::after {
    content: ""; position: absolute; inset-inline-start: 0; top: calc(var(--hp-seal-size) / 2 - 1.5px);
    height: 3px; border-radius: 3px; pointer-events: none;
}
body.hp-ui .hp-seals-list::before { width: calc(100% * 11 / 12); background: repeating-linear-gradient(90deg, var(--hx-line-2) 0 6px, transparent 6px 11px); opacity: .9; }
body.hp-ui .hp-seals-list::after {
    width: calc(100% * 11 / 12 * var(--hp-seals-fill, 0));
    background: linear-gradient(90deg, #b8823c, #e8c27c 70%, #f6dea6);
    box-shadow: 0 0 0 .5px rgba(110, 70, 25, .25);
}
html[dir="rtl"] body.hp-ui .hp-seals-list::after { background: linear-gradient(270deg, #b8823c, #e8c27c 70%, #f6dea6); }

body.hp-ui .hp-seals-item { position: relative; z-index: 1; display: grid; justify-items: center; align-content: start; gap: 10px; padding-inline: 4px; text-align: center; }
body.hp-ui .hp-seals-item .hp-seal-svg { width: var(--hp-seal-size); height: var(--hp-seal-size); }
body.hp-ui .hp-seals-caption { display: grid; gap: 1px; color: var(--hx-ink-3); font-size: .78rem; line-height: 1.3; }
body.hp-ui .hp-seals-caption-figure { color: var(--hx-ink-2); font-size: .92rem; font-weight: 700; font-variant-numeric: tabular-nums; }
body.hp-ui .hp-seals-item.is-earned .hp-seals-caption-figure { color: var(--hx-ink); }
body.hp-ui .hp-seals-item.is-locked .hp-seals-caption { opacity: .8; }
body.hp-ui .hp-seals-sr { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

body.hp-ui .hp-seals-next { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; margin: 20px 0 0; color: var(--hx-ink-2); font-size: .9rem; }
body.hp-ui .hp-seals-next strong { color: var(--hx-ink); font-variant-numeric: tabular-nums; }
body.hp-ui .hp-seals-next .icon { width: 1rem; height: 1rem; color: var(--hx-quill); }
body.hp-ui .hp-seals-next-sep { color: var(--hx-ink-3); }

@media (max-width: 900px) {
    body.hp-ui .hp-seals-list { --hp-seal-size: 92px; }
}
@media (max-width: 720px) {
    body.hp-ui .hp-seals { margin-top: 14px; }
    body.hp-ui .hp-seals-list { --hp-seal-size: 84px; grid-template-columns: repeat(3, minmax(0, 1fr)); row-gap: 18px; }
    body.hp-ui .hp-seals-list::before,
    body.hp-ui .hp-seals-list::after { display: none; }
}

/* ---------- The toast for a newly earned seal ---------- */
body.hp-ui .hp-seal-toast {
    position: fixed; z-index: 80; inset-inline-start: 50%; bottom: max(20px, env(safe-area-inset-bottom));
    display: flex; align-items: center; gap: 14px; width: min(440px, calc(100vw - 32px)); padding: 12px 12px 12px 14px;
    border: 1px solid color-mix(in srgb, var(--hx-quill) 45%, var(--hx-line)); border-radius: 20px;
    background: var(--hx-surface); color: var(--hx-ink); box-shadow: var(--hx-shadow-lg);
    opacity: 0; transform: translate(-50%, 16px);
}
html[dir="rtl"] body.hp-ui .hp-seal-toast { transform: translate(50%, 16px); }
body.hp-ui .hp-seal-toast[hidden] { display: none; }
body.hp-ui .hp-seal-toast.is-in { opacity: 1; transform: translate(-50%, 0); }
html[dir="rtl"] body.hp-ui .hp-seal-toast.is-in { transform: translate(50%, 0); }
body.hp-ui .hp-seal-toast-seal .hp-seal-svg { width: 56px; height: 56px; }
body.hp-ui .hp-seal-toast-body { display: grid; gap: 2px; min-width: 0; flex: 1; font-size: .86rem; line-height: 1.4; }
body.hp-ui .hp-seal-toast-title { color: var(--hx-ink); font-family: var(--hx-f-display); font-size: 1.2rem; font-weight: 400; line-height: 1.15; }
body.hp-ui .hp-seal-toast-text { color: var(--hx-ink-2); }
body.hp-ui .hp-seal-toast-text strong { color: var(--hx-ink); }
body.hp-ui .hp-seal-toast-link { justify-self: start; margin-top: 2px; color: var(--hx-royal-ink); font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
body.hp-ui .hp-seal-toast-close {
    display: inline-grid; place-items: center; flex: none; align-self: flex-start; width: 34px; height: 34px; padding: 0;
    border: 0; border-radius: 999px; background: transparent; color: var(--hx-ink-3); cursor: pointer;
}
body.hp-ui .hp-seal-toast-close:hover { background: var(--hx-surface-2); color: var(--hx-ink); }
body.hp-ui :is(.hp-seal-toast-close, .hp-seal-toast-link):focus-visible { outline: 2px solid var(--hx-focus); outline-offset: 2px; }
body.hp-ui .hp-seal-toast-close .icon { width: 16px; height: 16px; }
/* Above the floating help button on phones */
@media (max-width: 640px) {
    body.hp-ui .hp-seal-toast { bottom: calc(74px + env(safe-area-inset-bottom, 0px)); }
}
@media (prefers-reduced-motion: no-preference) {
    body.hp-ui .hp-seal-toast { transition: opacity .32s ease, transform .42s var(--hx-ease); }
}
@media print {
    body.hp-ui .hp-seal-toast { display: none; }
}
