/* Maika: an adaptive Japanese minimalist theme. Washi paper, sumi ink and a shu (vermilion) seal.
   Uses system fonts only. */

:root {
    color-scheme: light dark;
    --background: #f6f3ec;
    --surface: #eeeae0;
    --primary: #2b2925;
    --secondary: #5f5b53;
    --muted: #8d877b;
    --links: #2f4f6e;
    --accent: #b9412d;
    --seal-ink: #f6f3ec;
    --rule: #dcd6c9;
    --selection: #b9412d2e;
    --mincho: "Hiragino Mincho ProN", "Yu Mincho", "YuMincho", "Iowan Old Style", "Times New Roman", serif;
    --gothic: "Hiragino Sans", "Hiragino Kaku Gothic ProN", -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
    --mono: ui-monospace, "SF Mono", Menlo, monospace;
    --measure: 34em;
}

@media (prefers-color-scheme: dark) {
    :root {
        --background: #161513;
        --surface: #201f1c;
        --primary: #e6e1d6;
        --secondary: #aaa496;
        --muted: #78736a;
        --links: #93b3d2;
        --accent: #de6a50;
        --seal-ink: #161513;
        --rule: #34322d;
        --selection: #de6a5038;
    }
}

html {
    font-size: 100%;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--gothic);
    font-size: 1.0625em;
    font-weight: 300;
    line-height: 1.95;
    letter-spacing: 0.01em;
    color: var(--primary);
    background: var(--background);
    box-sizing: border-box;
    max-width: var(--measure);
    margin: 0 auto;
    padding: 3.5em 1.5em 4em;
    overflow-wrap: anywhere;
    word-break: break-word;
}

::selection {
    background: var(--selection);
}

/* NNW text size preference */
.smallText { font-size: 0.9em; }
.mediumText { font-size: 1em; }
.largeText { font-size: 1.15em; }
.xLargeText { font-size: 1.3em; }
.xxLargeText { font-size: 1.5em; }

/* Scroll progress: a single brush line drawn down the right edge */

.maika-scroll {
    position: fixed;
    top: 0;
    right: 0.6em;
    bottom: 0;
    width: 1px;
    background: var(--rule);
    z-index: 10;
    pointer-events: none;
}

.maika-scroll-ink {
    display: block;
    height: 100%;
    background: var(--accent);
    transform: scaleY(0);
    transform-origin: center top;
}

/* Masthead */

.masthead {
    position: relative;
    margin: 0 0 3.5em;
}

.maika-vertical {
    display: none;
}

.maika-seal {
    display: grid;
    place-items: center;
    width: 2.1em;
    height: 2.1em;
    margin-bottom: 1.75em;
    border-radius: 0.2em;
    background: var(--accent);
    color: var(--seal-ink);
    font-family: var(--mincho);
    font-size: 1.15em;
    font-weight: 600;
    line-height: 1;
    transform: rotate(-4deg);
    box-shadow: inset 0 0 0 0.12em var(--accent), inset 0 0 0 0.2em var(--seal-ink);
    opacity: 0.92;
}

.maika-seal:empty {
    visibility: hidden;
}

.maika-feed {
    display: flex;
    align-items: center;
    gap: 0.6em;
    margin: 0;
    font-size: 0.7em;
    font-weight: 400;
    letter-spacing: 0.24em;
    text-transform: uppercase;
    color: var(--muted);
}

.maika-feed a {
    color: inherit;
    text-decoration: none;
}

.maika-avatar {
    width: 1.5em;
    height: 1.5em;
    border-radius: 50%;
    object-fit: cover;
    filter: grayscale(0.35);
}

.maika-avatar[src=""] {
    display: none;
}

.masthead .articleTitle {
    margin-top: 1.1em;
}

.masthead .articleTitle:has(a:empty) {
    display: none;
}

.maika-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0 1.4em;
    margin: 1.3em 0 0;
    font-size: 0.72em;
    letter-spacing: 0.12em;
    color: var(--muted);
}

.maika-date:empty {
    display: none;
}

.byline {
    margin-top: 0.25em;
    font-size: 0.72em;
    letter-spacing: 0.08em;
    color: var(--secondary);
}

.byline:empty {
    display: none;
}

.byline a {
    color: inherit;
    text-decoration: none;
}

/* A short ink stroke, thick at the start and fading out like a brush */
.maika-brush {
    width: 4.5em;
    height: 3px;
    margin-top: 2.5em;
    border-radius: 3px 1px 1px 3px;
    background: linear-gradient(90deg, var(--primary) 0%, var(--primary) 55%, transparent 100%);
    opacity: 0.85;
}

