/* Storyfellow — private project Note (floating scratchpad) */

.brand-bar-actions {
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
    gap: 0;
}

.brand-note {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--st-touch, 44px);
    height: var(--st-touch, 44px);
    margin: 0;
    padding: 0;
    border: none;
    border-radius: 0;
    background: none;
    background-color: transparent;
    background-image: none;
    box-shadow: none;
    color: #111;
    cursor: pointer;
    flex-shrink: 0;
    position: relative;
    -webkit-appearance: none;
    appearance: none;
    -webkit-tap-highlight-color: transparent;
    transition: none;
}

/* Naked glyph only — never a filled/rounded container in any state,
 * including while the popover textarea is focused (body:has). */
.brand-bar .brand-note:hover,
.brand-bar .brand-note:focus,
.brand-bar .brand-note:active,
.brand-bar .brand-note[aria-expanded="true"],
.brand-bar .brand-note.is-open,
body:has(.project-note-text:focus) .brand-note,
body:has(.project-note-text:focus-visible) .brand-note,
body:has(.project-note:not([hidden])) .brand-note {
    background: none !important;
    background-color: transparent !important;
    background-image: none !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    -webkit-tap-highlight-color: transparent;
}

.brand-bar .brand-note:focus,
.brand-bar .brand-note:active,
.brand-bar .brand-note[aria-expanded="true"],
.brand-bar .brand-note.is-open,
body:has(.project-note-text:focus) .brand-note,
body:has(.project-note-text:focus-visible) .brand-note,
body:has(.project-note:not([hidden])) .brand-note {
    outline: none !important;
}

/* Minimal keyboard-only cue when the control itself is focused — never a fill. */
.brand-bar .brand-note:focus-visible {
    outline: 1px solid rgba(17, 17, 17, 0.35);
    outline-offset: 4px;
    background: none !important;
    background-color: transparent !important;
    box-shadow: none !important;
}

.brand-note svg {
    display: block;
    width: 21px;
    height: 21px;
}

/* Restrained “has note” cue — quiet ink dot, not a badge. */
.brand-note.has-note::after {
    content: "";
    position: absolute;
    top: 10px;
    right: 10px;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.45;
    pointer-events: none;
}

/*
 * Host must NOT be a full-viewport layer over the header.
 * A full-screen focus-within ancestor over the Note icon was painting a
 * pale rounded square behind the glyph while the textarea was focused.
 * Outside-click is handled in JS on document; the panel positions itself.
 */
.project-note {
    position: fixed;
    top: 0;
    left: 0;
    width: 0;
    height: 0;
    overflow: visible;
    z-index: 1050;
    pointer-events: none;
    background: none !important;
    outline: none !important;
    box-shadow: none !important;
}

.project-note:focus,
.project-note:focus-within {
    background: none !important;
    outline: none !important;
    box-shadow: none !important;
}

.project-note[hidden] {
    display: none;
}

.project-note-panel {
    pointer-events: auto;
    position: fixed;
    width: min(320px, calc(100vw - 24px));
    min-height: 220px;
    max-height: min(420px, calc(100dvh - 88px));
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    padding: 28px 16px 16px;
    background: #fff;
    color: var(--st-ink, #111);
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.08);
    border-radius: 2px;
}

.project-note-close {
    position: absolute;
    top: 4px;
    right: 6px;
    width: 32px;
    height: 32px;
    margin: 0;
    padding: 0;
    border: none;
    background: transparent;
    color: var(--st-muted, #6b6560);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
}

.project-note-close:hover {
    color: var(--st-ink, #111);
}

.project-note-text {
    flex: 1 1 auto;
    width: 100%;
    min-height: 160px;
    margin: 0;
    padding: 0;
    border: none;
    border-radius: 0;
    resize: none;
    outline: none;
    box-shadow: none;
    background: transparent;
    background-color: transparent;
    color: inherit;
    font-family: var(--st-font-sans);
    font-size: 15px;
    line-height: 1.55;
    font-weight: 400;
    -webkit-appearance: none;
    appearance: none;
}

/*
 * Beat DesignSystem `textarea:focus-visible { box-shadow: 0 0 0 1px … }`
 * which draws an inner grey rectangle around the Note field when typing.
 */
textarea.project-note-text:focus,
textarea.project-note-text:focus-visible,
textarea.project-note-text:active {
    border: none;
    border-radius: 0;
    outline: none;
    outline-offset: 0;
    box-shadow: none;
    background: transparent;
    background-color: transparent;
    -webkit-appearance: none;
    appearance: none;
}

.project-note-text::placeholder {
    color: var(--st-muted, #6b6560);
    opacity: 0.85;
}

@media (max-width: 767px) {
    .project-note-panel {
        width: auto;
        min-height: 200px;
        max-height: min(50dvh, 360px);
        padding: 30px 14px 14px;
    }

    .project-note-text {
        font-size: 16px;
        min-height: 140px;
    }
}
