/*
 * Site header (includes/site-header.php + site-header-template.php).
 *
 * The bar, dropdowns, credits pill and avatar menu use the older .nsh rules
 * in the Oxygen base-styles sheet. This file adds the rest: the Tools rail
 * (desktop), the phone panels, the tools accordion, and the notification
 * bell (moved here from the old header block).
 *
 * Breakpoint: desktop over 1024px, phone at 1024px and under (same as the
 * older header rules).
 */

/* ===== Bar additions ===== */

/* Tools button in the bar looks like the other bar links */
.nsh-v2 .nsh-tools-btn {
    background: none;
    border: 0;
    font: inherit;
    font-size: 14px;
}
.nsh-v2 .nsh-tools-btn svg,
.nsh-v2 .nsh-phone-btn svg {
    width: 15px !important; /* site forces every svg to 1em */
    height: 15px !important;
}
.nsh-v2 .nsh-link[aria-current="page"] { color: var(--text-primary, #e5e5e5); }

/* Dropdowns also open for keyboard users */
.nsh-v2 .nsh-item:focus-within > .nsh-drop {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* Phone buttons: hidden on desktop */
/* .nsh-v2 prefix: the header's ".nsh *" reset would otherwise zero the padding and margin */
.nsh-v2 .nsh-phone-btns { display: none; margin-left: auto; gap: 8px; }
.nsh-v2 .nsh-phone-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 44px;
    padding: 0 14px;
    background: var(--surface, #1f1f1f);
    border: 1px solid var(--border-light, rgba(255, 255, 255, 0.12));
    border-radius: 6px;
    color: var(--text-primary, #e5e5e5);
    font: inherit;
    font-size: 14px;
    cursor: pointer;
}

/* ===== Tools rail (desktop) ===== */

/* Room for the rail so it never covers the page */
@media (min-width: 1025px) {
    body.nsh-has-rail { padding-left: 40px; }
    /* The site pins the header with an inline "position: fixed; left: 0;
       width: 100%" rule; start it after the rail instead. */
    body.nsh-has-rail .nsh-v2 { left: 40px; width: auto; }
}

.nsh-rail {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: 40px;
    z-index: 10000;
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
}
.nsh-rail-btn {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 84px 0 0;
    background: var(--bg-secondary, #111111);
    border: 0;
    border-right: 1px solid var(--border, rgba(255, 255, 255, 0.08));
    color: var(--text-secondary, #a1a1a1);
    cursor: pointer;
}
.nsh-rail-btn svg {
    width: 16px !important; /* site forces every svg to 1em */
    height: 16px !important;
}
.nsh-rail-btn span {
    writing-mode: vertical-rl;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}
.nsh-rail:hover .nsh-rail-btn,
.nsh-rail.is-pinned .nsh-rail-btn { color: var(--primary, #fbbf24); background: var(--surface, #1f1f1f); }

/* The menu that slides out of the rail, over the page */
.nsh-rail-fly {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 40px;
    width: 300px;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 16px 12px;
    background: var(--bg-secondary, #111111);
    border-right: 1px solid var(--border-light, rgba(255, 255, 255, 0.12));
    box-shadow: 12px 0 32px rgba(0, 0, 0, 0.55);
    visibility: hidden;
    opacity: 0;
    transform: translateX(-8px);
    transition: opacity 0.15s, transform 0.15s, visibility 0s linear 0.15s;
}
/* Opens on hover (after a short pause, so crossing the edge does not open it),
   on keyboard focus, or when pinned by a click */
.nsh-rail:hover .nsh-rail-fly,
.nsh-rail:has(:focus-visible) .nsh-rail-fly,
.nsh-rail.is-pinned .nsh-rail-fly {
    visibility: visible;
    opacity: 1;
    transform: none;
    transition: opacity 0.15s 0.12s, transform 0.15s 0.12s, visibility 0s 0.12s;
}
.nsh-rail.is-pinned .nsh-rail-fly { transition-delay: 0s; }

@media (max-width: 1024px) {
    .nsh-rail { display: none; }
    .nsh-v2 .nsh-phone-btns { display: flex; }
}

/* ===== Tools menu (rail and phone Tools panel) ===== */

.nsh-picker { margin-bottom: 12px; }
.nsh-picker label {
    display: block;
    margin-bottom: 4px;
    font-size: 12px;
    color: var(--text-secondary, #a1a1a1);
}
.nsh-picker select {
    width: 100%;
    padding: 7px 8px;
    background: var(--surface, #1f1f1f);
    border: 1px solid var(--border-light, rgba(255, 255, 255, 0.12));
    border-radius: 6px;
    color: var(--text-primary, #e5e5e5);
    font: inherit;
    font-size: 14px;
}

.nsh-this-project {
    margin-bottom: 12px;
    padding: 8px;
    border: 1px solid var(--border-light, rgba(255, 255, 255, 0.12));
    border-left: 3px solid var(--primary, #fbbf24);
    border-radius: 6px;
}
.nsh-this-project p { margin: 0 0 4px; font-size: 12px; color: var(--text-secondary, #a1a1a1); }
.nsh-this-project strong { color: var(--text-primary, #e5e5e5); }
.nsh-this-project ul { list-style: none; margin: 0; padding: 0; }

.nsh-all-tools {
    display: block;
    padding: 7px 8px;
    border-radius: 6px;
    color: var(--primary, #fbbf24);
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
}

.nsh-group summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px;
    border-radius: 6px;
    color: var(--text-primary, #e5e5e5);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    list-style: none;
}
.nsh-group summary::-webkit-details-marker { display: none; }
.nsh-group summary::after { content: "+"; color: var(--text-muted, #6b6b6b); }
.nsh-group[open] summary::after { content: "\2212"; } /* minus sign */
.nsh-group ul { list-style: none; margin: 0 0 4px; padding: 0 0 0 8px; }

.nsh-this-project a,
.nsh-group ul a,
.nsh-group-all {
    display: block;
    padding: 5px 8px;
    border-radius: 5px;
    color: var(--text-secondary, #a1a1a1);
    font-size: 14px;
    text-decoration: none;
}
.nsh-group-all { margin: 0 0 8px 8px; font-size: 13px; color: var(--primary, #fbbf24); }
.nsh-group summary:hover,
.nsh-all-tools:hover,
.nsh-this-project a:hover,
.nsh-group ul a:hover,
.nsh-group-all:hover { background: var(--surface, #1f1f1f); color: var(--text-primary, #e5e5e5); }
.nsh-group ul a[aria-current="page"] {
    background: var(--surface-hover, #252525);
    color: var(--text-primary, #e5e5e5);
    box-shadow: inset 3px 0 0 var(--primary, #fbbf24);
}

/* ===== Phone panels (<dialog>) ===== */

html:has(.nsh-panel[open]) { overflow: hidden; } /* no page scroll behind an open panel */

.nsh-panel {
    position: fixed;
    top: 0;
    bottom: 0;
    width: min(360px, 88vw);
    max-width: none;
    height: 100%;
    max-height: none;
    margin: 0;
    padding: 0;
    border: 0;
    background: var(--bg-secondary, #111111);
    color: var(--text-primary, #e5e5e5);
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
}
.nsh-panel-left { left: 0; right: auto; border-right: 1px solid var(--border-light, rgba(255, 255, 255, 0.12)); }
.nsh-panel-right { right: 0; left: auto; border-left: 1px solid var(--border-light, rgba(255, 255, 255, 0.12)); }
.nsh-panel::backdrop { background: rgba(0, 0, 0, 0.6); }
.nsh-panel-inner { display: flex; flex-direction: column; height: 100%; }
.nsh-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 8px 8px 16px;
    border-bottom: 1px solid var(--border, rgba(255, 255, 255, 0.08));
}
.nsh-panel-head h2 { margin: 0; font-size: 16px; color: var(--text-primary, #e5e5e5); }
.nsh-panel-head form { margin: 0; }
.nsh-panel-close {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: 0;
    color: var(--text-secondary, #a1a1a1);
    cursor: pointer;
}
.nsh-panel-close svg { width: 20px !important; height: 20px !important; } /* site forces every svg to 1em */
.nsh-panel-body { flex: 1; overflow-y: auto; padding: 12px 14px 24px; }

/* Tap targets at least 44px tall */
.nsh-panel .nsh-group summary,
.nsh-panel .nsh-group ul a,
.nsh-panel .nsh-all-tools,
.nsh-panel .nsh-this-project a,
.nsh-panel .nsh-group-all,
.nsh-panel-links a { display: flex; align-items: center; min-height: 44px; }

.nsh-panel-links { list-style: none; margin: 0 0 8px; padding: 0; }
.nsh-panel-links a {
    padding: 0 8px;
    border-radius: 6px;
    color: var(--text-primary, #e5e5e5);
    font-size: 15px;
    font-weight: 600;
    text-decoration: none;
}
.nsh-panel-links a:hover { background: var(--surface, #1f1f1f); }
.nsh-panel-links a.is-danger { color: var(--danger, #ef4444); }
.nsh-panel-credits { display: inline-flex; margin: 0 0 8px 8px; }
.nsh-panel-account { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border, rgba(255, 255, 255, 0.08)); }
.nsh-panel-account p { margin: 0 0 8px; padding: 0 8px; font-size: 13px; color: var(--text-secondary, #a1a1a1); }
.nsh-panel-account .nsh-panel-links a { font-weight: 500; }
.nsh-panel-cta { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
.nsh-panel-cta a { text-align: center; }

@media (prefers-reduced-motion: reduce) {
    .nsh-rail-fly { transition: none; }
}

/* ===== Notification bell (moved from the old header block) ===== */
.nsh-bell{position:relative;background:none;border:none;cursor:pointer;padding:6px;color:#a1a1a1;transition:color .2s;display:flex;align-items:center}
.nsh-bell:hover{color:#e5e5e5}
.nsh-bell svg{width:20px;height:20px}
.nsh-bell-dot{display:none;position:absolute;top:4px;right:4px;width:8px;height:8px;background:#ef4444;border-radius:50%;border:2px solid #0a0a0a}
.nsh-bell.has-unread .nsh-bell-dot{display:block}
.nsh-bell-panel{display:none;position:absolute;top:100%;right:0;margin-top:8px;width:380px;max-height:480px;background:#1a1a1a;border:1px solid rgba(255,255,255,.1);border-radius:12px;box-shadow:0 12px 40px rgba(0,0,0,.5);z-index:9999;overflow:hidden}
.nsh-bell-panel.is-open{display:block}
.nsh-bell-panel-header{display:flex;align-items:center;justify-content:space-between;padding:14px 16px;border-bottom:1px solid rgba(255,255,255,.08)}
.nsh-bell-panel-title{font-size:14px;font-weight:600;color:#e5e5e5}
.nsh-bell-mark-all{background:none;border:none;font-size:12px;color:#fbbf24;cursor:pointer;padding:0}
.nsh-bell-mark-all:hover{text-decoration:underline}
.nsh-bell-panel-list{overflow-y:auto;max-height:420px;overscroll-behavior:contain}
.nsh-bell-empty{padding:40px 16px;text-align:center;color:#555;font-size:13px}
.nsh-notif-item{display:block;padding:12px 16px;border-bottom:1px solid rgba(255,255,255,.05);cursor:pointer;transition:background .15s;text-decoration:none}
.nsh-notif-item:hover{background:rgba(255,255,255,.03)}
.nsh-notif-item.is-unread{border-left:3px solid #fbbf24;padding-left:13px;background:rgba(251,191,36,.03)}
.nsh-notif-item.is-read{opacity:.65}
.nsh-notif-title{font-size:13px;font-weight:600;color:#e5e5e5;margin-bottom:3px;display:flex;align-items:center;gap:8px}
.nsh-notif-title .nsh-unread-dot{width:6px;height:6px;background:#fbbf24;border-radius:50%;flex-shrink:0}
.nsh-notif-body{font-size:12px;color:#888;line-height:1.4;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}
.nsh-notif-body a{color:#fbbf24}
.nsh-notif-meta{font-size:11px;color:#555;margin-top:4px}
.nsh-notif-link-btn{display:inline-block;margin-top:6px;font-size:12px;font-weight:600;color:#fbbf24;text-decoration:none}
.nsh-notif-link-btn:hover{text-decoration:underline}
.nsh-notif-dismiss{float:right;background:none;border:none;color:#555;font-size:16px;cursor:pointer;padding:0 0 0 8px;line-height:1}
.nsh-notif-dismiss:hover{color:#ef4444}
@media(max-width:480px){.nsh-bell-panel{width:calc(100vw - 24px);right:-60px}}
/* Company-pool (shared credits) indicator - overrides the pill's yellow/red svg color */
.nsh-credits .nsh-credits-org{display:inline-flex;align-items:center}
.nsh-credits .nsh-credits-org svg{width:13px;height:13px;color:#a1a1a1}
.nsh-credits.is-low .nsh-credits-org svg{color:#a1a1a1}
.nsh-m-credits-org{display:inline-flex;align-items:center;gap:5px;margin-left:6px;font-size:12px;color:#a1a1a1}
.nsh-m-credits-org svg{width:13px;height:13px;flex-shrink:0}
