/* Base — shared by every page. Kept as a single stylesheet on purpose:
   one request, no framework, so it can serve as the performance baseline. */

/* One palette for every page and every visitor — the log-in state is shown by
   the corner icon, not by the background. */

:root {
    --sky: #4a9fe0;
    --navy: #0a1a35;
    --text: #ffffff;
    --text-muted: rgba(255, 255, 255, 0.75);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100svh;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    line-height: 1.6;
    color: var(--text);
    background: linear-gradient(160deg, var(--sky) 0%, var(--navy) 100%);
    background-attachment: fixed;
}

/* Homepage */

.page {
    position: relative;
    min-height: 100svh;
    display: flex;
    align-items: center;
    padding: 4rem 1.5rem 8rem;
}

.intro {
    max-width: 36rem;
    margin-inline: auto;
}

.intro__name {
    margin: 0;
    font-size: clamp(2.25rem, 7vw, 4rem);
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 1.1;
}

.intro__tld {
    color: var(--text-muted);
    font-weight: 300;
}

.intro__quote {
    margin: 2rem 0 0;
    padding-left: 1.25rem;
    border-left: 2px solid rgba(255, 255, 255, 0.3);
    font-size: clamp(0.95rem, 2vw, 1.05rem);
    font-style: italic;
    color: var(--text-muted);
}

.social {
    position: absolute;
    left: 1.5rem;
    right: 1.5rem;
    bottom: 1.5rem;
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.75rem 1.5rem;
}

.social__link {
    color: var(--text);
    text-decoration: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.35);
    padding-bottom: 0.15rem;
    transition: border-color 0.2s ease;
}

.social__link:hover,
.social__link:focus-visible {
    border-bottom-color: var(--text);
}

/* Log in / log out — small arrow pinned to the top-right corner. Positioned
   against .page (which is the only positioned ancestor), same as .social. */

.corner {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    margin: 0;
    line-height: 0; /* no descender gap around the inline SVG */
}

.corner__link {
    display: block;
    padding: 0.5rem; /* keeps the tap target usable on touch */
    border: 0;
    background: none;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.2s ease, transform 0.2s ease;
}

.corner__link:hover,
.corner__link:focus-visible {
    color: var(--text);
    transform: translateX(2px); /* nudges the arrow along its own direction */
}

/* Log-out arrow points the other way, so the nudge has to follow it. */

.corner__link--out:hover,
.corner__link--out:focus-visible {
    transform: translateX(-2px);
}

/* Top-left counterpart of .corner, for links only visible when logged in. Text
   (not an icon), so it is nudged to sit on the same line as the corner icon. */

.corner-left {
    position: absolute;
    top: 1.8rem;
    left: 1.5rem;
    display: flex;
    gap: 1.5rem;
}

@media (prefers-reduced-motion: reduce) {
    .corner__link {
        transition: color 0.2s ease;
    }

    .corner__link:hover,
    .corner__link:focus-visible {
        transform: none;
    }
}

/* Login page — same background, just a centred panel on top. */

.page--centered {
    justify-content: center;
    padding-bottom: 4rem;
}

.panel {
    width: 100%;
    max-width: 22rem;
    padding: 2rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 0.75rem;
    background: rgba(0, 0, 0, 0.25);
}

.panel__title {
    margin: 0 0 1.5rem;
    font-size: 1.5rem;
    font-weight: 600;
}

.panel__note {
    margin: 0 0 1.5rem;
    color: var(--text-muted);
}

.field {
    margin-bottom: 1.25rem;
}

.field__label {
    display: block;
    margin-bottom: 0.35rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.field input {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 0.375rem;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text);
    font: inherit;
}

.field input:focus-visible {
    outline: 2px solid var(--text);
    outline-offset: 1px;
}

