/* 
   1. UNIFONT EX - RESTRICTED TO BLOCKS
   unicode-range: U+2580-259F
   size-adjust: 120% (Stretches width to match Noto)
   ascent-override: 60% (Drastically lowers the visual center of blocks)
*/
@font-face {
  font-family: 'UnifontEX';
  font-style: normal;
  font-display: swap;
  font-weight: 400;
  src: url(https://cdn.jsdelivr.net/fontsource/fonts/unifontex@latest/latin-400-normal.woff2) format('woff2'), url(https://cdn.jsdelivr.net/fontsource/fonts/unifontex@latest/latin-400-normal.woff) format('woff');
  unicode-range: U+2580-259F;
  size-adjust: 120%; 
  ascent-override: 60%;
}

:root {
    --bg-color: #0a0a0a;
    --text-color: #d4d4d4;
    --accent-color: #a0a0a0;
    --dim-color: #404040;
    --selection-bg: #d32f2f;
    --selection-text: #ffffff;
    
    /* Post-it Theme */
    --note-bg: rgba(26, 26, 26, 0.80);
    --note-header: #252525;
    --note-border: #404040;
    --note-text: #d4d4d4;
    --note-shadow: 0 4px 20px rgba(0,0,0,0.5);
    
    /* 
       THE STABILITY STACK:
       1. UnifontEX (Blocks only)
       2. Noto Sans Mono (Stable primary text)
       3. Noto Symbols (Google's comprehensive set)
       4. Noto Symbols 2 (Extended set)
       5. System Monospace Stack 
    */
    --font-main: 'UnifontEX', 'Noto Sans Mono', 'Noto Sans Symbols', 'Noto Sans Symbols 2', Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
    
    --font-reading-size: 2.1vmin; 
    --line-height: 1.6;
}

/* --- THEMES --- */

[data-theme="light"] {
    --bg-color: #f5f5f5;
    --text-color: #1a1a1a;
    --accent-color: #555555;
    --dim-color: #777777; 
    --selection-bg: #d32f2f;
    --selection-text: #ffffff;
    
    --note-bg: rgba(255, 255, 255, 0.80);
    --note-header: #e0e0e0;
    --note-border: #cccccc;
    --note-text: #1a1a1a;
    --note-shadow: 0 4px 20px rgba(0,0,0,0.1);
}

[data-theme="burgundy"] {
    --bg-color: #2d0a0a;
    --text-color: #ffd1d1;
    --accent-color: #ff4d4d;
    --dim-color: #5d1212;
    --selection-bg: #ff4d4d;
    --selection-text: #ffffff;
    
    --note-bg: rgba(45, 10, 10, 0.80);
    --note-header: #4a0e0e;
    --note-border: #5d1212;
    --note-text: #ffd1d1;
    --note-shadow: 0 4px 20px rgba(0,0,0,0.5);
}

[data-theme="burgundy-light"] {
    --bg-color: #fff0f0;
    --text-color: #4a0e0e;
    --accent-color: #8b0000;
    --dim-color: #ffcccc;
    --selection-bg: #d32f2f;
    --selection-text: #ffffff;
    
    --note-bg: rgba(255, 240, 240, 0.80);
    --note-header: #ffcccc;
    --note-border: #ff9999;
    --note-text: #4a0e0e;
    --note-shadow: 0 4px 20px rgba(0,0,0,0.1);
}

::selection {
    background: var(--selection-bg);
    color: var(--selection-text);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: var(--font-main);
    overflow: hidden;
    width: 100vw;
    height: 100vh;
    
    /* Startup Fade Mechanics */
    opacity: 0;
    animation: pageEntry 0.4s ease-out forwards;
    
    /* Smooth theme transitions after load */
    transition: background-color 0.8s ease, color 0.8s ease;
}

@keyframes pageEntry {
    0% { opacity: 0; }
    100% { opacity: 1; }
}

/* Hide Fullscreen button on Desktop globally */
#sep-fs, #btn-fullscreen {
    display: none !important;
}

/* --- Settings Menu Structural Helpers --- */
.mobile-setting { display: none !important; }
.settings-mobile-layout { display: contents; }
.settings-left { display: contents; }

/* Force elements to use the variable stack */
pre, textarea, input, select, button {
    font-family: var(--font-main);
}

/* UI Lock */
body.ui-locked button, 
body.ui-locked .overlay,
body.ui-locked .note {
    pointer-events: none !important;
    opacity: 0.5;
    transition: opacity 0.3s;
}

/* ASCII Backdrop */
#ascii-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    font-size: 14px;
    line-height: 1;
    opacity: 0; /* Default to invisible to prevent flash-on-load */
    overflow: hidden;
    color: var(--text-color);
    background-color: var(--bg-color);
    transition: opacity 0.5s ease, background-color 0.8s ease, color 0.8s ease;
    white-space: pre;
    font-family: 'Courier New', Courier, monospace; 
}

/* Custom Tooltip */
#global-tooltip {
    position: fixed;
    pointer-events: none;
    background: var(--note-bg);
    color: var(--note-text);
    border: 1px solid var(--note-border);
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
    z-index: 1000;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
    white-space: normal; /* Allow wrapping/breaks */
    text-align: center;  /* Center the text */
    line-height: 1.4;    /* Better spacing for multi-line */
    opacity: 0;
    transition: opacity 0.15s ease, transform 0.15s ease;
    transform: translate(-50%, -100%); 
    margin-top: -10px;
}
#global-tooltip.visible {
    opacity: 1;
}

