/* ClearJournal: one readable column beside a sidebar, quiet chrome, pool-blue light and dark. */

/* Light is the default. Dark and Water are chosen with the switch in the footer (js/theme.js sets data-theme). */
:root {
    color-scheme: light;
    --bg: #e4f1f5;
    --surface: #f6fbfc;
    --fg: #12293a;
    --muted: #3f586b;
    --faint: #4b6476;
    --line: #bcd5de;
    --accent: #086a8e;
    --accent-hover: #054b66;
    --on-accent: #ffffff;
    --code-bg: #d9eaf0;
    --mark: #c4e6ee;
    --danger: #b3261e;
    --wash: #dcecf2;
    --backdrop: url("../img/water-light.svg");
    --header-bg: none;

    --serif: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Palatino, Charter, "Bitstream Charter", Georgia, serif;
    --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, monospace;

    --measure: 40rem;
    --sidebar: 16rem;
    --gutter: 3rem;
    --radius: 6px;
}

/* Dark: a pool at night. */
:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0c1a26;
    --surface: #112333;
    --fg: #dbe7f0;
    --muted: #9db2c3;
    --faint: #8499ab;
    --line: #1f3447;
    --accent: #4cc3e0;
    --accent-hover: #8adbee;
    --on-accent: #06202c;
    --code-bg: #132a3c;
    --mark: #1f4a57;
    --danger: #ff8a80;
    --wash: #10303f;
    --backdrop: none;
    --header-bg: linear-gradient(180deg, var(--wash), var(--bg));
}

/* Water: deep teal with silky light streaks. */
:root[data-theme="water"] {
    color-scheme: dark;
    --bg: #0a4f62;
    --surface: #0c4658;
    --fg: #f0fafc;
    --muted: #c4e4eb;
    --faint: #a9d5df;
    --line: #4b98aa;
    --accent: #5fdcef;
    --accent-hover: #a6eef8;
    --on-accent: #04303d;
    --code-bg: #083c4c;
    --mark: #1d6d80;
    --danger: #ffb4a9;
    --wash: #0a4f62;
    --backdrop: url("../img/water.svg");
    --header-bg: none;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    margin: 0;
    background: var(--bg);
    color: var(--fg);
    font-family: var(--serif);
    font-size: 1.125rem;
    line-height: 1.65;
    text-rendering: optimizeLegibility;
}

/* The water picture sits in a fixed layer behind the page, so it stays put while the text scrolls over it. */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    background: var(--bg) var(--backdrop) center / cover no-repeat;
    pointer-events: none;
}

a {
    color: var(--accent);
    text-decoration-thickness: 1px;
    text-underline-offset: 0.18em;
}