.button {
    width: 100%;
    padding: 0.6rem 1rem;
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 0.375rem;
    background: rgba(255, 255, 255, 0.12);
    color: var(--text);
    font: inherit;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.button:hover,
.button:focus-visible {
    background: rgba(255, 255, 255, 0.22);
}

.form__errors {
    margin: 0.5rem 0 1rem;
    padding-left: 1.1rem;
    font-size: 0.85rem;
    color: #ffd7d7;
}

/* Notes (private, behind login) — wider than the login panel, same glass look. */

.notes {
    max-width: 48rem;
    margin-inline: auto;
    padding: 2rem 1.5rem 4rem;
}

.notes__header {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem 1.5rem;
    margin-bottom: 1.5rem;
}

.notes__title {
    margin: 0;
    font-size: 1.75rem;
    font-weight: 600;
}

.notes__nav,
.notes__actions {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.notes__actions {
    margin-top: 1.5rem;
}

.notes__link {
    color: var(--text);
    text-decoration: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.35);
    background: none;
    transition: border-color 0.2s ease;
}

.notes__link:hover,
.notes__link:focus-visible {
    border-bottom-color: var(--text);
}

.notes__link--primary {
    font-weight: 600;
}

.notes__link--danger {
    color: #ffd7d7;
}

.notes__empty {
    color: var(--text-muted);
}

.notes__section,
.notes__form {
    margin-bottom: 1.5rem;
    padding: 1.25rem 1.5rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 0.75rem;
    background: rgba(0, 0, 0, 0.25);
}

.notes .button {
    width: auto;
    padding-inline: 1.5rem;
}

.button--danger {
    border-color: rgba(255, 180, 180, 0.6);
}

.note-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.note-row {
    display: flex;
    gap: 1rem;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}

.note-row__thumb {
    flex: none;
    width: 64px;
    height: 64px;
    border-radius: 0.375rem;
    object-fit: cover;
}

/* Keeps titles aligned whether or not a row has a preview. */

.note-row__thumb--empty {
    background: rgba(255, 255, 255, 0.06);
}

.note-row__title {
    color: var(--text);
    font-weight: 600;
    text-decoration: none;
}

.note-row__title:hover,
.note-row__title:focus-visible {
    text-decoration: underline;
}

.note-row__meta {
    font-size: 0.85rem;
    color: var(--text-muted);
    overflow-wrap: anywhere;
}

.note-file {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem 1rem;
}

.note-file__thumb {
    display: block;
    border-radius: 0.375rem;
}

.note-file__size {
    color: var(--text-muted);
}

.notes .field textarea {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 0.375rem;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text);
    font: inherit;
    resize: vertical;
}

.notes .field textarea:focus-visible {
    outline: 2px solid var(--text);
    outline-offset: 1px;
}

.field__help {
    margin-top: 0.25rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.file__current {
    margin: 0 0 0.5rem;
    font-size: 0.9rem;
    overflow-wrap: anywhere;
}

.file__clear {
    margin-left: 0.75rem;
    color: var(--text-muted);
}

/* Rendered markdown */

.prose {
    overflow-wrap: anywhere;
}

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

.prose > :last-child {
    margin-bottom: 0;
}

.prose a {
    color: var(--text);
}

.prose img {
    max-width: 100%;
}

.prose code,
.prose pre {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.9em;
}

.prose code {
    padding: 0.1em 0.3em;
    border-radius: 0.25rem;
    background: rgba(0, 0, 0, 0.3);
}

.prose pre {
    padding: 0.75rem 1rem;
    overflow-x: auto;
    border-radius: 0.375rem;
    background: rgba(0, 0, 0, 0.35);
}

.prose pre code {
    padding: 0;
    background: none;
}

.prose blockquote {
    margin-inline: 0;
    padding-left: 1rem;
    border-left: 2px solid rgba(255, 255, 255, 0.3);
    color: var(--text-muted);
}

.prose table {
    border-collapse: collapse;
}

.prose th,
.prose td {
    padding: 0.35rem 0.75rem;
    border: 1px solid rgba(255, 255, 255, 0.25);
}

/* Blog — bare-bones for now, proper styling (and syntax highlighting) comes later. */

.blog {
    max-width: 48rem;
    margin-inline: auto;
    padding: 2rem 1.5rem 4rem;
}

.blog__header {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem 1.5rem;
    margin-bottom: 1.5rem;
}

.blog__title,
.post__title {
    margin: 0;
    font-size: 1.75rem;
    font-weight: 600;
}

.blog__nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1.25rem;
}

