/* ================================================================
   ByteSide.io — Sticky Notes
   ----------------------------------------------------------------
   Desktop-resident notes (NOT a window app). Plain-text markdown
   source via contenteditable=plaintext-only; rendered HTML in view-
   mode via window.ByteSideStickiesMD. Dark glass-blur surface +
   color-tinted left stripe + accent — voidcore-aligned aesthetic
   (matches .window glass + brand orange focus glow).
   ================================================================ */

.sticky-notes-host {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 5;
}

.sticky-note {
    --note-tint: var(--byte-sticky-yellow);

    position: absolute;
    pointer-events: auto;
    width: 240px;
    height: 220px;
    min-width: 180px;
    min-height: 140px;
    max-width: 480px;
    max-height: 480px;
    display: flex;
    flex-direction: column;
    border-radius: 6px;
    background: var(--byte-surface-glass);
    backdrop-filter: blur(20px) saturate(1.2);
    -webkit-backdrop-filter: blur(20px) saturate(1.2);
    border: 1px solid var(--byte-border);
    color: var(--byte-text);
    font-family: var(--byte-font-mono);
    box-shadow: var(--byte-shadow-window, 0 8px 24px rgba(0, 0, 0, 0.35));
    transition: box-shadow 200ms ease, border-color 200ms ease, transform 200ms ease;
    overflow: hidden;
}

.sticky-note[data-color="yellow"] { --note-tint: var(--byte-sticky-yellow); }
.sticky-note[data-color="green"]  { --note-tint: var(--byte-sticky-green); }
.sticky-note[data-color="blue"]   { --note-tint: var(--byte-sticky-blue); }
.sticky-note[data-color="pink"]   { --note-tint: var(--byte-sticky-pink); }

/* Color-stripe on left edge — note's tint identifier */
.sticky-note::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 3px;
    background: var(--note-tint);
    z-index: 1;
    pointer-events: none;
}

.sticky-note.is-focused {
    z-index: 9;
    border-color: var(--byte-border-warm, rgba(253, 125, 0, 0.20));
    box-shadow:
        var(--byte-shadow-window-focus, 0 12px 36px rgba(0, 0, 0, 0.55)),
        0 0 0 1px rgba(253, 125, 0, 0.18);
}

.sticky-note.is-editing {
    border-color: var(--byte-primary-soft, rgba(253, 125, 0, 0.30));
}

.sticky-note.is-dragging {
    transition: none;
    cursor: grabbing;
    box-shadow:
        0 4px 12px rgba(0, 0, 0, 0.40),
        0 16px 48px rgba(0, 0, 0, 0.60);
}

/* ============================================================
   Top bar — drag handle + color-cycle + close
   ============================================================ */
.sticky-note__bar {
    flex: 0 0 28px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    padding: 4px 6px 4px 10px;     /* +4px left clears the color-stripe */
    background: linear-gradient(
        to bottom,
        color-mix(in srgb, var(--note-tint) 18%, transparent) 0%,
        transparent 100%
    );
    border-bottom: 1px solid var(--byte-border);
    cursor: grab;
    user-select: none;
}
.sticky-note__bar:active { cursor: grabbing; }

.sticky-note__color-btn,
.sticky-note__close-btn {
    width: 22px;
    height: 22px;
    padding: 0;
    border: 1px solid var(--byte-border);
    border-radius: 4px;
    background: transparent;
    color: var(--byte-text-muted);
    font: inherit;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 120ms ease, border-color 120ms ease, color 120ms ease, transform 120ms ease;
}
.sticky-note__color-btn i,
.sticky-note__close-btn i {
    font-size: 13px;
    pointer-events: none;
}
.sticky-note__color-btn:hover {
    color: var(--note-tint);
    border-color: var(--note-tint);
    background: color-mix(in srgb, var(--note-tint) 10%, transparent);
}
.sticky-note__close-btn:hover {
    color: var(--byte-danger);
    border-color: var(--byte-danger);
    background: color-mix(in srgb, var(--byte-danger) 12%, transparent);
}
.sticky-note__color-btn:active,
.sticky-note__close-btn:active { transform: scale(0.92); }

/* Two-click delete confirm — first click sets .is-confirming */
.sticky-note__close-btn.is-confirming {
    background: var(--byte-danger);
    color: #fff;
    border-color: var(--byte-danger);
}
.sticky-note__close-btn.is-confirming::after {
    content: '?';
    font-weight: 700;
    margin-left: 1px;
    font-size: 11px;
}

/* ============================================================
   Body — contenteditable; raw markdown in edit mode, rendered HTML in view
   ============================================================ */
.sticky-note__body {
    flex: 1 1 auto;
    padding: 10px 12px 12px;
    overflow-y: auto;
    overflow-x: hidden;
    font-family: var(--byte-font-mono);
    font-size: 13px;
    line-height: 1.55;
    color: var(--byte-text);
    outline: none;
    cursor: text;
    -webkit-user-select: text;
    user-select: text;
    word-wrap: break-word;
}
.sticky-note__body:empty::before {
    content: attr(data-placeholder);
    color: var(--byte-text-subtle);
    font-style: italic;
    pointer-events: none;
}

