/* ============================================================
   Reading Mode Plugin - Frontend Styles
   Variables are injected inline from admin settings
   ============================================================ */

/* ── Variables (fallbacks) ── */
:root {
    --rm-light-bg:     #f8f6f1;
    --rm-light-title:  #1a1a1a;
    --rm-light-text:   #2c2c2c;
    --rm-light-link:   #1a5276;
    --rm-dark-bg:      #1a2232;
    --rm-dark-title:   #f0f4f8;
    --rm-dark-text:    #dde1e5;
    --rm-dark-link:    #7fb3d3;
    --rm-font-family:  Georgia, serif;
    --rm-font-size:    17px;
    --rm-line-height:  1.8;
    --rm-width:        860px;
    --rm-toolbar-h:    54px;
    --rm-progress-h:   4px;
    --rm-transition:   0.25s ease;
}

/* ── Open button ── */
.rm-open-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 16px;
    background: transparent;
    border: 1.5px solid currentColor;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    opacity: 0.75;
    transition: opacity var(--rm-transition), background var(--rm-transition);
    text-decoration: none;
    color: inherit;
}
.rm-open-btn:hover {
    opacity: 1;
    background: rgba(0,0,0,0.05);
}
.rm-btn-wrap {
    margin: 8px 0 12px;
}
.rm-btn-meta {
    margin-bottom: 16px;
}

/* Floating button */
.rm-floating-btn-wrap {
    position: fixed;
    bottom: 28px;
    right: 28px;
    z-index: 9990;
}
.rm-floating-btn-wrap .rm-open-btn {
    box-shadow: 0 4px 20px rgba(0,0,0,0.18);
    background: #1a2232;
    color: #fff;
    border-color: transparent;
    border-radius: 50px;
    padding: 10px 20px;
    opacity: 0.9;
    font-size: 14px;
}
.rm-floating-btn-wrap .rm-open-btn:hover {
    opacity: 1;
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(0,0,0,0.24);
}

/* ── Overlay ── */
.rm-overlay {
    position: fixed;
    inset: 0;
    z-index: 99999;
    background: rgba(0, 0, 0, 0.7);
    overflow: hidden;
    animation: rm-fade-in 0.2s ease;
}

@keyframes rm-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.rm-container {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    background: var(--rm-light-bg);
    color: var(--rm-light-text);
    transition: background var(--rm-transition), color var(--rm-transition);
}

.rm-container.rm-dark {
    background: var(--rm-dark-bg);
    color: var(--rm-dark-text);
}

/* ── Toolbar ── */
.rm-toolbar {
    flex-shrink: 0;
    height: var(--rm-toolbar-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    border-bottom: 1px solid rgba(128,128,128,0.15);
    background: inherit;
    position: sticky;
    top: 0;
    z-index: 10;
}
.rm-toolbar-right {
    display: flex;
    align-items: center;
    gap: 6px;
}
.rm-reading-time {
    font-size: 13px;
    opacity: 0.6;
}

/* Tool buttons */
.rm-tool-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid rgba(128,128,128,0.25);
    border-radius: 6px;
    padding: 5px 10px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: inherit;
    transition: background var(--rm-transition), opacity var(--rm-transition);
    white-space: nowrap;
}
.rm-tool-btn:hover {
    background: rgba(128,128,128,0.1);
}
.rm-font-controls {
    display: flex;
    align-items: center;
    gap: 4px;
    border: 1px solid rgba(128,128,128,0.25);
    border-radius: 6px;
    overflow: hidden;
    padding: 0 6px;
}
.rm-font-controls .rm-tool-btn {
    border: none;
    border-radius: 0;
    padding: 5px 8px;
}
.rm-font-display {
    font-size: 12px;
    min-width: 30px;
    text-align: center;
    opacity: 0.7;
}
.rm-close-btn {
    font-size: 16px;
    padding: 5px 11px;
    border-color: rgba(128,128,128,0.35);
}

/* ── Progress bar ── */
.rm-progress-wrap {
    flex-shrink: 0;
    height: var(--rm-progress-h);
    background: rgba(128,128,128,0.15);
    position: relative;
}
.rm-progress-bar {
    height: 100%;
    width: 0%;
    background: #3b82f6;
    transition: width 0.1s linear;
    border-radius: 0 2px 2px 0;
}
.rm-container.rm-dark .rm-progress-bar {
    background: #60a5fa;
}

/* ── Content ── */
.rm-content-wrap {
    flex: 1;
    overflow-y: auto;
    padding: 40px 24px;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}
