/* ==========================================
   Canvas Onboarding Instruction Tips
   ========================================== */
.canvas-onboarding-tips {
    position: fixed;
    top: var(--header-height) !important;
    right: -460px; /* hidden off-screen */
    bottom: 0;
    left: auto;
    width: 440px;
    max-width: 90vw;
    /* dvh (dynamic viewport height) fixes iPad/iOS Safari landscape, where 100vh is taller than
       the visible area (browser chrome) so the drawer bottom + its scroll ran off-screen. vh first
       as a fallback for browsers without dvh. */
    height: calc(100vh - var(--header-height)) !important;
    height: calc(100dvh - var(--header-height)) !important;
    max-height: calc(100vh - var(--header-height)) !important;
    max-height: calc(100dvh - var(--header-height)) !important;
    z-index: 1500;
    box-sizing: border-box !important;
    overflow: hidden !important;
    background: rgba(8, 13, 22, 0.88);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: none;
    border-left: 1px solid var(--border-glass);
    border-radius: 0; /* clean side strip */
    padding: 24px;
    font-size: 0.85rem !important;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    pointer-events: auto;
    box-shadow: -15px 0 45px rgba(0, 0, 0, 0.6), inset 1px 0 0 rgba(255, 255, 255, 0.06);
    font-family: var(--font-body);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    opacity: 0;
    user-select: text !important;
    -webkit-user-select: text !important;
}

/* Open state */
.canvas-onboarding-tips.open {
    transform: translateX(-460px);
    opacity: 1;
}

.tips-header {
    margin-bottom: 8px;
    padding-right: 15px; /* space for close button */
}

.tips-header h2 {
    margin: 0 0 6px 0;
    font-family: var(--font-heading);
    font-size: 1.1rem !important;
    font-weight: 700;
    letter-spacing: 1px;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.tips-header p {
    margin: 0;
    font-size: 0.8rem !important;
    line-height: 1.5;
    color: var(--text-muted);
}

.tips-content {
    overflow-y: auto !important;
    min-height: 0 !important;
    box-sizing: border-box !important;
    padding-right: 6px;
    padding-bottom: calc(90px + env(safe-area-inset-bottom)) !important; /* Prevent overlap with floating bottom toolbar (also grown by the safe-area inset) */
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Accordion Styling */
.tips-group {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-glass);
    border-radius: 10px;
    overflow: hidden;
    transition: background 0.3s ease;
}

.tips-group:hover {
    background: rgba(255, 255, 255, 0.04);
}

.tips-group-summary {
    padding: 10px 14px;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
    user-select: none !important;
    -webkit-user-select: none !important;
    outline: none;
    font-size: 0.85rem !important;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.tips-group-summary:focus-visible {
    outline: none;
    box-shadow: inset 0 0 0 2px var(--border-focus);
}

.tips-group-summary::-webkit-details-marker {
    display: none;
}

/* Custom indicator chevron style */
.tips-group-summary::after {
    content: '▼';
    font-size: 0.65rem;
    color: var(--text-muted);
    transition: transform 0.2s ease;
}

.tips-group[open] .tips-group-summary::after {
    transform: rotate(180deg);
    color: var(--accent-aurora);
}

.tips-group-content {
    padding: 12px 14px;
    border-top: 1px solid var(--border-glass);
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: rgba(0, 0, 0, 0.15);
}

.tips-explanation {
    margin: 0 0 6px 0;
    font-size: 0.8rem !important;
    color: var(--text-muted);
    line-height: 1.4;
}

.tip-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    line-height: 1.5;
    font-size: 0.8rem !important;
}

.tip-item strong {
    color: var(--text-primary);
    font-weight: 600;
    font-size: 0.85rem !important;
}

.tip-item span {
    font-size: 0.8rem !important;
}

/* ==========================================
   Help Center — redesigned content (class-based, one type scale)
   Scale: title 0.78 / body 0.72 / small 0.68 / eyebrow 0.66-0.7 uppercase
   ========================================== */

/* Segmented tab bar (was inline-styled) */
.help-tabs {
    display: flex;
    gap: 2px;
    padding: 3px;
    margin-bottom: 14px;
    background: rgba(0, 0, 0, 0.22);
    border: 1px solid var(--border-glass);
    border-radius: 10px;
    flex-shrink: 0;
}
.help-tab-btn {
    flex: 1;
    padding: 7px 4px;
    background: transparent;
    border: none;
    border-radius: 7px;
    color: var(--text-secondary);
    font-family: var(--font-heading);
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.3px;
    cursor: pointer;
    transition: color 0.15s ease, background 0.15s ease;
    box-shadow: none !important;
    transform: none !important;
    height: auto;
}
.help-tab-btn:hover { color: var(--text-primary); background: rgba(255, 255, 255, 0.04); }
.help-tab-btn.active {
    color: var(--accent-aurora);
    background: rgba(var(--accent-aurora-rgb), 0.12);
}

/* Tab panels: shown via .active instead of inline display */
.help-content-section { display: none; flex-direction: column; gap: 14px; }
.help-content-section.active { display: flex; }

/* Intro card */
.help-intro {
    display: flex;
    flex-direction: column;
    gap: 7px;
    padding: 12px 14px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-glass);
    border-left: 2px solid var(--accent-aurora);
    border-radius: 10px;
}
.help-intro h4 { margin: 0; font-family: var(--font-heading); font-size: 0.78rem; font-weight: 700; color: var(--text-primary); }
.help-intro p { margin: 0; font-size: 0.72rem; line-height: 1.55; color: var(--text-secondary); }

