@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* =============================================
   Scribe Editor Demo - Design System
   Extracted from React project
   ============================================= */

:root {
    /* Core palette - Professional slate with teal accent */
    --background: hsl(210, 20%, 98%);
    --foreground: hsl(222, 47%, 11%);

    --card: hsl(0, 0%, 100%);
    --card-foreground: hsl(222, 47%, 11%);

    --popover: hsl(0, 0%, 100%);
    --popover-foreground: hsl(222, 47%, 11%);

    /* Vibrant teal primary */
    --primary: hsl(173, 80%, 40%);
    --primary-foreground: hsl(0, 0%, 100%);

    --secondary: hsl(210, 20%, 96%);
    --secondary-foreground: hsl(222, 47%, 11%);

    --muted: hsl(210, 20%, 96%);
    --muted-foreground: hsl(215, 16%, 47%);

    --accent: hsl(173, 80%, 95%);
    --accent-foreground: hsl(173, 80%, 30%);

    --destructive: hsl(0, 84%, 60%);
    --destructive-foreground: hsl(0, 0%, 100%);

    --border: hsl(214, 32%, 91%);
    --ring: hsl(173, 80%, 40%);

    --radius: 0.5rem;

    /* Editor-specific tokens */
    --editor-bg: hsl(0, 0%, 100%);
    --editor-border: hsl(214, 32%, 91%);
    --editor-selection: hsl(173, 80%, 90%);
    --editor-selection-text: hsl(173, 80%, 25%);
    --editor-cursor: hsl(173, 80%, 40%);
    --editor-placeholder: hsl(215, 16%, 65%);

    /* Toolbar tokens */
    --toolbar-bg: hsl(0, 0%, 100%);
    --toolbar-border: hsl(214, 32%, 88%);
    --toolbar-shadow: hsl(222, 47%, 11%);
    --toolbar-button-hover: hsl(210, 20%, 96%);
    --toolbar-button-active: hsl(173, 80%, 95%);
    --toolbar-button-active-text: hsl(173, 80%, 35%);
    --toolbar-separator: hsl(214, 32%, 91%);

    /* Code block tokens */
    --code-bg: hsl(220, 14%, 96%);
    --code-text: hsl(222, 47%, 20%);
    --code-border: hsl(214, 32%, 88%);

    /* Link tokens */
    --link: hsl(173, 80%, 40%);
    --link-hover: hsl(173, 80%, 30%);

    /* Container */
    --container-max-width: 1200px;
}

/* =============================================
   Layout & Container
   ============================================= */

.container {
    width: 100%;
    max-width: var(--container-max-width);
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* =============================================
   Hero Section
   ============================================= */

.hero {
    position: relative;
    overflow: hidden;
    border-bottom: 1px solid var(--border);
    background: var(--background);
}

.hero-bg {
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, hsla(173, 80%, 40%, 0.05) 0%, transparent 40%, hsla(173, 80%, 40%, 0.1) 100%);
    pointer-events: none;
}

.hero-content {
    position: relative;
    padding: 4rem 0;
    text-align: center;
}

.hero-copy {
    max-width: 48rem;
    margin: 0 auto;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.375rem 0.75rem;
    background: var(--secondary);
    color: var(--secondary-foreground);
    border-radius: 9999px;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 1rem;
}

.hero h1 {
    font-size: clamp(2rem, 5vw, 3.5rem);
    font-weight: 700;
    letter-spacing: -0.025em;
    margin-bottom: 1rem;
}

.hero h1 .accent {
    background: linear-gradient(135deg, var(--primary) 0%, hsl(173, 80%, 50%) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero p {
    font-size: clamp(1rem, 2vw, 1.25rem);
    color: var(--muted-foreground);
    margin-bottom: 2rem;
    max-width: 42rem;
    margin-left: auto;
    margin-right: auto;
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: center;
}

/* =============================================
   Buttons
   ============================================= */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 500;
    font-family: 'Inter', system-ui, sans-serif;
    cursor: pointer;
    transition: all 0.15s ease-out;
    text-decoration: none;
    background: var(--primary);
    color: var(--primary-foreground);
}

.btn:hover {
    background: hsl(173, 80%, 35%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px hsla(173, 80%, 40%, 0.3);
}

.btn.ghost {
    background: transparent;
    color: var(--foreground);
    border: 1px solid var(--border);
}

.btn.ghost:hover {
    background: var(--secondary);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px hsla(var(--toolbar-shadow), 0.08);
}

.hero-btn {
    padding: 0.875rem 2rem;
    font-size: 1.125rem;
}

/* =============================================
   Features Section
   ============================================= */

.features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    padding: 4rem 0;
}

.feature-card {
    text-align: center;
    padding: 2rem 1.5rem;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: all 0.15s ease-out;
}

.feature-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px hsla(var(--toolbar-shadow), 0.08);
    border-color: var(--primary);
}