.rm-content {
    max-width: var(--rm-width);
    margin: 0 auto;
    font-family: var(--rm-font-family);
    font-size: var(--rm-font-size);
    line-height: var(--rm-line-height);
    transition: font-size 0.15s ease;
}
.rm-title {
    font-family: var(--rm-font-family);
    font-size: calc(var(--rm-font-size) * 1.65);
    line-height: 1.3;
    margin: 0 0 28px;
    padding-bottom: 20px;
    border-bottom: 1px solid rgba(128,128,128,0.2);
    color: var(--rm-light-title);
}
.rm-container.rm-dark .rm-title {
    color: var(--rm-dark-title);
}

/* ── Text link (after_meta position — sits next to author name) ── */
.rm-text-link {
    display: inline-flex;
    align-items: center;
    font-size: inherit;
    color: inherit;
    opacity: 0.6;
    text-decoration: none;
    cursor: pointer;
    transition: opacity 0.2s;
    white-space: nowrap;
}
.rm-text-link:hover { opacity: 1; text-decoration: none; color: inherit; }

/* The | separator before the link */
.rm-meta-trigger-wrap::before {
    content: ' | ';
    opacity: 0.4;
    margin: 0 2px;
}
/* After-meta inject wrapper — display controlled by JS */
.rm-meta-trigger-wrap { display: none; }

/* Content typography */
.rm-body p {
    margin: 0 0 1.4em;
}
.rm-body a {
    color: var(--rm-light-link);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
}
.rm-container.rm-dark .rm-body a {
    color: var(--rm-dark-link);
}
.rm-body h2, .rm-body h3, .rm-body h4 {
    margin: 1.6em 0 0.6em;
    line-height: 1.35;
}
.rm-body h2 { font-size: calc(var(--rm-font-size) * 1.4); }
.rm-body h3 { font-size: calc(var(--rm-font-size) * 1.2); }
.rm-body h4 { font-size: calc(var(--rm-font-size) * 1.1); }

.rm-body img {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
    margin: 8px 0;
}
.rm-body figure {
    margin: 1.5em 0;
    text-align: center;
}
.rm-body figcaption {
    font-size: 0.85em;
    opacity: 0.65;
    margin-top: 6px;
}
.rm-body blockquote {
    border-left: 4px solid rgba(128,128,128,0.35);
    margin: 1.5em 0;
    padding: 0.5em 1.2em;
    opacity: 0.85;
    font-style: italic;
}
.rm-container.rm-dark .rm-body blockquote {
    border-left-color: rgba(255,255,255,0.2);
}
.rm-body pre, .rm-body code {
    font-family: 'Courier New', monospace;
    background: rgba(0,0,0,0.06);
    border-radius: 4px;
    font-size: 0.88em;
}
.rm-container.rm-dark .rm-body pre,
.rm-container.rm-dark .rm-body code {
    background: rgba(255,255,255,0.07);
}
.rm-body pre {
    padding: 12px 16px;
    overflow-x: auto;
}
.rm-body code {
    padding: 2px 5px;
}
.rm-body ul, .rm-body ol {
    padding-left: 1.6em;
    margin: 0 0 1.2em;
}
.rm-body li {
    margin-bottom: 0.4em;
}
.rm-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5em 0;
    font-size: 0.92em;
}
.rm-body th, .rm-body td {
    padding: 8px 12px;
    border: 1px solid rgba(128,128,128,0.2);
}
.rm-body th {
    background: rgba(0,0,0,0.05);
    font-weight: 600;
}
.rm-container.rm-dark .rm-body th {
    background: rgba(255,255,255,0.07);
}

/* ── Responsive ── */
@media (max-width: 640px) {
    .rm-content-wrap {
        padding: 24px 16px;
    }
    .rm-toolbar {
        padding: 0 12px;
    }
    .rm-font-display {
        display: none;
    }
    .rm-tool-btn {
        padding: 5px 8px;
        font-size: 12px;
    }
}

/* ── Scrollbar ── */
.rm-content-wrap::-webkit-scrollbar {
    width: 6px;
}
.rm-content-wrap::-webkit-scrollbar-track {
    background: transparent;
}
.rm-content-wrap::-webkit-scrollbar-thumb {
    background: rgba(128,128,128,0.3);
    border-radius: 3px;
}
.rm-content-wrap::-webkit-scrollbar-thumb:hover {
    background: rgba(128,128,128,0.5);
}
