/* Note cards and composer. Also loaded by the home page's Quick Notes. */

/* ===== Notes ===== */
.notes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1rem;
}

.notes-list-header,
.note-reader-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.notes-list-header {
    margin-bottom: 0.75rem;
}

.notes-list-header h2 {
    margin-bottom: 0;
}

.notes-count {
    margin-top: 0.2rem;
    color: var(--text-muted);
    font-size: 0.8rem;
}

.notes-search {
    width: min(100%, 20rem);
}

.note-card {
    display: block;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}

a.note-card,
button.note-card {
    cursor: pointer;
}

a.note-card:hover,
button.note-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    border-color: var(--border-strong);
}

.note-card h3 {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    /* User text: a pasted URL has no break opportunity and would otherwise
       widen the whole page. See the note on .task-text. */
    overflow-wrap: anywhere;
}

.note-card p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
    overflow-wrap: anywhere;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.note-card .note-date {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.75rem;
}

.note-card .note-link {
    display: inline-block;
    margin-top: 0.4rem;
    font-size: 0.8rem;
    color: var(--accent);
    text-decoration: none;
    cursor: pointer;
    overflow-wrap: anywhere;
}

.note-card .note-link:hover { text-decoration: underline; }

.note-reader {
    width: min(100%, 42rem);
    max-height: min(85vh, 52rem);
    overflow-y: auto;
}

.note-reader-heading {
    align-items: flex-start;
}

.note-reader-heading h2 {
    min-width: 0;
    overflow-wrap: anywhere;
}

.note-reader .note-date {
    color: var(--text-muted);
    font-size: 0.8rem;
    margin: 0.5rem 0 1rem;
}

.note-reader-body {
    color: var(--text-primary);
    line-height: 1.7;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}

.note-reader .note-link {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    margin-top: 0.75rem;
}

.note-reader .modal-actions {
    margin-top: 1.25rem;
}

.note-color-bar {
    height: 3px;
    border-radius: 2px;
    margin-bottom: 0.75rem;
}

.note-color-accent { background: var(--accent); }
.note-color-success { background: var(--success); }
.note-color-warning { background: var(--warning); }
.note-color-danger { background: var(--danger); }
.note-color-cyan { background: #06b6d4; }
.note-color-pink { background: #f472b6; }

/* Note composer */
/* The form is a flex column so every group gets an even 12px rhythm. As a
   plain block the groups stacked flush, and only inputs carried a margin --
   which is what pulled the Link hint away from the field it describes. */
.note-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.note-form input,
.note-form textarea {
    width: 100%;
}

/* No margin-bottom here: .form-group's own 0.5rem gap already spaces this
   from the .form-help paragraph, matching the tasks and calendar forms. */
.note-form input {
    font-weight: 600;
}

.note-form textarea {
    resize: vertical;
    display: block;
}

/* margin-top reset: the form's flex gap already separates the action row,
   and flex margins do not collapse the way block margins do. */
.note-form-actions {
    margin-top: 0;
    display: flex;
    gap: 0.5rem;
}

.color-picker {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}
.color-radio {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}
.color-swatch {
    display: inline-block;
    position: relative;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: transform 0.15s, border-color 0.15s;
}
/* The swatch is a 24px dot, but it is the only tap target for choosing a
   note colour. A transparent overlay extends the hit area to 44px without
   altering the drawn circle or the focus ring, which are both sized to it. */
.color-swatch::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 44px;
    height: 44px;
    transform: translate(-50%, -50%);
}
.color-radio:focus + .color-swatch,
.color-swatch:hover {
    border-color: var(--bg-card);
    transform: scale(1.15);
}
.color-radio:checked + .color-swatch {
    border-color: var(--text-primary);
    box-shadow: 0 0 0 2px var(--bg-card), 0 0 0 3px var(--accent-light);
}

.quick-note-form {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    /* Lets Save drop to its own line rather than crushing the field once the
       row runs out of room. */
    flex-wrap: wrap;
}
/* iOS zooms the viewport whenever a focused control renders below 16px, which
   yanks the page sideways and leaves the user pinch-zoomed out. Measured at
   15.2px here, and 14.4px for the Pomodoro minute field in home.css. Every
   other control in the app inherits 16px from body. */
.quick-note-form input {
    /* min-width:0 is the load-bearing part. A flex item defaults to
       min-width:auto, which floors an <input> at its intrinsic width (roughly
       the default size=20 character box). That refused to shrink and pushed
       the whole page's layout viewport out to 431px on a 390px screen, which
       in turn stretched every fixed layer including the tab bar. */
    flex: 1 1 6rem;
    min-width: 0;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 16px;
}
.quick-note-composer {
    margin-bottom: 1rem;
}

.note-actions {
    display: flex;
    gap: 0.35rem;
    margin-top: 0.75rem;
    justify-content: flex-end;
}

/* ===== Empty State ===== */
/* The empty state is a grid item. Without spanning every column,
   text-align: center only centers it inside the first column. */
.notes-grid > .empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 1rem;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .notes-grid {
        grid-template-columns: 1fr;
    }

    /* Standalone element on its own line, so the inline-target exemption does
       not apply. Measured 20px, under even the 24px WCAG 2.2 AA minimum. */
    .note-card .note-link {
        display: inline-flex;
        align-items: center;
        min-height: 44px;
    }

    .notes-list-header {
        align-items: stretch;
        flex-direction: column;
    }

    .notes-search {
        width: 100%;
    }
}
