/* ============================================================
   NoteAll – Global Styles
   Dark mode · Glassmorphism · Inter font
   ============================================================ */

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --clr-bg: #0d0f1a;
    --clr-surface: rgba(255, 255, 255, 0.05);
    --clr-border: rgba(255, 255, 255, 0.10);
    --clr-text: #e8eaf6;
    --clr-muted: #9094b0;
    --clr-primary: #6c63ff;
    --clr-primary-h: #8c85ff;
    --clr-secondary: #00d4aa;
    --clr-danger: #ff6b6b;
    --clr-success: #00e5a0;
    --radius: 16px;
    --radius-sm: 10px;
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
    --transition: 0.25s cubic-bezier(.4, 0, .2, 1);
    font-family: 'Inter', system-ui, sans-serif;
}

html,
body {
    height: 100%;
}

body {
    background-color: var(--clr-bg);
    color: var(--clr-text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* ── Scrollbar ──────────────────────────────────────────────── */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--clr-border);
    border-radius: 99px;
}

/* ── Utility ────────────────────────────────────────────────── */
.hidden {
    display: none !important;
}

/* ── Animated background blobs ─────────────────────────────── */
.bg-blobs {
    position: fixed;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: 0;
}

.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.18;
    animation: blobFloat 12s ease-in-out infinite alternate;
}

.blob-1 {
    width: 520px;
    height: 520px;
    background: var(--clr-primary);
    top: -120px;
    left: -80px;
    animation-duration: 14s;
}

.blob-2 {
    width: 400px;
    height: 400px;
    background: var(--clr-secondary);
    bottom: -100px;
    right: -60px;
    animation-duration: 10s;
}

.blob-3 {
    width: 300px;
    height: 300px;
    background: #ff6baa;
    top: 50%;
    left: 45%;
    animation-duration: 16s;
}

@keyframes blobFloat {
    from {
        transform: translate(0, 0) scale(1);
    }

    to {
        transform: translate(30px, -40px) scale(1.08);
    }
}

/* ── Glass card ─────────────────────────────────────────────── */
.glass-card {
    background: var(--clr-surface);
    border: 1px solid var(--clr-border);
    border-radius: var(--radius);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: var(--shadow);
    padding: 2.5rem 2rem;
}

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.6rem;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: linear-gradient(135deg, var(--clr-primary), var(--clr-primary-h));
    color: #fff;
    box-shadow: 0 4px 20px rgba(108, 99, 255, 0.35);
}

.btn-primary:not(:disabled):hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 28px rgba(108, 99, 255, 0.50);
}

.btn-secondary {
    background: linear-gradient(135deg, var(--clr-secondary), #00b894);
    color: #001a14;
    font-weight: 700;
}

.btn-secondary:hover {
    transform: translateY(-2px);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--clr-border);
    color: var(--clr-muted);
}

.btn-outline:hover {
    border-color: var(--clr-primary);
    color: var(--clr-primary);
}

.btn-icon {
    background: var(--clr-surface);
    border: 1px solid var(--clr-border);
    color: var(--clr-text);
    padding: 0.55rem 1rem;
    font-size: 0.85rem;
}

.btn-icon:hover {
    background: rgba(108, 99, 255, 0.15);
    border-color: var(--clr-primary);
}

.btn-spinner {
    animation: spin 1s linear infinite;
    display: inline-block;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ── Bootstrap Icons Adjustment ── */
.btn i,
.logo i,
.logo-small i {
    font-size: 1.1em;
    vertical-align: middle;
}

.btn i[class^="bi-"]+span,
.btn i[class^="bi-"]+label,
.btn i[class^="bi-"] {
    margin-right: 0.25rem;
}

/* Specifically for buttons where text follows the icon directly */
.btn i+span,
.btn i+text,
.btn-icon i {
    margin-right: 0.4rem;
}

/* Fix for buttons with only icon + text nodes */
.btn i:only-child {
    margin-right: 0;
}

/* ── Inputs ─────────────────────────────────────────────────── */
input[type="text"] {
    width: 100%;
    padding: 0.75rem 1rem;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--clr-border);
    border-radius: var(--radius-sm);
    color: var(--clr-text);
    font-family: inherit;
    font-size: 1rem;
    outline: none;
    transition: var(--transition);
}