.feature-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 3rem;
    height: 3rem;
    background: linear-gradient(135deg, var(--primary), hsl(173, 80%, 50%));
    color: var(--primary-foreground);
    border-radius: 0.5rem;
    font-weight: 700;
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.feature-card h3 {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--foreground);
}

.feature-card p {
    font-size: 0.875rem;
    color: var(--muted-foreground);
    margin: 0;
}

/* =============================================
   Demo Section
   ============================================= */

.demo {
    padding: 4rem 0;
}

.section-heading {
    text-align: center;
    margin-bottom: 2.5rem;
}

.section-heading h2 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
    color: var(--foreground);
}

.section-heading p {
    font-size: 1rem;
    color: var(--muted-foreground);
    margin: 0;
}

/* =============================================
   Base Styles
   ============================================= */

* {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', system-ui, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    margin: 0;
    padding: 0;
    background: var(--background);
    color: var(--foreground);
}

/* =============================================
   Editor Content Styles
   ============================================= */

.scribe-content {
    min-height: 200px;
    outline: none;
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 16px;
    line-height: 1.75;
    color: var(--foreground);
}

.scribe-content:focus {
    outline: none;
}

.scribe-content p {
    margin-bottom: 1rem;
    line-height: 1.75;
}

.scribe-content h1 {
    font-size: 2.25rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    margin-top: 2rem;
    line-height: 1.2;
    letter-spacing: -0.025em;
}

.scribe-content h1:first-child {
    margin-top: 0;
}

.scribe-content h2 {
    font-size: 1.875rem;
    font-weight: 700;
    margin-bottom: 1.25rem;
    margin-top: 1.75rem;
    line-height: 1.3;
    letter-spacing: -0.025em;
}

.scribe-content h2:first-child {
    margin-top: 0;
}

.scribe-content h3 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 1rem;
    margin-top: 1.5rem;
}

.scribe-content h3:first-child {
    margin-top: 0;
}

.scribe-content strong,
.scribe-content b {
    font-weight: 600;
}

.scribe-content em,
.scribe-content i {
    font-style: italic;
}

.scribe-content u {
    text-decoration: underline;
    text-underline-offset: 2px;
}

.scribe-content s,
.scribe-content strike {
    text-decoration: line-through;
}

.scribe-content a {
    color: var(--link);
    text-decoration: underline;
    text-underline-offset: 2px;
    transition: color 0.15s ease-out;
}

.scribe-content a:hover {
    color: var(--link-hover);
}

.scribe-content code:not(pre code) {
    background: var(--code-bg);
    color: var(--code-text);
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
}

.scribe-content pre {
    background: var(--code-bg);
    border: 1px solid var(--code-border);
    padding: 1rem;
    border-radius: 0.5rem;
    overflow-x: auto;
    margin-bottom: 1rem;
}

.scribe-content pre code {
    background: transparent;
    padding: 0;
    font-size: 0.875rem;
}

.scribe-content blockquote {
    border-left: 3px solid var(--primary);
    padding-left: 1rem;
    padding-top: 0.25rem;
    padding-bottom: 0.25rem;
    margin: 1rem 0;
    font-style: italic;
    color: var(--muted-foreground);
}

.scribe-content ul {
    list-style-type: disc;
    padding-left: 1.5rem;
    margin-bottom: 1rem;
}

.scribe-content ul li {
    margin-bottom: 0.25rem;
}

.scribe-content ol {
    list-style-type: decimal;
    padding-left: 1.5rem;
    margin-bottom: 1rem;
}

.scribe-content ol li {
    margin-bottom: 0.25rem;
}

.scribe-content hr {
    margin: 2rem 0;
    border: none;
    border-top: 1px solid var(--border);
}

/* Selection styles */
.scribe-content ::selection {
    background: var(--editor-selection);
    color: var(--editor-selection-text);
}

/* Placeholder */
.scribe-content[data-placeholder]:empty::before {
    content: attr(data-placeholder);
    color: var(--editor-placeholder);
    pointer-events: none;
}

/* =============================================
   Editor Shell
   ============================================= */

.editor-shell {
    position: relative;
    background: var(--editor-bg);
    border: 1px solid var(--editor-border);
    border-radius: var(--radius);
    padding: 1rem;
    min-height: 400px;
    transition: box-shadow 0.2s ease-out;
}

.editor-shell:focus-within {
    box-shadow: 0 0 0 2px var(--ring), 0 0 0 4px hsla(173, 80%, 40%, 0.1);
}

.editor {
    outline: none;
    min-height: 300px;
}

/* =============================================
   Toolbar Base Styles
   ============================================= */