/* Notes Layer */
#notes-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 50;
    pointer-events: none;
    overflow: hidden;
}

/* Main App */
#app {
    position: relative;
    z-index: 10;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* Allow pointer events for specific UI elements */
button, input, #composition-wrapper, .overlay, select, #intro-content {
    pointer-events: auto;
}

section {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none; /* Prevent clicks on hidden screens */
    transition: opacity 0.5s ease;
}

section.active { 
    opacity: 1; 
    pointer-events: auto; /* Re-enable clicks when active */
    z-index: 20; 
}

/* STATIC TITLE LAYOUT - FLEXBOX FIX */
h1.project-title {
    font-size: 8vw;
    font-weight: 700;
    margin-bottom: 4rem;
    white-space: nowrap;
    line-height: 1; 
    
    /* NEW: Use Flexbox Gap instead of letter-spacing */
    display: flex;
    justify-content: center;
    gap: 1.5rem; 
}

/* Individual spans allow scrambling without layout breaking */
h1.project-title span {
    display: flex; /* Center the glyph inside the box */
    justify-content: center;
    align-items: center;
    
    /* Fix clipping and stretching */
    width: 1.2ch; 
    height: 1.2em; 
    line-height: 1; 
    overflow: visible; 
    
    /* Reset weight to avoid synthetic bolding on blocks */
    font-weight: normal;
    
    text-align: center;
}

button {
    background: none;
    border: none;
    color: var(--accent-color);
    font-family: var(--font-main);
    cursor: pointer;
    font-size: 1.2rem;
    padding: 0.5rem 1rem;
    transition: color 0.2s ease;
}

button:hover { color: var(--text-color); }
button.active { color: var(--text-color); font-weight: bold; }
button.danger { color: #d32f2f; }

.icon-btn {
    font-size: 1.4rem;
    padding: 0.2rem 0; 
    line-height: 1;
    vertical-align: middle;
    width: 48px; 
    min-width: 48px; 
    text-align: center;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    overflow: hidden; 
}

/* AI Indicator & Skip Button - Symmetrical */
#nav-skip, #ai-indicator {
    position: absolute;
    top: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    transition: opacity 0.3s ease, color 0.2s ease;
}

#nav-skip {
    left: 100%;
    margin-left: 2.5rem; 
    color: #d32f2f;
    opacity: 0;
    pointer-events: none;
    white-space: nowrap;
}
#nav-skip.visible {
    opacity: 1;
    pointer-events: auto;
}
    /* Override for visible skip (higher specificity beats display:none) */
    .footer-center #nav-skip.visible {
        display: flex;
    }

#nav-skip:hover { color: var(--text-color); }

#ai-indicator {
    right: 100%;
    margin-right: 2.5rem;
    color: var(--selection-bg); /* Use selection red/white */
    opacity: 0; 
    pointer-events: auto;
    cursor: help;
}
#ai-indicator.visible {
    opacity: 1;
}
#ai-indicator:hover { 
    opacity: 0.8; 
}

.separator {
    color: var(--dim-color);
    margin: 0 0.5rem;
}

/* --- INTRO SEQUENCE REWORK --- */
#intro-sequence .intro-controls {
    display: none; /* Hide old buttons */
}

#intro-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    max-width: 800px;
    width: 90%;
    min-height: 400px; /* Use min-height for flexibility */
    transition: opacity 0.2s ease-in-out;
}

#intro-content.fading-out {
    opacity: 0;
}

.intro-title {
    font-size: 1.4rem;
    font-weight: bold;
    color: var(--accent-color);
    letter-spacing: 0.2em;
    text-transform: uppercase;
    margin-bottom: 2rem;
    margin-top: 1rem;
}

.intro-text {
    font-size: 1.1rem;
    line-height: 1.8;
    white-space: normal; /* Allow text to wrap naturally */
    margin-bottom: 2rem;
    max-width: 600px;
    user-select: text; /* ENABLE SELECTION */
}

.intro-link {
    cursor: pointer;
    color: var(--text-color);
    font-weight: bold;
    border-bottom: 1px solid var(--accent-color);
    transition: color 0.2s, border-color 0.2s;
}
.intro-link:hover {
    color: var(--selection-bg);
    border-bottom-color: var(--selection-bg);
}

.intro-example {
    font-size: var(--font-reading-size);
    line-height: var(--line-height);
    letter-spacing: 0.05em;
    white-space: pre;
    display: flex;
    align-items: flex-start; /* FIX: Anchor Geode to top */
    justify-content: center;
    width: auto; /* Let it size to content */
    margin-bottom: 2.5rem; /* Added spacing */
}

.intro-example pre {
    text-align: left; /* Align multi-line geodes correctly */
}

/* Loading Screen */
#loading-screen {
    background: var(--bg-color); 
    z-index: 30;
    transition: background-color 0.8s ease;
}

#loader-display { 
    font-size: var(--font-reading-size);
    line-height: var(--line-height);
    color: var(--text-color);
    white-space: pre;
    text-align: left;
    display: inline-block;
    margin: 0 auto; 
    transition: opacity 0.5s ease;
}

/* READER LAYOUT */

#composition-wrapper {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center; /* Center Vertically */
    align-items: center;     /* Center Horizontally */
    width: 100%;
    padding: 0 2rem; 
    overflow: hidden;
    position: relative; 
}