input[type="text"]::placeholder {
    color: var(--clr-muted);
}

input[type="text"]:focus {
    border-color: var(--clr-primary);
    box-shadow: 0 0 0 3px rgba(108, 99, 255, 0.20);
}

.input-group {
    display: flex;
    gap: 0.5rem;
    align-items: stretch;
    margin-top: 1rem;
}

.glass-card .input-group input {
    flex: 1;
    min-width: 0;
    /* allow flex shrink past intrinsic width */
    width: auto;
    /* override global width:100% so flex:1 takes over */
    margin-top: 0;
}

.glass-card .input-group .btn {
    width: auto;
    /* override .glass-card .btn{width:100%} */
    flex-shrink: 0;
}

/* ── Error / success messages ───────────────────────────────── */
.error-msg {
    color: var(--clr-danger);
    font-size: 0.85rem;
    margin-top: 0.5rem;
}

.copy-feedback {
    color: var(--clr-success);
    font-size: 0.9rem;
    margin-top: 0.5rem;
    text-align: center;
}

/* ── Shake animation ────────────────────────────────────────── */
@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    20%,
    60% {
        transform: translateX(-6px);
    }

    40%,
    80% {
        transform: translateX(6px);
    }
}

.shake {
    animation: shake 0.5s ease;
}


/* ============================================================
   LANDING PAGE
   ============================================================ */

.landing-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.landing-container {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 900px;
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3rem;
}

/* Header */
.landing-header {
    text-align: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    justify-content: center;
    margin-bottom: 0.75rem;
}

.logo-icon {
    font-size: 2.8rem;
}

.logo-text {
    font-size: 2.8rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #fff 40%, var(--clr-primary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.tagline {
    font-size: 1.15rem;
    color: var(--clr-muted);
}

.tagline strong {
    color: var(--clr-secondary);
}

/* Cards grid */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    width: 100%;
}

.glass-card {
    text-align: center;
    position: relative;
    overflow: hidden;
}

.glass-card::before {
    content: '';
    position: absolute;
    top: -60px;
    right: -60px;
    width: 160px;
    height: 160px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(108, 99, 255, 0.25), transparent 70%);
    pointer-events: none;
}

.card-icon {
    font-size: 2.5rem;
    margin-bottom: 1rem;
}

.glass-card h2 {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.glass-card p {
    color: var(--clr-muted);
    font-size: 0.95rem;
    margin-bottom: 1.5rem;
    line-height: 1.55;
}

.glass-card .btn {
    width: 100%;
}

/* Join code input */
#join-code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.4rem;
    text-align: center;
    letter-spacing: 0.25em;
    text-transform: uppercase;
}

/* Footer */
.landing-footer {
    color: var(--clr-muted);
    font-size: 0.85rem;
    text-align: center;
}

/* Note counter balloon */
.note-counter-balloon {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    background: rgba(13, 15, 26, 0.60);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--clr-border);
    border-radius: 99px;
    padding: 0.5rem 1.25rem;
    color: var(--clr-text);
    font-size: 0.85rem;
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    animation: slideInRight 0.6s cubic-bezier(.4, 0, .2, 1) forwards;
}

.light-theme .note-counter-balloon {
    background: rgba(255, 255, 255, 0.7);
}

@keyframes slideInRight {
    from {
        transform: translateX(100px);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.pulse-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--clr-success);
    box-shadow: 0 0 6px var(--clr-success);
    animation: pulse 1.5s infinite;
}


/* ============================================================
   NOTE PAGE
   ============================================================ */

