/* Custom style overrides */

/* Secondary text (dates, meta) - readable on both themes: 4.9:1 light, 5.4:1 dark */
:root {
    --meta-color: #6f6790;
}

@media (prefers-color-scheme: dark) {
    :root {
        --meta-color: #8a84a0;
    }
}

/* Body font */
body main {
    line-height: 1.8em;
}

/* Visited links — apply theme's visited color everywhere, not just blog list */
a:visited {
    color: var(--visited-color);
}

/* Override theme's monospace date — unify with body font */
time {
    font-family: inherit;
    font-size: inherit;
}

/* Code font */
code,
pre,
kbd,
samp {
    font-family: "JetBrains Mono", monospace;
    font-size: 0.9em;
}

/* Blog post header */
main > h1 {
    line-height: 1.4em;
}

/* Blog post meta (date + reading time) */
.post-meta {
    display: flex;
    align-items: center;
    gap: 0.75em;
    color: var(--meta-color);
    margin-top: 0;
    margin-bottom: 2.75em;
}

.reading-time {
    font-style: italic;
}

.reading-time::before {
    content: "·";
    margin-right: 0.75em;
    opacity: 0.5;
}

/* Inline code in blog content */
content code {
    background: rgba(168, 156, 216, 0.12);
    padding: 0.15em 0.4em;
    border-radius: 4pt;
}

@media (prefers-color-scheme: dark) {
    content code {
        background: rgba(168, 156, 216, 0.15);
    }
}

/* Blockquote */
blockquote {
    border-left: 3px solid rgba(168, 156, 216, 0.45);
    margin-left: 0;
    margin-right: 0;
    padding-left: 1.25em;
}

@media (prefers-color-scheme: dark) {
    blockquote {
        border-left-color: rgba(168, 156, 216, 0.3);
    }
}

/* Swup page transitions */
main {
    transition: opacity 0.2s ease;
}

html.is-animating main {
    opacity: 0;
}

/* Text selection */
::selection {
    background: #fde98a;
    color: #1a1030;
}

@media (prefers-color-scheme: dark) {
    ::selection {
        background: #fad85a;
        color: #0d0820;
    }
}

body {
    background: linear-gradient(150deg, #fdfcfa 0%, #f4f2fc 100%);
    min-height: 100vh;
}

@media (prefers-color-scheme: dark) {
    body {
        background: #01242e;
    }
}

/* Section headers */
h3.h-prefix {
    display: flex;
    align-items: baseline;
    gap: 0.4em;
    margin: 2em 0 0.65em;
}

h3.h-prefix::before {
    content: "/";
    color: #a89cd8;
    font-weight: 400;
}

.highlight {
    background-color: #f0eef8;
    margin-left: calc(-12px - 0.5em);
    margin-right: calc(-12px - 0.5em);
    padding: 1.25em calc(12px + 0.5em);
    border-radius: 12px;
}

@media (prefers-color-scheme: dark) {
    .highlight {
        background-color: rgba(168, 156, 216, 0.08);
    }
}

.highlight pre {
    background-color: transparent !important;
    margin: 0;
    padding: 0;
}

/* An image beside the text on wide screens, and full width on narrow ones */
.figure-aside {
    float: right;
    width: 50%;
    margin: 0.3em 0 1em 1.75em;
}

.figure-aside img {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 14px;
    border: 1px solid rgba(168, 156, 216, 0.2);
}

@media (max-width: 640px) {
    .figure-aside {
        float: none;
        width: 100%;
        margin: 1.5em 0;
    }
}

/* A new section never starts beside a floated image */
.figure-aside ~ h2 {
    clear: both;
}

/* Code blocks never sit beside a floated image; their background would run under it */
.highlight {
    clear: both;
}

/* main sets line-height in em, which children inherit as a fixed 28.8px; at the smaller code size that double-spaces every line */
pre {
    line-height: 1.6;
}

.highlight pre code {
    padding: 0;
}

/* App cards */
.apps-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5em;
    margin: 1.75em 0;
}

.app-card {
    background: rgba(168, 156, 216, 0.06);
    border-radius: 18px;
    border: 1px solid rgba(168, 156, 216, 0.2);
    padding: 1.6em;
    display: flex;
    flex-direction: column;
    gap: 1.1em;
    text-decoration: none;
    color: inherit;
    position: relative;
    --rx: 0deg;
    --ry: 0deg;
    --px: 0;
    --py: 0;
    --mx: 50%;
    --my: 50%;
    --glare: 0;
    --scale: 1;
}

.app-card:hover {
    text-decoration: none;
}

