/* ===================================================================
   A2Z Page Kit - one stylesheet for every kit component.

   Loaded INSIDE each component's Shadow DOM on publisher pages (so it
   cannot touch the page) and as a normal stylesheet inside A2Z frames.
   Everything is scoped under .k; nothing relies on :host so the same
   rules work in both places.

   Theme: .k[data-theme="light|dark|os|inherit"]. The kit resolves "auto"
   to light or dark from the background actually behind the component;
   "os" follows the visitor's system; "inherit" draws on the page's own
   text colour with no surfaces (footers that are already styled).
   Accent: --k-accent / --k-accent-2 / --k-accent-ink (set by the kit
   from a validated #rrggbb). Per-button brand colours arrive as
   --k-net / --k-net-ink through the CSSOM - never a style attribute.
   =================================================================== */

.k {
    --k-accent: #4b5bd6;
    --k-accent-2: #7b5bf0;
    --k-accent-ink: #ffffff;
    --k-accent-fg: #3f4fc9;
    --k-bg: #ffffff;
    --k-surface: #f7f6fb;
    --k-surface-2: #efedf7;
    --k-line: #e3e1ec;
    --k-line-strong: #c9c5d9;
    --k-ink: #10162b;
    --k-ink-2: #454d63;
    --k-ink-3: #5f677d;
    --k-ok: #067647;
    --k-focus: #3f4fc9;
    --k-shadow: 0 1px 2px rgba(16, 22, 43, .06), 0 8px 24px -6px rgba(16, 22, 43, .18);
    --k-shadow-lg: 0 2px 6px rgba(16, 22, 43, .08), 0 22px 48px -12px rgba(16, 22, 43, .32);
    --k-radius: 12px;
    --k-font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
    --k-ease: cubic-bezier(.2, .7, .2, 1);
    --k-size: 40px;
    --k-gap: 8px;
    color: var(--k-ink);
    font-family: var(--k-font);
    font-size: 15px;
    line-height: 1.45;
    -webkit-text-size-adjust: 100%;
    box-sizing: border-box;
}
.k *, .k *::before, .k *::after { box-sizing: border-box; }
.k[hidden], .k [hidden] { display: none !important; }

.k[data-theme="dark"] {
    --k-accent-fg: #aab6ff;
    --k-bg: #121a30;
    --k-surface: #18213b;
    --k-surface-2: #1f2947;
    --k-line: #2a3456;
    --k-line-strong: #3d4a75;
    --k-ink: #eef1fb;
    --k-ink-2: #c3c9dc;
    --k-ink-3: #9aa3bd;
    --k-ok: #4ade80;
    --k-focus: #aab6ff;
    --k-shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 28px -6px rgba(0, 0, 0, .55);
    --k-shadow-lg: 0 2px 6px rgba(0, 0, 0, .35), 0 24px 52px -12px rgba(0, 0, 0, .7);
    color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
    .k[data-theme="os"] {
        --k-accent-fg: #aab6ff;
        --k-bg: #121a30;
        --k-surface: #18213b;
        --k-surface-2: #1f2947;
        --k-line: #2a3456;
        --k-line-strong: #3d4a75;
        --k-ink: #eef1fb;
        --k-ink-2: #c3c9dc;
        --k-ink-3: #9aa3bd;
        --k-ok: #4ade80;
        --k-focus: #aab6ff;
        --k-shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 28px -6px rgba(0, 0, 0, .55);
        --k-shadow-lg: 0 2px 6px rgba(0, 0, 0, .35), 0 24px 52px -12px rgba(0, 0, 0, .7);
        color-scheme: dark;
    }
}
.k[data-theme="inherit"] {
    --k-ink: currentColor;
    --k-ink-2: currentColor;
    --k-ink-3: currentColor;
    --k-bg: transparent;
    --k-surface: rgba(127, 127, 127, .12);
    --k-surface-2: rgba(127, 127, 127, .2);
    --k-line: rgba(127, 127, 127, .35);
    --k-line-strong: rgba(127, 127, 127, .55);
    --k-focus: currentColor;
    color: inherit;
    font-family: inherit;
}
/* A publisher accent replaces the brand gradient with a flat colour. */
.k[style*="--k-accent"] { --k-accent-fg: var(--k-accent); }

