/* ==========================================================================
   share.css — self-hosted Share button (replacement for AddThis / ShareThis)
   No third-party code, fonts or images. Pairs with share.js + the markup in
   share-snippet.html. Full documentation: SHARE_BUTTON_GUIDE.md

   THEMING: every colour comes from a --share-* variable. Each one falls back
   to the site's own theme variable (--primary, --secondary, --bg-color,
   --text-color, --border-radius, --shadow-lg) and then to a built-in
   light/dark default, so it works on themed AND plain sites with no edits.
   To restyle, override the --share-* variables on .share — do not edit rules.

   SPECIFICITY (important): selectors inside the dialog are deliberately
   written ".share .share-dialog .xxx" (specificity 0,3,0). Host sites often
   have global rules such as  button:not(.btn)  /  a:hover  /  input  /  li  /
   h2  /  p  that would otherwise restyle the widget. Do not "simplify" them.
   ========================================================================== */

/* ---- Built-in defaults (used only when the site defines no theme vars) --- */
:root {
    --share-d-bg:        #ffffff;
    --share-d-panel:     #f4f5f7;
    --share-d-fg:        #1b1f24;
    --share-d-accent:    #0b57d0;
    --share-d-on-accent: #ffffff;
}
@media (prefers-color-scheme: dark) {
    :root {
        --share-d-bg:        #12161c;
        --share-d-panel:     #1c222b;
        --share-d-fg:        #eef1f5;
        --share-d-accent:    #7cb7ff;
        --share-d-on-accent: #0b1220;
    }
}

/* ---- Variables (override these on .share to restyle) -------------------- */
.share {
    --share-btn-bg:    var(--secondary,     var(--share-d-panel));
    --share-btn-fg:    var(--text-color,    var(--share-d-fg));
    --share-accent:    var(--primary,       var(--share-d-accent));
    --share-on-accent: var(--bg-color,      var(--share-d-on-accent));
    --share-panel-bg:  var(--bg-color,      var(--share-d-bg));
    --share-panel-fg:  var(--text-color,    var(--share-d-fg));
    --share-field-bg:  var(--secondary,     var(--share-d-panel));
    --share-radius:    var(--border-radius, 12px);
    --share-radius-sm: var(--border-radius-sm, 8px);
    --share-shadow:    var(--shadow-lg,     0 8px 30px rgba(0, 0, 0, .4));
    --share-line:      color-mix(in srgb, var(--share-panel-fg) 28%, transparent);
    --share-target:    44px;               /* minimum touch target size */
}

.share[hidden] { display: none; }           /* hidden until share.js runs */

/* ---- The Share button -------------------------------------------------- */
/* :where() keeps specificity at zero, so a site class such as .control-btn
   (used with class="share-btn control-btn") always wins over these defaults. */
:where(.share-btn) {
    display:         inline-flex;
    align-items:     center;
    justify-content: center;
    gap:             .5em;
    min-block-size:  var(--share-target);
    min-inline-size: var(--share-target);
    padding:         .55em 1.1em;
    background:      var(--share-btn-bg);
    color:           var(--share-btn-fg);
    border:          1px solid var(--share-accent);
    border-radius:   var(--share-radius);
    font:            inherit;
    font-weight:     700;
    line-height:     1.2;
    cursor:          pointer;
    box-shadow:      0 2px 6px rgba(0, 0, 0, .25);
}
:where(.share-btn):hover {
    background: var(--share-accent);
    color:      var(--share-on-accent);
}
.share .share-btn .share-icon {
    inline-size:  1.15em;
    block-size:   1.15em;
    flex:         none;
    fill:         none;
    stroke:       currentColor;
    stroke-width: 2;
    stroke-linecap:  round;
    stroke-linejoin: round;
}

/* Optional floating variant:  <div class="share share--float" …>
   Bottom-LEFT on purpose: the DR templates keep Back-to-top at bottom-right.
   Physical "left" (not inline-start) so RTL pages never collide with it.   */
