/* =========================================================
   Tibiarok — the social dock (js/social-dock.js; README, "The social dock")
   ---------------------------------------------------------
   Loaded by the landing pages and the downloads pages, after css/site.css.
   Wide screens (>= 1024 px, data-mode="wide"): tabs on the right edge inside the gold frame, one panel beside them.
   Narrower (data-mode="sheet"): a button at the bottom right (Discord's mark and name while it is the one service, else
   "Comunidade") and a bottom sheet.
   The embed loads when its panel opens (2026-11-20): no card before it; the head carries the service's own link (.sd-join).
   No transform on anything that takes the focus or holds it (the site's gold cursor follows the focus by anchor
   positioning, which ignores transforms): the panels move by their offsets. Every size here is a default to tune.
   ========================================================= */

.sd {
    --sd-bg: rgba(5, 15, 26, 0.97);
    --sd-tab-bg: rgba(5, 15, 26, 0.9);
    --sd-line: rgba(222, 168, 76, 0.55);
    --sd-line-soft: rgba(222, 168, 76, 0.25);
    --sd-gold: var(--tr-gold, #dea84c);
    --sd-gold-hi: #f6d57a;
    --sd-text: #e9e4d6;
    --sd-muted: rgba(255, 255, 255, 0.68);
    --sd-edge: calc(12px * var(--frame-scale, 1));   /* the frame's inner edge on the right */
    --sd-top: calc(42px * var(--frame-scale, 1) + 76px); /* under the navbar band */
    --sd-tab-w: 36px;
    --sd-gap: 10px;
    color: var(--sd-text);
    font-size: .95rem;
}
.sd [hidden] { display: none !important; }

/* ---- wide: the tabs ---- */
.sd-rail {
    position: fixed;
    z-index: 1033; /* over the frame (1031) and the logo's link (1032), under the gold cursor (1035) */
    right: var(--sd-edge);
    top: var(--sd-top);
    bottom: 24px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-end;
    gap: 8px;
    pointer-events: none;
}
.sd .sd-tab {
    pointer-events: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    width: var(--sd-tab-w);
    padding: 10px 0 12px;
    background: var(--sd-tab-bg);
    color: var(--sd-text);
    border: 1px solid var(--sd-line) !important;
    border-right-width: 0 !important;
    border-radius: 8px 0 0 8px !important;
    box-shadow: -4px 4px 14px rgba(0, 0, 0, 0.45);
    cursor: pointer;
    font: inherit;
    font-size: .8rem;
    letter-spacing: .06em;
    transition: width .15s ease, background-color .15s ease, color .15s ease;
}
.sd .sd-tab:hover { background: rgba(32, 26, 14, 0.94); color: #fff; border-color: var(--sd-gold) !important; }
/* the call: the Discord tab glows three times a few seconds after the page loads, until the visitor has opened the dock once
   (js/social-dock.js; a box-shadow, never a transform: the tab takes the focus) */
.sd .sd-tab.is-calling { animation: sd-call 1.8s ease-out 2.5s 3; }
@keyframes sd-call {
    0%   { box-shadow: -4px 4px 14px rgba(0, 0, 0, 0.45), 0 0 0 0 rgba(246, 213, 122, 0.75); border-color: var(--sd-gold-hi); }
    70%  { box-shadow: -4px 4px 14px rgba(0, 0, 0, 0.45), 0 0 0 12px rgba(246, 213, 122, 0); }
    100% { box-shadow: -4px 4px 14px rgba(0, 0, 0, 0.45), 0 0 0 0 rgba(246, 213, 122, 0); }
}
.sd .sd-tab[aria-expanded="true"] {
    width: calc(var(--sd-tab-w) + 6px);
    background: rgba(40, 30, 12, 0.96);
    color: var(--sd-gold-hi);
    border-color: var(--sd-gold) !important;
}
.sd-tab .sd-name { writing-mode: vertical-rl; white-space: nowrap; }
.sd-ico { display: block; flex: none; width: 24px; height: 24px; border-radius: 5px; }

/* ---- the panel (both layouts) ---- */
.sd-panel {
    position: fixed;
    z-index: 1034;
    display: flex;
    flex-direction: column;
    background: var(--sd-bg);
    border: 1px solid var(--sd-line);
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.65);
    color: var(--sd-text);
    overflow: hidden; /* the embed keeps to the rounded corners */
    opacity: 0;
    transition: opacity .18s ease, right .22s ease, bottom .26s ease;
}
.sd-panel.is-open { opacity: 1; }
.sd-panel.is-dragging { transition: none; }

.sd[data-mode="wide"] .sd-panel {
    top: var(--sd-top);
    right: calc(var(--sd-edge) + var(--sd-tab-w) + var(--sd-gap) + 6px - 24px); /* 24 px nearer the edge, closed: it slides in */
    width: 480px;
    max-width: calc(100vw - var(--sd-edge) - var(--sd-tab-w) - 40px);
    height: min(680px, 80vh, calc(100vh - var(--sd-top) - 24px));
    border-radius: 12px;
}
.sd[data-mode="wide"] .sd-panel.is-open { right: calc(var(--sd-edge) + var(--sd-tab-w) + var(--sd-gap) + 6px); }

.sd[data-mode="sheet"] .sd-panel {
    left: max(0px, calc(50% - 320px));
    right: max(0px, calc(50% - 320px));
    height: 85vh;
    height: 85dvh;
    bottom: -85vh;
    bottom: -85dvh;
    border-bottom: 0;
    border-radius: 16px 16px 0 0;
    padding-bottom: env(safe-area-inset-bottom);
}
.sd[data-mode="sheet"] .sd-panel.is-open { bottom: 0; }

.sd-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1033;
    background: rgba(0, 0, 0, 0.55);
    opacity: 0;
    transition: opacity .2s ease;
    touch-action: none;
}
.sd-backdrop.is-open { opacity: 1; }

