/* Caligraph tile: the swiped page, the raw-markdown editor and the page list. */

.cali-viewport {
    /* The page slides sideways inside this; the shell's .content clips it. */
    position: relative;
}

.cali-page {
    display: block;
    /* Vertical scrolling stays with the browser, horizontal drags come to us. */
    touch-action: pan-y;
    line-height: 1.6;
    color: #333;
    /* A note is read, not skimmed: give it a little more air than the shell. */
    font-size: 17px;
}

.cali-page h1, .cali-page h2, .cali-page h3 {
    line-height: 1.25;
    margin: 1.2em 0 0.4em;
    text-align: left;
    color: #222;
}

.cali-page h1 { font-size: 1.5em; }
.cali-page h2 { font-size: 1.25em; }
.cali-page h3 { font-size: 1.1em; }

.cali-page > :first-child {
    margin-top: 0;
}

.cali-page p {
    margin: 0 0 1em;
}

.cali-page ul, .cali-page ol {
    padding-left: 22px;
    margin: 0 0 1em;
    list-style: revert;
}

.cali-page li {
    /* The shell styles every <li> as a grey flex row; inside a note they are
       ordinary list items again. */
    background: none;
    display: list-item;
    padding: 0;
    margin-bottom: 6px;
}

.cali-page blockquote {
    margin: 0 0 1em;
    padding: 4px 0 4px 16px;
    border-left: 3px solid #42f5b6;
    color: #555;
    font-style: italic;
}

.cali-page code {
    background-color: #f0f0f0;
    border-radius: 3px;
    padding: 1px 4px;
    font-size: 0.9em;
}

.cali-page pre {
    background-color: #f5f5f5;
    border-radius: 6px;
    padding: 12px;
    overflow-x: auto;
}

.cali-page pre code {
    background: none;
    padding: 0;
}

.cali-page hr {
    border: none;
    border-top: 1px solid #ddd;
    margin: 1.5em 0;
}

.cali-page img {
    max-width: 100%;
}

/* --- the raw-markdown editor ------------------------------------------ */

.cali-editor {
    width: 100%;
    min-height: 60vh;
    border: none;
    outline: none;
    resize: none;
    overflow: hidden; /* it grows to its content instead of scrolling itself */
    padding: 0;
    background: none;
    color: #333;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    font-size: 15px;
    line-height: 1.6;
    box-sizing: border-box;
}

/* --- pager ------------------------------------------------------------- */

.cali-pager {
    position: sticky;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 0 4px;
    /* Fades the note out behind the dots rather than cutting it off. */
    background: linear-gradient(to bottom, rgba(255,255,255,0), #fff 45%);
}

.cali-dot {
    width: 8px;
    height: 8px;
    padding: 0;
    margin: 0;
    border: none;
    border-radius: 50%;
    background-color: #ddd;
    cursor: pointer;
}

.cali-dot:hover {
    background-color: #bbb;
}

.cali-dot.current {
    background-color: #42f5b6;
    transform: scale(1.35);
}

.cali-count {
    font-size: 13px;
    color: #888;
}

/* --- empty state ------------------------------------------------------- */

.cali-empty {
    text-align: center;
    color: #888;
    margin-top: 25vh;
}

/* --- the pages popup --------------------------------------------------- */

.cali-page-list {
    max-height: 55vh;
    overflow-y: auto;
    margin: 0 0 10px;
}

.cali-page-row {
    background-color: #f9f9f9;
    border-radius: 6px;
    padding: 12px;
    margin-bottom: 6px;
    gap: 10px;
    cursor: pointer;
}

.cali-page-row.current {
    background-color: #e8fff7;
    box-shadow: inset 3px 0 0 #42f5b6;
}

.cali-page-row.empty {
    justify-content: center;
    color: #999;
    cursor: default;
}

.cali-page-title {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cali-row-controls {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.cali-row-btn {
    width: 32px;
    height: 32px;
    padding: 0;
    margin: 0;
    border-radius: 50%;
    background-color: #eee;
    color: #333;
    font-size: 15px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cali-row-btn:hover:not(:disabled) {
    background-color: #ddd;
}

.cali-row-btn:disabled {
    opacity: 0.35;
    cursor: default;
}

.cali-row-btn.danger {
    background-color: #f44336;
    color: white;
}

.cali-row-btn.danger:hover {
    background-color: #d32f2f;
}

.cali-popup-actions {
    display: flex;
    gap: 10px;
}
