/* Page-specific styles for /typer */

/* Typewriter line overlays (middle band = “2nd line” from top). */
:root {
    /* Top band: slightly lighter than before so glyphs don’t read as “smaller” under the overlay. */
    --tw-line1-overlay: 0.86;
    --tw-line2-overlay: 0.72;
    --tw-line3-overlay: 0.4;
}

body {
    background-color: #000;
}

/* Desk page: no document scroll — toolbar stays visible */
html:has(body.typer-desk-body) {
    height: 100%;
    overflow: hidden;
}

.typer-desk-body {
    height: 100%;
    min-height: 100%;
    margin: 0;
    overflow: hidden;
    padding-top: 0;
}

.typer-main {
    width: 60%;
    margin: 0 auto;
    padding: 40px 0;
}

.typer-header {
    text-align: center;
}

.typer-title {
    margin: 0 0 10px 0;
    font-weight: normal;
}

.typer-root {
    margin-top: 10px;
    min-height: 60vh;
    padding: 30px;
    display: flex;
    align-items: flex-start;
    justify-content: center;
}

.typer-intro {
    max-width: 720px;
    text-align: center;
}

.typer-intro p {
    margin: 0 0 14px 0;
}

.typer-auth-card {
    max-width: 720px;
    width: 100%;
    text-align: center;
    border: 1px solid #334155;
    border-radius: 8px;
    padding: 26px;
    background: rgba(2, 6, 23, 0.6);
    margin-top: 0;
}

.typer-auth-header {
    margin: 0 0 18px 0;
}

.typer-auth-title {
    margin: 0 0 8px 0;
    font-weight: normal;
}

.typer-auth-status p {
    margin: 0 0 12px 0;
}

.auth-user {
    color: #60a5fa;
}

.typer-auth-actions {
    display: flex;
    gap: 14px;
    justify-content: center;
    flex-wrap: wrap;
    margin: 14px 0 6px 0;
}

.typer-btn {
    border: none;
    background-color: #60a5fa;
    color: #000;
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 12pt;
    cursor: pointer;
}

.typer-btn:hover:not(:disabled) {
    opacity: 0.9;
}

.typer-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.typer-btn-secondary {
    background-color: rgba(96, 165, 250, 0.15);
    color: #60a5fa;
    border: 1px solid rgba(96, 165, 250, 0.35);
}

.typer-auth-error {
    margin: 14px 0 0 0;
    color: #f87171;
}

/* Desk (post-auth) */
.typer-desk-main {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 0;
    height: 100%;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.desk-root {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    padding: 0;
}

.desk-shell {
    width: 100%;
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.desk-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 14px 18px;
    border-bottom: 1px solid rgba(51, 65, 85, 0.6);
    transition: opacity 0.2s ease;
    position: relative;
    z-index: 80;
}

/* Focus mode: dimmed toolbar (~60% fade) + fullscreen requested from deskPage.js */
.desk-toolbar.desk-toolbar--faded,
.desk-doc-title-bar.desk-toolbar--faded {
    opacity: 0.4;
}

.desk-toolbar-left,
.desk-toolbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
    /* ~2nd-line atmospheric match, bumped ~25% brighter (cap at 1). */
    opacity: min(1, calc((1 - var(--tw-line2-overlay)) * 1.25));
}

.desk-toolbar-item {
    position: relative;
    display: inline-flex;
    align-items: center;
    z-index: 20;
}

.desk-hoverbox,
.desk-popover {
    position: absolute;
    top: calc(100% + 10px);
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    min-width: 90px;
    border: 1px solid #334155;
    border-radius: 12px;
    padding: 14px 16px;
    background: rgba(2, 6, 23, 0.9);
    color: #e0e0e4;
    box-sizing: border-box;
    z-index: 30;
}

.desk-hoverbox {
    display: none;
}

.desk-metric-hoverbox {
    width: 90px;
    min-width: 90px;
    text-align: center;
}

.desk-toolbar-item:hover .desk-hoverbox {
    display: block;
}

.desk-hoverbox--visible {
    display: block;
}

.desk-popover {
    min-height: 80px;
}

.pomodoro-panel {
    min-width: 280px;
}

.pomodoro-status-hoverbox {
    min-width: 130px;
    text-align: center;
}

.pomodoro-status-phase {
    font-size: 10pt;
    color: #94a3b8;
    margin-bottom: 4px;
}

.pomodoro-status-time {
    font-size: 16pt;
    letter-spacing: 0.04em;
    color: #e0e0e4;
}

.pomodoro-status-hoverbox--flash {
    animation: pomodoroHoverFlash 0.6s ease-in-out 1;
}

@keyframes pomodoroHoverFlash {
    0% {
        opacity: 0.4;
    }
    50% {
        opacity: 1;
    }
    100% {
        opacity: 0.9;
    }
}