/* 
   New Anchor Layout:
   The anchor holds the pre and title.
   It has position: relative to contain the absolute title.
   It is a flex item of composition-wrapper, so it stays centered.
*/
#composition-anchor {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 100%;
}

#composition-display {
    font-size: var(--font-reading-size);
    line-height: var(--line-height);
    letter-spacing: 0.05em;
    white-space: pre;
    text-align: left;
    user-select: text;
    display: block; /* Ensure it behaves as a block within flex */
    /* No margin auto needed here, parent flex handles it */
    transition: opacity 0.5s ease;
}

/* Title hangs off the bottom of the anchor */
#title-container {
    position: absolute;
    top: 100%; /* Push below passage */
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 800px;
    text-align: center;
    padding-top: 2.5rem; /* Gap between passage and title */
}

#composition-title {
    font-size: calc(var(--font-reading-size) * 0.7); 
    color: var(--dim-color);
    cursor: pointer;
    transition: color 0.3s ease, opacity 0.5s ease;
    
    /* JITTER FIX: Lock the geometry of the title */
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 1.5em; /* Ensure it occupies space even if empty */
    line-height: 1.5; /* Strict line height */
    
    letter-spacing: 0.1em;
    opacity: 0;
    user-select: text;
}

#composition-title:hover {
    color: var(--accent-color);
}

#composition-title.revealed {
    color: var(--text-color);
    opacity: 0.8 !important;
}

#composition-title.hidden {
    display: none !important;
}

/* UNIFIED FOOTER */
#reader-footer {
    width: 100%;
    height: 80px; 
    display: flex; 
    justify-content: space-between;
    align-items: center;
    padding: 0 2rem;
    position: absolute;
    bottom: 0;
    left: 0;
    z-index: 40;
    pointer-events: none; /* Let clicks pass through empty space */
}

#reader-footer > * {
    pointer-events: auto; /* Re-enable pointer events for children */
}

/* Title/Intro Mode: Hide center passage navigation arrows */
.view-title #reader-footer .footer-center .nav-btn {
    opacity: 0;
    pointer-events: none;
}
.view-intro #reader-footer .footer-center #nav-random {
    font-size: 1.4rem; /* Match other icons */
}


.footer-left, .footer-center, .footer-right {
    flex: 1;
    display: flex;
    align-items: center;
}

.footer-left {
    justify-content: flex-start;
    gap: 0.5rem;
}

.footer-left .separator {
    margin: 0 1rem;
}

.footer-center {
    justify-content: center;
    position: relative; 
    gap: 3rem; 
}

.footer-right {
    justify-content: flex-end;
}

.version-info {
    font-size: 0.8rem;
    color: var(--dim-color);
    opacity: 0.6;
    text-decoration: none !important;
    border: none !important;
    outline: none !important;
    pointer-events: auto; 
    transition: opacity 0.2s ease, color 0.2s ease;
}

.version-info:hover {
    opacity: 1;
    color: var(--accent-color);
    text-decoration: none !important;
    border: none !important;
}

/* UI Corners Top */
.ui-corner {
    position: absolute;
    padding: 2rem;
    z-index: 60; /* Bumped above Notes Layer (50) */
}
.top-right { top: 0; right: 0; }
.top-left { top: 0; left: 0; }

.filters {
    display: flex;
    align-items: center; /* Center boxes */
    gap: 0.5rem;
}

.filter-btn {
    font-weight: normal;
    opacity: 0.3;
    font-size: 1.2rem; 
    /* Flex Box force vertical centering of glyphs */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 32px; /* Fixed height container */
    padding: 0 0.5rem; 
    border: 1px solid transparent; 
    line-height: 1;
}
.filter-btn.active { 
    opacity: 1; 
    border-bottom: 2px solid var(--text-color); 
    font-weight: normal;
}

/* Geode Symbol Size */
.filter-btn[data-type="geode"] {
    font-size: 0.95em; 
}

#nav-fav.favorited {
    color: var(--text-color); 
}

/* Overlays */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    z-index: 100;
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(5px);
}
[data-theme="light"] .overlay { background: rgba(255, 255, 255, 0.95); }
.overlay.hidden { display: none; }

.mobile-setting {
    display: none;
}

.overlay-content {
    background: transparent;
    text-align: center;
    max-width: 600px;
    padding: 2rem;
    font-size: 1.2rem;
    
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    height: 70vh;
}

.settings-list {
    width: 400px;
    height: auto;
    max-height: 80vh;
    justify-content: center;
}

.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    min-height: 40px; /* Ensure uniform height */
}

.setting-row.note-size-row {
    margin-bottom: 1.5rem; /* Reduced to match standard */
}

.list-tabs {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--dim-color);
    padding-bottom: 1rem;
    flex-shrink: 0;
}

.scroll-list {
    flex-grow: 1;
    overflow-y: auto;
    text-align: left;
    padding: 1rem;
    background: rgba(255,255,255,0.05);
    border-radius: 4px;
    scrollbar-width: thin;
    scrollbar-color: var(--accent-color) transparent;
}

.list-item {
    padding: 1rem 0.8rem;
    cursor: pointer;
    border-bottom: 1px solid var(--dim-color);
    transition: background 0.2s;
    font-size: 0.9rem;
    
    white-space: pre; 
    font-family: var(--font-main);
    overflow-x: auto; 
    overflow-y: hidden;
}
.list-item:hover { background: rgba(255,255,255,0.1); }