.blog__link {
    color: var(--text);
    text-decoration: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.35);
}

.blog__link:hover,
.blog__link:focus-visible,
.blog__link--current {
    border-bottom-color: var(--text);
}

.blog__empty,
.post__meta,
.post-row__meta,
.comment__meta {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.badge {
    padding: 0 0.4em;
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 0.25rem;
    font-size: 0.8rem;
    text-transform: uppercase;
}

.badge--draft {
    border-color: rgba(255, 215, 150, 0.7);
    color: #ffe2b0;
    text-transform: none;
}

.post-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.post-row {
    padding: 0.75rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}

.post-row__meta {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.post-row__title {
    color: var(--text);
    font-size: 1.15rem;
    font-weight: 600;
    text-decoration: none;
}

.post-row__title:hover,
.post-row__title:focus-visible {
    text-decoration: underline;
}

.post-row__excerpt {
    margin: 0.25rem 0 0;
    color: var(--text-muted);
}

.post__header {
    margin-bottom: 1.5rem;
}

.comments {
    margin-top: 3rem;
    padding-top: 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.25);
}

.comments__title {
    margin: 0 0 1rem;
    font-size: 1.25rem;
}

.comments__message {
    padding: 0.5rem 0.75rem;
    border-radius: 0.375rem;
    background: rgba(255, 255, 255, 0.12);
}

.comment {
    padding: 0.75rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}

.comment__content p {
    margin: 0.25rem 0 0;
}

.comments__form {
    margin-top: 1.5rem;
}

.comments__form textarea {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 0.375rem;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text);
    font: inherit;
    resize: vertical;
}

.comments__form .button {
    width: auto;
    padding-inline: 1.5rem;
}

/* Bookmarks — bare-bones like the blog; same page frame and glass form as notes. */

.bookmarks {
    max-width: 48rem;
    margin-inline: auto;
    padding: 2rem 1.5rem 4rem;
}

.bookmarks__header {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem 1.5rem;
    margin-bottom: 1.5rem;
}

.bookmarks__title {
    margin: 0;
    font-size: 1.75rem;
    font-weight: 600;
}

.bookmarks__nav,
.bookmarks__actions,
.bookmarks__pages {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.bookmarks__actions,
.bookmarks__pages {
    margin-top: 1.5rem;
}

.bookmarks__link {
    color: var(--text);
    text-decoration: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.35);
}

.bookmarks__link:hover,
.bookmarks__link:focus-visible {
    border-bottom-color: var(--text);
}

.bookmarks__link--primary {
    font-weight: 600;
}

.bookmarks__link--danger {
    color: #ffd7d7;
}

.bookmarks__empty,
.bookmarks__summary {
    color: var(--text-muted);
}

.bookmarks__search {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.bookmarks__search input,
.bookmarks .field textarea {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 0.375rem;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text);
    font: inherit;
}

.bookmarks .field textarea {
    resize: vertical;
}

.bookmarks .button {
    width: auto;
    padding-inline: 1.5rem;
}

.bookmarks__form {
    padding: 1.25rem 1.5rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 0.75rem;
    background: rgba(0, 0, 0, 0.25);
}