.note-body {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: auto;
}

/* Header */
.note-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.65rem 1.25rem;
    background: rgba(13, 15, 26, 0.80);
    border-bottom: 1px solid var(--clr-border);
    backdrop-filter: blur(16px);
    z-index: 10;
    position: relative;
    gap: 1rem;
    flex-wrap: wrap;
}

.note-header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.note-header-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.logo-small {
    font-size: 1.05rem;
    font-weight: 700;
    text-decoration: none;
    color: var(--clr-text);
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.logo-small:hover {
    color: var(--clr-primary);
}

.note-code-tag {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.95rem;
    letter-spacing: 0.15em;
    font-weight: 600;
    background: rgba(108, 99, 255, 0.18);
    border: 1px solid rgba(108, 99, 255, 0.35);
    padding: 0.25rem 0.75rem;
    border-radius: 99px;
    color: var(--clr-primary-h);
}

/* Participants */
.participants-bar {
    display: flex;
    gap: -0.5rem;
    align-items: center;
}

.avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
    color: #fff;
    border: 2px solid var(--clr-bg);
    margin-left: -6px;
    cursor: default;
    transition: var(--transition);
}

.avatar:first-child {
    margin-left: 0;
}

.avatar:hover {
    transform: translateY(-3px) scale(1.1);
    z-index: 2;
}

/* Sync indicator */
.sync-indicator {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8rem;
    color: var(--clr-muted);
    padding: 0.3rem 0.75rem;
    border-radius: 99px;
    background: rgba(255, 255, 255, 0.04);
    transition: var(--transition);
}

.sync-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--clr-muted);
    transition: var(--transition);
    flex-shrink: 0;
}

.sync-indicator.synced .sync-dot {
    background: var(--clr-success);
    box-shadow: 0 0 6px var(--clr-success);
}

.sync-indicator.syncing .sync-dot {
    background: #ffd060;
    animation: pulse 1s infinite;
}

.sync-indicator.pending .sync-dot {
    background: #ffa040;
}

.sync-indicator.error .sync-dot {
    background: var(--clr-danger);
}

.sync-indicator.synced {
    color: var(--clr-success);
}

.sync-indicator.error {
    color: var(--clr-danger);
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.3;
    }
}

.sync-indicator.flash {
    animation: flashAnim 0.6s ease;
}

@keyframes flashAnim {
    0% {
        background: rgba(0, 229, 160, 0.25);
    }

    100% {
        background: rgba(255, 255, 255, 0.04);
    }
}

/* Editor */
.editor-wrapper {
    flex: 1;
    display: flex;
    overflow: hidden;
    position: relative;
    background: var(--clr-bg);
}

/* Left: Text Editor Column */
.text-column {
    width: 50%;
    flex: 0 0 50%;
    display: flex;
    flex-direction: column;
    position: relative;
    border-right: 1px solid var(--clr-border);
}

/* Right: Drawing Column */
.drawing-column {
    width: 50%;
    flex: 0 0 50%;
    display: flex;
    flex-direction: column;
    position: relative;
    background: rgba(0, 0, 0, 0.2);
}

.note-textarea {
    flex: 1;
    resize: none;
    border: none;
    outline: none;
    background: transparent;
    color: var(--clr-text);
    font-family: 'JetBrains Mono', 'Courier New', monospace;
    font-size: 1rem;
    line-height: 1.8;
    padding: 2rem 2rem 2rem 4.5rem;
    /* left padding = room for gutter */
    caret-color: var(--clr-primary);
}

.note-textarea::placeholder {
    color: rgba(144, 148, 176, 0.45);
}

.note-textarea:disabled {
    cursor: wait;
}

