/* ============================================================
 * style.css — Txt-to-Handwriting
 *
 * Organised by section:
 *   1. Reset & Base
 *   2. Canvas Output
 *   3. Sidebar — Paper Thumbnails
 *   4. Sidebar — Font Thumbnails
 *   5. Custom Scrollbar
 *   6. Editor Toolbar
 *   7. Editor Content (contenteditable)
 *   8. Animations (modal, fade, zoom)
 * ============================================================ */

/* ─── 1. Reset & Base ─────────────────────────────────────────── */

* {
    box-sizing: border-box;
}

body {
    margin: 0;
}

/* ─── 2. Canvas Output ────────────────────────────────────────── */

#outputCanvas {
    max-width: 100%;
    height: auto;
    background-color: white;
    border-radius: 2px;
}

/* ─── 3. Sidebar — Paper Thumbnails ───────────────────────────── */

.paper-thumb {
    aspect-ratio: 3 / 4;
    border: 2px solid transparent;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    transition: border-color 0.15s ease,
                box-shadow 0.15s ease,
                transform 0.15s ease;
    background: #f9fafb;
}

.paper-thumb:hover {
    border-color: #93c5fd;
    transform: scale(1.03);
}

.paper-thumb.active {
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.thumb-inner {
    width: 100%;
    height: 100%;
}

/* Ruled notebook preview */
.ruled-thumb {
    background: white;
    background-image:
        linear-gradient(
            to bottom,
            transparent 20%,
            transparent calc(20% + 0px),
            rgba(0, 150, 255, 0.2) calc(20% + 0px),
            rgba(0, 150, 255, 0.2) calc(20% + 1px),
            transparent calc(20% + 1px)
        );
    background-size: 100% 12px;
    position: relative;
}

.ruled-thumb::after {
    content: '';
    position: absolute;
    left: 18%;
    top: 0;
    bottom: 0;
    width: 1px;
    background: rgba(255, 0, 0, 0.25);
}

/* Blank paper preview */
.blank-thumb {
    background: white;
}

/* Grid paper preview */
.grid-thumb {
    background: white;
    background-image:
        linear-gradient(to bottom, transparent calc(100% - 1px), rgba(0, 150, 255, 0.15) calc(100% - 1px)),
        linear-gradient(to right,  transparent calc(100% - 1px), rgba(0, 150, 255, 0.15) calc(100% - 1px));
    background-size: 10px 10px;
}

/* Photo background preview */
.bg1-thumb {
    background: url('../picture/Background 1.jpeg') center / cover no-repeat;
}

/* ─── 4. Sidebar — Font Thumbnails ────────────────────────────── */

.font-thumb {
    padding: 6px 10px;
    border: 1.5px solid #e5e7eb;
    border-radius: 6px;
    cursor: pointer;
    transition: border-color 0.15s ease,
                background 0.15s ease,
                color 0.15s ease;
    background: #fff;
    color: #374151;
}

.font-thumb:hover {
    border-color: #93c5fd;
    background: #eff6ff;
}

.font-thumb.active {
    border-color: #3b82f6;
    background: #eff6ff;
    color: #1e40af;
}

/* ─── 5. Custom Scrollbar ─────────────────────────────────────── */

.custom-scrollbar::-webkit-scrollbar {
    width: 6px;
}

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

.custom-scrollbar::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

.custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* ─── 6. Editor Toolbar ───────────────────────────────────────── */

.editor-toolbar {
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.toolbar-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 28px;
    border: 1px solid transparent;
    border-radius: 4px;
    background: transparent;
    color: #6b7280;
    cursor: pointer;
    transition: background 0.12s ease,
                color 0.12s ease,
                border-color 0.12s ease;
}

.toolbar-btn:hover {
    background: #f3f4f6;
    color: #374151;
    border-color: #e5e7eb;
}

.toolbar-btn:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 1px;
}

.toolbar-btn.active {
    background: #eff6ff;
    color: #2563eb;
    border-color: #bfdbfe;
}

.toolbar-sep {
    width: 1px;
    height: 20px;
    background: #e5e7eb;
    margin: 0 3px;
}

/* ─── 7. Editor Content (contenteditable) ─────────────────────── */

.editor-content {
    white-space: pre-wrap;
    word-break: break-word;
    min-height: 200px;
}

.editor-content:focus {
    border-color: #60a5fa;
}

.editor-content ul,
.editor-content ol {
    margin: 4px 0;
    padding-left: 28px;
}

.editor-content ul {
    list-style-type: disc;
}

.editor-content ol {
    list-style-type: decimal;
}

.editor-content li {
    margin-bottom: 2px;
}

.editor-content h1 {
    font-size: 48px;
    margin: 4px 0;
    line-height: 1.2;
}

.editor-content h2 {
    font-size: 36px;
    margin: 4px 0;
    line-height: 1.3;
}

.editor-content h3 {
    font-size: 28px;
    margin: 4px 0;
    line-height: 1.4;
}

.editor-content p,
.editor-content div {
    font-size: 24px;
    margin: 0;
}

/* ─── 8. Animations ───────────────────────────────────────────── */

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes zoomIn {
    from { opacity: 0; transform: scale(0.95); }
    to   { opacity: 1; transform: scale(1); }
}