/* the head: the service, its line, its own link, the close button (and the handle on the sheet) */
.sd-head {
    position: relative;
    flex: none;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 12px 10px 16px;
    border-bottom: 1px solid var(--sd-line-soft);
}
.sd-head-ico .sd-ico { width: 28px; height: 28px; border-radius: 6px; }
.sd-heading { flex: 1 1 auto; display: flex; flex-direction: column; min-width: 0; }
.sd-title { margin: 0; font-size: 1.05rem; font-weight: 600; line-height: 1.2; color: var(--sd-gold-hi); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sd-sub { font-size: .78rem; color: var(--sd-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* the panel's one call to action: the invite (or the channel), in the site's gold */
.sd .sd-join {
    flex: none;
    display: inline-flex;
    align-items: center;
    min-height: 40px;
    padding: 6px 16px;
    font-size: .92rem;
    font-weight: 700;
    line-height: 1.1;
    white-space: nowrap;
}
.sd .sd-close {
    flex: none;
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    padding: 0;
    background: rgba(0, 0, 0, 0.3);
    color: var(--sd-text);
    border: 1px solid rgba(222, 168, 76, 0.4) !important;
    border-radius: 8px !important;
    font: inherit;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
}
.sd .sd-close:hover { color: #fff; border-color: var(--sd-gold) !important; }
/* the cross is drawn (js/social-dock.js), so it sits in the middle whatever the font: 10 px of ink, as the old glyph had */
.sd-close-ico { display: block; width: 20px; height: 20px; pointer-events: none; }
.sd-handle { display: none; }
.sd[data-mode="sheet"] .sd-head { padding-top: 22px; touch-action: none; }
.sd[data-mode="sheet"] .sd-handle {
    display: block;
    position: absolute;
    top: 8px;
    left: calc(50% - 22px);
    width: 44px;
    height: 4px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.35);
}

/* the services as tabs, on the sheet only (wide screens have the side tabs) */
.sd-switch {
    flex: none;
    display: flex;
    gap: 6px;
    padding: 8px 12px;
    overflow-x: auto;
    border-bottom: 1px solid var(--sd-line-soft);
}
.sd[data-mode="wide"] .sd-switch { display: none; }
.sd .sd-switch [role="tab"] {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 40px;
    padding: 6px 14px 6px 8px;
    background: rgba(0, 0, 0, 0.3);
    color: var(--sd-text);
    border: 1px solid rgba(222, 168, 76, 0.35) !important;
    border-radius: 20px !important;
    font: inherit;
    white-space: nowrap;
    cursor: pointer;
}
.sd .sd-switch [role="tab"][aria-selected="true"] { background: rgba(222, 168, 76, 0.16); color: var(--sd-gold-hi); border-color: var(--sd-gold) !important; }
.sd-switch .sd-ico { width: 22px; height: 22px; }

/* one service: its embed, built when its panel opens */
.sd-views, .sd-view { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.sd-embed {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    overscroll-behavior: contain;
    background: rgba(0, 0, 0, 0.35);
}
.sd-embed:focus { outline: none; }
.sd-embed iframe { display: block; width: 100%; height: 100%; border: 0; background: transparent; }
.sd-embed.is-video iframe { height: auto; aspect-ratio: 16 / 9; }
.sd-status { position: absolute; inset: 0; margin: 0; display: grid; place-items: center; font-size: .9rem; color: var(--sd-muted); pointer-events: none; }
.sd-sentinel { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

/* ---- narrow: the button ---- */
.sd .sd-fab {
    position: fixed;
    z-index: 1033;
    right: calc(16px + env(safe-area-inset-right));
    bottom: calc(16px + env(safe-area-inset-bottom));
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 48px;
    padding: 0 18px 0 14px;
    background: linear-gradient(180deg, #12304d 0%, #081929 100%);
    color: var(--sd-gold-hi);
    border: 1px solid var(--sd-gold) !important;
    border-radius: 24px !important;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.55), 0 0 0 3px rgba(8, 25, 41, 0.6);
    font: inherit;
    font-weight: 600;
    letter-spacing: .02em;
    cursor: pointer;
    transition: opacity .2s ease, visibility .2s ease;
}
.sd .sd-fab:hover { color: #fff; }
.sd-fab-ico { width: 22px; height: 22px; flex: none; }
.sd .sd-fab.is-away { opacity: 0; visibility: hidden; pointer-events: none; }
.sd[data-mode="wide"] .sd-fab,
.sd[data-mode="wide"] .sd-backdrop { display: none !important; }
.sd[data-mode="sheet"] .sd-rail { display: none !important; }

/* a phone's head: the title and the link keep their room; under 360 px the head's icon steps aside */
.sd[data-mode="sheet"] .sd-head { gap: 8px; padding-left: 14px; padding-right: 10px; }
@media (max-width: 479.98px) {
    .sd[data-mode="sheet"] .sd-sub { display: none; }
}
@media (max-width: 359.98px) {
    .sd[data-mode="sheet"] .sd-head-ico { display: none; }
    .sd .sd-join { padding: 6px 12px; }
}

/* under 1024 px the page's last line can scroll above the button */
@media (max-width: 1023.98px) {
    .site-foot { padding-bottom: calc(40px + 64px + env(safe-area-inset-bottom)); }
}

@media (prefers-reduced-motion: reduce) {
    .sd-panel, .sd-backdrop, .sd .sd-tab, .sd .sd-fab { transition: none; }
    .sd .sd-tab.is-calling { animation: none; }
}
