/* style.css
 * =========================================================================
 * Virtual Graph Paper — hand-crafted styles
 * Covers: canvas layers, tool bar (icon+label buttons), style bar,
 * action buttons, coordinate bar, full-width bottom ad banner,
 * sidebar, kbd chips, print.
 * ========================================================================= */

/* =========================================================================
   CANVAS LAYERS
   ========================================================================= */
#canvasWrap {
    position: absolute;
    inset: 0;
    overflow: hidden;
}
#gridLayer {
    position: absolute;
    top: 0; left: 0;
    z-index: 1;
}
#drawLayer {
    position: absolute;
    top: 0; left: 0;
    z-index: 2;
    cursor: crosshair;
    touch-action: none;
}

/* =========================================================================
   TOOLS BAR  (Row 1 — large labeled tool buttons)
   ========================================================================= */
#toolsBar {
    display: flex;
    align-items: stretch;
    gap: 0;
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    padding: 0 10px;
    min-height: 64px;         /* tall enough for icon + label */
    z-index: 20;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
}
#toolsBar::-webkit-scrollbar { display: none; }

/* Logo */
.tools-logo {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 0 8px;
    flex-shrink: 0;
    user-select: none;
}
.logo-icon { font-size: 1.25rem; }
.logo-text {
    font-size: 0.95rem;
    font-weight: 700;
    color: #334155;
    letter-spacing: -0.01em;
    white-space: nowrap;
}
.logo-accent { color: #6366f1; }

/* Vertical separator between toolbar groups */
.tools-vsep {
    width: 1px;
    background: #e2e8f0;
    margin: 8px 6px;
    flex-shrink: 0;
}

/* Tool group wrapper (label + row of buttons) */
.tool-group {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    padding: 4px 2px;
    flex-shrink: 0;
}
.tool-group-label {
    font-size: 0.5rem;
    font-weight: 700;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 0 4px;
    margin-bottom: 2px;
}
.tool-group-btns {
    display: flex;
    align-items: center;
    gap: 2px;
}

/* ---- Individual Tool Button ---- */
.tool-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-width: 48px;
    padding: 5px 7px;
    border-radius: 7px;
    border: 1.5px solid transparent;
    background: transparent;
    cursor: pointer;
    transition: background 120ms ease, border-color 120ms ease, transform 80ms ease;
    flex-shrink: 0;
}
.tool-btn:hover {
    background: #f1f5f9;
    border-color: #e2e8f0;
    transform: translateY(-1px);
}
.tool-btn:active {
    transform: translateY(0);
    background: #e8ecf4;
}
.tool-active {
    background: #eef2ff !important;
    border-color: #6366f1 !important;
}
.tool-active .tool-label {
    color: #4f46e5 !important;
    font-weight: 700 !important;
}

.tool-icon {
    font-size: 1.25rem;
    line-height: 1;
    display: block;
}
/* Unicode symbol shapes — slightly larger for readability */
.tool-sym {
    font-size: 1.05rem;
}
.tool-label {
    font-size: 0.58rem;
    font-weight: 500;
    color: #64748b;
    line-height: 1;
    white-space: nowrap;
}

/* Cursor classes toggled on #drawLayer by JS */
.cursor-select    { cursor: default; }
.cursor-crosshair { cursor: crosshair; }
.cursor-text      { cursor: text; }
.cursor-eraser    { cursor: cell; }
.cursor-pan       { cursor: grab; }
.cursor-panning   { cursor: grabbing; }