.animate-in {
    animation-duration: 0.2s;
    animation-fill-mode: both;
}

.fade-in {
    animation-name: fadeIn;
}

.zoom-in {
    animation-name: zoomIn;
}

#main-desk {
    background-color: #e8eaed;
}

/* ─── 9. Edit Area Modal ──────────────────────────────────────── */

.resize-handle {
    position: absolute;
    width: 12px;
    height: 12px;
    background-color: white;
    border: 2px solid #3b82f6;
    border-radius: 50%;
    z-index: 10;
}

.resize-handle.nw { top: 0; left: 0; transform: translate(-50%, -50%); cursor: nwse-resize; }
.resize-handle.ne { top: 0; right: 0; transform: translate(50%, -50%); cursor: nesw-resize; }
.resize-handle.sw { bottom: 0; left: 0; transform: translate(-50%, 50%); cursor: nesw-resize; }
.resize-handle.se { bottom: 0; right: 0; transform: translate(50%, 50%); cursor: nwse-resize; }

.resize-handle.n { top: 0; left: 50%; transform: translate(-50%, -50%); cursor: ns-resize; }
.resize-handle.s { bottom: 0; left: 50%; transform: translate(-50%, 50%); cursor: ns-resize; }
.resize-handle.w { top: 50%; left: 0; transform: translate(-50%, -50%); cursor: ew-resize; }
.resize-handle.e { top: 50%; right: 0; transform: translate(50%, -50%); cursor: ew-resize; }

/* =========================================
   🌙 DARK MODE OVERRIDES 
   ========================================= */
   
/* Define Dark Theme Variables */
body.dark-mode {
    --dm-bg: #121212;
    --dm-surface: #1f2937;
    --dm-surface-2: #374151;
    --dm-border: #4b5563;
    --dm-text: #e5e7eb;
    --dm-text-light: #f3f4f6;
    --dm-text-muted: #9ca3af;
    --dm-desk-bg: #111827;
    --dm-accent: #60a5fa;
    --dm-accent-bg: #1e3a8a;
    --dm-accent-text: #bfdbfe;

    /* Paper colors */
    --dm-paper-bg: #ffffff;
    --dm-paper-text: #111827;
    --dm-paper-border: #d1d5db;

    /* 1. Global Background and Text */
    background-color: var(--dm-bg);
    color: var(--dm-text);
}

/* 2. Header and Sidebars */
body.dark-mode header,
body.dark-mode aside,
body.dark-mode .bg-white:not(#textInput, #outputCanvas, #editorToolbar, #headingSelect) {
    background-color: var(--dm-surface);
    border-color: var(--dm-surface-2);
}

/* Keep paper/editor surfaces white for realism */
body.dark-mode #textInput,
body.dark-mode #outputCanvas {
    background-color: var(--dm-paper-bg);
    color: var(--dm-paper-text);
    border-color: var(--dm-paper-border);
}

/* 3. Text Colors */
body.dark-mode .text-gray-800,
body.dark-mode .text-gray-900 {
    color: var(--dm-text-light);
}

body.dark-mode .text-gray-600:not(#headingSelect),
body.dark-mode .text-gray-500 {
    color: var(--dm-text-muted);
}

/* 4. The Gray Background behind the Canvas */
body.dark-mode #main-desk {
    background-color: var(--dm-desk-bg);
}

/* 5. Left Sidebar: Paper Thumbnails */
body.dark-mode .paper-thumb {
    background: var(--dm-surface-2);
    border-color: transparent;
}

body.dark-mode .paper-thumb.active {
    border-color: var(--dm-accent);
    box-shadow: 0 0 0 2px rgba(96, 165, 250, 0.4);
}

/* 6. Left Sidebar: Font Thumbnails */
body.dark-mode .font-thumb {
    background: var(--dm-surface);
    border-color: var(--dm-border);
    color: var(--dm-text);
}

body.dark-mode .font-thumb:hover {
    background: var(--dm-surface-2);
    border-color: var(--dm-accent);
}

body.dark-mode .font-thumb.active {
    background: var(--dm-accent-bg);
    border-color: var(--dm-accent);
    color: var(--dm-accent-text);
}

/* 7. Removed Toolbar Overrides to maintain light mode style */

/* 8. Buttons (like the dark mode toggle itself!) */
body.dark-mode button.bg-white,
body.dark-mode a.bg-white {
    background-color: var(--dm-surface-2);
    border-color: var(--dm-border);
    color: var(--dm-text);
}

body.dark-mode button.bg-white:hover,
body.dark-mode a.bg-white:hover {
    background-color: var(--dm-border);
}

/* 9. Download Dropdown UI */
body.dark-mode #downloadMenu {
    background-color: var(--dm-surface);
    border: 1px solid var(--dm-border);
}

body.dark-mode #downloadMenu button {
    color: var(--dm-text);
    background-color: transparent;
}

body.dark-mode #downloadMenu button:hover {
    background-color: var(--dm-surface-2);
    color: var(--dm-text-light);
}

body.dark-mode #downloadAllBtn {
    border-top-color: var(--dm-border);
}