/* Cards, pills, dialogs and the empty state. */

/* ---------- Section labels (e.g. "Notizen") ---------- */

.main-content > section > h2 {
    width: fit-content;
    margin-bottom: 20px;
    padding: 6px 14px;

    background-color: var(--ink);
    border: var(--border-pill);
    border-radius: var(--radius-pill);
    color: var(--white);
    font-size: var(--fs-sm);
    font-weight: var(--fw-black);
    letter-spacing: var(--ls-label);
    text-transform: uppercase;
}

/* ---------- Cards ---------- */

#content,
#trash_content,
#archive_content {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr));
    gap: 26px;
}

.notes-card {
    min-height: 180px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 12px;
    padding: 22px 24px;

    background-color: var(--card-pink);
    border: var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
}

/* Card colors repeat every 6 cards */
.notes-card:nth-child(6n + 1) { background-color: var(--card-pink); }
.notes-card:nth-child(6n + 2) { background-color: var(--card-mint); }
.notes-card:nth-child(6n + 3) { background-color: var(--card-yellow); }
.notes-card:nth-child(6n + 4) { background-color: var(--card-lilac); }
.notes-card:nth-child(6n + 5) { background-color: var(--card-peach); }
.notes-card:nth-child(6n + 6) { background-color: var(--card-blue); }

/* Slight tilt */
.notes-card:nth-child(3n + 1) { transform: rotate(var(--tilt-left)); }
.notes-card:nth-child(3n) { transform: rotate(var(--tilt-right)); }

/* ---------- Pills (buttons on cards) ---------- */

/* The clickable text area of a card (opens the dialog) */
.card-open-button {
    flex: 1;
    min-width: 0;
    display: flex;               /* flex + flex-start keeps the text at the top */
    flex-direction: column;
    justify-content: flex-start;
    padding: 0;

    background: none;
    border: none;
    text-align: left;
}

.card-title {
    display: block;
    margin-bottom: 6px;

    font-size: var(--fs-lg);
    font-weight: var(--fw-black);

    /* One line, then "..." */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-text {
    display: -webkit-box;
    -webkit-line-clamp: 4;       /* cut after 4 lines */
    -webkit-box-orient: vertical;
    overflow: hidden;
    overflow-wrap: anywhere;     /* break long words without spaces */

    font-weight: var(--fw-regular);
}

.card-buttons {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 8px;
}

.card-date {
    margin-right: auto;          /* pushes the buttons to the right */
    font-size: var(--fs-sm);
    font-weight: var(--fw-bold);
}

/* Round icon buttons, 40px so they are easy to hit */
.card-buttons button,
.dialog-header button,
.dialog-footer button {
    width: 40px;
    height: 40px;
    flex: none;
    display: flex;
    justify-content: center;
    align-items: center;

    background-color: var(--white);
    border: var(--border-pill);
    border-radius: var(--radius-round);
    box-shadow: var(--shadow-pill);
}

.card-buttons button:hover,
.dialog-header button:hover,
.dialog-footer button:hover {
    background-color: var(--sun);
}

/* ---------- Dialog (full note) ---------- */

.note-dialog {
    width: min(90vw, 700px);
    max-height: 90dvh;
    margin: auto;               /* center (the * reset removed the default) */
    padding: 28px;
    overflow-y: auto;

    background-color: var(--white);
    border: var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-compose);
    color: var(--ink);
}

.note-dialog::backdrop {
    background-color: var(--dots);
    backdrop-filter: blur(2px);
}

.dialog-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 16px;
}

.dialog-header h2 {
    min-width: 0;
    font-size: var(--fs-xl);
    font-weight: var(--fw-black);
    overflow-wrap: anywhere;
}

.dialog-buttons {
    display: flex;
    gap: 8px;
    margin-left: auto;           /* stays on the right, also when the title is hidden (edit mode) */
}

/* ---------- Dialog: edit mode ---------- */

/* Normal view is shown by default, edit mode is hidden */
#dialog_edit {
    display: none;
}

/* Class "editing" (set in dialog.js) switches the two around */
.note-dialog.editing #dialog_edit {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.note-dialog.editing #dialog_title,
.note-dialog.editing #dialog_edit_button,
.note-dialog.editing #dialog_text,
.note-dialog.editing .dialog-footer {
    display: none;
}