/* On wide windows, set the feed and date vertically beside the title */
@media (min-width: 900px) {
    body {
        padding-top: 5em;
    }

    .maika-vertical {
        position: absolute;
        top: 0;
        left: -4.75em;
        display: flex;
        gap: 1em;
        writing-mode: vertical-rl;
        font-size: 0.68em;
        letter-spacing: 0.3em;
        text-transform: uppercase;
        color: var(--muted);
        white-space: nowrap;
    }

    .maika-vertical-date {
        color: var(--accent);
    }

    .maika-vertical span:empty {
        display: none;
    }
}

/* Headings */

:is(h1, h2, h3, h4, h5, h6) {
    font-family: var(--mincho);
    font-weight: 400;
    line-height: 1.45;
    letter-spacing: 0.03em;
    color: var(--primary);
    text-wrap: balance;
    margin-block-start: 2.75em;
    margin-block-end: 0;
}

.articleTitle h1 {
    font-size: 2.05em;
    font-weight: 300;
    line-height: 1.35;
    letter-spacing: 0.02em;
    margin: 0;
}

.articleBody h2 {
    font-size: 1.32em;
}

.articleBody h2::before {
    content: "";
    display: block;
    width: 0.55em;
    height: 0.55em;
    margin-bottom: 1em;
    border: 1px solid var(--accent);
    border-radius: 50%;
}

.articleBody h3 {
    font-size: 1.05em;
    font-weight: 600;
}

h4, h5, h6 {
    font-size: 1em;
    color: var(--secondary);
}

:is(h1, h2, h3, h4, h5, h6) a {
    color: inherit;
    text-decoration: none;
}

/* Body text */

p {
    margin: 0;
}

.articleBody > * + * {
    margin-block-start: 1.35em;
}

.articleBody > :is(h2, h3, h4) + * {
    margin-block-start: 0.8em;
}

a {
    color: var(--links);
    text-decoration-color: var(--rule);
    text-decoration-thickness: 1px;
    text-underline-offset: 0.3em;
}

a:hover,
a:focus {
    color: var(--accent);
    text-decoration-color: currentColor;
}

strong,
b {
    font-weight: 600;
}

em,
i {
    font-style: italic;
}

/* Three quiet points in place of a rule */
hr {
    border: 0;
    height: 0.3em;
    margin: 3em auto;
    width: 2.6em;
    background: radial-gradient(circle, var(--muted) 0.11em, transparent 0.13em) 0 0 / 0.9em 0.3em repeat-x;
    opacity: 0.8;
}

/* Lists */

ul {
    list-style: none;
    padding-left: 1.3em;
}

ul > li {
    position: relative;
}

ul > li::before {
    content: "";
    position: absolute;
    left: -1.1em;
    top: 0.88em;
    width: 0.45em;
    height: 1px;
    background: var(--accent);
}

ol {
    padding-left: 1.8em;
}

ol li::marker {
    color: var(--muted);
    font-family: var(--mincho);
    font-size: 0.9em;
}

li + li {
    margin-top: 0.45em;
}

/* Quotes */

blockquote {
    margin: 2.5em 0;
    padding: 0 0 0 1.4em;
    border-left: 1px solid var(--accent);
    font-family: var(--mincho);
    font-size: 1.08em;
    line-height: 1.85;
    color: var(--secondary);
}

blockquote p + p {
    margin-top: 0.8em;
}

cite {
    color: var(--muted);
}

/* Code */

code,
pre {
    font-family: var(--mono);
    font-size: 0.82em;
    font-weight: 400;
}

code {
    padding: 0.1em 0.35em;
    background: var(--surface);
    border-radius: 0.15em;
}

pre {
    margin: 2em 0;
    padding: 1.2em 1.3em;
    background: var(--surface);
    overflow-x: auto;
    line-height: 1.65;
    white-space: pre;
    word-break: normal;
    overflow-wrap: normal;
}

pre code {
    padding: 0;
    background: none;
    font-size: 1em;
}

/* Media */

img,
video {
    display: block;
    max-width: 100%;
    height: auto;
}

.articleBody > img,
figure {
    margin-block: 2.25em;
}

figcaption {
    margin-top: 0.75em;
    font-size: 0.72em;
    letter-spacing: 0.08em;
    text-align: center;
    color: var(--muted);
}