/* --- SMILEY ANNOTATIONS / POST-IT SYSTEM --- */

.sa-global-dragging, .sa-global-dragging * { 
    user-select: none !important; 
    cursor: grabbing !important; 
}

.sa-icon {
    width: 14px;
    height: 14px;
    pointer-events: none;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.sa-note {
    position: absolute;
    display: block;
    background: transparent !important;
    border: none !important;
    pointer-events: auto;
    min-height: 28px !important;
    max-height: 95vh;
    box-sizing: border-box !important;
    overflow: visible !important;
}

.sa-note-visual {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    background: var(--note-bg) !important;
    color: var(--note-text) !important;
    border: 1px solid var(--note-border) !important;
    box-shadow: var(--note-shadow);
    border-radius: 4px;
    overflow: hidden;
    backdrop-filter: blur(10px);
    transition: opacity 0.4s ease, box-shadow 0.2s;
}

.sa-note.sa-selected .sa-note-visual {
    box-shadow: 0 8px 24px rgba(0,0,0,0.45);
}

.sa-note.sa-group-selected .sa-note-visual {
    box-shadow: 0 8px 24px rgba(0,0,0,0.45);
    border-color: var(--accent-color) !important;
}

.sa-note.sa-closing {
    pointer-events: none;
}
.sa-note.sa-closing .sa-note-visual {
    opacity: 0;
    filter: blur(15px);
    transition: opacity 0.3s ease, filter 0.3s ease;
}

.sa-animating-height {
    transition: height 0.4s cubic-bezier(0.2, 0.8, 0.2, 1), top 0.4s cubic-bezier(0.2, 0.8, 0.2, 1) !important;
}

.sa-resizing {
    transition: none !important;
    animation: none !important;
}

.sa-note.sa-dragging {
    transition: transform 0.15s cubic-bezier(0.2, 0.8, 0.2, 1) !important;
}

.sa-note.sa-minimized .sa-note-visual {
    overflow: hidden;
}

.sa-note.sa-minimized .sa-body {
    height: 0 !important;
    padding: 0 !important;
    opacity: 0;
    pointer-events: none;
}

.sa-note.sa-minimized .sa-resize-handle {
    display: none !important;
}

.sa-header {
    height: 28px;
    background: var(--note-header) !important;
    display: flex;
    align-items: center;
    padding: 0 8px;
    cursor: grab;
    user-select: none;
    flex-shrink: 0;
    width: 100%;
    box-sizing: border-box;
    border-bottom: 1px solid var(--note-border);
}

.sa-header:active {
    cursor: grabbing;
}

.sa-collapsed-title {
    font-weight: 700;
    font-size: 12px;
    color: var(--note-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-grow: 1;
    pointer-events: none;
    opacity: 0.5;
    margin-left: 8px;
}

.sa-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
    z-index: 2;
}

.sa-btn {
    background: none !important;
    border: none;
    padding: 2px;
    border-radius: 2px;
    cursor: pointer;
    opacity: 0.4;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--note-text) !important;
    transition: opacity 0.2s ease, background-color 0.2s;
}

.sa-btn:hover {
    opacity: 1;
    background: rgba(255,255,255,0.1) !important;
}

.sa-body {
    flex-grow: 1;
    position: relative;
    min-height: 0;
    overflow: hidden; /* Added overflow hidden */
}

.sa-watermark {
    position: absolute;
    top: 57%; /* Visual compensation for high baselines */
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 120px;
    line-height: 1; /* Crushes extra vertical space */
    opacity: 0.05;
    pointer-events: none;
    color: var(--note-text);
    font-family: 'Noto Sans Symbols 2', 'UnifontEX', sans-serif;
    z-index: 0;
    white-space: nowrap;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sa-raw-editor {
    width: 100%;
    height: 100%;
    border: none;
    background: transparent;
    resize: none;
    padding: 12px;
    font-family: var(--font-main);
    font-size: 13px;
    color: var(--note-text);
    outline: none;
    box-sizing: border-box;
    line-height: 1.5;
    scrollbar-width: none;
    user-select: text;
    z-index: 1;
    position: relative;
}
.sa-raw-editor::-webkit-scrollbar { display: none; }

.sa-note[data-size="small"] .sa-raw-editor { font-size: 11px; }
.sa-note[data-size="medium"] .sa-raw-editor { font-size: 13px; }
.sa-note[data-size="big"] .sa-raw-editor { font-size: 16px; }

.sa-resize-handle {
    position: absolute;
    z-index: 100;
    touch-action: none;
}

.sa-resize-br { bottom: -10px; right: -10px; width: 30px; height: 30px; cursor: nwse-resize; z-index: 102; }
.sa-resize-bl { bottom: -10px; left: -10px; width: 30px; height: 30px; cursor: nesw-resize; z-index: 102; }
.sa-resize-tr { 
    top: -5px; 
    right: -5px; 
    width: 10px; 
    height: 10px; 
    cursor: nesw-resize; 
    z-index: 102; 
}
.sa-resize-tl { top: -10px; left: -10px; width: 30px; height: 30px; cursor: nwse-resize; z-index: 102; }

.sa-resize-b { bottom: -8px; left: 10px; right: 10px; height: 16px; cursor: ns-resize; z-index: 101; }
.sa-resize-r { top: 10px; bottom: 10px; right: -8px; width: 16px; cursor: ew-resize; z-index: 101; }
.sa-resize-l { top: 10px; bottom: 10px; left: -8px; width: 16px; cursor: ew-resize; z-index: 101; }
.sa-resize-t { top: -8px; left: 10px; right: 10px; height: 16px; cursor: ns-resize; z-index: 101; }

/* Startup Fade Utility */
.startup-fade {
    animation: fadeEntry 2s ease-out forwards;
}

@keyframes fadeEntry {
    0% { opacity: 0; }
    100% { opacity: 1; }
}

/* CLOCK STYLES */
#clock-display {
    position: fixed;
    top: 22vh;
    left: 50%;
    transform: translateX(-50%);
    
    font-family: var(--font-main);
    font-size: 13vmin; /* Significantly bigger */
    font-weight: normal; 
    line-height: 1;
    color: var(--dim-color);
    
    /* Layout Logic matching Title Screen */
    display: flex;
    justify-content: center;
    gap: 1rem; /* Distinct spacing between digits */
    
    opacity: 0;
    transition: opacity 0.5s ease, color 0.5s ease;
    user-select: none;
    
    z-index: 35;
    pointer-events: none; 
}