.bookmarks__fetch {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.bookmarks__notice {
    margin: 0 0 1.25rem;
    padding: 0.5rem 0.75rem;
    border-radius: 0.375rem;
    background: rgba(255, 255, 255, 0.12);
    overflow-wrap: anywhere;
}

.bookmarks .bookmarks__restore {
    display: block;
    margin-top: 0.5rem;
    padding: 0.2rem 0.75rem;
    font-size: 0.85rem;
}

.bookmarks__notice--error {
    background: rgba(255, 120, 120, 0.2);
    color: #ffd7d7;
}

/* htmx toggles .htmx-request on the indicator while the request runs. Its own
   injected <style> for this is switched off (htmx-config meta) because CSP
   does not allow inline styles. */

.htmx-indicator {
    display: none;
    color: var(--text-muted);
}

.htmx-indicator.htmx-request {
    display: inline;
}

/* In the DOM (so Enter can "click" it), invisible and out of the layout. */

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

/* Checkboxes in the same glass look as the text inputs. appearance: none drops
   the native box; the tick is a rotated two-sided border, not an SVG — a
   data: URI image would be blocked by CSP (img-src 'self'). The width/padding
   overrides undo `.field input`, which is meant for text fields. */

.bookmarks .field input[type="checkbox"] {
    appearance: none;
    display: inline-grid;
    place-content: center;
    flex: none;
    width: 1.1rem;
    height: 1.1rem;
    margin: 0 0.5rem 0 0;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 0.25rem;
    background: rgba(255, 255, 255, 0.08);
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

/* Native parts drawn by the browser (the date picker's calendar icon) come out
   light on this dark background instead of black-on-navy. */

.bookmarks .field input[type="date"] {
    color-scheme: dark;
}

.bookmarks .field input[type="checkbox"]::before {
    content: "";
    width: 0.3rem;
    height: 0.6rem;
    margin-top: -0.15rem;
    border: solid var(--navy);
    border-width: 0 2px 2px 0;
    transform: rotate(45deg) scale(0);
    transition: transform 0.1s ease;
}

.bookmarks .field input[type="checkbox"]:checked {
    border-color: var(--text);
    background: var(--text);
}

.bookmarks .field input[type="checkbox"]:checked::before {
    transform: rotate(45deg) scale(1);
}

.bookmarks .field input[type="checkbox"]:focus-visible {
    outline: 2px solid var(--text);
    outline-offset: 2px;
}

.bookmarks .field label:has(input[type="checkbox"]) {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
}

/* Tag checkboxes (CheckboxSelectMultiple: a <div> per option) as a wrap of
   pills; a checked one lights up. */

.bookmarks #id_tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.bookmarks #id_tags label {
    padding: 0.2rem 0.75rem 0.2rem 0.45rem;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
    font-size: 0.9rem;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.bookmarks #id_tags label:hover {
    border-color: rgba(255, 255, 255, 0.6);
}

.bookmarks #id_tags label:has(input:checked) {
    border-color: rgba(255, 255, 255, 0.8);
    background: rgba(255, 255, 255, 0.2);
}

.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 1rem;
}

.tag {
    display: inline-block;
    padding: 0 0.5em;
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 999px;
    color: var(--text);
    font-size: 0.8rem;
    text-decoration: none;
}

.tag--current {
    outline: 2px solid var(--text);
}

.tag__count {
    color: var(--text-muted);
}

/* One rule per Tag.Color value — literal class names, never built from a variable. */

.tag--gray   { background: rgba(160, 160, 160, 0.3); }
.tag--red    { background: rgba(230, 70, 70, 0.4); }
.tag--orange { background: rgba(240, 140, 40, 0.4); }
.tag--yellow { background: rgba(230, 200, 40, 0.4); }
.tag--green  { background: rgba(60, 180, 90, 0.4); }
.tag--blue   { background: rgba(60, 120, 230, 0.45); }
.tag--purple { background: rgba(150, 90, 220, 0.45); }
.tag--pink   { background: rgba(230, 90, 170, 0.4); }

.bookmark-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.bookmark-row {
    display: flex;
    gap: 0.75rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}

/* The empty span keeps titles aligned when a bookmark has no favicon. */

/* Shown at the stored size (32px) — clearer than the usual 16px. */

.bookmark-row__icon {
    flex: none;
    width: 32px;
    height: 32px;
    margin-top: 0.1rem;
}

.bookmark-row__body {
    min-width: 0;
}

.bookmark-row__title {
    color: var(--text);
    font-weight: 600;
    text-decoration: none;
    overflow-wrap: anywhere;
}

.bookmark-row__title:hover,
.bookmark-row__title:focus-visible {
    text-decoration: underline;
}

.bookmark-row__meta {
    font-size: 0.85rem;
    color: var(--text-muted);
    overflow-wrap: anywhere;
}

.bookmark-row__description {
    margin: 0.25rem 0 0;
}

.bookmark-row__tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    margin-top: 0.35rem;
}