.toolbar {
    display: flex;
    align-items: center;
    gap: 0.125rem;
    padding: 0.375rem 0.5rem;
    background: var(--toolbar-bg);
    border: 1px solid var(--toolbar-border);
    border-radius: var(--radius);
    box-shadow: 0 2px 8px hsla(var(--toolbar-shadow), 0.08);
}

.toolbar .group {
    display: flex;
    align-items: center;
    gap: 0.125rem;
}

.toolbar .separator {
    width: 1px;
    height: 1.25rem;
    background: var(--toolbar-separator);
    margin: 0 0.25rem;
}

.toolbar button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border: none;
    background: transparent;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: all 0.15s ease-out;
    color: hsla(var(--foreground), 0.8);
}

.toolbar button:hover {
    background: var(--toolbar-button-hover);
    color: var(--foreground);
}

.toolbar button:focus {
    outline: none;
    box-shadow: 0 0 0 2px var(--ring), 0 0 0 4px hsla(173, 80%, 40%, 0.1);
    outline-offset: 1px;
}

.toolbar button.active {
    background: var(--toolbar-button-active);
    color: var(--toolbar-button-active-text);
}

.toolbar button:disabled {
    opacity: 0.4;
    pointer-events: none;
}

.toolbar button svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.toolbar button .toolbar-tag {
    font-size: 0.75rem;
    font-weight: 600;
    font-family: 'Inter', system-ui, sans-serif;
}

/* =============================================
   Floating Toolbar
   ============================================= */

.toolbar.floating {
    position: fixed;
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transform: translateX(-50%) translateY(4px) scale(0.98);
    transition: opacity 0.15s ease-out, transform 0.15s ease-out;
    box-shadow: 0 4px 20px hsla(var(--toolbar-shadow), 0.15);
}

.toolbar.floating.visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(-50%) translateY(0) scale(1);
}

/* =============================================
   Link Modal
   ============================================= */

.link-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 40;
    display: none;
}

.link-modal-backdrop.visible {
    display: block;
}

.link-modal {
    position: fixed;
    z-index: 50;
    background: var(--popover);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 8px 32px hsla(var(--toolbar-shadow), 0.2);
    padding: 0.75rem;
    min-width: 300px;
    display: none;
    transform-origin: top left;
    animation: modal-scale-in 0.15s ease-out;
}

.link-modal.visible {
    display: block;
}

@keyframes modal-scale-in {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.link-modal form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.link-modal .input-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.link-modal .input-group svg {
    width: 16px;
    height: 16px;
    color: var(--muted-foreground);
    flex-shrink: 0;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.link-modal input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    font-size: 0.875rem;
    color: var(--foreground);
    font-family: 'Inter', system-ui, sans-serif;
}

.link-modal input::placeholder {
    color: var(--muted-foreground);
}

.link-modal .actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.link-modal .actions .left,
.link-modal .actions .right {
    display: flex;
    gap: 0.25rem;
}

.link-modal button {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.625rem;
    font-size: 0.75rem;
    border: none;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: all 0.15s ease-out;
    font-family: 'Inter', system-ui, sans-serif;
    font-weight: 500;
}

.link-modal button svg {
    width: 14px;
    height: 14px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.link-modal button.remove {
    background: transparent;
    color: var(--destructive);
}

.link-modal button.remove:hover {
    background: hsla(var(--destructive), 0.1);
}

.link-modal button.cancel {
    background: transparent;
    color: var(--muted-foreground);
}

.link-modal button.cancel:hover {
    background: var(--secondary);
}

.link-modal button.apply {
    background: var(--primary);
    color: var(--primary-foreground);
}

.link-modal button.apply:hover {
    background: hsl(173, 80%, 35%);
}

.link-modal button:disabled {
    opacity: 0.5;
    pointer-events: none;
}

/* =============================================
   Demo Page Specific
   ============================================= */

.panel {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.panel-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
}

.panel-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
    margin: 0 0 0.25rem 0;
    color: var(--foreground);
}

.panel-header p {
    font-size: 0.875rem;
    color: var(--muted-foreground);
    margin: 0;
}

.tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.tab {
    padding: 0.75rem 1.5rem;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--muted-foreground);
    transition: all 0.15s ease-out;
    font-family: 'Inter', system-ui, sans-serif;
}

.tab:hover {
    color: var(--foreground);
    background: var(--muted);
}

.tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
}

/* Fixed toolbar container */
.toolbar-container {
    padding: 1rem;
}

/* ===============================================
   Code Section
   ============================================= */

.code-section {
    background: hsla(173, 80%, 40%, 0.03);
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    padding: 4rem 0;
}

.code-header {
    text-align: center;
    margin-bottom: 2rem;
}

.code-header h3 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--foreground);
}

.code-header p {
    color: var(--muted-foreground);
    margin: 0;
}