#clock-display.visible {
    opacity: 0.8; /* Much more visible in Dark Mode */
}

/* Light Mode adjustments */
[data-theme="light"] #clock-display.visible {
    opacity: 0.5; /* Balanced for light backgrounds */
    color: var(--dim-color);
}

.clock-digit {
    /* Exact Title Screen geometry to prevent block overlap */
    display: flex;
    justify-content: center;
    align-items: center;
    
    width: 1.2ch; /* Sufficient width for block chars */
    height: 1.2em;
    overflow: visible;
}

.setting-row.disabled {
    opacity: 0.3;
    pointer-events: none;
    filter: grayscale(1);
}



/* --- ABOUT & SUBTITLE STYLING --- */

.subtitle {
    margin-top: -3rem; 
    margin-bottom: 3rem;
    font-size: 1rem;
    color: var(--dim-color);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    text-align: center;
}

.stealth-link {
    color: inherit;
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: color 0.2s, border-color 0.2s;
}
.stealth-link:hover {
    color: var(--accent-color);
    border-bottom-color: var(--accent-color);
}

.about-split-layout {
    display: flex;
    flex-direction: row;
    width: 800px;
    max-width: 90vw;
    height: auto;
    min-height: 400px;
    align-items: stretch;
    background: transparent;
    padding: 0;
}

/* LEFT PANEL */
.about-left {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border-right: 1px solid var(--dim-color);
    padding: 2rem;
}

#about-symbol-display {
    font-size: 8rem;
    line-height: 1;
    color: var(--text-color);
    margin-bottom: 2rem;
    font-family: var(--font-main);
    min-height: 1.2em;
    display: flex;
    justify-content: center;
    align-items: center;
}

.about-brand {
    font-size: 1.2rem;
    letter-spacing: 0.3em;
    color: var(--text-color); /* Full opacity */
    font-weight: bold;
}

/* RIGHT PANEL */
.about-right {
    flex: 1.2; 
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 3rem;
    text-align: center;
}

.about-avatar-link {
    display: block;
    cursor: pointer;
    transition: opacity 0.2s;
}
.about-avatar-link:hover {
    opacity: 0.8;
}

.about-avatar {
    width: 110px; /* Bigger */
    height: 110px;
    border-radius: 50%;
    margin-bottom: 1.5rem;
    border: none; /* No outline */
    box-shadow: none; /* No shadow */
}

.about-header {
    font-size: 1.2rem;
    letter-spacing: 0.2em;
    margin-bottom: 1.5rem;
    color: var(--text-color);
    font-weight: bold;
    text-transform: uppercase;
}

.about-text {
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--text-color);
    margin-bottom: 2rem;
}
.about-text p { margin-bottom: 0.8rem; }
.about-text em { 
    color: var(--dim-color); /* Lighter grey */
    font-style: italic; /* Actual Italics */
}

.social-row {
    display: flex;
    justify-content: center;
    gap: 1.2rem;
    margin-bottom: 2rem;
}

.social-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    color: var(--dim-color);
    transition: color 0.3s ease;
}
.social-icon:hover {
    color: var(--selection-bg); /* Match selected text color */
    transform: none; /* No movement */
}

.credit-text {
    font-size: 0.75rem;
    color: var(--dim-color);
    margin-bottom: 2rem;
    line-height: 1.4;
}
.credit-text p { margin-bottom: 0.2rem; }
.credit-text a {
    color: var(--accent-color);
    text-decoration: none;
    border-bottom: 1px dotted var(--accent-color);
}
.credit-text a:hover {
    color: var(--text-color);
    border-bottom-style: solid;
}

#btn-close-about {
    margin-top: auto;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .about-split-layout {
        flex-direction: column;
        width: 100%;
        height: auto;
        max-height: 90vh;
        overflow-y: auto;
    }
    .about-left {
        border-right: none;
        border-bottom: 1px solid var(--dim-color);
        padding: 2rem 1rem;
        flex: 0 0 auto;
    }
    #about-symbol-display { font-size: 5rem; margin-bottom: 1rem; }
    .about-right { padding: 2rem 1rem; }
}

/* Slider Styling - True Unicode Character Aesthetic */
input[type=range] {
    -webkit-appearance: none;
    width: 140px; /* Slightly wider to show off chars */
    background: transparent;
    vertical-align: middle;
    font-size: 16px; /* Controls size of track chars */
}

input[type=range]:focus { outline: none; }