/* ── Canvas Styling ── */
.canvas-container {
    flex: 1;
    position: relative;
    cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' fill='%236c63ff' class='bi bi-pencil-fill' viewBox='0 0 16 16'%3E%3Cpath d='M12.854.146a.5.5 0 0 0-.707 0L10.5 1.793 14.207 5.5l1.647-1.646a.5.5 0 0 0 0-.708zm.646 6.061L9.793 2.5 3.293 9H3.5a.5.5 0 0 1 .5.5v.5h.5a.5.5 0 0 1 .5.5v.5h.5a.5.5 0 0 1 .5.5v.5h.5a.5.5 0 0 1 .5.5v.207zm-7.468 7.468A.5.5 0 0 1 6 13.5V13h-.5a.5.5 0 0 1-.5-.5V12h-.5a.5.5 0 0 1-.5-.5V11h-.5a.5.5 0 0 1-.5-.5V10h-.5a.5.5 0 0 1-.175-.032l-.179.178a.5.5 0 0 0-.11.168l-2 5a.5.5 0 0 0 .65.65l5-2a.5.5 0 0 0 .168-.11z'/%3E%3C/svg%3E") 0 16, crosshair;
    overflow: auto;
    /* Enable scroll */
    background: rgba(0, 0, 0, 0.1);
}

/* Custom scrollbar for the canvas area */
.canvas-container::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.canvas-container::-webkit-scrollbar-thumb {
    background: var(--clr-border);
    border-radius: 4px;
}

#drawing-canvas {
    display: block;
    background-image:
        linear-gradient(rgba(255, 255, 255, .03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, .03) 1px, transparent 1px);
    background-size: 50px 50px;
}

/* ── Drawing Toolbar ── */
.drawing-toolbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.6rem 1rem;
    background: rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid var(--clr-border);
    backdrop-filter: blur(8px);
    z-index: 5;
}

.btn-tool {
    padding: 0.45rem 0.6rem;
}

.btn-tool.active {
    background: var(--clr-primary);
    color: #fff;
    border-color: var(--clr-primary);
}

.tool-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.tool-label {
    font-size: 0.75rem;
    color: var(--clr-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.color-picker {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    border: 1px solid var(--clr-border);
    cursor: pointer;
    padding: 0;
    background: none;
}

.brush-size {
    width: 60px;
    height: 4px;
    cursor: pointer;
    accent-color: var(--clr-primary);
}

.editor-status-bar {
    display: flex;
    gap: 1.5rem;
    align-items: center;
    padding: 0.4rem 1.5rem;
    /* Reduced padding from 4.5rem to be more standard */
    background: rgba(13, 15, 26, 0.70);
    border-top: 1px solid var(--clr-border);
    font-size: 0.78rem;
    color: var(--clr-muted);
    backdrop-filter: blur(8px);
}

/* Specific padding for text side to align with gutter */
.text-column .editor-status-bar {
    padding-left: 4.5rem;
}

/* ── Cursor gutter ────────────────────────────────────────── */
.editor-gutter {
    position: absolute;
    left: 0;
    top: 0;
    width: 4rem;
    /* matches left padding of textarea */
    bottom: 40px;
    /* clear status bar */
    overflow: hidden;
    pointer-events: none;
    z-index: 3;
}

.cursor-marker {
    position: absolute;
    left: 0.35rem;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0 0.3rem;
    border-radius: 6px;
    max-width: 3.2rem;
    /* collapsed: shows initial only */
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.40);
    opacity: 0.92;
    transition: max-width 0.25s ease, opacity 0.2s ease;
    cursor: default;
    pointer-events: auto;
    /* allow hover tooltip */
}

.cursor-marker:hover {
    max-width: 9rem;
    /* expand to show name */
    opacity: 1;
}

.cursor-marker.is-self {
    opacity: 0.45;
}

.cursor-marker.is-self:hover {
    opacity: 0.75;
}

.cursor-initial {
    flex-shrink: 0;
    width: 1.6rem;
    height: 1.6rem;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.72rem;
    font-weight: 800;
    color: #fff;
    background: rgba(0, 0, 0, 0.20);
    /* subtle inner shadow */
}

.cursor-label {
    font-family: 'Inter', sans-serif;
    font-size: 0.72rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.92);
    white-space: nowrap;
    letter-spacing: 0.02em;
}