a:hover {
    color: var(--accent-hover);
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.wrap {
    max-width: var(--measure);
    margin: 0 auto;
    padding: 0 1.25rem;
}

.skip {
    position: absolute;
    left: -999px;
}

.skip:focus {
    left: 1rem;
    top: 1rem;
    background: var(--surface);
    padding: 0.5rem 0.75rem;
    z-index: 10;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

/* Header, sidebar & footer */

.frame {
    width: 100%;
    max-width: calc(var(--sidebar) + var(--gutter) + var(--measure) + 2.5rem);
    margin: 0 auto;
    padding: 0 1.25rem;
}

.site-header {
    padding: 2.25rem 0 2.5rem;
    background: var(--header-bg);
}

.site-header-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem 1.5rem;
}

.site-title {
    font-family: var(--sans);
    font-weight: 650;
    font-size: 1.05rem;
    letter-spacing: -0.01em;
    color: var(--fg);
    text-decoration: none;
}

.site-title:hover {
    color: var(--accent);
}

.site-nav {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.25rem 1.25rem;
    font-family: var(--sans);
    font-size: 0.95rem;
}

.site-nav a {
    color: var(--muted);
    text-decoration: none;
    padding: 0.25rem 0;
    border-bottom: 1px solid transparent;
}

.site-nav a:hover {
    color: var(--fg);
}

.site-nav a[aria-current="page"] {
    color: var(--fg);
    border-bottom-color: var(--accent);
}

.theme-switch {
    display: inline-flex;
    align-items: center;
    gap: 0.15rem;
    padding: 0.15rem;
    border: 1px solid var(--line);
    border-radius: 999px;
}

.theme-switch[hidden] {
    display: none;
}

.theme-switch button {
    font: inherit;
    font-size: 0.8rem;
    color: var(--muted);
    background: none;
    border: 0;
    border-radius: 999px;
    padding: 0.1rem 0.65rem;
    cursor: pointer;
}

.theme-switch button:hover {
    color: var(--fg);
}

.theme-switch button[aria-pressed="true"] {
    color: var(--on-accent);
    background: var(--accent);
}

.site-body {
    flex: 1 0 auto;
    display: grid;
    grid-template-columns: var(--sidebar) minmax(0, var(--measure));
    grid-template-areas: "side main";
    column-gap: var(--gutter);
    align-items: start;
    justify-content: center;
    width: 100%;
    max-width: calc(var(--sidebar) + var(--gutter) + var(--measure) + 2.5rem);
    margin: 0 auto;
    padding: 0 1.25rem;
}

.site-body > main {
    grid-area: main;
    min-width: 0;
}

/* Sign-in and error pages: no sidebar, content centred. */
.site-body.is-plain {
    grid-template-columns: minmax(0, var(--measure));
    grid-template-areas: "main";
    max-width: calc(var(--measure) + 2.5rem);
}

.sidebar {
    grid-area: side;
    position: sticky;
    top: 1.5rem;
    max-height: calc(100dvh - 3rem);
    overflow-y: auto;
    font-family: var(--sans);
    font-size: 0.9rem;
    line-height: 1.45;
}

.side-section + .side-section {
    margin-top: 2rem;
}

.sidebar h2 {
    margin: 0 0 0.6rem;
    padding-bottom: 0.35rem;
    border-bottom: 1px solid var(--line);
    font-size: 0.8rem;
    font-weight: 650;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--faint);
}

.sidebar h3 {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    margin: 1rem 0 0.25rem;
    font-size: 0.9rem;
    font-weight: 650;
    color: var(--fg);
}

.side-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.side-list li {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.12rem 0;
}

.side-recent {
    margin-bottom: 0.5rem;
}

.sidebar a {
    color: var(--fg);
    text-decoration: none;
    overflow-wrap: anywhere;
}

.sidebar a:hover {
    color: var(--accent);
    text-decoration: underline;
}

.side-count {
    color: var(--faint);
    font-weight: 400;
    font-variant-numeric: tabular-nums;
}

.side-empty {
    margin: 0;
    color: var(--muted);
}

.site-footer {
    flex-shrink: 0;
    margin-top: 4rem;
    padding: 1.5rem 0 2.5rem;
    border-top: 1px solid var(--line);
    font-family: var(--sans);
    font-size: 0.85rem;
    color: var(--faint);
}

.site-footer-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem 1.25rem;
}

.site-footer span {
    margin-right: auto;
}

.site-footer a {
    color: var(--muted);
}

@media (max-width: 60rem) {
    .site-body {
        grid-template-columns: minmax(0, var(--measure));
        grid-template-areas: "main" "side";
    }

    .sidebar {
        position: static;
        max-height: none;
        overflow: visible;
        margin-top: 3rem;
        padding-top: 1.5rem;
        border-top: 1px solid var(--line);
    }
}

/* Entries */

.feed .entry + .entry {
    margin-top: 3rem;
    padding-top: 3rem;
    border-top: 1px solid var(--line);
}

.entry-header {
    margin-bottom: 0.75rem;
}

.entry-date {
    font-family: var(--sans);
    font-size: 0.85rem;
    color: var(--faint);
    text-decoration: none;
    font-variant-numeric: tabular-nums;
}

.entry-date:hover {
    color: var(--accent);
}

.entry-title {
    font-size: 1.6rem;
    line-height: 1.25;
    letter-spacing: -0.01em;
    font-weight: 600;
    margin: 0.35rem 0 0;
}

h1.entry-title {
    font-size: 2rem;
}

.entry-title a {
    color: inherit;
    text-decoration: none;
}