/* 3D tilt, driven by assets/js/tilt.js. The transform only exists while moving so text is crisp at rest. */
.app-card.is-tilting {
    transform: perspective(900px) rotateX(var(--rx)) rotateY(var(--ry)) scale(var(--scale));
    transform-style: preserve-3d;
    will-change: transform;
    z-index: 1;
    box-shadow:
        calc(var(--ry) * -1.2) calc(var(--rx) * 1.2 + 14px) 36px rgba(40, 20, 90, calc(var(--glare) * 0.16)),
        0 2px 6px rgba(40, 20, 90, calc(var(--glare) * 0.06));
}

/* --glare doubles as the "lift" amount (0 at rest, 1 when engaged) so depth eases in and out with the tilt */
.app-card.is-tilting .app-screenshot {
    transform: translateZ(calc(var(--glare) * var(--tilt-depth, 36px)));
    box-shadow: calc(var(--ry) * -0.8) calc(var(--rx) * 0.8 + 10px) 24px rgba(20, 10, 60, calc(var(--glare) * 0.22));
}

.app-card.is-tilting .app-info {
    transform: translateZ(calc(var(--glare) * var(--tilt-depth, 36px) * 0.5));
}

.app-card.is-tilting .app-screenshot img {
    transform: translate(calc(var(--px) * -10px), calc(var(--py) * -8px)) scale(calc(1 + var(--glare) * 0.06));
}

.app-card.is-tilting .app-screenshot--icon img {
    transform: translate(calc(var(--px) * -14px), calc(var(--py) * -12px)) scale(calc(1 + var(--glare) * 0.04));
}

/* Light sheen that follows the pointer */
.app-card::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    pointer-events: none;
    opacity: var(--glare);
    background: radial-gradient(
        circle at var(--mx) var(--my),
        rgba(255, 255, 255, 0.28),
        rgba(255, 255, 255, 0.06) 35%,
        transparent 60%
    );
    mix-blend-mode: soft-light;
}

.app-card.is-tilting::after {
    transform: translateZ(calc(var(--glare) * var(--tilt-depth, 36px) * 1.1));
}

.app-screenshot {
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 3;
    background: rgba(168, 156, 216, 0.12);
    border-radius: 12px;
    overflow: hidden;
}

.app-card-badge {
    position: absolute;
    top: 0.65em;
    right: 0.65em;
    padding: 0.45em 1em;
    background: rgba(90, 55, 170, 0.90);
    backdrop-filter: blur(6px);
    border-radius: 999px;
    font-size: 0.65em;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #fff;
}

.app-screenshot img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.app-screenshot img.align-top {
    object-position: top;
}

/* Tools without a screenshot show their icon centred in the same frame, so every card lines up */
.app-screenshot--icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

.app-screenshot--icon img {
    width: 66%;
    height: auto;
}

.app-title {
    display: flex;
    align-items: center;
    gap: 0.4em;
    flex-wrap: wrap;
    margin-bottom: 0.5em;
}

.app-title strong {
    color: var(--heading-color);
    font-weight: 700;
    letter-spacing: -0.01em;
}

.badge {
    font-size: 0.65em;
    font-weight: 600;
    padding: 0.3em 0.5em;
    border-radius: 4px;
    letter-spacing: 0.03em;
    line-height: 1;
}

.badge-ios {
    background: #dbeafe;
    color: #1d4ed8;
}

.badge-macos {
    background: #ede9fe;
    color: #6d28d9;
}

.app-info p {
    margin: 0;
    font-size: 0.875em;
    line-height: 1.5;
    color: #666;
}

/* Header layout — flex to push toggle to the right */
header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1em;
}

.header-left {
    flex: 1;
    min-width: 0;
}

/* Theme toggle button */
.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 2.1em;
    height: 2.1em;
    padding: 0;
    background: none;
    border: 1.5px solid rgba(168, 156, 216, 0.35);
    border-radius: 50%;
    cursor: pointer;
    color: var(--text-color);
    transition:
        border-color 0.15s ease,
        color 0.15s ease,
        transform 0.2s ease;
    margin-top: 0.25em;
}

.theme-toggle:hover {
    border-color: #a89cd8;
    color: #8b6fcb;
    transform: rotate(18deg);
}

.theme-toggle:focus-visible {
    outline: 2px solid #a89cd8;
    outline-offset: 3px;
}

.theme-toggle svg {
    width: 1em;
    height: 1em;
    display: block;
}

/* Show sun in dark mode (click → light), moon in light mode (click → dark) */
.theme-toggle .icon-sun  { display: none; }
.theme-toggle .icon-moon { display: block; }