/* ── Modal ──────────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    background: rgba(6, 8, 20, 0.75);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.modal {
    max-width: 440px;
    width: 100%;
    text-align: center;
    animation: slideUp 0.35s cubic-bezier(.4, 0, .2, 1);
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-icon {
    font-size: 2.8rem;
    margin-bottom: 0.75rem;
}

.modal h2 {
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.modal p {
    color: var(--clr-muted);
    margin-bottom: 1.25rem;
    font-size: 0.95rem;
}

#input-name {
    margin-bottom: 0.5rem;
    font-size: 1.05rem;
}

#btn-enter {
    width: 100%;
    margin-top: 1rem;
}

/* Share modal specifics */
.share-code-display {
    font-family: 'JetBrains Mono', monospace;
    font-size: 2.5rem;
    font-weight: 700;
    letter-spacing: 0.3em;
    color: var(--clr-primary-h);
    background: rgba(108, 99, 255, 0.10);
    border: 1px solid rgba(108, 99, 255, 0.25);
    border-radius: var(--radius-sm);
    padding: 1rem;
    margin-bottom: 1.25rem;
}

.share-url-group input {
    font-size: 0.85rem;
    letter-spacing: 0;
    color: var(--clr-muted);
}

#btn-close-share {
    width: 100%;
    margin-top: 0.75rem;
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 900px) {
    .note-body {
        overflow: auto;
    }

    .editor-wrapper {
        flex-direction: column;
        overflow: visible;
    }

    .text-column {
        border-right: none;
        border-bottom: 1px solid var(--clr-border);
        min-height: 55vh;
        height: auto;
        flex: 0 0 auto;
        width: 100%;
    }

    .drawing-column {
        min-height: 55vh;
        height: auto;
        flex: 0 0 auto;
        width: 100%;
    }

    .logo-text {
        font-size: 2rem;
    }

    .tagline {
        font-size: 1rem;
    }

    .glass-card {
        padding: 1.75rem 1.25rem;
    }

    .note-textarea {
        padding: 1.25rem 1.5rem;
        font-size: 0.95rem;
    }

    .text-column .editor-status-bar {
        padding-left: 1.5rem;
    }

    .editor-status-bar {
        padding: 0.35rem 1rem;
        flex-wrap: wrap;
    }

    .note-header {
        padding: 0.5rem 0.85rem;
    }
}

/* ============================================================
   LIGHT THEME
   ============================================================ */
.light-theme {
    --clr-bg: #f0f2f5;
    --clr-surface: rgba(255, 255, 255, 0.85);
    --clr-border: rgba(0, 0, 0, 0.1);
    --clr-text: #1a1d2d;
    --clr-muted: #6b7280;
    --clr-primary: #5a52e0;
    --clr-primary-h: #4b40db;
    --clr-secondary: #00a382;
}

/* Override hard-coded dark opacity backgrounds for light theme */
.light-theme .note-header {
    background: rgba(255, 255, 255, 0.90);
}

.light-theme .editor-status-bar {
    background: rgba(255, 255, 255, 0.85);
}

.light-theme .modal-overlay {
    background: rgba(0, 0, 0, 0.25);
}

.light-theme input[type="text"] {
    background: rgba(0, 0, 0, 0.03);
}

.light-theme .sync-indicator {
    background: rgba(0, 0, 0, 0.05);
}

.light-theme .note-code-tag {
    background: rgba(90, 82, 224, 0.12);
}

.light-theme .btn-icon {
    background: rgba(0, 0, 0, 0.03);
}

.light-theme .btn-icon:hover {
    background: rgba(90, 82, 224, 0.10);
}

.light-theme .logo-text {
    background: linear-gradient(135deg, #1a1d2d 40%, var(--clr-primary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}