#dialog_edit input,
#dialog_edit textarea {
    width: 100%;
    padding: 12px 16px;

    border: var(--border);
    border-radius: var(--radius-md);
    font-size: var(--fs-md);
    color: var(--ink);
}

#dialog_title_input {
    font-size: var(--fs-lg);
    font-weight: var(--fw-black);
}

#dialog_edit textarea {
    resize: vertical;
    line-height: 1.6;
}

.dialog-edit-buttons {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 12px;
}

.dialog-edit-buttons button {
    padding: 10px 22px;

    background-color: var(--white);
    border: var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-btn);
}

.dialog-edit-buttons .save-button {
    background-color: var(--coral);
}

.dialog-edit-buttons button:active {
    box-shadow: none;
    transform: translate(4px, 4px);
}

/* ---------- Dialog: name ---------- */

#name_dialog {
    width: min(90vw, 420px);
}

#name_dialog h2 {
    margin-bottom: 16px;
    font-size: var(--fs-xl);
    font-weight: var(--fw-black);
}

#name_dialog label {
    font-weight: var(--fw-bold);
}

#name_input {
    width: 100%;
    margin: 8px 0 20px;
    padding: 12px 16px;

    border: var(--border);
    border-radius: var(--radius-md);
    font-size: var(--fs-md);
    color: var(--ink);
}

/* ---------- Dialog: note text (rendered Markdown) ---------- */

#dialog_text {
    overflow-wrap: anywhere;
    line-height: 1.6;
}

/* Space between paragraphs, lists, headings ... */
#dialog_text > * + * {
    margin-top: 12px;
}

#dialog_text h1,
#dialog_text h2,
#dialog_text h3 {
    font-size: var(--fs-lg);
    font-weight: var(--fw-black);
}

#dialog_text ul,
#dialog_text ol {
    padding-left: 24px;
}

#dialog_text a {
    color: var(--title-accent);
    text-decoration: underline;
}

#dialog_text blockquote {
    padding-left: 12px;
    border-left: 4px solid var(--ink);
    color: var(--mute);
}

#dialog_text code {
    padding: 0 6px;
    background-color: var(--cream);
    border-radius: 6px;
}

#dialog_text pre {
    padding: 12px 16px;
    overflow-x: auto;           /* long code lines scroll instead of breaking the dialog */
    background-color: var(--cream);
    border: var(--border-pill);
    border-radius: var(--radius-sm);
}

#dialog_text pre code {
    padding: 0;
    background: none;
}

#dialog_text img {
    max-width: 100%;
}

.dialog-footer {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 24px;
    margin-top: 24px;
}

#dialog_counter {
    font-size: var(--fs-sm);
    font-weight: var(--fw-bold);
}

/* ---------- Empty state (no notes / nothing found) ---------- */

/* Spans all grid columns, so it is centered in the section */
.empty-state {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 40px 0;

    text-align: center;
}

.empty-icon {
    width: 140px;
    height: 140px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 12px;

    background-color: var(--mint);
    border: var(--border-thick);
    border-radius: var(--radius-round);
    box-shadow: var(--shadow-compose);
}

.empty-state .icon {
    width: 56px;
    height: 56px;
}

.empty-state h3 {
    font-size: var(--fs-xl);
    font-weight: var(--fw-black);
}

.empty-state p {
    color: var(--mute);
}

.empty-state button {
    margin-top: 8px;
    padding: 12px 24px;

    background-color: var(--coral);
    border: var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-btn);
}

.empty-state button:active {
    box-shadow: none;
    transform: translate(4px, 4px);
}

/* ---------- Trash cards: dashed border and lighter shadow ---------- */

#trash_content .notes-card {
    border: var(--border-dashed);
    box-shadow: var(--shadow-card-trash);
}

/* ---------- Pinned note (above the input area) ---------- */

/* No pinned note = empty section = no space */
#pinned_section:empty {
    display: none;
}

/* Same card as in the list, but yellow, straight and not so tall */
#pinned_section .notes-card {
    min-height: 0;
    background-color: var(--sun);
    transform: none;
}
