/* ============================================================
   Web Lab — Emoji Explorer, Range Finder & Code Editor Styles
   ============================================================ */

/* --- Shared: Unicode / Emoji --- */
.snippet-textarea {
    height: 100px;
    font-size: 1.1rem;
    background: #fafafa;
}

.preview-box {
    font-size: clamp(3rem, 15vw, 6rem);
    text-align: center;
    margin: 20px 0;
}

.unicode-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(34px, 1fr));
    gap: 4px;
    background: #fff;
    padding: 8px;
    border-radius: 8px;
    max-height: 500px;
    overflow-y: auto;
    border: 1px solid #eee;
}

.char-tile {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    aspect-ratio: 1;
    background: #fdfdfd;
    border: 1px solid #f0f0f0;
    border-radius: 4px;
    cursor: default;
    transition: background 0.12s, border-color 0.12s;
}

.char-tile:hover {
    background: #ede8f5;
    border-color: var(--primary-purple, #2d1b4e);
}

.gap-after  { border-right: 4px solid var(--accent-magenta) !important; }
.gap-before { border-left:  4px solid var(--accent-magenta) !important; }

.tile-symbol {
    font-size: 1.2rem;
    line-height: 1;
    user-select: none;
}

/* --- Range Finder: nav & stats --- */
.nav-group {
    display: flex;
    gap: 10px;
    margin-top: 15px;
    flex-wrap: wrap;
}

.stats-box {
    margin-top: 15px;
    font-size: 0.85rem;
    color: var(--primary-purple);
    font-weight: 600;
    word-break: break-word;
}

/* --- Emoji error flash animation --- */
.error-flash { animation: flashRed 0.3s; }

@keyframes flashRed {
    0%   { background-color: #fafafa; }
    50%  { background-color: #ffebee; }
    100% { background-color: #fafafa; }
}

/* --- Code Editor (Monaco) --- */

/* The editor container must fill the space between header and footer.
   body is already display:flex flex-direction:column in style.css,
   but the editor uses a <div> not <main>, so we target it explicitly. */
.editor-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding-bottom: 8px;
    min-height: 0;
}

.editor-layout {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    margin-top: 12px;
    gap: 0;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    overflow: hidden;
    border: 1px solid #333;
}

@media (min-width: 1024px) {
    .editor-layout { flex-direction: row; }
}

.editor-side {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 250px;
    background: #1e1e1e;   /* Monaco dark bg */
}

.editor-tabs {
    display: flex;
    background: #252526;
    padding: 0 8px;
    border-bottom: 1px solid #1e1e1e;
    gap: 2px;
    flex-shrink: 0;
}

.tab-btn {
    padding: 10px 18px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    font-family: 'Cascadia Code', 'Fira Code', monospace;
    font-size: 0.85rem;
    color: #858585;
    margin-top: 4px;
    transition: color 0.15s, border-color 0.15s;
    white-space: nowrap;
}

.tab-btn:hover { color: #ccc; }

.tab-btn.active {
    color: #fff;
    border-bottom-color: #007acc;   /* VS Code blue accent */
    background: #1e1e1e;
}

/* editor-core fills remaining height, Monaco panes sit inside */
.editor-core {
    flex: 1;
    position: relative;
    overflow: hidden;
    min-height: 300px;
}

/* Each Monaco pane fills the core absolutely; hidden until active */
.monaco-pane {
    position: absolute;
    inset: 0;
    display: none;
}

.monaco-pane.active { display: block; }

/* Resizer handle */
.resizer {
    display: none;
    width: 5px;
    background: #3c3c3c;
    cursor: col-resize;
    transition: background 0.15s;
    z-index: 10;
    flex-shrink: 0;
}

.resizer:hover,
.resizer.dragging { background: #007acc; }

@media (min-width: 1024px) { .resizer { display: block; } }

.preview-side {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 250px;
    background: #fff;
}

.preview-toolbar {
    display: flex;
    gap: 10px;
    padding: 10px;
    background: #f5f3f8;
    border-bottom: 1px solid #ddd;
    flex-shrink: 0;
}

.preview-frame {
    flex: 1;
    width: 100%;
    border: none;
    background: #fff;
}

/* --- Emoji: info box & code list --- */
.hint {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.info-box {
    font-size: 0.85rem;
    background: #f0f7ff;
    padding: 15px;
    border-left: 4px solid var(--accent-teal);
    border-radius: 4px;
}

.info-cols {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.info-cols > div { flex: 1; min-width: 120px; }

.code-list {
    margin-top: 5px;
    padding-left: 0;
    list-style-type: none;
    line-height: 1.8;
}

/* wave-canvas styles are in science.css */

/* obs-guide styles are in science.css */

/* --- Range Finder: gap legend note --- */
.gap-legend-note {
    font-size: 0.75rem;
    color: #888;
    margin-top: 15px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.gap-swatch {
    display: inline-block;
    width: 10px;
    height: 10px;
    background: var(--accent-magenta);
    flex-shrink: 0;
}

/* ── Editor action toolbar (below Monaco panes) ─────────────── */
.editor-actions {
    display: flex;
    gap: 8px;
    padding: 8px 10px;
    background: #252526;
    border-top: 1px solid #1e1e1e;
    flex-shrink: 0;
}

.ed-action-btn {
    flex: 1;
    padding: 7px 10px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.3px;
    transition: opacity 0.15s, transform 0.1s;
    white-space: nowrap;
}

.ed-action-btn:hover  { opacity: 0.85; }
.ed-action-btn:active { transform: scale(0.97); }

.ed-btn-warn    { background: #a0522d; color: #fff; }
.ed-btn-success { background: #00873c; color: #fff; }
.ed-btn-neutral { background: #3c3c3c; color: #ccc; }

/* ── Save indicator in tab bar ───────────────────────────────── */
.tab-spacer { flex: 1; }

.save-indicator {
    align-self: center;
    padding: 3px 10px;
    font-size: 0.72rem;
    font-family: monospace;
    color: #4ec94e;
    opacity: 0;
    transition: opacity 0.3s;
    white-space: nowrap;
    pointer-events: none;
    user-select: none;
}

.save-indicator.visible { opacity: 1; }

/* ── Reset confirmation modal ────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-overlay[hidden] { display: none; }

.modal-box {
    background: #2d2d2d;
    border: 1px solid #555;
    border-radius: 10px;
    padding: 28px 32px;
    max-width: 420px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
    color: #e0e0e0;
    animation: modal-in 0.15s ease;
}

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

.modal-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 12px;
    color: #f0a040;
}

.modal-body {
    font-size: 0.9rem;
    line-height: 1.6;
    color: #b0b0b0;
    margin-bottom: 22px;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.modal-actions .ed-action-btn {
    flex: 0 0 auto;
    padding: 8px 20px;
    font-size: 0.85rem;
}

/* ================================================================
   Emoji Explorer — layout & components
   ================================================================ */

/* ── Page layout: two columns side by side, stack on mobile ── */
.emoji-layout {
    display: flex;
    gap: 16px;
    margin-top: 16px;
    align-items: flex-start;
}

/* Each column is a flex stack of panels */
.emoji-col {
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-width: 0;
}

.emoji-col-left  { flex: 0 0 280px; }
.emoji-col-right {
    flex: 1 1 360px;
    flex-direction: row;   /* two panels side by side */
    flex-wrap: wrap;
}

/* ── All emoji panels: tighten default padding ── */
.emoji-panel-editor,
.emoji-panel-preview,
.emoji-panel-ref,
.emoji-panel-tones {
    padding: 16px 18px;
    margin-bottom: 0;   /* gap on parent handles spacing */
}

/* Right column panels share width equally and match heights */
.emoji-panel-ref,
.emoji-panel-tones {
    flex: 1 1 200px;
}

.emoji-panel-editor h3,
.emoji-panel-preview h3,
.emoji-panel-ref h3,
.emoji-panel-tones h3 {
    font-size: 1rem;
    margin-bottom: 4px;
}

/* ── Panel 1: Snippet editor ── */
.emoji-input {
    width: 100%;
    font-family: monospace;
    font-size: 0.88rem;
    padding: 8px 10px;
    border: 1px solid #d5cce8;
    border-radius: 6px;
    background: #fdfcff;
    box-sizing: border-box;
    margin-bottom: 10px;
}

.emoji-input:focus {
    outline: 2px solid var(--accent-green);
    border-color: var(--accent-green);
}

.emoji-random-btn {
    background: var(--accent-green, #00873c) !important;
    font-size: 0.85rem;
    min-height: 38px;
    padding: 6px 12px;
}

/* ── Panel 2: Live preview ── */
.emoji-panel-preview {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.emoji-preview-box {
    font-size: clamp(4rem, 8vw, 7rem);
    line-height: 1.1;
    padding: 16px 0 10px;
    min-height: 90px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
}

.current-code-box {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 11px;
    background: #f0f7ff;
    border-left: 4px solid var(--accent-teal, #0097a7);
    border-radius: 6px;
    font-size: 0.8rem;
    flex-wrap: wrap;
    row-gap: 2px;
    width: 100%;
}

.current-code-label {
    color: var(--text-muted);
    font-weight: 600;
    white-space: nowrap;
}

.current-code-box code {
    font-size: 0.82rem;
    color: var(--accent-magenta, #c2185b);
    word-break: break-all;
}

/* ── Shared table styles (panels 3 & 4) ── */
.emoji-ref-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.78rem;
    margin-top: 8px;
}

.emoji-ref-table th {
    background: #ede8f5;
    color: var(--primary-purple, #2d1b4e);
    font-weight: 700;
    padding: 5px 8px;
    text-align: left;
    border-bottom: 2px solid #d5cce8;
    white-space: nowrap;
}

.emoji-ref-table td {
    padding: 3px 8px;
    border-bottom: 1px solid #f0ecf8;
    vertical-align: middle;
}

.emoji-ref-table tr:last-child td { border-bottom: none; }
.emoji-ref-table tr:hover td { background: #faf8ff; }

.ref-emoji { font-size: 1.1rem; text-align: center; width: 30px; }
.ref-name  { color: var(--text-muted); font-size: 0.74rem; }
.ref-code  { white-space: nowrap; }
.ref-code code { font-size: 0.72rem; }
.tone-result { font-size: 1.15rem; text-align: center; }

/* Swatch dot */
.swatch-dot {
    display: inline-block;
    width: 17px;
    height: 17px;
    border-radius: 50%;
    border: 1.5px solid rgba(0,0,0,0.15);
    vertical-align: middle;
}

/* ── Panel 4: Skin-tone modifiers ── */
.skin-tone-panel { border-top-color: var(--accent-magenta, #c2185b) !important; }

.skin-tone-example-box {
    margin-top: 10px;
    padding: 8px 10px;
    background: #f9f6ff;
    border-left: 3px solid var(--accent-magenta, #c2185b);
    border-radius: 5px;
    font-size: 0.74rem;
}

.skin-tone-example-box strong { display: block; margin-bottom: 5px; font-size: 0.78rem; }
.skin-tone-examples { display: flex; flex-direction: column; gap: 3px; }

.tone-snippet { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }

.tone-snippet-label {
    color: var(--text-muted);
    font-weight: 600;
    min-width: 64px;
    flex-shrink: 0;
    font-size: 0.71rem;
}

.tone-snippet-code {
    font-size: 0.69rem;
    color: var(--primary-purple, #2d1b4e);
    word-break: break-all;
}

/* ── No-cheating toast ── */
.cheat-toast {
    position: fixed;
    bottom: 28px;
    left: 50%;
    transform: translateX(-50%) translateY(16px);
    background: #2d1b4e;
    color: white;
    padding: 12px 22px;
    border-radius: 10px;
    font-size: 0.92rem;
    font-weight: 600;
    box-shadow: 0 8px 30px rgba(0,0,0,0.3);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s, transform 0.22s;
    z-index: 999;
    text-align: center;
    max-width: 90vw;
}

.cheat-toast code {
    background: rgba(255,255,255,0.15);
    padding: 1px 5px;
    border-radius: 4px;
    color: #9be7ff;
}

.cheat-toast.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ── Mobile: stack all four panels in one column ── */
@media (max-width: 700px) {
    .emoji-layout,
    .emoji-col-right {
        flex-direction: column;
    }
    .emoji-col-left,
    .emoji-col-right,
    .emoji-panel-ref,
    .emoji-panel-tones {
        flex: 1 1 auto;
        width: 100%;
    }
}



/* ── Emoji Explorer fixes ──────────────────────────────────── */

/* Larger gap between emoji display and code box */
.emoji-preview-box {
    margin-bottom: 20px !important;
}

/* Bigger font in reference and tone tables */
.emoji-ref-table td,
.emoji-ref-table th {
    font-size: 0.88rem !important;
    padding: 5px 10px !important;
}
.ref-emoji  { font-size: 1.3rem !important; }
.ref-name   { font-size: 0.82rem !important; }
.ref-code   { font-size: 0.82rem !important; }
.ref-code code { font-size: 0.8rem !important; }

/* Hide the "Try it" skin-tone example box */
.skin-tone-example-box { display: none !important; }

/* Left column stretches so preview panel matches reference panel bottom */
.emoji-col-left {
    align-self: stretch;
}
.emoji-panel-preview {
    flex: 1 !important;   /* grow to fill remaining left column height */
}

/* ── Unicode Range Finder fixes ────────────────────────────── */

/* Prev/Next buttons already side-by-side via btn-group — ensure 50/50 */
.btn-group .nav-btn { flex: 1 1 0; }

/* "Find 255" button distinct colour */
#search-btn {
    background: var(--accent-teal) !important;
}

/* Narrow settings column — flex column so inner panel fills height */
.range-controls {
    flex: 0 0 200px !important;
    min-width: 160px !important;
    display: flex;
    flex-direction: column;
}

.range-controls .panel {
    flex: 1;
    overflow-y: auto;
    box-sizing: border-box;
}

/* Character preview panel fills remaining height */
.range-split {
    display: flex;
    gap: 20px;
    margin-top: 12px;
    align-items: stretch;   /* let style.css rule land, but be explicit here too */
}

.range-visual {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.range-visual h3 { flex-shrink: 0; }

#unicode-grid {
    flex: 1;
    max-height: none !important;
    overflow-y: auto;
}