/* Subtle note callout (e.g. "blank frame?") */
.help-note {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    padding: 9px 11px;
    font-size: 0.68rem;
    line-height: 1.5;
    color: var(--text-muted);
    background: rgba(var(--accent-aurora-violet-rgb), 0.06);
    border: 1px solid rgba(var(--accent-aurora-violet-rgb), 0.2);
    border-radius: 8px;
}
.help-note svg { flex-shrink: 0; margin-top: 1px; color: var(--accent-aurora-violet); }
.help-note strong { color: var(--text-secondary); }

/* Eyebrow section label */
.help-eyebrow {
    margin: 2px 0 -2px 0;
    font-family: var(--font-heading);
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.7px;
    text-transform: uppercase;
    color: var(--text-muted);
}

/* Numbered steps */
.help-steps { display: flex; flex-direction: column; gap: 13px; }
.help-step { display: flex; gap: 11px; align-items: flex-start; }
.help-step-num {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-family: var(--font-heading);
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--accent-aurora);
    background: rgba(var(--accent-aurora-rgb), 0.12);
    border: 1px solid rgba(var(--accent-aurora-rgb), 0.35);
}
.help-step-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.help-step-body strong { font-size: 0.73rem; font-weight: 600; color: var(--text-primary); }
.help-step-body p { margin: 0; font-size: 0.68rem; line-height: 1.5; color: var(--text-secondary); }

/* Keyboard shortcuts */
.help-shortcuts { width: 100%; border-collapse: collapse; }
.help-shortcuts th {
    padding: 0 0 7px 0;
    text-align: left;
    font-family: var(--font-heading);
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-glass);
}
.help-shortcuts td {
    padding: 7px 0;
    font-size: 0.7rem;
    color: var(--text-secondary);
    vertical-align: middle;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.help-shortcuts tr:last-child td { border-bottom: none; }
.help-shortcuts td:first-child { width: 36%; white-space: nowrap; }

/* Keycap */
.help-kbd {
    display: inline-block;
    padding: 1px 6px;
    font-family: var(--font-mono);
    font-size: 0.64rem;
    font-weight: 700;
    line-height: 1.5;
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--border-glass);
    border-bottom-width: 2px;
    border-radius: 5px;
}

/* Feedback form */
.help-form-intro { margin: 0; font-size: 0.7rem; line-height: 1.5; color: var(--text-secondary); }
.help-field { display: flex; flex-direction: column; gap: 5px; }
.help-field > label {
    font-family: var(--font-heading);
    font-size: 0.64rem;
    font-weight: 700;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    color: var(--text-muted);
}
.help-input {
    width: 100%;
    box-sizing: border-box;
    padding: 8px 10px;
    font-family: var(--font-body);
    font-size: 0.74rem;
    color: var(--text-primary);
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border-glass);
    border-radius: 8px;
    outline: none;
    transition: border-color 0.15s ease;
}
.help-input:focus-visible { border-color: rgba(var(--accent-aurora-rgb), 0.5); }
textarea.help-input { resize: vertical; min-height: 96px; line-height: 1.5; }

.close-tips-btn {
    position: absolute;
    top: 16px;
    right: 16px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    box-shadow: none;
    transition: color 0.2s;
}

.close-tips-btn:hover {
    color: var(--accent-aurora);
    transform: none;
    box-shadow: none;
}

/* Disable pointer events on iframes when Space is held to allow click-through dragging */
body.space-held iframe {
    pointer-events: none !important;
}

/* Responsive Help Button in Header */
.help-btn-mobile {
    display: none;
}

/* Glassmorphic Canvas Toolbar */
.canvas-toolbar {
    position: fixed;
    bottom: calc(25px + env(safe-area-inset-bottom));
    left: 50%;
    transform: translateX(-50%);
    z-index: 120; /* Keep it above everything else, including warning banner */
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-glass);
    padding: 6px 12px;
    border-radius: 9999px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.1);
    user-select: none;
    transition: border-color 0.3s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.canvas-toolbar,
.canvas-toolbar * {
    pointer-events: auto !important;
}

/* Premium Custom CSS Tooltips */
[data-tooltip] {
    position: relative;
}

[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 10px);
    left: 50%;
    transform: translateX(-50%) translateY(5px);
    background: rgba(8, 13, 22, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-glass);
    /* Always a dark glass chip regardless of app theme, so its text stays fixed-light rather than
       following --text-primary (which Nordic Light flips to a dark color for the main canvas). */
    color: #f8fafc;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 0.68rem;
    font-family: var(--font-body);
    font-weight: 500;
    white-space: nowrap;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s cubic-bezier(0.16, 1, 0.3, 1), transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    transition-delay: 0s;
    z-index: 1000;
}