.pomodoro-panel-heading {
    font-size: 12pt;
    margin-bottom: 10px;
}

.pomodoro-panel-status {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    font-size: 10pt;
    color: #94a3b8;
}

.pomodoro-panel-timer {
    margin: 8px 0 12px;
    font-size: 20pt;
    letter-spacing: 0.04em;
}

.pomodoro-runtime-actions,
.pomodoro-settings-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.pomodoro-runtime-actions {
    margin-bottom: 12px;
}

.pomodoro-label {
    display: block;
    margin: 8px 0 4px;
    font-size: 10pt;
    color: #94a3b8;
}

.pomodoro-input {
    width: 100%;
    box-sizing: border-box;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid #334155;
    background: #020617;
    color: #e0e0e4;
    font-size: 11pt;
    font-family: inherit;
}

.pomodoro-input:focus {
    outline: none;
    border-color: #60a5fa;
}

.pomodoro-error {
    margin: 10px 0 0;
    font-size: 10pt;
    color: #f87171;
}

.pomodoro-settings-actions {
    margin-top: 12px;
}

.desk-hoverbox-value {
    font-size: 20pt;
    color: #e0e0e4;
}

.desk-toolbar-btn {
    appearance: none;
    background: transparent;
    border: none;
    color: #e0e0e4;
    font-size: 12pt;
    padding: 4px 2px;
    cursor: pointer;
}

.desk-toolbar-btn:hover {
    color: #88bbfb;
    text-decoration: underline;
}

.desk-toolbar-sep {
    color: #b5bac3;
}

.desk-toolbar-saved {
    font-size: 12pt;
    color: #e0e0e4;
    white-space: nowrap;
}

.desk-doc-title-bar {
    flex-shrink: 0;
    padding: 8px 18px 10px;
    transition: opacity 0.2s ease;
    /* No fill — same base as toolbar so title matches toolbar text brightness. */
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
}

/* Same perceived color as .desk-toolbar-btn inside .desk-toolbar-left (group opacity over black). */
.desk-doc-title-text {
    grid-column: 2;
    justify-self: center;
    font-size: 11pt;
    letter-spacing: 0.04em;
    font-weight: 500;
    color: color-mix(
        in srgb,
        #e0e0e4 calc(min(1, (1 - var(--tw-line2-overlay)) * 1.25) * 100%),
        black
    );
}

.desk-doc-title-saved {
    grid-column: 3;
    justify-self: end;
    font-size: 11pt;
    color: color-mix(
        in srgb,
        #e0e0e4 calc(min(1, (1 - var(--tw-line2-overlay)) * 1.25) * 100%),
        black
    );
    white-space: nowrap;
}

.desk-doc-title-saved--hidden {
    visibility: hidden;
}

.write-overlay {
    position: fixed;
    inset: 0;
    z-index: 2500;
    background-color: rgba(0, 0, 0, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
}

.write-overlay[hidden] {
    display: none !important;
}

.write-overlay-inner {
    width: 100%;
    max-width: 400px;
    border: 1px solid #334155;
    border-radius: 12px;
    padding: 22px 24px;
    background: rgba(2, 6, 23, 0.95);
    color: #e0e0e4;
}

.write-overlay-heading {
    margin: 0 0 14px 0;
    font-size: 14pt;
    font-weight: normal;
}

.write-overlay-label {
    display: block;
    font-size: 11pt;
    color: #94a3b8;
    margin-bottom: 6px;
}

.write-overlay-input {
    width: 100%;
    box-sizing: border-box;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid #334155;
    background: #020617;
    color: #e0e0e4;
    font-size: 14pt;
    font-family: inherit;
}

.write-overlay-input:focus {
    outline: none;
    border-color: #60a5fa;
}

.write-overlay-error {
    margin: 10px 0 0;
    font-size: 11pt;
    color: #f87171;
}

.write-overlay-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 18px;
}

.open-doc-list {
    margin-top: 14px;
    width: 100%;
    max-height: 55vh;
    overflow-y: auto;
    color: #e0e0e4;
    font-size: 12pt;
    border: 1px solid rgba(51, 65, 85, 0.35);
    border-radius: 10px;
    padding: 12px;
    box-sizing: border-box;
}

.open-doc-item {
    width: 100%;
    text-align: left;
    display: block;
    padding: 10px 12px;
    margin: 0 0 6px 0;
    border-radius: 8px;
    background: transparent;
    border: 1px solid rgba(51, 65, 85, 0.25);
    color: #e0e0e4;
    cursor: pointer;
}

.open-doc-item:last-child {
    margin-bottom: 0;
}

.open-doc-item:hover {
    border-color: rgba(136, 187, 251, 0.65);
}

.open-doc-item[aria-current="true"] {
    border-color: rgba(96, 165, 250, 0.9);
    box-shadow: inset 0 0 0 1px rgba(96, 165, 250, 0.35);
}