.entry-title a:hover {
    color: var(--accent);
}

.entry.is-draft {
    outline: 1px dashed var(--line);
    outline-offset: 1rem;
}

.badge {
    display: inline-block;
    margin-left: 0.5rem;
    padding: 0.05rem 0.5rem;
    border-radius: 999px;
    font-family: var(--sans);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    background: var(--code-bg);
    color: var(--muted);
    vertical-align: 0.1em;
}

.entry-owner {
    margin: 1rem 0 0;
    font-family: var(--sans);
    font-size: 0.85rem;
}

/* Written content */

.entry-content {
    overflow-wrap: break-word;
}

.entry-content > :first-child {
    margin-top: 0;
}

.entry-content > :last-child {
    margin-bottom: 0;
}

.entry-content p,
.entry-content ul,
.entry-content ol,
.entry-content dl,
.entry-content blockquote,
.entry-content pre,
.entry-content table,
.entry-content figure {
    margin: 0 0 1.1em;
}

.entry-content h1,
.entry-content h2,
.entry-content h3,
.entry-content h4 {
    line-height: 1.3;
    margin: 1.6em 0 0.5em;
    font-weight: 600;
}

.entry-content h1 { font-size: 1.5rem; }
.entry-content h2 { font-size: 1.35rem; }
.entry-content h3 { font-size: 1.15rem; }
.entry-content h4 { font-size: 1rem; }

.entry-content ul,
.entry-content ol {
    padding-left: 1.4em;
}

.entry-content li + li {
    margin-top: 0.25em;
}

.entry-content li > ul,
.entry-content li > ol {
    margin: 0.25em 0 0;
}

.entry-content .contains-task-list {
    list-style: none;
    padding-left: 0.2em;
}

.entry-content blockquote {
    padding: 0 0 0 1.1em;
    border-left: 3px solid var(--line);
    color: var(--muted);
    font-style: italic;
}

.entry-content hr {
    border: 0;
    height: 1px;
    background: var(--line);
    margin: 2em 0;
}

.entry-content img {
    display: block;
    max-width: 100%;
    height: auto;
    border-radius: var(--radius);
    margin: 0.25em auto;
}

.entry-content code,
.entry-content kbd {
    font-family: var(--mono);
    font-size: 0.85em;
    background: var(--code-bg);
    padding: 0.1em 0.35em;
    border-radius: 4px;
}

.entry-content pre {
    font-family: var(--mono);
    font-size: 0.85rem;
    line-height: 1.55;
    background: var(--code-bg);
    padding: 0.9rem 1rem;
    border-radius: var(--radius);
    overflow-x: auto;
}

.entry-content pre code {
    padding: 0;
    background: none;
    font-size: inherit;
}

.entry-content mark {
    background: var(--mark);
    color: inherit;
}

.entry-content table {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--sans);
    font-size: 0.9rem;
    display: block;
    overflow-x: auto;
}

.entry-content th,
.entry-content td {
    padding: 0.4rem 0.6rem;
    border-bottom: 1px solid var(--line);
    text-align: left;
}

.entry-content .footnotes {
    font-size: 0.9rem;
    color: var(--muted);
}

/* YouTube: a thumbnail until clicked, then the player */

.entry-content .video {
    margin: 0.25em 0 1.1em;
}

.video-link,
.video-frame {
    position: relative;
    display: block;
    width: 100%;
    aspect-ratio: 16 / 9;
    border-radius: var(--radius);
    overflow: hidden;
    background: #000;
}

.entry-content .video-link img {
    width: 100%;
    height: 100%;
    margin: 0;
    object-fit: cover;
    border-radius: 0;
    opacity: 0.92;
    transition: opacity 0.15s;
}

.video-link:hover img,
.video-link:focus-visible img {
    opacity: 1;
}

.video-play {
    position: absolute;
    inset: 50% auto auto 50%;
    width: 68px;
    height: 48px;
    transform: translate(-50%, -50%);
    border-radius: 12px;
    background: rgb(20 20 20 / 0.8);
    transition: background 0.15s;
}