/* Edit mode — slightly more prominent monospace look (raw source) */
.sticky-note.is-editing .sticky-note__body {
    white-space: pre-wrap;
    color: var(--byte-text);
    caret-color: var(--byte-primary);
}

/* Body scrollbar — minimal, voidcore-tinted */
.sticky-note__body::-webkit-scrollbar { width: 6px; }
.sticky-note__body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.10);
    border-radius: 3px;
}
.sticky-note__body::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.18);
}
.sticky-note__body::-webkit-scrollbar-track { background: transparent; }

/* ============================================================
   Markdown-rendered elements (view mode only)
   ============================================================ */
.sticky-note__body > h1,
.sticky-note__body > h2,
.sticky-note__body > h3 {
    font-family: var(--byte-font-mono);
    font-weight: 700;
    letter-spacing: -0.01em;
    margin: 0 0 6px;
}
.sticky-note__body > h1 {
    font-size: 16px;
    color: var(--note-tint);
    border-bottom: 1px solid var(--byte-border);
    padding-bottom: 4px;
}
.sticky-note__body > h2 {
    font-size: 14px;
    color: var(--byte-text);
}
.sticky-note__body > h3 {
    font-size: 13px;
    color: var(--byte-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.sticky-note__body > h2:not(:first-child),
.sticky-note__body > h3:not(:first-child) { margin-top: 10px; }

.sticky-note__body p {
    margin: 0 0 6px;
}
.sticky-note__body p:last-child { margin-bottom: 0; }

.sticky-note__body strong {
    color: var(--byte-text);
    font-weight: 700;
}
.sticky-note__body em {
    color: var(--byte-text);
    font-style: italic;
}
.sticky-note__body code {
    font-family: var(--byte-font-code);
    background: rgba(255, 255, 255, 0.06);
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 12px;
    color: var(--byte-code-blue);
    border: 1px solid var(--byte-border);
}
.sticky-note__body pre {
    background: rgba(0, 0, 0, 0.30);
    padding: 8px 10px;
    border-radius: 4px;
    border: 1px solid var(--byte-border);
    margin: 6px 0;
    overflow-x: auto;
}
.sticky-note__body pre code {
    background: transparent;
    border: none;
    padding: 0;
    color: var(--byte-text);
    font-size: 12px;
}
.sticky-note__body a {
    color: var(--byte-primary);
    text-decoration: none;
    border-bottom: 1px dashed var(--byte-primary);
    transition: border-bottom-style 120ms ease;
}
.sticky-note__body a:hover {
    border-bottom-style: solid;
}
.sticky-note__body ul,
.sticky-note__body ol {
    margin: 4px 0 6px;
    padding-left: 22px;
}
.sticky-note__body ul li::marker { color: var(--note-tint); }
.sticky-note__body ol li::marker { color: var(--byte-text-muted); }
.sticky-note__body li { margin: 1px 0; }
.sticky-note__body blockquote {
    border-left: 2px solid var(--note-tint);
    padding: 2px 0 2px 8px;
    margin: 6px 0;
    color: var(--byte-text-muted);
    font-style: italic;
}

/* ============================================================
   Resize handle — bottom-right corner
   ============================================================ */
.sticky-note__resize {
    position: absolute;
    right: 2px;
    bottom: 2px;
    width: 12px;
    height: 12px;
    cursor: nwse-resize;
    z-index: 2;
    background:
        linear-gradient(135deg,
            transparent 0%,
            transparent 50%,
            rgba(255, 255, 255, 0.30) 50%,
            rgba(255, 255, 255, 0.30) 60%,
            transparent 60%,
            transparent 80%,
            rgba(255, 255, 255, 0.30) 80%,
            rgba(255, 255, 255, 0.30) 90%,
            transparent 90%);
    border-radius: 0 0 5px 0;
    opacity: 0.5;
    transition: opacity 120ms ease;
}
.sticky-note:hover .sticky-note__resize,
.sticky-note.is-focused .sticky-note__resize { opacity: 1; }

/* Spawn animation — note fades + scales in when newly created.
   Voidcore-flavor: snappy ease-out, no bounce. ~180ms. */
@keyframes sticky-note-spawn {
    from {
        opacity: 0;
        transform: scale(0.94) translateY(-4px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}
.sticky-note.is-spawning {
    animation: sticky-note-spawn 180ms cubic-bezier(0.2, 0.8, 0.4, 1.0);
    transform-origin: center center;
}

/* Reduced-motion users: kill all transitions/animations. The .is-focused
   visual change is still conveyed via border-color + box-shadow (instant). */
@media (prefers-reduced-motion: reduce) {
    .sticky-note,
    .sticky-note__color-btn,
    .sticky-note__close-btn,
    .sticky-note__body a,
    .sticky-note__resize {
        transition: none !important;
    }
    .sticky-note.is-spawning { animation: none; }
    .sticky-note.is-dragging { transform: none; }
}