/* Track - Repeating '░' Character via SVG */
input[type=range]::-webkit-slider-runnable-track {
    width: 100%;
    height: 20px;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='20'%3E%3Ctext x='50%25' y='60%25' dominant-baseline='middle' text-anchor='middle' font-family='monospace' font-weight='bold' fill='%23555555'%3E░%3C/text%3E%3C/svg%3E");
    background-repeat: repeat-x;
    background-position: center;
    border: none;
}
input[type=range]::-moz-range-track {
    width: 100%;
    height: 20px;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='20'%3E%3Ctext x='50%25' y='60%25' dominant-baseline='middle' text-anchor='middle' font-family='monospace' font-weight='bold' fill='%23555555'%3E░%3C/text%3E%3C/svg%3E");
    background-repeat: repeat-x;
    background-position: center;
    border: none;
}

/* Thumb - Solid Block */
input[type=range]::-webkit-slider-thumb {
    height: 16px;
    width: 12px; /* Roughly char width */
    background: var(--text-color);
    cursor: pointer;
    -webkit-appearance: none;
    margin-top: 2px; /* Align with text baseline */
    border: none;
    border-radius: 0;
    box-shadow: none;
}
input[type=range]::-moz-range-thumb {
    height: 16px;
    width: 12px;
    background: var(--text-color);
    cursor: pointer;
    border: none;
    border-radius: 0;
    box-shadow: none;
}



/* Home Button Logic */
#nav-home {
    transition: opacity 0.3s, color 0.3s;
}

/* When on title screen (parent class added by JS) */
.view-title #nav-home {
    opacity: 0.2;
    pointer-events: none;
    filter: grayscale(100%);
}

/* ==========================================
   MOBILE RESPONSIVENESS & PROMPT STYLES
   ========================================== */

/* --- Mobile Prompt --- */
body.prompt-active {
    overflow: hidden !important;
    height: 100vh !important;
    width: 100vw !important;
}

#landscape-prompt {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 9999;
    background: var(--bg-color);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    pointer-events: all;
}

#landscape-prompt.hidden {
    display: none !important;
}

.landscape-prompt-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    text-align: center;
    padding: 2rem;
    max-width: 300px;
}

.landscape-prompt-icon {
    font-size: 4rem;
    color: var(--dim-color);
    display: inline-block;
    line-height: 1;
    transform-origin: center center;
    will-change: transform;
}

.landscape-prompt-icon.rotating {
    animation: promptRotate 2.5s ease-in-out infinite;
}

@keyframes promptRotate {
    0%, 100% { transform: rotate(0deg); }
    50% { transform: rotate(90deg); }
}

.landscape-prompt-text {
    font-size: 1rem;
    color: var(--accent-color);
    line-height: 1.6;
    letter-spacing: 0.05em;
}

body.prompt-active #app, 
body.prompt-active #ascii-backdrop, 
body.prompt-active #notes-layer {
    opacity: 0;
    pointer-events: none;
}

/* Only rotate if JS adds this class */
.landscape-prompt-icon.rotating {
    animation: promptRotate 2.5s ease-in-out infinite;
}

@keyframes promptRotate {
    0%, 100% { transform: rotate(0deg); }
    50% { transform: rotate(90deg); }
}

.landscape-prompt-text {
    font-size: 1rem;
    color: var(--accent-color);
    line-height: 1.6;
    letter-spacing: 0.05em;
}

/* Hide the rest of the app when prompt is active */
body.prompt-active #app, 
body.prompt-active #ascii-backdrop, 
body.prompt-active #notes-layer {
    opacity: 0;
    pointer-events: none;
}

/* --- Hide filters on title screen --- */
.view-title .ui-corner.top-left {
    display: none;
}