/* Export / header buttons (top-right) */
.hdr-btn {
    padding: 5px 12px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background 140ms, color 140ms, border-color 140ms;
    flex-shrink: 0;
}
.hdr-btn-ghost {
    background: transparent;
    border: 1.5px solid #e2e8f0;
    color: #475569;
}
.hdr-btn-ghost:hover { background: #f8fafc; border-color: #cbd5e1; }
.hdr-btn-primary {
    background: #6366f1;
    border: 1.5px solid #6366f1;
    color: #fff;
}
.hdr-btn-primary:hover { background: #4f46e5; border-color: #4f46e5; }
.hdr-btn-outline {
    background: transparent;
    border: 1.5px solid #6366f1;
    color: #6366f1;
}
.hdr-btn-outline:hover { background: #eef2ff; }


/* =========================================================================
   STYLE BAR  (Row 2 — stroke/fill/dash/opacity + action buttons)
   ========================================================================= */
#styleBar {
    display: flex;
    align-items: center;
    gap: 0;
    background: #fafbfd;
    border-bottom: 1px solid #e8ecf2;
    padding: 0 10px;
    min-height: 38px;
    z-index: 19;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    flex-shrink: 0;
}
#styleBar::-webkit-scrollbar { display: none; }

.style-group {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 6px;
    flex-shrink: 0;
}
.style-vsep {
    width: 1px;
    height: 20px;
    background: #e2e8f0;
    margin: 0 4px;
    flex-shrink: 0;
}
.style-item {
    display: flex;
    align-items: center;
    gap: 5px;
    flex-shrink: 0;
}
.style-label {
    font-size: 0.65rem;
    color: #94a3b8;
    font-weight: 500;
    white-space: nowrap;
}
.style-val {
    font-size: 0.65rem;
    color: #475569;
    min-width: 1.5rem;
    text-align: right;
    font-weight: 600;
}
.color-swatch {
    height: 1.5rem;
    width: 1.75rem;
    border: none;
    background: transparent;
    padding: 0;
    cursor: pointer;
    border-radius: 4px;
}
.slider {
    cursor: pointer;
    accent-color: #6366f1;
}
.style-select {
    border: 1px solid #e2e8f0;
    border-radius: 5px;
    padding: 2px 6px;
    font-size: 0.7rem;
    color: #334155;
    background: #fff;
    cursor: pointer;
}
.toggle-check {
    cursor: pointer;
    accent-color: #6366f1;
}

/* Action buttons (Undo/Redo/Dup, Z-order, Group) in style bar */
.act-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
    min-width: 36px;
    padding: 3px 5px;
    border-radius: 5px;
    border: 1px solid transparent;
    background: transparent;
    cursor: pointer;
    transition: background 100ms, border-color 100ms;
    flex-shrink: 0;
}
.act-btn:hover {
    background: #f1f5f9;
    border-color: #e2e8f0;
}
.act-icon {
    font-size: 0.9rem;
    line-height: 1;
}
.act-label {
    font-size: 0.5rem;
    font-weight: 500;
    color: #94a3b8;
    line-height: 1;
}


/* =========================================================================
   SIDEBAR  (left panel — grid settings)
   ========================================================================= */
.sidebar {
    width: 13rem;
    flex-shrink: 0;
}
.sidebar-heading {
    font-size: 0.6rem;
    font-weight: 700;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 6px;
}
.sidebar-label {
    display: block;
    font-size: 0.7rem;
    color: #94a3b8;
    margin-bottom: 3px;
}
.sidebar-select {
    width: 100%;
    border: 1px solid #e2e8f0;
    border-radius: 5px;
    padding: 4px 6px;
    font-size: 0.72rem;
    background: #fff;
    color: #334155;
    cursor: pointer;
}
.sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.72rem;
    color: #475569;
}
.sidebar-num-input {
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    padding: 2px 5px;
    font-size: 0.72rem;
    color: #334155;
    background: #fff;
}