.code-window {
    max-width: 800px;
    margin: 0 auto;
    background: #1e1e1e;
    border-radius: 0.75rem;
    box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    border: 1px solid #333;
}

.window-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    background: #252526;
    border-bottom: 1px solid #333;
    height: 44px;
}

.window-controls {
    display: flex;
    gap: 8px;
}

.control {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.control.red {
    background: #ff5f56;
}

.control.yellow {
    background: #ffbd2e;
}

.control.green {
    background: #27c93f;
}

.window-tabs {
    display: flex;
    gap: 2px;
    height: 100%;
    margin-top: 10px;
    /* Push tabs down to align bottom with header bottom */
}

.window-tab {
    background: transparent;
    border: none;
    color: #969696;
    padding: 0 1.5rem;
    height: 34px;
    font-size: 0.875rem;
    cursor: pointer;
    border-radius: 6px 6px 0 0;
    transition: all 0.1s ease;
    font-family: 'Inter', system-ui, sans-serif;
    font-weight: 500;
}

.window-tab:hover {
    background: #2d2d2d;
    color: #e0e0e0;
}

.window-tab.active {
    background: #1e1e1e;
    color: #fff;
    box-shadow: 0 -1px 0 #1e1e1e;
    /* Hide bottom border locally */
}

.window-content {
    position: relative;
    padding: 1.5rem;
    color: #d4d4d4;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 0.9rem;
    line-height: 1.6;
}

.code-panel {
    display: none;
}

.code-panel.active {
    display: block;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

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

.code-panel pre {
    margin: 0;
    overflow-x: auto;
}

.btn-copy {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #fff;
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    font-family: 'Inter', sans-serif;
    opacity: 0;
}

.window-content:hover .btn-copy {
    opacity: 1;
}

.btn-copy:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Syntax Highlighting (Dark Mode) */
.token.kwd {
    color: #c586c0;
    font-weight: bold;
}

/* Keywords: purple */
.token.str {
    color: #ce9178;
}

/* Strings: orange/brown */
.token.fn {
    color: #dcdcaa;
}

/* Functions: yellow */
.token.cmt {
    color: #6a9955;
    font-style: italic;
}

/* Comments: green */
.token.cls {
    color: #4ec9b0;
}

/* Classes/Components: teal */
.token.attr {
    color: #9cdcfe;
}

/* Attributes/Props: light blue */
.token.num {
    color: #b5cea8;
}

/* Numbers: light green */

/* =============================================
   API Section
   ============================================= */

.api {
    padding: 4rem 0;
}

.api h2 {
    text-align: center;
    font-size: 1.875rem;
    font-weight: 700;
    margin-bottom: 2.5rem;
    color: var(--foreground);
}

.api-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

.api-card {
    padding: 1.5rem;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: all 0.15s ease-out;
}

.api-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px hsla(var(--toolbar-shadow), 0.08);
    border-color: var(--primary);
}

.api-card h4 {
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 1rem;
    font-weight: 600;
    color: var(--primary);
    margin: 0 0 0.75rem 0;
}

.api-card p {
    font-size: 0.875rem;
    color: var(--muted-foreground);
    margin: 0 0 0.75rem 0;
    line-height: 1.6;
}

.api-card span {
    display: block;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 0.75rem;
    color: var(--code-text);
    background: var(--code-bg);
    padding: 0.5rem;
    border-radius: 0.25rem;
}

/* =============================================
   Footer
   ============================================= */

.footer {
    border-top: 1px solid var(--border);
    background: hsla(173, 80%, 40%, 0.02);
    padding: 2rem 0;
}

.footer-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    text-align: center;
}

.footer-content div {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.footer-content strong {
    font-weight: 600;
    color: var(--foreground);
}

.version {
    display: inline-flex;
    padding: 0.125rem 0.5rem;
    font-size: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 9999px;
    color: var(--muted-foreground);
}

.footer-content p {
    font-size: 0.875rem;
    color: var(--muted-foreground);
    margin: 0;
}

.footer-content a {
    color: var(--foreground);
    text-decoration: none;
    transition: color 0.15s ease-out;
}

.footer-content a:hover {
    color: var(--primary);
}

/* =============================================
   Responsive
   ============================================= */

@media (max-width: 768px) {
    .hero-content {
        padding: 3rem 0;
    }

    .features {
        grid-template-columns: 1fr;
        padding: 3rem 0;
    }

    .demo {
        padding: 3rem 0;
    }

    .code-grid {
        grid-template-columns: 1fr;
    }

    .api-grid {
        grid-template-columns: 1fr;
    }

    .tabs {
        flex-direction: column;
        gap: 0;
    }

    .tab {
        border-bottom: none;
        border-left: 2px solid transparent;
        text-align: left;
    }

    .tab.active {
        border-left-color: var(--primary);
        border-bottom-color: transparent;
    }
}