.share.share--float {
    position: fixed;
    left:     max(1rem, env(safe-area-inset-left));
    bottom:   max(1rem, env(safe-area-inset-bottom));
    z-index:  500;
}
.share.share--float .share-btn {
    border-radius: 9999px;
    box-shadow:    0 4px 15px rgba(0, 0, 0, .4);
}

/* ---- The dialog ---------------------------------------------------------- */
.share .share-dialog {
    box-sizing:    border-box;
    inline-size:   min(26rem, calc(100vw - 2rem));
    max-block-size: min(85vh, 40rem);
    padding:       0;
    margin:        auto;
    overflow:      auto;
    color:         var(--share-panel-fg);
    background:    var(--share-panel-bg);
    border:        1px solid var(--share-accent);
    border-radius: var(--share-radius);
    box-shadow:    var(--share-shadow);
    font-size:     1rem;
    font-weight:   400;
    line-height:   1.4;
    text-align:    start;
}
.share .share-dialog::backdrop { background: rgba(0, 0, 0, .6); }
.share .share-dialog[open]     { animation: share-pop .18s ease-out; }
.share .share-dialog .share-body { padding: 1rem 1.1rem 1.2rem; }

body:has(.share-dialog[open]) { overflow: hidden; }    /* stop page scrolling behind it */

.share .share-dialog .share-head {
    display:         flex;
    align-items:     center;
    justify-content: space-between;
    gap:             1rem;
    margin-block-end: .9rem;
}
/* A <div>, not an <h2>: keeps host heading styles (and the page's heading
   outline / SEO) untouched. The dialog is named via aria-labelledby.       */
.share .share-dialog .share-title {
    margin:      0;
    color:       inherit;
    font-family: inherit;
    font-size:   1.2rem;
    font-weight: 700;
    line-height: 1.25;
    text-shadow: none;
}

.share .share-dialog .share-close {
    inline-size:  var(--share-target);
    block-size:   var(--share-target);
    margin:       0;
    margin-inline-end: -.5rem;
    padding:      0;
    background:   transparent;
    color:        inherit;
    border:       0;
    border-radius: 50%;
    font-family:  inherit;
    font-size:    1.7rem;
    font-weight:  400;
    line-height:  1;
    cursor:       pointer;
    opacity:      1;
}
.share .share-dialog .share-close:hover { background: var(--share-line); color: inherit; opacity: 1; }

/* URL field + Copy button */
.share .share-dialog .share-copy { display: flex; gap: .5rem; }
.share .share-dialog .share-url {
    flex:          1 1 auto;
    inline-size:   auto;
    max-inline-size: none;
    min-inline-size: 0;
    min-block-size: var(--share-target);
    margin:        0;
    padding:       0 .75rem;
    color:         inherit;
    background:    var(--share-field-bg);
    border:        1px solid var(--share-line);
    border-radius: var(--share-radius-sm);
    box-shadow:    none;
    font-family:   inherit;
    font-size:     .9rem;
    text-overflow: ellipsis;
}
.share .share-dialog .share-copy-btn {
    flex:          none;
    min-block-size: var(--share-target);
    margin:        0;
    padding:       0 1rem;
    color:         var(--share-on-accent);
    background:    var(--share-accent);
    border:        1px solid var(--share-accent);
    border-radius: var(--share-radius-sm);
    font-family:   inherit;
    font-size:     1rem;
    font-weight:   700;
    cursor:        pointer;
    opacity:       1;
}
.share .share-dialog .share-copy-btn:hover { filter: brightness(1.12); opacity: 1; }

.share .share-dialog .share-status {
    min-block-size: 1.4em;
    margin:         .35rem 0 .6rem;
    font-size:      .9rem;
    text-align:     start;
    hyphens:        none;
}

