/* ============================================================
   Breakdance Dark Mode Toggle  –  toggle.css

   The toggle is rendered via the [bddmt_toggle] shortcode.
   Place it in your Breakdance header using:
     Elements panel → "Shortcode" element → [bddmt_toggle]

   The wrapper is inline-flex so it sits naturally inside any
   Breakdance nav / header row without needing extra containers.
   ============================================================ */

/* ---- Wrapper ---- */
#bddmt-wrapper {
    position: relative;          /* anchor for the dropdown */
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    /* z-index only needed so the dropdown floats above header content */
    z-index: 9999;
}

/* ---- Trigger button ---- */
#bddmt-trigger {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: none;
    border-radius: 8px;
    background: transparent;
    cursor: pointer;
    color: currentColor;   /* inherits from header so it matches your nav text */
    transition: background 0.15s, transform 0.12s, opacity 0.15s;
    opacity: 0.75;
}

#bddmt-trigger:hover {
    background: rgba(0, 0, 0, 0.06);
    opacity: 1;
    transform: scale(1.05);
}

#bddmt-trigger:focus-visible {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

/* ---- Trigger icons ---- */
#bddmt-trigger .bddmt-icon {
    width: 20px;
    height: 20px;
    position: absolute;
    transition: opacity 0.2s, transform 0.2s;
}

/* Default: show Auto icon */
#bddmt-trigger .bddmt-icon--light  { opacity: 0; transform: scale(0.7); }
#bddmt-trigger .bddmt-icon--dark   { opacity: 0; transform: scale(0.7); }
#bddmt-trigger .bddmt-icon--auto   { opacity: 1; transform: scale(1);   }

[data-bddmt-mode="light"] #bddmt-trigger .bddmt-icon--light { opacity: 1; transform: scale(1);   }
[data-bddmt-mode="light"] #bddmt-trigger .bddmt-icon--dark  { opacity: 0; transform: scale(0.7); }
[data-bddmt-mode="light"] #bddmt-trigger .bddmt-icon--auto  { opacity: 0; transform: scale(0.7); }

[data-bddmt-mode="dark"] #bddmt-trigger .bddmt-icon--light  { opacity: 0; transform: scale(0.7); }
[data-bddmt-mode="dark"] #bddmt-trigger .bddmt-icon--dark   { opacity: 1; transform: scale(1);   }
[data-bddmt-mode="dark"] #bddmt-trigger .bddmt-icon--auto   { opacity: 0; transform: scale(0.7); }

[data-bddmt-mode="auto"] #bddmt-trigger .bddmt-icon--light  { opacity: 0; transform: scale(0.7); }
[data-bddmt-mode="auto"] #bddmt-trigger .bddmt-icon--dark   { opacity: 0; transform: scale(0.7); }
[data-bddmt-mode="auto"] #bddmt-trigger .bddmt-icon--auto   { opacity: 1; transform: scale(1);   }

/* ---- Dropdown menu ---- */
#bddmt-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 160px;
    margin: 0;
    padding: 6px;
    list-style: none;
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-radius: 12px;
    box-shadow:
        0 4px 24px rgba(0, 0, 0, 0.12),
        0 1px 4px  rgba(0, 0, 0, 0.08),
        0 0 0 1px rgba(0, 0, 0, 0.06);
    transform-origin: top right;
    transform: scale(0.92) translateY(-4px);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1),
                opacity 0.15s ease;
}

#bddmt-menu[aria-hidden="false"] {
    transform: scale(1) translateY(0);
    opacity: 1;
    pointer-events: auto;
}

#bddmt-menu li {
    margin: 0;
    padding: 0;
}

/* ---- Menu option buttons ---- */
.bddmt-option {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 9px 12px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: #1c1c1e;
    font-size: 15px;
    font-weight: 400;
    line-height: 1.3;
    cursor: pointer;
    text-align: left;
    transition: background 0.12s;
}

.bddmt-option:hover,
.bddmt-option:focus-visible {
    background: rgba(0, 0, 0, 0.06);
    outline: none;
}

.bddmt-option svg {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    color: #555;
}

/* Active / selected state – checkmark via box-shadow ring */
.bddmt-option[aria-current="true"] {
    font-weight: 600;
    color: #000;
}

.bddmt-option[aria-current="true"] svg {
    color: #000;
}

.bddmt-option[aria-current="true"]::after {
    content: "";
    display: block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #000;
    margin-left: auto;
    flex-shrink: 0;
}

/* ============================================================
   Dark-mode styles for the widget itself.
   Primary selector:  body.dark-mode  (Breakdance community convention
                      — used by darkify.js and most tutorials)
   Secondary selector: [data-theme="dark"]  on <html>  (bonus hook for
                      custom CSS that prefers the attribute approach)
   ============================================================ */
body.dark-mode #bddmt-trigger,
[data-theme="dark"] #bddmt-trigger {
    background: transparent;
    /* colour is inherited from header — dark mode headers handle their own text colour */
}

body.dark-mode #bddmt-trigger:hover,
[data-theme="dark"] #bddmt-trigger:hover {
    background: rgba(255, 255, 255, 0.1);
}

body.dark-mode #bddmt-menu,
[data-theme="dark"] #bddmt-menu {
    background: rgba(44, 44, 46, 0.97);
    box-shadow:
        0 4px 24px rgba(0, 0, 0, 0.5),
        0 1px 4px  rgba(0, 0, 0, 0.3),
        0 0 0 1px rgba(255, 255, 255, 0.06);
}

body.dark-mode .bddmt-option,
[data-theme="dark"] .bddmt-option {
    color: #f2f2f7;
}

body.dark-mode .bddmt-option svg,
[data-theme="dark"] .bddmt-option svg {
    color: #aeaeb2;
}

body.dark-mode .bddmt-option:hover,
body.dark-mode .bddmt-option:focus-visible,
[data-theme="dark"] .bddmt-option:hover,
[data-theme="dark"] .bddmt-option:focus-visible {
    background: rgba(255, 255, 255, 0.08);
}

body.dark-mode .bddmt-option[aria-current="true"],
[data-theme="dark"] .bddmt-option[aria-current="true"] {
    color: #fff;
}

body.dark-mode .bddmt-option[aria-current="true"] svg,
[data-theme="dark"] .bddmt-option[aria-current="true"] svg {
    color: #fff;
}

body.dark-mode .bddmt-option[aria-current="true"]::after,
[data-theme="dark"] .bddmt-option[aria-current="true"]::after {
    background: #fff;
}

/* ============================================================
   Responsive – dropdown repositions on very small screens
   ============================================================ */
@media (max-width: 360px) {
    #bddmt-menu {
        right: auto;
        left: 0;
    }
}