/* Read overlay — column width matches .typewriter-stage (padding 0 300px desktop, 20px mobile) */
.read-overlay {
    position: fixed;
    inset: 0;
    z-index: 2500;
    background-color: #000;
    overflow: hidden;
}

.read-overlay-inner {
    box-sizing: border-box;
    width: 100%;
    height: 100%;
    min-height: 100%;
    padding: 0 300px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.read-overlay-header {
    flex: 0 0 auto;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding: 16px 0 12px 0;
}

.read-overlay-close {
    padding: 4px 2px;
    color: #8b2323;
}

.read-overlay-close:hover {
    color: #b91c1c;
    text-decoration: underline;
}

.read-overlay-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding-bottom: 28px;
    /* Same perceived brightness as the typewriter active line: base #d1d5db under --tw-line3-overlay. */
    color: color-mix(in srgb, #d1d5db calc((1 - var(--tw-line3-overlay)) * 100%), black);
    font-size: 20px;
    line-height: 1.4;
    font-family: inherit;
    font-weight: 400;
    white-space: pre-wrap;
    word-wrap: break-word;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.read-overlay-body::-webkit-scrollbar {
    display: none;
}

/* (placeholder removed; desktop will render here next) */

/* Typewriter (MVP) */
.typewriter-stage {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    padding: 0 300px;
    box-sizing: border-box;
    z-index: 1;
}

.typewriter-root {
    position: relative;
    width: 100%;
    max-width: none;
    height: 100%;
    margin: 0;
    isolation: isolate;
    box-sizing: border-box;
}

/* When the textarea isn’t focused, slim frame around the full visible typing area. */
.typewriter-root:not(:focus-within)::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: calc(50% - var(--tw-active-line-offset-px, 50px));
    height: var(--tw-visible-height-px, 120px);
    z-index: 2;
    pointer-events: none;
    box-sizing: border-box;
    box-shadow: inset 0 0 0 1px rgba(51, 65, 85, 0.6);
}

.desk-shell.pomodoro-open .typewriter-root:not(:focus-within)::before {
    content: none;
}

.typewriter-root::after {
    content: "";
    position: absolute;
    /* Match textarea: avoid transform on text stack (reduces “shrunken” glyph look). */
    top: calc(50% - var(--tw-active-line-offset-px, 50px));
    height: var(--tw-visible-height-px, 120px);
    left: 0;
    right: 0;
    z-index: 1;
    pointer-events: none;
    /* Atmospheric fade: active line ~same brightness as old “middle” line;
       lines above are darker (more atmospheric). */
    background: linear-gradient(
        to bottom,
        rgba(0, 0, 0, var(--tw-line1-overlay)) 0%,
        rgba(0, 0, 0, var(--tw-line1-overlay)) 33.333%,
        rgba(0, 0, 0, var(--tw-line2-overlay)) 33.333%,
        rgba(0, 0, 0, var(--tw-line2-overlay)) 66.666%,
        rgba(0, 0, 0, var(--tw-line3-overlay)) 66.666%,
        rgba(0, 0, 0, var(--tw-line3-overlay)) 100%
    );
}

.typewriter-textarea {
    position: absolute;
    top: calc(50% - var(--tw-active-line-offset-px, 50px));
    left: 0;
    width: 100%;
    z-index: 0;
    resize: none;
    overflow: hidden;
    border: none;
    outline: none;
    background: transparent;
    color: #d1d5db;
    padding: 0;
    margin: 0;
    font-family: inherit;
    font-weight: 400;
    /* Full-width lines: stretch inter-word space so wrapped lines hit both margins. */
    text-align: justify;
    text-align-last: left;
    text-justify: inter-word;
    /* Avoid transform blur; keep glyph weight consistent across lines. */
    transform: none;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* Unauthorized dialog */
.typer-dialog-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    background-color: rgba(0, 0, 0, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.typer-dialog {
    width: 100%;
    max-width: 560px;
    text-align: center;
    border: 1px solid #334155;
    border-radius: 12px;
    padding: 22px;
    background: rgba(2, 6, 23, 0.9);
}

.typer-dialog-title {
    margin: 0 0 10px 0;
    font-weight: normal;
}

.typer-dialog-message {
    margin: 0 0 10px 0;
    font-size: 12pt;
}

.typer-dialog-submessage {
    margin: 0;
    color: #9ca3af;
    font-size: 11pt;
}

.typer-dialog-actions {
    margin-top: 16px;
}

@media (max-width: 768px) {
    .typer-main {
        width: 100%;
        padding: 20px 0;
    }

    .typer-auth-card {
        margin-top: -20px;
    }

    .typewriter-stage {
        padding: 0 20px;
    }

    .read-overlay-inner {
        padding: 0 20px;
    }
}