/* Network grid */
.share .share-dialog .share-list {
    display:  grid;
    grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr));
    gap:      .5rem;
    margin:   0;
    padding:  0;
    list-style: none;
}
.share .share-dialog .share-list > li {
    margin:     0;
    text-align: start;
    font-size:  1rem;
}
.share .share-dialog .share-list > li[hidden] { display: none; }
.share .share-dialog .share-net {
    display:     flex;
    align-items: center;
    gap:         .65rem;
    min-block-size: var(--share-target);
    padding:     .45rem .7rem;
    color:       inherit;
    background:  transparent;
    border:      1px solid var(--share-line);
    border-radius: var(--share-radius-sm);
    font:        inherit;
    text-decoration: none;
    text-shadow: none;
    opacity:     1;
}
.share .share-dialog .share-net::after { content: none; }      /* no host "external link" arrow */
.share .share-dialog .share-net:hover {
    color:        var(--share-on-accent);
    background:   var(--share-accent);
    border-color: var(--share-accent);
    text-decoration: none;
    opacity:      1;
}

/* Coloured letter badge — decorative (aria-hidden); the text label is the name */
.share .share-dialog .share-badge {
    display:     inline-grid;
    place-items: center;
    flex:        none;
    inline-size: 1.7rem;
    block-size:  1.7rem;
    color:       #fff;
    background:  var(--share-accent);
    border-radius: 6px;
    font-size:   .85rem;
    font-weight: 700;
    line-height: 1;
}
.share .share-dialog .share-badge svg {
    inline-size: 1rem; block-size: 1rem; fill: none; stroke: currentColor;
    stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.share [data-net="facebook"]  .share-badge { background: #1877f2; }
.share [data-net="x"]         .share-badge { background: #000;    outline: 1px solid var(--share-line); }
.share [data-net="whatsapp"]  .share-badge { background: #128c7e; }
.share [data-net="telegram"]  .share-badge { background: #229ed9; }
.share [data-net="reddit"]    .share-badge { background: #ff4500; }
.share [data-net="linkedin"]  .share-badge { background: #0a66c2; }
.share [data-net="bluesky"]   .share-badge { background: #1185fe; }
.share [data-net="threads"]   .share-badge { background: #000;    outline: 1px solid var(--share-line); }
.share [data-net="pinterest"] .share-badge { background: #e60023; }
/* Accent-coloured badges (email, sms) would vanish on the accent hover background → invert them */
.share [data-net="email"]:hover .share-badge,
.share [data-net="sms"]:hover   .share-badge { background: var(--share-on-accent); color: var(--share-accent); }

/* Visually hidden but read by screen readers */
.share .share-sr {
    position: absolute !important;
    inline-size: 1px; block-size: 1px;
    margin: -1px; padding: 0; overflow: hidden;
    clip-path: inset(50%); white-space: nowrap; border: 0;
}

/* Keyboard focus */
.share :focus-visible {
    outline:        3px solid var(--share-accent);
    outline-offset: 2px;
}

/* ---- Phones: dialog becomes a bottom sheet ------------------------------- */
@media (max-width: 600px) {
    .share .share-dialog {
        inline-size:     100%;
        max-inline-size: 100%;
        margin:          auto 0 0 0;            /* pin to the bottom edge */
        border-inline: 0;
        border-block-end: 0;
        border-radius:   var(--share-radius) var(--share-radius) 0 0;
        padding-block-end: env(safe-area-inset-bottom);
    }
    .share .share-dialog[open] { animation-name: share-sheet; }
    .share .share-dialog .share-list { grid-template-columns: 1fr 1fr; }
}

@keyframes share-pop   { from { opacity: 0; transform: scale(.96); } }
@keyframes share-sheet { from { opacity: .5; transform: translateY(2rem); } }

@media (prefers-reduced-motion: reduce) {
    .share .share-dialog[open] { animation: none; }
}

/* Never print the widget */
@media print {
    .share { display: none !important; }
}
