/*
  NoteTaking's base stylesheet (NT-029): the design tokens and the few rules every page shares, served by the
  instance itself (FR-WEB-10: no CDN, no web font, no icon font). The components bring their own scoped styles
  (*.razor.css) and use only these custom properties, so a theme (NT-041) is a different set of values for them.
  System fonts only; the look is quiet on purpose, after Simplenote's three panes.
*/

:root {
    color-scheme: light;

    --nt-font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --nt-font-mono: ui-monospace, "Cascadia Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;

    /* Colors. Text on its own background is at least 4.5:1 (WCAG 2.2 AA). */
    --nt-bg: #fff;
    --nt-bg-sidebar: #f6f7f7;
    --nt-text: #1d2327;
    --nt-text-muted: #50575e;
    --nt-border: #dcdcde;
    --nt-hover: #eceef0;
    --nt-selected: #e6ebfc;
    --nt-accent: #3858e9;
    --nt-accent-strong: #2a43b8;
    --nt-accent-contrast: #fff;
    --nt-notice-bg: #fcf0e3;
    --nt-notice-text: #4a2d00;
    --nt-notice-border: #b76e00;

    /* Geometry. */
    --nt-bar-height: 3.25rem;
    --nt-sidebar-width: 15rem;
    --nt-list-width: 21rem;
    --nt-radius: 6px;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    background: var(--nt-bg);
    color: var(--nt-text);
    font-family: var(--nt-font);
    font-size: 100%;
    line-height: 1.5;
}

a {
    color: var(--nt-accent-strong);
}

/* Keyboard focus is always visible and never only a color change (NFR-UX-01). */
:focus-visible {
    outline: 2px solid var(--nt-accent);
    outline-offset: 2px;
}

button {
    font: inherit;
}

/* One notice at a time: while the reconnect notice shows (blazor.web.js puts one of these classes on it), the error
   bar stays hidden; blazor.web.js sets its display inline, hence !important. */
body:has(#components-reconnect-modal.components-reconnect-show, #components-reconnect-modal.components-reconnect-failed, #components-reconnect-modal.components-reconnect-rejected, #components-reconnect-modal.components-reconnect-paused, #components-reconnect-modal.components-reconnect-resume-failed) #blazor-error-ui {
    display: none !important;
}

/* NT-022: once the session of the page's circuit has ended (session.js puts this class on the root element), nothing
   the page showed is displayed any more: not the shell (note list, editor, sidebar), not the framework's error bar for
   the closed circuit (blazor.web.js sets its display inline, hence !important). The reconnect notice stays possible:
   it shows no user data and offers the reload. */
html.nt-session-ended body > :not(#components-reconnect-modal):not(#nt-signed-out) {
    display: none !important;
}

/* NT-022: the one line an ended page shows (FrameworkNotices), so it is never blank. Hidden (the hidden attribute)
   while the session lives. */
html.nt-session-ended #nt-signed-out {
    display: block !important;
    margin: 2rem 1rem;
}

/* What an empty pane says: a title and one plain sentence. */
.nt-empty {
    padding: 2.5rem 1.5rem;
    text-align: center;
    color: var(--nt-text-muted);
}

.nt-empty p {
    margin: 0 0 0.5rem;
}

.nt-empty-title {
    font-size: 1.0625rem;
    font-weight: 600;
    color: var(--nt-text);
}

/* Animations and transitions stop when the user asks for less motion (NFR-UX-03). */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* Text for screen readers only: out of sight, still read. */
.nt-visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

/* NT-033: the shell and the reconnect notice share the window. The notice is a bar in the flow below the shell, never over
   the editor or the note list (as a fixed bar it covered the last lines of the panes at phone width). */
body:has(> .nt-shell) {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
}

body:has(> .nt-shell) > .nt-shell {
    flex: 1 1 auto;
    min-height: 0;
    height: auto;
}

body:has(> .nt-shell) > #components-reconnect-modal {
    position: static;
    flex: 0 0 auto;
}

/* NT-033: a note in the editor pane: the save indicator above the editing surface. */
.nt-note {
    display: flex;
    flex-direction: column;
    min-height: 100%;
}

.nt-note-bar {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding: 0.5rem 1rem 0;
    min-height: 1.75rem;
}

/* NT-037: the note's action in its bar ("Move to trash", or "Restore" for a note in the trash), a 44 px target (NFR-UX-01). */
.nt-note-bar {
    gap: 0.5rem;
}

.nt-note-action {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    min-height: 2.75rem;
    padding: 0 0.75rem;
    border: 1px solid transparent;
    border-radius: var(--nt-radius);
    background: transparent;
    color: var(--nt-text-muted);
    font-size: 0.875rem;
    cursor: pointer;
}

.nt-note-action:hover {
    border-color: var(--nt-border);
    background: var(--nt-hover);
    color: var(--nt-text);
}

.nt-note-action:disabled {
    cursor: progress;
    opacity: 0.7;
}

.nt-note-action svg {
    stroke: currentColor;
    stroke-width: 1.75;
    fill: none;
}

.nt-note-bar-text {
    margin: 0 auto 0 0;
    color: var(--nt-notice-text);
    font-size: 0.875rem;
}

.nt-note-problem {
    margin: 0.25rem 1rem 0;
    color: var(--nt-notice-text);
    font-size: 0.875rem;
}

/* A note in the trash, shown read-only as text (NT-037): its line breaks kept, nothing to edit. */
.nt-trashed-text {
    padding: 1rem;
    color: var(--nt-text-muted);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

/* The save indicator (SaveIndicator, FR-WEB-03): quiet text, the state in data-save-state. */
.nt-save {
    font-size: 0.875rem;
    color: var(--nt-text-muted);
}

.nt-save[data-save-state="kept"],
.nt-save[data-save-state="unsaved"],
.nt-save[data-save-state="conflict"],
.nt-save[data-save-state="too-large"],
.nt-save[data-save-state="rejected"],
.nt-save[data-save-state="limit"] {
    color: var(--nt-notice-text);
}

/* The link to a conflict copy: a 44 px target, like every control of the shell on touch layouts (NFR-UX-01). */
.nt-save-copy {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.75rem;
    min-width: 2.75rem;
    margin-left: 0.25rem;
    padding: 0 0.5rem;
}

/* While the page is offline (connection.js puts nt-offline on the root element), the circuit cannot update the indicator: if
   the editor holds edits the circuit has not had (data-unsaved, set by the editor's script) or a save was under way, the
   indicator says what is true, that the text is kept in this browser (FR-WEB-04, FR-WEB-05). */
.nt-save-offline {
    display: none;
}

html.nt-offline .nt-note:has([data-unsaved]) .nt-save-offline,
html.nt-offline .nt-save[data-save-state="saving"] .nt-save-offline {
    display: inline;
    color: var(--nt-notice-text);
}

html.nt-offline .nt-note:has([data-unsaved]) .nt-save-text,
html.nt-offline .nt-save[data-save-state="saving"] .nt-save-text {
    display: none;
}

/* NT-139: while a new note opens, the page holds the keys typed for it (editor/src/newnote.js puts nt-new-note-pending on the root
   element): the New note button says the note is on its way, so typing that does not show yet is not mistaken for lost. */
html.nt-new-note-pending [data-new-note]::after {
    content: "Opening…";
    margin-left: 0.375rem;
    font-size: 0.875em;
    color: var(--nt-notice-text);
}