/* First tooltip in a hover/focus sequence waits briefly before showing, so just
   passing over the toolbar doesn't flash every label; once one is open,
   .tooltip-instant (toggled in core.js) skips the delay for adjacent ones. */
[data-tooltip]:hover::after,
[data-tooltip]:focus-visible::after {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
    transition-delay: 0.4s;
}

body.tooltip-instant [data-tooltip]:hover::after,
body.tooltip-instant [data-tooltip]:focus-visible::after {
    transition-delay: 0s;
}

[data-tooltip]::before {
    content: '';
    position: absolute;
    bottom: calc(100% + 5px);
    left: 50%;
    transform: translateX(-50%) translateY(5px);
    border-width: 5px;
    border-style: solid;
    border-color: rgba(8, 13, 22, 0.95) transparent transparent transparent;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s cubic-bezier(0.16, 1, 0.3, 1), transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    transition-delay: 0s;
    z-index: 1000;
}

[data-tooltip]:hover::before,
[data-tooltip]:focus-visible::before {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
    transition-delay: 0.4s;
}

body.tooltip-instant [data-tooltip]:hover::before,
body.tooltip-instant [data-tooltip]:focus-visible::before {
    transition-delay: 0s;
}

/* Top bar tooltips direction override (go downwards to prevent screen cutoff) */
.top-bar [data-tooltip]::after {
    bottom: auto;
    top: calc(100% + 10px);
    transform: translateX(-50%) translateY(-5px);
}

.top-bar [data-tooltip]:hover::after,
.top-bar [data-tooltip]:focus-visible::after {
    transform: translateX(-50%) translateY(0);
}

.top-bar [data-tooltip]::before {
    bottom: auto;
    top: calc(100% + 5px);
    border-color: transparent transparent rgba(8, 13, 22, 0.95) transparent;
    transform: translateX(-50%) translateY(-5px);
}

.top-bar [data-tooltip]:hover::before,
.top-bar [data-tooltip]:focus-visible::before {
    transform: translateX(-50%) translateY(0);
}

.canvas-toolbar:hover {
    border-color: rgba(255, 255, 255, 0.15);
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.toolbar-btn {
    background: transparent;
    color: var(--text-secondary);
    border: none;
    border-radius: 9999px;
    padding: 6px 14px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    font-family: var(--font-heading);
    cursor: pointer;
    box-shadow: none !important;
    transform: none !important;
    transition: color 0.2s ease, background-color 0.2s ease, transform 0.15s ease-out;
    height: 32px;
}

.toolbar-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.toolbar-btn:active {
    transform: scale(0.96) !important;
}

.toolbar-btn.active {
    background: var(--accent-gradient);
    color: #020617;
    box-shadow: 0 2px 8px rgba(var(--accent-aurora-rgb), 0.3) !important;
}

.toolbar-separator {
    width: 1px;
    height: 20px;
    background: var(--border-glass);
    margin: 0 4px;
}

/* Keep the zoom cluster ("- 50% +") together as a single flex item, so on a narrow
   toolbar it wraps to the next row as one unit instead of the minus staying behind
   while the % select and plus jump down separately. */
.toolbar-zoom-group {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.toolbar-zoom-btn {
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-secondary);
    border: 1px solid var(--border-glass);
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: none !important;
    transform: none !important;
    transition: color 0.2s ease, border-color 0.2s ease, background-color 0.2s ease, transform 0.15s ease-out;
    padding: 0;
}

.toolbar-zoom-btn:hover {
    color: var(--accent-aurora);
    border-color: var(--border-focus);
    background: rgba(255, 255, 255, 0.08);
}

.toolbar-zoom-btn:active {
    transform: scale(0.92) !important;
}

.toolbar-zoom-label {
    font-family: var(--font-heading);
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-primary);
    min-width: 44px;
    text-align: center;
}

.toolbar-reset-btn {
    background: transparent;
    color: var(--text-muted);
    border: none;
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 0.75rem;
    cursor: pointer;
    border-radius: 9999px;
    padding: 4px 10px;
    transition: color 0.2s ease, background-color 0.2s ease, transform 0.15s ease-out;
    box-shadow: none !important;
    transform: none !important;
    height: 28px;
}

.toolbar-reset-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.toolbar-reset-btn:active {
    transform: scale(0.96) !important;
}

/* Pan Mode Active Overrides */
body.pan-mode-active .canvas-viewport {
    cursor: grab;
}

body.pan-mode-active.dragging .canvas-viewport {
    cursor: grabbing !important;
}

/* Disable interactions inside devices when panning */
body.pan-mode-active iframe,
body.pan-mode-active button:not(.toolbar-btn):not(.toolbar-zoom-btn):not(.toolbar-reset-btn),
body.pan-mode-active input,
body.pan-mode-active select,
body.pan-mode-active a {
    pointer-events: none !important;
}