.floated {
    float: left;
    width: auto;
    margin: 0.4em 1.4em 0.6em 0;
}

.articleBody > img.floated {
    margin-block: 0.4em 0.6em;
}

.clearfix::after {
    content: "";
    display: block;
    clear: both;
}

/* Tables */

table {
    display: block;
    width: 100%;
    overflow-x: auto;
    border-collapse: collapse;
    font-size: 0.82em;
}

th,
td {
    padding: 0.7em 0.9em 0.7em 0;
    text-align: left;
    border-bottom: 1px solid var(--rule);
    vertical-align: top;
    min-width: 5em;
    overflow-wrap: normal;
    word-break: normal;
    hyphens: auto;
}

th {
    font-weight: 400;
    font-size: 0.85em;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--muted);
    border-bottom-color: var(--primary);
}

/* Footer */

.footer {
    margin-top: 4.5em;
}

.maika-end {
    margin: 0 auto 2.5em;
    font-family: var(--mincho);
    font-size: 1.05em;
    text-align: center;
    color: var(--accent);
}

.meta {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.6em;
    padding-top: 1.5em;
    border-top: 1px solid var(--rule);
    font-size: 0.75em;
    letter-spacing: 0.1em;
    color: var(--muted);
}

.meta a {
    color: var(--secondary);
    text-decoration: none;
}

.meta .source-link {
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--primary);
}

.meta .source-link::after {
    content: "  \2192";
    color: var(--accent);
}

.meta a:hover {
    color: var(--accent);
}

.externalLink:has(a[href=""]) {
    display: none;
}

/* linker.js reference citations */

.nnw-ref-citation {
    font-size: 0.62em;
    color: var(--accent);
    margin-left: 0.15em;
}

.extracted-links-header {
    margin-top: 3em;
    font-family: var(--gothic);
    font-size: 0.7em;
    font-weight: 400;
    letter-spacing: 0.24em;
    text-transform: uppercase;
    color: var(--muted);
}

.extracted-links {
    margin-top: 0.75em;
    padding-left: 1.6em;
    font-size: 0.78em;
    line-height: 1.8;
    color: var(--muted);
}

.extracted-links a {
    color: var(--secondary);
    text-decoration: none;
}

.extracted-links a:hover {
    color: var(--accent);
}

/* youtube-link-rewrite.js embeds */

.nnw-youtube-embed {
    margin: 2.25em 0 2.5em;
}

.nnw-youtube-frame {
    aspect-ratio: 16 / 9;
    width: 100%;
    overflow: hidden;
    background: #000000;
}

.nnw-youtube-iframe,
.nnw-youtube-fallback {
    display: block;
    width: 100%;
    height: 100%;
    border: 0;
}

.nnw-youtube-actions {
    margin-top: 0.8em;
    font-size: 0.7em;
    letter-spacing: 0.18em;
    text-align: right;
    text-transform: uppercase;
}

.nnw-youtube-app-link {
    color: var(--secondary);
    text-decoration: none;
}

.nnw-youtube-app-link::after {
    content: "  \2192";
    color: var(--accent);
}

.nnw-youtube-app-link:hover {
    color: var(--accent);
}

/* Hide Daring Fireball permalink stars */
a[title*="Permanent"],
a[title*="Permanent"] + .nnw-ref-citation {
    display: none;
}

@media (max-width: 640px) {
    body {
        font-size: 1em;
        line-height: 1.85;
        padding: 2em 1.4em 3em;
    }

    .articleTitle h1 {
        font-size: 1.65em;
    }

    .maika-scroll {
        right: 0.3em;
    }
}

/* Article media (NetNewsWire 7.3): feed images, audio and video above and below the body */
.articlePrimaryMedia:empty,
.articleEnclosures:empty {
    display: none;
}

.nnw-enclosure audio {
    display: block;
    width: 100%;
    accent-color: var(--accent);
}

.nnw-enclosure video,
.nnw-enclosure-video > iframe {
    display: block;
    width: 100%;
    max-width: 100%;
    height: auto;
    box-sizing: border-box;
    background: #000000;
}

.nnw-enclosure-video > iframe {
    aspect-ratio: 16 / 9;
    border: 0;
}

.nnw-primary-image-caption,
.nnw-enclosure-caption {
    margin-top: 0.75em;
    font-size: 0.72em;
    letter-spacing: 0.08em;
    text-align: center;
    color: var(--muted);
    overflow-wrap: anywhere;
}