/* --- Mobile / Narrow Viewports --- */
@media (max-width: 1024px) and (pointer: coarse) {
    /* Post-it notes */
    #notes-layer {
        display: none;
    }

    /* Top-right buttons: keep Settings and Fullscreen on mobile */
    #btn-add-note,
    #btn-add-note + .separator,
    #btn-lists,
    #sep-home,
    #nav-home {
        display: none !important;
    }

    #sep-fs {
        display: inline-block !important;
    }

    #btn-fullscreen {
        display: inline-flex !important;
    }

    /* Favorites button */
    #nav-fav {
        display: none;
    }

    /* Filter bar: hide journey + its separator */
    .filter-btn[data-type="journey"],
    .filter-btn[data-type="journey"] + .separator {
        display: none;
    }

    /* Footer: strip down to version info only */
    #reader-footer {
        padding: 0 0.75rem;
        height: 60px;
    }

    .footer-left {
        display: none;
    }

    .footer-center {
        position: static;
        gap: 0;
    }

    /* Hide random, AI indicator, and skip from normal flow */
    #nav-random,
    #ai-indicator,
    #nav-skip {
        display: none;
    }

    /* Back arrow: fixed left edge, vertically centered */
    #nav-back {
        position: fixed;
        left: 0.75rem;
        top: 50%;
        transform: translateY(-50%);
        z-index: 60;
        font-size: 1.6rem;
        width: 48px;
        height: 48px;
    }

    /* Forward arrow: fixed right edge, vertically centered */
    #nav-forward {
        position: fixed;
        right: 0.75rem;
        top: 50%;
        transform: translateY(-50%);
        z-index: 60;
        font-size: 1.6rem;
        width: 48px;
        height: 48px;
    }

    /* Skip journey: Force it to break out of footer and pin under the forward arrow */
    #reader-footer #nav-skip.visible {
        display: flex !important;
        justify-content: center !important;
        align-items: center !important;
        width: 48px !important;
        position: fixed !important;
        right: 0.75rem !important;
        left: auto !important;
        top: calc(50% + 55px) !important;
        bottom: auto !important;
        transform: translateY(-50%) !important;
        z-index: 100 !important;
        font-size: 1.4rem !important;
        opacity: 1 !important;
        visibility: visible !important;
        pointer-events: auto !important;
        margin: 0 !important;
    }

    /* AI indicator: top center */
    #ai-indicator {
        display: none;
    }
    
    #ai-indicator.visible {
        display: flex;
        position: fixed;
        top: 0.75rem;
        bottom: auto;
        left: 50%;
        right: auto;
        transform: translateX(-50%);
        margin: 0;
        height: auto;
        z-index: 60;
        font-size: 1.3rem;
        width: auto;
        min-width: auto;
        opacity: 1;
        pointer-events: auto;
    }

    /* Overlays: constrain to viewport */
    .overlay-content {
        max-width: 90vw;
        padding: 1.5rem;
    }

    /* Settings Menu Custom Mobile UI */
    .desktop-setting { display: none !important; }
    .mobile-setting { display: flex !important; }

    #settings-menu,
    #about-overlay {
        background: transparent !important;
        backdrop-filter: none !important; 
    }

    /* Hide everything inside the app EXCEPT the open overlay */
    #app:has(#settings-menu:not(.hidden)) > *:not(#settings-menu),
    #app:has(#about-overlay:not(.hidden)) > *:not(#about-overlay) {
        opacity: 0 !important;
        pointer-events: none !important;
        transition: opacity 0.2s ease;
    }

    .settings-list {
        width: 100vw !important;
        max-width: none !important;
        padding: 0 !important;
        display: flex !important;
        flex-direction: column;
        align-items: center;
        justify-content: center;
    }

    .settings-mobile-layout {
        display: grid !important;
        grid-template-columns: 1fr auto 1fr;
        align-items: center;
        width: 100%;
        gap: 2rem; 
        margin-bottom: 2rem;
    }

    .settings-left {
        display: flex !important;
        flex-direction: column;
        justify-content: center;
        align-items: stretch; /* Allows rows to stretch full width */
        width: 100%;
        max-width: 220px; /* Constrains the column so it looks like a neat block */
        margin: 0 auto; /* Centers the block inside its half of the screen */
        gap: 2rem;
    }

    .settings-right {
        display: flex !important;
        flex-direction: row; /* Places icons side by side */
        justify-content: center;
        align-items: center;
        width: 100%;
        gap: 3.5rem; /* Space between the two big icons */
    }

    .settings-right .icon-btn {
        font-size: 3.5rem; /* Much bigger */
        width: auto;
        height: auto;
        min-width: 0;
        padding: 0;
        line-height: 1;
    }

    .settings-divider {
        width: 1px;
        align-self: stretch; /* Matches height of the tallest column */
        background: var(--dim-color);
        margin: 0;
    }

    .setting-row {
        display: flex !important;
        justify-content: space-between !important; /* Pushes text to left, button to right */
        align-items: center !important;
        margin-bottom: 0 !important;
        min-height: auto !important;
        font-size: 1.1rem;
        width: 100% !important; /* Forces the row to fill the 220px column */
    }

    /* Compress About Overlay for Landscape */
    .about-split-layout {
        width: 100vw !important;
        max-width: 800px !important;
        height: 100vh !important;
        max-height: none !important;
        padding: 0 !important;
        gap: 1rem;
        align-items: center;
    }

    .about-left {
        padding: 1rem !important;
    }

    #about-symbol-display {
        font-size: 6.5rem !important; /* Bumped up from 5rem */
        margin-bottom: 0.5rem !important;
    }

    .about-brand {
        font-size: 1.15rem !important; /* Bumped up from 1rem */
        letter-spacing: 0.4em !important; /* Widened slightly to match the larger symbol */
    }

    .about-right {
        padding: 0.5rem 1rem !important;
        justify-content: center !important;
    }

    .about-header {
        font-size: 1rem !important;
        margin-bottom: 0.5rem !important;
        margin-top: 0 !important;
    }

    .about-avatar {
        width: 50px !important; /* Shrunk from 110px */
        height: 50px !important;
        margin-bottom: 0.5rem !important;
    }

    .about-text {
        font-size: 0.85rem !important;
        margin-bottom: 0.5rem !important;
        line-height: 1.4 !important;
    }

    .about-text p {
        margin-bottom: 0.4rem !important;
    }

    .social-row {
        margin-top: 0.5rem !important;     /* Breathing room from the bio text */
        margin-bottom: 1.5rem !important;  /* Pushes the credit text safely downward */
        gap: 2rem !important;              /* Spreads the buttons further apart horizontally */
    }

    .social-icon {
        width: 32px !important;            /* Much larger visual size */
        height: 32px !important;
        padding: 6px !important;           /* Creates a larger invisible touch target around the icon */
        margin: -6px !important;           /* Prevents the padding from ruining the visual alignment */
    }

    .credit-text {
        font-size: 0.65rem !important;
        margin-bottom: 0.5rem !important;
    }

    #btn-close-about {
        margin-top: 0.5rem !important;
        font-size: 1rem !important;
        padding: 0.2rem !important;
    }

    #list-menu .overlay-content {
        width: 90vw;
    }

    /* Compress sliders slightly on mobile */
    input[type=range] {
        width: 100px;
    }

    /* Force the close button to span across both columns */
    #btn-close-settings {
        grid-column: 1 / -1;
        margin-top: 1rem !important;
    }

    /* Hide desktop-only rows, show mobile-only rows */
    .desktop-setting {
        display: none !important;
    }

    .mobile-setting {
        display: flex !important;
    }

    /* UI corners & Version Info */
    .ui-corner {
        padding: 1rem;
    }

    .version-info {
        padding-right: 1.25rem;
    }

    /* Sizing up buttons for touch */
    .filter-btn {
        font-size: 1.3rem;
        height: 36px;
        padding: 0 0.6rem;
    }

    .icon-btn {
        width: 40px;
        min-width: 40px;
        height: 36px;
        font-size: 1.3rem;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .separator {
        margin: 0 0.25rem;
    }

    /* Composition */
    #composition-wrapper {
        padding: 0 3.5rem;
    }

    #composition-display {
        font-size: max(var(--font-reading-size), 16px);
        max-width: 100%;
        overflow-x: auto;
        overflow-y: hidden;
    }

    #title-container {
        padding-top: 1.5rem;
        width: 95vw;
        max-width: 100%;
    }

    #composition-title {
        font-size: 1.2rem;
    }

    #loader-display {
        font-size: 1.5rem;
    }

    /* Title screen: push down slightly */
    h1.project-title {
        margin-top: 6vh;
    }

    /* Clock */
    #clock-display {
        font-size: 10vmin;
        gap: 0.5rem;
    }

    .clock-digit {
        width: 1.1ch;
    }

    /* --- Hide UI during Intro Sequence (Keep Right Arrow) --- */
    .view-intro .ui-corner { display: none !important; }
    .view-intro .footer-left,
    .view-intro .footer-right,
    .view-intro #nav-back,
    .view-intro #nav-skip,
    .view-intro #ai-indicator {
        display: none !important;
    }

    /* --- Universal Intro Sequence Mobile Layout --- */
    #intro-content {
        display: flex !important;
        flex-direction: column;
        justify-content: center; /* Dead vertical center */
        align-items: center;
        width: 100vw !important;
        min-height: 100vh !important;
        max-height: none !important;
        padding: 0 4.5rem 0 2rem !important; /* Protects the right arrow */
        box-sizing: border-box;
        gap: 2.5rem; 
    }

    .intro-title {
        font-size: 1.25rem !important;
        margin: 0 !important;
        text-align: center;
        width: 100%;
        text-transform: uppercase;
        letter-spacing: 0.2em;
    }

    .intro-example {
        display: flex;
        justify-content: center;
        width: 100% !important;
        margin: 0 !important;
    }

    .intro-example pre {
        font-size: 28px !important; 
        line-height: 1.4 !important;
    }

    /* Text blocks: split internally into columns */
    .intro-text {
        width: 100%;
        margin: 0 !important;
        column-count: 2; /* 2 Columns */
        column-gap: 2.5rem;
        text-align: left;
    }

    .intro-text p {
        font-size: 0.9rem !important; /* Shrunk by ~1pt */
        line-height: 1.6 !important;
        margin-top: 0 !important;
        margin-bottom: 1.2rem !important;
    }
    
    .intro-text p:last-child {
        margin-bottom: 0 !important;
    }

    /* --- BESPOKE EXCEPTIONS (Driven by JS data-step) --- */
    
    /* Screen 1 and 5: Prevent paragraphs from splitting across columns */
    #intro-content[data-step="0"] .intro-text p,
    #intro-content[data-step="4"] .intro-text p {
        break-inside: avoid;
    }

    /* Screen 2 (Barcodes): Hide "As you wander around..." transition text on mobile */
    #intro-content[data-step="1"] > .intro-text:first-child {
        display: none !important;
    }

    /* Screen 4 (Geodes): Custom Grid Layout (Example Left, Text Right) */
    #intro-content[data-step="3"] {
        display: grid !important;
        grid-template-columns: 1fr 1fr;
        grid-template-rows: auto auto; 
        align-content: center;
        align-items: center;
        gap: 2rem 2.5rem;
    }

    #intro-content[data-step="3"] .intro-title {
        grid-column: 1 / -1; 
    }

    #intro-content[data-step="3"] .intro-example {
        grid-column: 1;
        justify-content: flex-end; 
    }
    
    #intro-content[data-step="3"] .intro-example pre {
        font-size: 22px !important; 
    }

    #intro-content[data-step="3"] .intro-text {
        grid-column: 2;
        column-count: 1; /* Disable columns since it's constrained to right half */
    }
}

/* --- Tablet and up: Intro two-column layout --- */
@media (min-width: 1025px) {
    #intro-content {
        flex-direction: row;
        align-items: flex-start;
        gap: 3rem;
        max-width: 860px;
        width: 90%;
        text-align: left;
    }

    #intro-content > .intro-title,
    #intro-content > .intro-text {
        flex: 1;
        min-width: 0;
    }

    #intro-content > .intro-example {
        flex: 0 0 auto;
        align-self: flex-start;
    }
}

/* --- Tablet-specific --- */
@media (min-width: 1025px) and (max-width: 1280px) {
    #about-symbol-display {
        font-size: 6rem;
    }

    .about-right {
        padding: 2rem;
    }
}