html[data-theme="dark"] .theme-toggle .icon-sun  { display: block; }
html[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

@media (prefers-reduced-motion: reduce) {
    .theme-toggle {
        transition: none;
    }
}

/* Site title — flex row so monogram and name share a baseline */
.title {
    display: block;
    color: inherit;
    margin-bottom: 0.3em;
}

.title h2 {
    display: flex;
    align-items: center;
    gap: 0.4em;
    margin: 0;
}

/* CSS monogram — JB interlocked letters in a gradient rounded rect */
.site-monogram {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-family: "Space Grotesk", sans-serif;
    font-weight: 700;
    font-size: 1.1em;
    color: #fff;
    line-height: 1;
    letter-spacing: 0;
    padding: 0.18em 0.22em;
    background: linear-gradient(135deg, #3131de 0%, #8b6fcb 100%);
    border-radius: 0.28em;
    transition: filter 0.18s ease;
    user-select: none;
}

.title:hover .site-monogram {
    filter: brightness(1.22);
}

.title:hover .name-grotesk {
    opacity: 0.7;
}

.title:focus {
    outline: none;
}

.title:focus-visible {
    outline: 2px solid #a89cd8;
    outline-offset: 5px;
    border-radius: 4px;
}

.site-monogram::before { content: "J"; }
.site-monogram::after  { content: "B"; margin-left: -0.09em; }

@media (prefers-reduced-motion: reduce) {
    .site-monogram,
    .title .name-grotesk {
        transition: none;
    }
}

/* Site title — Space Grotesk */
.title .name-grotesk {
    font-family: "Space Grotesk", sans-serif;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    transition: opacity 0.18s ease;
}

/* Reusable infobox */
.infobox {
    margin: 1.5em 0 2em;
    padding: 1.1em 1.4em;
    background: rgba(168, 156, 216, 0.06);
    border: 1px solid rgba(168, 156, 216, 0.2);
    border-radius: 14px;
}

@media (prefers-color-scheme: dark) {
    .infobox {
        background: rgba(168, 156, 216, 0.04);
        border-color: rgba(168, 156, 216, 0.15);
    }
}

/* Get in touch row */
.get-in-touch {
    display: flex;
    align-items: center;
    gap: 0.4em;
    margin: 0.6em 0 1.75em;
}

.get-in-touch .contact-links {
    margin: 0;
    padding-left: 1em;
}

/* Contact icon links */
.contact-links {
    display: flex;
    align-items: center;
    gap: 1.1em;
}

.contact-links a {
    display: flex;
    align-items: center;
    color: #777;
    text-decoration: none;
    transition:
        color 0.15s ease,
        transform 0.15s ease;
}

.contact-links a:hover {
    color: #8b6fcb;
    transform: translateY(-2px);
    text-decoration: none;
}

.contact-links svg {
    width: 1.35em;
    height: 1.35em;
}

@media (prefers-color-scheme: dark) {
    .contact-links a {
        color: #8a8898;
    }

    .contact-links a:hover {
        color: #b3a8e0;
    }
}

/* External link icon */
.icon-external-link {
    display: inline-block;
    vertical-align: middle;
    margin-left: 0.25em;
    position: relative;
    top: -0.1em;
    width: 1em;
    height: 1em;
}

/* Blog posts list */
ul.blog-posts li {
    padding: 0.45em 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

ul.blog-posts li:last-child {
    border-bottom: none;
}

ul.blog-posts li span {
    color: var(--meta-color);
    font-variant-numeric: tabular-nums;
}

/* Phones: date above a full-width title instead of a fixed 130px date column */
@media (max-width: 480px) {
    ul.blog-posts li {
        flex-direction: column;
        gap: 0.1em;
        padding: 0.7em 0;
    }

    ul.blog-posts li span {
        flex: none;
        font-size: 0.8em;
    }

    ul.blog-posts li a {
        line-height: 1.5;
    }
}

@media (max-width: 480px) {
    .apps-grid {
        grid-template-columns: 1fr;
    }
}

/* Footer */
.footer-content {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 1em;
    padding: 1.5em 0 0.5em;
    border-top: 1px solid rgba(0, 0, 0, 0.07);
}

.footer-content .contact-links {
    margin: 0;
}

/* html[data-theme] outranks the generic per-theme .contact-links colors */
.footer-content .contact-links a,
html[data-theme] .footer-content .contact-links a {
    color: var(--meta-color);
}

.footer-content .contact-links a:hover {
    color: #8b6fcb;
}

@media (prefers-color-scheme: dark) {
    .footer-content .contact-links a:hover {
        color: #b3a8e0;
    }
}

.footer-content small {
    color: var(--meta-color);
    white-space: nowrap;
    font-size: 0.8em;
}

@media (prefers-color-scheme: dark) {
    .footer-content {
        border-top-color: rgba(255, 255, 255, 0.08);
    }
}

/* Missing dark mode variants — via system preference (no-JS fallback) */
@media (prefers-color-scheme: dark) {
    .app-info p {
        color: #8a84a0;
    }

    .badge-ios {
        background: rgba(147, 197, 253, 0.13);
        color: #93c5fd;
    }

    .badge-macos {
        background: rgba(168, 156, 216, 0.15);
        color: #c4bceb;
    }

    ul.blog-posts li {
        border-bottom-color: rgba(255, 255, 255, 0.06);
    }

    .app-card {
        background: rgba(168, 156, 216, 0.07);
        border-color: rgba(168, 156, 216, 0.18);
    }

    body {
        background: #0f0d1a;
    }
}

/* ============================================================
   THEME TOGGLE — CSS VARIABLE OVERRIDES
   These override the theme's media-query-based variables from
   style.html so the explicit data-theme attribute takes priority.
   ============================================================ */

html[data-theme="dark"] {
    --background-color: #0f0d1a;
    --heading-color: #ede9ff;
    --text-color: #c9c5e0;
    --link-color: #9ab5e8;
    --visited-color: #b3a8e0;
    --blockquote-color: #b8b2d0;
    --meta-color: #8a84a0;
}

html[data-theme="light"] {
    --background-color: #fff;
    --heading-color: #222;
    --text-color: #444;
    --link-color: #3273dc;
    --visited-color: #8b6fcb;
    --blockquote-color: #222;
    --meta-color: #6f6790;
}

/* ============================================================
   DARK MODE — EXPLICIT OVERRIDES (mirrors @media blocks above,
   plus fills in elements that had no dark variant yet)
   ============================================================ */

html[data-theme="dark"] content code {
    background: rgba(168, 156, 216, 0.15);
}

html[data-theme="dark"] blockquote {
    border-left-color: rgba(168, 156, 216, 0.3);
}

html[data-theme="dark"] body {
    background: #0f0d1a;
}

html[data-theme="dark"] .highlight {
    background-color: rgba(168, 156, 216, 0.08);
}

html[data-theme="dark"] .infobox {
    background: rgba(168, 156, 216, 0.04);
    border-color: rgba(168, 156, 216, 0.15);
}

html[data-theme="dark"] .contact-links a {
    color: #8a8898;
}

html[data-theme="dark"] .contact-links a:hover {
    color: #b3a8e0;
}

html[data-theme="dark"] .footer-content .contact-links a:hover {
    color: #b3a8e0;
}

html[data-theme="dark"] .footer-content {
    border-top-color: rgba(255, 255, 255, 0.08);
}

html[data-theme="dark"] ::selection {
    background: #fad85a;
    color: #0d0820;
}

/* Elements that previously had no dark variant */
html[data-theme="dark"] .app-info p {
    color: #8a84a0;
}

html[data-theme="dark"] .badge-ios {
    background: rgba(147, 197, 253, 0.13);
    color: #93c5fd;
}

html[data-theme="dark"] .badge-macos {
    background: rgba(168, 156, 216, 0.15);
    color: #c4bceb;
}

html[data-theme="dark"] ul.blog-posts li {
    border-bottom-color: rgba(255, 255, 255, 0.06);
}

html[data-theme="dark"] .app-card {
    background: rgba(168, 156, 216, 0.07);
    border-color: rgba(168, 156, 216, 0.18);
}

html[data-theme="dark"] .theme-toggle {
    border-color: rgba(168, 156, 216, 0.25);
}

html[data-theme="dark"] .theme-toggle:hover {
    border-color: #b3a8e0;
    color: #c4bceb;
}

/* ============================================================
   LIGHT MODE — FORCED OVERRIDES
   Re-assert light values when data-theme="light" but system
   prefers dark (so the @media blocks above don't bleed through).
   ============================================================ */

html[data-theme="light"] content code {
    background: rgba(168, 156, 216, 0.12);
}

html[data-theme="light"] blockquote {
    border-left-color: rgba(168, 156, 216, 0.45);
}

html[data-theme="light"] body {
    background: linear-gradient(150deg, #fdfcfa 0%, #f4f2fc 100%);
}

html[data-theme="light"] .highlight {
    background-color: #f0eef8;
}

html[data-theme="light"] .infobox {
    background: rgba(168, 156, 216, 0.06);
    border-color: rgba(168, 156, 216, 0.2);
}

html[data-theme="light"] .contact-links a {
    color: #777;
}

html[data-theme="light"] .contact-links a:hover {
    color: #8b6fcb;
}

html[data-theme="light"] .footer-content .contact-links a:hover {
    color: #8b6fcb;
}

html[data-theme="light"] .footer-content {
    border-top-color: rgba(0, 0, 0, 0.07);
}

html[data-theme="light"] ::selection {
    background: #fde98a;
    color: #1a1030;
}

html[data-theme="light"] .app-info p {
    color: #666;
}

html[data-theme="light"] .badge-ios {
    background: #dbeafe;
    color: #1d4ed8;
}

html[data-theme="light"] .badge-macos {
    background: #ede9fe;
    color: #6d28d9;
}

html[data-theme="light"] ul.blog-posts li {
    border-bottom-color: rgba(0, 0, 0, 0.06);
}

html[data-theme="light"] .app-card {
    background: rgba(168, 156, 216, 0.06);
    border-color: rgba(168, 156, 216, 0.2);
}


/* Charts (layouts/shortcodes/bar-chart.html, stacked-bar-chart.html).
   Series colors are the dataviz reference palette in fixed order, validated against this site's light and dark backgrounds. */
:root {
    --chart-single: #8b6fcb;
    --chart-1: #2a78d6;
    --chart-2: #eb6834;
    --chart-3: #1baf7a;
    --chart-4: #eda100;
    --chart-5: #e87ba4;
    --chart-6: #008300;
    --chart-7: #6250d6;
    --chart-8: #e34948;
    --chart-line: rgba(168, 156, 216, 0.25);
}

@media (prefers-color-scheme: dark) {
    :root {
        --chart-1: #3987e5;
        --chart-2: #d95926;
        --chart-3: #199e70;
        --chart-4: #c98500;
        --chart-5: #d55181;
        --chart-6: #0ca30c;
        --chart-7: #9085e9;
        --chart-8: #e66767;
    }
}

html[data-theme="dark"] {
    --chart-1: #3987e5;
    --chart-2: #d95926;
    --chart-3: #199e70;
    --chart-4: #c98500;
    --chart-5: #d55181;
    --chart-6: #0ca30c;
    --chart-7: #9085e9;
    --chart-8: #e66767;
}

html[data-theme="light"] {
    --chart-1: #2a78d6;
    --chart-2: #eb6834;
    --chart-3: #1baf7a;
    --chart-4: #eda100;
    --chart-5: #e87ba4;
    --chart-6: #008300;
    --chart-7: #6250d6;
    --chart-8: #e34948;
}

.chart {
    margin: 1.75em 0;
    font-size: 0.875em;
    line-height: 1.4;
}

.chart-title {
    color: var(--heading-color);
    font-weight: bold;
    margin-bottom: 0.75em;
}

.chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25em 1.1em;
    list-style: none;
    padding: 0;
    margin: 0 0 0.9em;
    color: var(--meta-color);
}

.chart-legend i {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 3px;
    margin-right: 0.45em;
    vertical-align: -1px;
}

.chart-rows {
    display: flex;
    flex-direction: column;
    gap: 0.55em;
}

.chart-row {
    display: grid;
    grid-template-columns: 15em 1fr;
    align-items: center;
    gap: 1em;
}

.chart-label {
    text-align: right;
}

.chart-track {
    display: flex;
    align-items: center;
    gap: 0.5em;
    min-width: 0;
}

/* --share is this row's total over the largest row; the rest of the track is room for the value */
.chart-stack {
    display: flex;
    gap: 2px;
    height: 18px;
    width: calc((100% - 6.5em) * var(--share));
}

.chart-seg {
    flex: 0 1 0;
    min-width: 0;
}

.chart-single {
    background: var(--chart-single);
}

/* Square at the baseline, rounded at the data end */
.chart-stack > :last-child {
    border-radius: 0 4px 4px 0;
}

.chart-value {
    color: var(--heading-color);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.chart-table {
    margin-top: 0.9em;
    color: var(--meta-color);
}

.chart-table summary {
    cursor: pointer;
}

.chart-table table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 0.5em;
    font-variant-numeric: tabular-nums;
}

.chart-table th,
.chart-table td {
    padding: 0.3em 0.5em;
    border-bottom: 1px solid var(--chart-line);
    text-align: right;
}

.chart-table tbody th,
.chart-table thead th:first-child {
    text-align: left;
    font-weight: normal;
}

@media (max-width: 640px) {
    .chart-row {
        grid-template-columns: 1fr;
        gap: 0.2em;
    }

    .chart-label {
        text-align: left;
    }

    .chart-table {
        overflow-x: auto;
    }
}