/* Zoom controls */
.zoom-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 5px;
    border: 1px solid #e2e8f0;
    background: #fff;
    cursor: pointer;
    font-size: 1rem;
    color: #475569;
    flex-shrink: 0;
    transition: background 100ms;
}
.zoom-btn:hover { background: #f1f5f9; }
.zoom-reset {
    flex: 1;
    border-radius: 5px;
    border: 1px solid #e2e8f0;
    padding: 3px 0;
    font-size: 0.72rem;
    color: #475569;
    background: #fff;
    cursor: pointer;
    text-align: center;
    transition: background 100ms;
}
.zoom-reset:hover { background: #f1f5f9; }


/* =========================================================================
   COORDINATE / STATUS BAR
   ========================================================================= */
.coord-bar {
    display: flex;
    align-items: center;
    height: 1.75rem;
    padding: 0 0.75rem;
    background: #f8fafc;
    border-top: 1px solid #e8ecf2;
    font-family: ui-monospace, monospace;
    font-size: 0.68rem;
    color: #64748b;
    user-select: none;
    gap: 0;
    flex-shrink: 0;
}
.coord-pair b {
    color: #6366f1;
    font-weight: 700;
    min-width: 2.75rem;
    display: inline-block;
}
.status-msg {
    margin-left: 1rem;
    font-family: system-ui, sans-serif;
    font-size: 0.67rem;
    color: #94a3b8;
    font-style: italic;
}


/* =========================================================================
   KEYBOARD SHORTCUT CHIPS
   ========================================================================= */
.kbd {
    display: inline-block;
    min-width: 1.3rem;
    padding: 1px 4px;
    text-align: center;
    font-size: 0.6rem;
    font-family: ui-monospace, monospace;
    border: 1px solid #cbd5e1;
    border-bottom-width: 2px;
    border-radius: 3px;
    background: #f8fafc;
    color: #64748b;
    line-height: 1.6;
    white-space: nowrap;
}


/* =========================================================================
   TEXT EDITOR OVERLAY
   ========================================================================= */
#textInput {
    min-width: 4rem;
    border: 1.5px solid #6366f1;
    border-radius: 3px;
    background: rgba(255,255,255,0.93);
    padding: 2px 5px;
    outline: none;
    box-shadow: 0 0 0 3px rgba(99,102,241,0.18);
}


/* =========================================================================
   FULL-WIDTH BOTTOM AD BANNER
   =========================================================================
   A leaderboard-style (728×90) ad slot that sits at the very bottom of
   the screen, spanning the full width.
   Replace the placeholder <div> content with your actual ad code.
   ========================================================================= */
#bottomAdBanner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: #f0f4ff;
    border-top: 1px solid #c7d2fe;
    padding: 6px 16px;
    min-height: 72px;         /* comfortable height for a leaderboard */
    z-index: 10;
}

.bottom-ad-label {
    font-size: 0.55rem;
    font-weight: 700;
    color: #a5b4fc;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    flex-shrink: 0;
}

/* Placeholder box — remove once you insert real ad code */
.ad-placeholder-leaderboard {
    flex: 1;
    max-width: 900px;
    min-height: 56px;
    border: 1.5px dashed #a5b4fc;
    border-radius: 8px;
    background: linear-gradient(90deg, #eef2ff 0%, #f5f3ff 50%, #eef2ff 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 200ms, border-color 200ms;
    overflow: hidden;
}
.ad-placeholder-leaderboard:hover {
    background: linear-gradient(90deg, #e0e7ff 0%, #ede9fe 50%, #e0e7ff 100%);
    border-color: #818cf8;
}
.ad-lb-inner {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 24px;
}
.ad-lb-icon {
    font-size: 1.75rem;
    opacity: 0.7;
    flex-shrink: 0;
}
.ad-lb-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.ad-lb-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: #6366f1;
    letter-spacing: -0.01em;
}
.ad-lb-dims {
    font-size: 0.65rem;
    color: #94a3b8;
    font-family: ui-monospace, monospace;
}
.ad-lb-cta {
    font-size: 0.7rem;
    font-weight: 600;
    color: #a5b4fc;
    border: 1px solid #c7d2fe;
    padding: 4px 12px;
    border-radius: 99px;
    white-space: nowrap;
    flex-shrink: 0;
    transition: background 150ms, color 150ms;
}
.ad-placeholder-leaderboard:hover .ad-lb-cta {
    background: #6366f1;
    color: #fff;
    border-color: #6366f1;
}


/* =========================================================================
   PRINT  —  hide all chrome, show only canvas
   ========================================================================= */
@media print {
    #toolsBar, #styleBar, aside, #textInput, #statusBar, #bottomAdBanner {
        display: none !important;
    }
    body, main, #canvasWrap {
        position: static !important;
        overflow: visible !important;
        background: #fff !important;
    }
    #gridLayer, #drawLayer {
        position: static !important;
    }
}