.k-sr {
    position: absolute !important;
    width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.k-ico { width: 1.25em; height: 1.25em; flex: none; display: block; }
.k :focus { outline: none; }
.k :focus-visible { outline: 2px solid var(--k-focus); outline-offset: 2px; }
.k :where(a) { color: inherit; }

/* ---------------- buttons shared by share / follow / contact ---------------- */
.k-list { display: flex; flex-wrap: wrap; gap: var(--k-gap); margin: 0; padding: 0; list-style: none; align-items: center; }
.k-list > li { margin: 0; padding: 0; display: flex; }
.k-al-center .k-list { justify-content: center; }
.k-al-right .k-list { justify-content: flex-end; }

.k-btn {
    --k-net: var(--k-accent);
    --k-net-ink: #fff;
    display: inline-flex; align-items: center; justify-content: center; gap: .5em;
    min-width: var(--k-size); height: var(--k-size);
    padding: 0 calc(var(--k-size) * .3);
    border: 1px solid transparent; border-radius: var(--k-radius);
    background: var(--k-net); color: var(--k-net-ink);
    font: 600 14px/1 var(--k-font); letter-spacing: .005em;
    text-decoration: none; white-space: nowrap; cursor: pointer;
    transition: transform .18s var(--k-ease), box-shadow .18s var(--k-ease), filter .18s var(--k-ease), background-color .18s;
    -webkit-tap-highlight-color: transparent;
}
.k-btn:hover { transform: translateY(-1px); filter: brightness(1.08) saturate(1.05); box-shadow: 0 6px 16px -6px color-mix(in srgb, var(--k-net) 70%, transparent); }
.k-btn:active { transform: translateY(0) scale(.97); }
.k-btn .k-ico { width: calc(var(--k-size) * .45); height: calc(var(--k-size) * .45); }
.k-d-icon .k-btn { padding: 0; width: var(--k-size); }
.k-s-s { --k-size: 34px; }
.k-s-m { --k-size: 42px; }
.k-s-l { --k-size: 52px; }
.k-s-l .k-btn { font-size: 15.5px; }
@media (pointer: coarse) { .k-s-s { --k-size: 40px; } }

.k-sh-circle .k-btn { border-radius: 999px; }
.k-sh-pill .k-btn { border-radius: 999px; }
.k-sh-square .k-btn { border-radius: 4px; }
.k-sh-rounded .k-btn { border-radius: var(--k-radius); }
.k-sh-circle.k-d-icon .k-btn { border-radius: 50%; }

/* styles */
.k-st-a2z .k-btn { background: linear-gradient(135deg, var(--k-accent), var(--k-accent-2)); color: var(--k-accent-ink); --k-net: var(--k-accent); }
.k-st-accent .k-btn { background: var(--k-accent); color: var(--k-accent-ink); --k-net: var(--k-accent); }
.k-st-mono .k-btn { background: var(--k-ink); color: var(--k-bg); --k-net: var(--k-ink); }
/* inherit + mono: glyphs in the page's own text colour (works on light and dark footers), brand colour on hover */
.k[data-theme="inherit"] .k-st-mono .k-btn { background: transparent; color: inherit; border-color: color-mix(in srgb, currentColor 40%, transparent); }
.k[data-theme="inherit"] .k-st-mono .k-btn:hover { background: var(--k-net); color: var(--k-net-ink); border-color: transparent; }
.k-st-outline .k-btn { background: transparent; color: var(--k-net); border-color: color-mix(in srgb, var(--k-net) 45%, transparent); }
.k-st-outline .k-btn:hover { background: color-mix(in srgb, var(--k-net) 10%, transparent); filter: none; box-shadow: none; }
.k-st-minimal .k-btn { background: transparent; color: var(--k-ink-2); border-color: transparent; }
.k-st-minimal .k-btn:hover { background: var(--k-surface-2); color: var(--k-net); filter: none; box-shadow: none; }
.k-st-soft .k-btn { background: color-mix(in srgb, var(--k-net) 12%, var(--k-bg)); color: var(--k-net); }
.k-st-soft .k-btn:hover { background: var(--k-net); color: var(--k-net-ink); filter: none; }
/* Near-black brand marks (X, Threads, TikTok...) disappear on a dark page: invert them. */
.k[data-theme="dark"] .k-st-brand .k-btn.k-darkbrand,
.k[data-theme="dark"] .k-st-soft .k-btn.k-darkbrand { background: #f2f4fa; color: #0b0f1c; }
.k[data-theme="dark"] .k-st-outline .k-btn.k-darkbrand,
.k[data-theme="dark"] .k-st-minimal .k-btn.k-darkbrand:hover { color: #f2f4fa; border-color: rgba(242, 244, 250, .4); }
@media (prefers-color-scheme: dark) {
    .k[data-theme="os"] .k-st-brand .k-btn.k-darkbrand,
    .k[data-theme="os"] .k-st-soft .k-btn.k-darkbrand { background: #f2f4fa; color: #0b0f1c; }
    .k[data-theme="os"] .k-st-outline .k-btn.k-darkbrand { color: #f2f4fa; border-color: rgba(242, 244, 250, .4); }
}
.k-btn.is-done { background: var(--k-ok) !important; color: #fff !important; border-color: transparent !important; }

.k-cta {
    display: inline-flex; align-items: center; gap: 6px;
    margin-inline-end: 4px;
    font: 700 13px/1.2 var(--k-font); letter-spacing: .04em; text-transform: uppercase;
    color: var(--k-ink-3);
}
.k-cta .k-ico { width: 16px; height: 16px; }

/* ---------------- share: layouts ---------------- */
.k-share { display: flex; align-items: center; flex-wrap: wrap; gap: 10px var(--k-gap); }
.k-share.k-al-center { justify-content: center; }
.k-share.k-al-right { justify-content: flex-end; }
.k-l-vertical { flex-direction: column; align-items: flex-start; }
.k-l-vertical .k-list { flex-direction: column; align-items: stretch; }
.k-l-vertical .k-btn { justify-content: flex-start; width: 100%; }
.k-l-vertical.k-d-icon .k-btn { justify-content: center; }

/* floating side rail */
.k-float {
    position: fixed; z-index: 2147483000;
    top: 50%; transform: translateY(-50%);
    display: flex; flex-direction: column; gap: 0;
    padding: 6px; border-radius: 16px;
    background: color-mix(in srgb, var(--k-bg) 86%, transparent);
    -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
    box-shadow: var(--k-shadow);
    border: 1px solid var(--k-line);
    transition: opacity .25s var(--k-ease), transform .25s var(--k-ease);
}
.k-float.k-pos-left { left: max(8px, env(safe-area-inset-left)); }
.k-float.k-pos-right { right: max(8px, env(safe-area-inset-right)); }
.k-float .k-list { flex-direction: column; gap: 6px; }
.k-float .k-cta { writing-mode: vertical-rl; transform: rotate(180deg); margin: 4px auto 6px; font-size: 11px; }
.k-float.k-flush { padding: 0; gap: 0; border: 0; border-radius: 0; background: none; box-shadow: none; -webkit-backdrop-filter: none; backdrop-filter: none; }
.k-float.k-flush.k-pos-left { left: 0; }
.k-float.k-flush.k-pos-right { right: 0; }
.k-float.k-flush .k-list { gap: 0; }
.k-float.k-flush .k-btn { border-radius: 0; }
.k-float.k-flush.k-pos-left .k-list > li:first-child .k-btn { border-start-end-radius: 10px; }
.k-float.k-flush.k-pos-left .k-list > li:last-child .k-btn { border-end-end-radius: 10px; }
.k-float.k-flush.k-pos-right .k-list > li:first-child .k-btn { border-start-start-radius: 10px; }
.k-float.k-flush.k-pos-right .k-list > li:last-child .k-btn { border-end-start-radius: 10px; }
.k-float .k-btn .k-name {
    position: absolute; top: 50%; transform: translate(0, -50%) scale(.96); opacity: 0; pointer-events: none;
    padding: 6px 10px; border-radius: 8px; background: var(--k-ink); color: var(--k-bg);
    font: 600 12.5px/1 var(--k-font); white-space: nowrap; box-shadow: var(--k-shadow);
    transition: opacity .15s, transform .15s;
}
.k-float .k-btn { position: relative; }
.k-float.k-pos-left .k-btn .k-name { left: calc(100% + 10px); }
.k-float.k-pos-right .k-btn .k-name { right: calc(100% + 10px); }
.k-float .k-btn:hover .k-name, .k-float .k-btn:focus-visible .k-name { opacity: 1; transform: translate(0, -50%) scale(1); }
.k-float.is-away { opacity: 0; pointer-events: none; }
.k-float.k-pos-left.is-away { transform: translate(-16px, -50%); }
.k-float.k-pos-right.is-away { transform: translate(16px, -50%); }

/* bottom bar (phones) */
.k-bar {
    position: fixed; z-index: 2147483000; left: 0; right: 0; bottom: 0;
    padding: 6px max(6px, env(safe-area-inset-right)) calc(6px + env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-left));
    background: color-mix(in srgb, var(--k-bg) 92%, transparent);
    -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
    border-top: 1px solid var(--k-line);
    box-shadow: 0 -8px 24px -12px rgba(16, 22, 43, .25);
    transition: transform .25s var(--k-ease);
}
.k-bar .k-list { flex-wrap: nowrap; gap: 6px; justify-content: stretch; }
.k-bar .k-list > li { flex: 1 1 0; min-width: 0; }
.k-bar .k-btn { width: 100%; padding: 0 4px; min-width: 0; height: 44px; border-radius: 10px; }
.k-bar .k-btn .k-name { overflow: hidden; text-overflow: ellipsis; font-size: 12px; }
.k-bar.k-bar-stacked .k-btn { flex-direction: column; gap: 3px; height: 52px; font-size: 11px; }
.k-bar.is-away { transform: translateY(110%); }

/* compact "Share" button + panel */
.k-trigger {
    display: inline-flex; align-items: center; gap: 8px;
    height: var(--k-size); padding: 0 18px 0 14px; border-radius: 999px;
    border: 1px solid transparent;
    background: linear-gradient(135deg, var(--k-accent), var(--k-accent-2)); color: var(--k-accent-ink);
    font: 650 14.5px/1 var(--k-font); cursor: pointer;
    box-shadow: 0 8px 20px -10px color-mix(in srgb, var(--k-accent) 80%, transparent);
    transition: transform .18s var(--k-ease), box-shadow .18s var(--k-ease);
}
.k-trigger:hover { transform: translateY(-1px); box-shadow: 0 12px 26px -10px color-mix(in srgb, var(--k-accent) 85%, transparent); }
.k-trigger .k-ico { width: 18px; height: 18px; }
.k-st-outline .k-trigger, .k-st-minimal .k-trigger { background: transparent; color: var(--k-accent-fg); border-color: var(--k-line-strong); box-shadow: none; }
.k-st-mono .k-trigger { background: var(--k-ink); color: var(--k-bg); box-shadow: none; }
.k-trigger.k-trigger-fab { position: fixed; z-index: 2147483000; bottom: calc(18px + env(safe-area-inset-bottom)); width: 54px; height: 54px; padding: 0; justify-content: center; }
.k-trigger.k-trigger-fab .k-ico { width: 22px; height: 22px; }
.k-trigger.k-trigger-fab.k-pos-left { left: 18px; }
.k-trigger.k-trigger-fab.k-pos-right { right: 18px; }

.k-anchor { position: relative; display: inline-block; }
.k-panel {
    position: absolute; z-index: 2147483001; top: calc(100% + 10px); inset-inline-start: 0;
    width: min(340px, calc(100vw - 24px));
    padding: 14px; border-radius: 18px;
    background: var(--k-bg); color: var(--k-ink);
    border: 1px solid var(--k-line); box-shadow: var(--k-shadow-lg);
    animation: k-pop .18s var(--k-ease);
}
.k-al-right .k-panel { inset-inline-start: auto; inset-inline-end: 0; }
.k-panel.k-up { top: auto; bottom: calc(100% + 10px); }
.k-panel-fixed { position: fixed; bottom: calc(84px + env(safe-area-inset-bottom)); top: auto; }
.k-panel-fixed.k-pos-right { right: 18px; left: auto; }
.k-panel-fixed.k-pos-left { left: 18px; right: auto; }
.k-panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 0 0 12px; }
.k-panel-head h2 { margin: 0; font: 700 15px/1.3 var(--k-font); color: var(--k-ink); }
.k-x {
    display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 50%;
    border: 0; background: var(--k-surface-2); color: var(--k-ink-2); cursor: pointer;
}
.k-x .k-ico { width: 16px; height: 16px; }
.k-x:hover { background: var(--k-line); color: var(--k-ink); }
.k-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; margin: 0; padding: 0; list-style: none; }
.k-tile {
    --k-net: var(--k-accent); --k-net-ink: #fff;
    display: flex; flex-direction: column; align-items: center; gap: 7px; width: 100%;
    padding: 12px 6px 10px; border-radius: 14px; border: 1px solid transparent;
    background: var(--k-surface); color: var(--k-ink-2);
    font: 600 12px/1.2 var(--k-font); text-align: center; text-decoration: none; cursor: pointer;
    transition: background-color .15s, border-color .15s, transform .15s var(--k-ease);
}
.k-tile:hover { background: var(--k-surface-2); border-color: var(--k-line); transform: translateY(-1px); color: var(--k-ink); }
.k-tile-ico { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 12px; background: var(--k-net); color: var(--k-net-ink); }
.k-tile-ico .k-ico { width: 20px; height: 20px; }
.k[data-theme="dark"] .k-tile.k-darkbrand .k-tile-ico { background: #f2f4fa; color: #0b0f1c; }
.k-tile.is-done .k-tile-ico { background: var(--k-ok); color: #fff; }
.k-urlrow { display: flex; gap: 8px; margin-top: 12px; }
.k-urlrow input {
    flex: 1; min-width: 0; height: 40px; padding: 0 12px; border-radius: 10px;
    border: 1px solid var(--k-line-strong); background: var(--k-surface); color: var(--k-ink-2);
    font: 13px/1 var(--k-font);
}
.k-small-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    height: 40px; padding: 0 14px; border-radius: 10px; border: 0;
    background: var(--k-ink); color: var(--k-bg); font: 650 13px/1 var(--k-font); cursor: pointer; white-space: nowrap;
}
.k-small-btn .k-ico { width: 16px; height: 16px; }
.k-small-btn.is-done { background: var(--k-ok); color: #fff; }
.k-note { margin: 10px 0 0; font-size: 12.5px; color: var(--k-ink-3); }

@media (max-width: 520px) {
    .k-panel:not(.k-panel-inline) {
        position: fixed; left: 8px !important; right: 8px !important; top: auto !important;
        bottom: calc(8px + env(safe-area-inset-bottom)); width: auto;
        border-radius: 20px; animation: k-sheet .22s var(--k-ease);
    }
}
@keyframes k-pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes k-sheet { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }

/* QR + Mastodon mini dialogs */
.k-qr { display: grid; place-items: center; gap: 10px; padding: 6px 0 2px; }
.k-qr canvas, .k-qr svg { width: 184px !important; height: 184px !important; border-radius: 12px; background: #fff; padding: 10px; }
.k-qr-url { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; color: var(--k-ink-3); }
.k-field { display: grid; gap: 6px; margin: 4px 0 0; }
.k-field label { font: 600 13px/1.3 var(--k-font); color: var(--k-ink-2); }
.k-field input {
    height: 42px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--k-line-strong);
    background: var(--k-bg); color: var(--k-ink); font: 14px/1 var(--k-font);
}
.k-field .k-hint { font-size: 12px; color: var(--k-ink-3); }
.k-err { color: #b42318; font-size: 12.5px; min-height: 1em; }
.k[data-theme="dark"] .k-err { color: #fca5a5; }

/* ---------------- frame mode (inside /embed/w/{slug}) ---------------- */
.k-frame-root { padding: 2px; }

@media (prefers-reduced-motion: reduce) {
    .k *, .k *::before, .k *::after { transition: none !important; animation: none !important; }
}
@media print { .k-float, .k-bar, .k-trigger-fab, .k-fixed { display: none !important; } }

/* ---------------- inside A2Z frames ----------------
   Kit components sit on the publisher's page, so their frame shows them
   the same way: no card around them, just a little breathing room. */
html.k-html .e-card { background: transparent; border-color: transparent; padding: 6px 4px 4px; }
html.k-html .e-foot { margin-top: 10px; }

/* Sample page for floating components (builder preview only). */
html.k-demo-html, html.k-demo-html body { background: var(--e-bg); }
html.k-demo-html body { overflow-x: hidden; }
.k-demo-card { position: absolute !important; top: 0; left: 0; width: 1px; padding: 0 !important; border: 0 !important; background: none !important; pointer-events: none; }
.k-demo-card * { pointer-events: auto; }
.k-demo { min-height: 100%; color: var(--e-ink); }
.k-demo-top {
    display: flex; align-items: center; gap: 10px; padding: 12px 18px;
    border-bottom: 1px solid var(--e-line); background: var(--e-bg);
    font: 700 14px/1 var(--e-font); color: var(--e-ink);
}
.k-demo-logo { width: 22px; height: 22px; border-radius: 7px; background: linear-gradient(135deg, #22b06b, #0e8f6a); }
.k-demo-top nav { margin-left: auto; display: flex; gap: 14px; font-weight: 500; font-size: 13px; color: var(--e-ink-3); }
@media (max-width: 480px) { .k-demo-top nav { display: none; } }
.k-demo-main { padding: 22px 18px 120px; }
.k-demo-article { max-width: 640px; margin: 0 auto; font: 16px/1.65 Georgia, "Iowan Old Style", "Times New Roman", serif; color: var(--e-ink-2); }
.k-demo-article h1 { font: 800 clamp(22px, 5vw, 30px)/1.2 var(--e-font); letter-spacing: -.02em; color: var(--e-ink); margin: 4px 0 10px; }
.k-demo-article h2 { font: 750 20px/1.3 var(--e-font); color: var(--e-ink); margin: 26px 0 8px; letter-spacing: -.01em; }
.k-demo-article h3 { font: 700 16.5px/1.3 var(--e-font); color: var(--e-ink); margin: 18px 0 6px; }
.k-demo-article p { margin: 0 0 12px; }
.k-demo-kicker { font: 600 12px/1 var(--e-font) !important; text-transform: uppercase; letter-spacing: .08em; color: #16855a; }
.k-demo-lede { font-size: 17.5px; color: var(--e-ink); }
.k-demo-fig { margin: 18px 0; }
.k-demo-fig img { display: block; width: 100%; height: auto; border-radius: 14px; }
.k-demo-fig figcaption { font: 13px/1.4 var(--e-font); color: var(--e-ink-3); margin-top: 6px; }
.k-demo-slot { margin: 14px 0; }
.k-demo-slot:empty { display: none; }
.k-demo-end { color: var(--e-ink-3); font-style: italic; }