.video-play::after {
    content: "";
    position: absolute;
    inset: 50% auto auto 54%;
    transform: translate(-50%, -50%);
    border-style: solid;
    border-width: 10px 0 10px 17px;
    border-color: transparent transparent transparent #fff;
}

.video-link:hover .video-play,
.video-link:focus-visible .video-play {
    background: #e62117;
}

.video-frame iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

/* Pages */

.page-title {
    font-size: 2rem;
    line-height: 1.2;
    font-weight: 600;
    letter-spacing: -0.01em;
    margin: 0 0 0.5rem;
}

.page-intro,
.empty {
    color: var(--muted);
    font-family: var(--sans);
    font-size: 0.95rem;
}

.pager {
    display: flex;
    justify-content: space-between;
    gap: 1.5rem;
    margin-top: 3.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--line);
    font-family: var(--sans);
    font-size: 0.95rem;
}

.pager a {
    text-decoration: none;
}

.pager-older {
    margin-left: auto;
    text-align: right;
}

.entry-pager a {
    display: flex;
    flex-direction: column;
    max-width: 48%;
}

.pager-label {
    font-size: 0.8rem;
    color: var(--faint);
}

.pager-title {
    color: var(--fg);
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
}

.pager a:hover .pager-title {
    color: var(--accent);
}

/* History */

.history-year {
    margin-top: 2.5rem;
}

.history-year h2 {
    font-family: var(--sans);
    font-size: 1.4rem;
    font-weight: 650;
    margin: 0 0 0.25rem;
}

.history-year h3 {
    font-family: var(--sans);
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--faint);
    margin: 1.5rem 0 0.4rem;
}

.history-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.history-list li {
    display: grid;
    grid-template-columns: 2.25rem 1fr;
    gap: 0.75rem;
    padding: 0.3rem 0;
}

.history-list time {
    font-family: var(--sans);
    font-size: 0.85rem;
    color: var(--faint);
    font-variant-numeric: tabular-nums;
    padding-top: 0.2rem;
}

.history-list a {
    color: var(--fg);
    text-decoration: none;
}

.history-list a.has-title {
    font-weight: 600;
}

.history-list a:hover {
    color: var(--accent);
    text-decoration: underline;
}

/* Links */

.link-group {
    margin-top: 2rem;
}

.link-group h2 {
    font-family: var(--sans);
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--faint);
    margin: 0 0 0.5rem;
}

.link-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.link-list li {
    padding: 0.55rem 0;
    border-bottom: 1px solid var(--line);
}

.link-list li > a {
    font-weight: 600;
}

.link-host {
    margin-left: 0.5rem;
    font-family: var(--sans);
    font-size: 0.8rem;
    color: var(--faint);
}

.link-note {
    margin: 0.15rem 0 0;
    color: var(--muted);
    font-size: 1rem;
}

/* Login & errors */

.login {
    max-width: 22rem;
    margin: 2rem auto 0;
}

.login-form {
    display: grid;
    gap: 0.6rem;
    font-family: var(--sans);
}

.login-form label {
    font-size: 0.9rem;
    color: var(--muted);
}

.login-form input {
    font: inherit;
    font-size: 1rem;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--fg);
}

.field-error {
    color: var(--danger);
    font-family: var(--sans);
    font-size: 0.9rem;
    margin: 0;
}

.field-error:empty {
    display: none;
}

.button {
    display: inline-block;
    font-family: var(--sans);
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.2;
    padding: 0.6rem 1.1rem;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--fg);
    cursor: pointer;
    text-decoration: none;
}

.button:hover {
    border-color: var(--faint);
    color: var(--fg);
}

.button.primary {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--on-accent);
}

.button.primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    color: var(--on-accent);
}

.error-page {
    text-align: center;
    padding: 3rem 0;
}

.error-code {
    font-family: var(--sans);
    font-size: 4rem;
    font-weight: 700;
    color: var(--line);
    margin: 0;
    line-height: 1;
}

@media (max-width: 30rem) {
    body {
        font-size: 1.0625rem;
    }

    .site-header {
        padding: 1.5rem 0 1.75rem;
    }

    h1.entry-title,
    .page-title {
        font-size: 1.65rem;
    }
}
