/* Theme-independent layout for markneat.af.codes.
   Color tokens and the glow and Markdown marks painted with them live in
   index-light.css / index-dark.css. */

:root {
    --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    --spring: cubic-bezier(0.34, 1.56, 0.64, 1);

    /* Scroll-to-top button geometry. The footer derives its bottom padding from
       these, so the button and the footer text can never collide. */
    --fab-size: 2.5rem;
    --fab-inset: 1.5rem;
}

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

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

/* break-word only splits a word too long for a line of its own, as on a phone
   with enlarged text, and leaves every layout's widths alone. */
body {
    margin: 0;
    font-family: var(--font);
    line-height: 1.5;
    background: var(--bg);
    color: var(--fg);
    overflow-wrap: break-word;
    -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
p,
figure {
    margin: 0;
}

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

/* Every themed image is a <picture> so it can carry a dark variant. Left
   inline it would put the block-level image in an inline box, adding a
   line-height gap under it. */
picture {
    display: block;
}

a {
    color: inherit;
}

/* Keys in the copy are set as keycaps: --fg on --surface, as body text is. */
kbd {
    display: inline-block;
    padding: 0 .4em;
    border: 1px solid var(--hairline);
    border-bottom-width: 2px;
    border-radius: .35rem;
    background: var(--surface);
    font-family: var(--font);
    font-size: .85em;
    line-height: 1.5;
    color: var(--fg);
    white-space: nowrap;
}

a:focus-visible,
button:focus-visible {
    outline: 2px solid var(--accent-text);
    outline-offset: 2px;
}

.container {
    max-width: 68rem;
    margin: 0 auto;
    padding: 0 1.25rem;
}

/* Hero ------------------------------------------------------------------- */

.section-hero {
    /* .hero-sky, .top-brand and .top-actions are absolute; without this they
       would anchor to the initial containing block instead of the hero. The
       glow is wider than narrow viewports, so it's clipped here rather than
       scrolling the page sideways. */
    position: relative;
    overflow: hidden;
    overflow: clip;
    padding: 6rem 0 5rem;
    text-align: center;
}

/* The theme sheets paint the glow and color the Markdown marks. Both fade out
   before the hero's bottom edge, where the clip would otherwise cut them off
   in a line. */
.hero-sky {
    position: absolute;
    inset: 0;
    pointer-events: none;
    -webkit-mask-image: linear-gradient(to bottom, #000 60%, transparent 100%);
    mask-image: linear-gradient(to bottom, #000 60%, transparent 100%);
}

/* Markdown marks up the hero's two sides: what you type on the left, and what
   each becomes on the right, row for row. The box matches the viewBox's
   1200x760 shape at desktop width, so the marks frame the title; narrower,
   the slice crops them away at the sides before the copy can reach them. */
.marks {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 47.5rem;
}

/* In viewBox units, so the glyphs scale with the shapes beside them. */
.marks .raw {
    fill: var(--mark-raw);
    font-family: var(--mono);
    font-size: 30px;
    font-weight: 600;
}

.marks .rendered {
    fill: var(--mark);
}

/* Outlined shapes: the checkbox, its tick, the code pill and the table. */
.marks .rendered .outline {
    fill: none;
    stroke: var(--mark);
    stroke-width: 4;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.hero-copy,
.hero-media,
.top-brand,
.top-actions {
    position: relative;
    z-index: 1;
}

/* Top brand and actions -------------------------------------------------- */

.top-brand,
.top-actions {
    position: absolute;
    top: 1rem;
    height: 2.5rem;
    display: flex;
    align-items: center;
}

.top-brand {
    left: 1.5rem;
}

.top-actions {
    right: 1.5rem;
    gap: .5rem;
}

.top-brand .brand-logo {
    display: inline-flex;
    /* The padding keeps the monogram's far corners inside the circle. */
    padding: .25rem;
    background: var(--logo-circle);
    box-shadow: 0 2px 6px var(--icon-shadow);
    border-radius: 50%;
}

.top-brand .brand-logo img {
    width: 2rem;
}

.top-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: none;
    color: inherit;
    cursor: pointer;
    opacity: .75;
    transition: opacity .2s ease, color .2s ease;
}

@media (hover: hover) and (pointer: fine) {
    .top-btn:hover {
        opacity: 1;
        color: var(--accent-text);
    }
}

.top-btn:focus-visible {
    opacity: 1;
}

.theme-toggle .icon-sun,
.theme-toggle .icon-moon {
    display: none;
}

/* App icon and title ----------------------------------------------------- */

/* Rendered from AppIcon.icon, so the plate and corner mask are already in the
   image; drop-shadow follows its alpha. */
.app-icon {
    width: 7rem;
    margin: 0 auto;
}

.app-icon img {
    width: 100%;
    filter: drop-shadow(0 .6rem 1.2rem var(--icon-shadow));
}

/* Its floor gives way to 20vw only on a phone with enlarged text, where the
   name would otherwise be wider than the page. */
.hero-copy h1 {
    display: inline-block;
    margin-top: 1.5rem;
    font-size: clamp(min(2.75rem, 20vw), 7vw, 4.25rem);
    font-weight: 700;
    letter-spacing: -.035em;
    line-height: 1.1;
    color: var(--fg);
}

/* The name is painted in the icon's crimsons wherever text can be a gradient's
   clip; elsewhere it stays plain --fg. */
@supports ((-webkit-background-clip: text) or (background-clip: text)) {
    .hero-copy h1 {
        background: var(--title-gradient);
        -webkit-background-clip: text;
        background-clip: text;
        -webkit-text-fill-color: transparent;
    }
}

/* Widened from 36rem so the tagline sets in two lines on desktop rather than
   three, with room to spare for other systems' fonts. */
.tagline {
    max-width: 44rem;
    margin: 1rem auto 0;
    font-size: clamp(1.05rem, 1.6vw, 1.2rem);
    line-height: 1.55;
    color: var(--secondary);
    text-wrap: balance;
}

/* Buttons ---------------------------------------------------------------- */

.cta-row {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: .75rem;
    margin-top: 2rem;
}

/* A minimum height and wrapping labels, so a button too wide for a phone with
   enlarged text grows taller instead; a flex row wraps whole buttons first. */
.btn-primary,
.btn-ghost {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    min-height: 3rem;
    max-width: 100%;
    padding: .4rem 1.3rem;
    border-radius: .55rem;
    font-size: .95rem;
    font-weight: 600;
    text-decoration: none;
    transition: transform .3s var(--spring);
}

.btn-primary svg,
.btn-ghost svg {
    flex-shrink: 0;
}

/* Filled with AccentColor, the app's crimson. */
.btn-primary {
    background: var(--accent);
    color: var(--on-accent);
    box-shadow: 0 .5rem 1.25rem -.5rem var(--accent);
}

/* Glass, over the glow. */
.btn-ghost {
    border: 1px solid var(--glass-border);
    background: var(--glass);
    -webkit-backdrop-filter: blur(12px) saturate(160%);
    backdrop-filter: blur(12px) saturate(160%);
    color: var(--fg);
}

/* Two-line labels, shorter together than the button, so both buttons stay
   the same height. */
.btn-stack {
    display: inline-flex;
    flex-direction: column;
    align-items: flex-start;
    line-height: 1.15;
    text-align: left;
}

/* Full opacity: a muted color on the accent drops below 4.5:1. */
.btn-subtext {
    font-size: .7rem;
    font-weight: 500;
}

.btn-ghost .btn-subtext {
    color: var(--secondary);
}

/* scripts/platform-gate.js flags non-Mac visitors on <html>; the download is
   macOS-only, so the button becomes a faded, inert label there. */
.download-label-unavailable {
    display: none;
}

.not-macos .download-label {
    display: none;
}

.not-macos .download-label-unavailable {
    display: block;
}

.not-macos .btn-primary {
    opacity: .45;
    box-shadow: none;
    cursor: default;
    pointer-events: none;
}

@media (hover: hover) and (pointer: fine) {
    .btn-primary:hover,
    .btn-ghost:hover {
        transform: scale(1.03);
    }
}

/* Window screenshots ----------------------------------------------------- */

/* Captures of the window alone, with transparent rounded corners, so they
   draw no frame; drop-shadow follows the alpha, and its tight first layer
   gives the light window an edge on the light page. 60rem keeps the 1920px
   captures at 2x. Every capture shares one size, which the aspect-ratio and
   each <img>'s width and height repeat (AGENTS.md has the recipe). */
.screenshot {
    width: 100%;
    max-width: 60rem;
    margin: 0 auto;
    aspect-ratio: 1920 / 1200;
    filter: drop-shadow(0 1px 2px var(--window-rim-shadow)) drop-shadow(0 1.25rem 2rem var(--media-shadow));
}

.hero-media {
    margin-top: 4rem;
}

/* Comparison ------------------------------------------------------------- */

/* The hero's window in both of the app's views. Without JavaScript the two
   captures stack, each over its caption. scripts/compare.js flags <html>
   before first paint, and from then on they share one box: the Markdown
   source lies over the rendered view, cut off at --split, where the divider
   stands. */
.compare {
    max-width: 60rem;
    margin: 0 auto;
}

.compare-pane + .compare-pane {
    margin-top: 3rem;
}

.compare figcaption {
    margin-top: 1rem;
    font-size: .875rem;
    font-weight: 600;
    color: var(--secondary);
}

.compare-range,
.compare-divider {
    display: none;
}

.has-compare .compare {
    --split: 50%;
    position: relative;
    aspect-ratio: 1920 / 1200;
    /* Room for the captions, which hang under the window's bottom corners. */
    margin-bottom: 2.5rem;
    cursor: ew-resize;
    /* A sideways drag moves the divider; an upward or downward one still
       scrolls the page. */
    touch-action: pan-y;
    -webkit-user-select: none;
    user-select: none;
}

/* The pointer lands on .compare itself, so a drag never picks up an image. */
.has-compare .compare-pane {
    position: absolute;
    inset: 0;
    margin: 0;
    pointer-events: none;
}

/* On the picture, not the figure, whose caption hangs outside its box. */
.has-compare .compare-source picture {
    clip-path: inset(0 calc(100% - var(--split)) 0 0);
}

.has-compare .compare figcaption {
    position: absolute;
    top: 100%;
}

.has-compare .compare-source figcaption {
    left: .25rem;
}

.has-compare .compare-rendered figcaption {
    right: .25rem;
}

/* The slider itself, for the keyboard and assistive technology: unseen, and
   sitting on the handle so a screen reader's cursor lands there. Pointers
   drag anywhere on the window instead. */
.has-compare .compare-range {
    display: block;
    position: absolute;
    top: 50%;
    left: var(--split);
    width: 2.5rem;
    height: 2.5rem;
    margin: -1.25rem 0 0 -1.25rem;
    opacity: 0;
    pointer-events: none;
}

.has-compare .compare-divider {
    display: block;
    position: absolute;
    top: 0;
    bottom: 0;
    left: var(--split);
    width: 2px;
    margin-left: -1px;
    background: var(--accent);
    pointer-events: none;
}

/* Ringed in --on-accent, which holds 5:1 with the fill, so the handle reads
   over whatever part of the window it crosses. */
.compare-handle {
    position: absolute;
    top: 50%;
    left: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    margin: -1.25rem 0 0 -1.25rem;
    border-radius: 50%;
    background: var(--accent);
    color: var(--on-accent);
    box-shadow: 0 0 0 2px var(--on-accent), 0 .25rem .75rem var(--media-shadow);
    transition: transform .3s var(--spring);
}

/* Past the handle's own ring. */
.compare-range:focus-visible + .compare-divider .compare-handle {
    outline: 2px solid var(--accent-text);
    outline-offset: 4px;
}

@media (hover: hover) and (pointer: fine) {
    .compare:hover .compare-handle {
        transform: scale(1.05);
    }
}

/* Features --------------------------------------------------------------- */

.section-feature {
    padding: 5rem 0;
}

.feature-split {
    max-width: 60rem;
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: center;
    gap: 4rem;
}

.feature-split-reverse .feature-text {
    order: 2;
}

.feature-text {
    max-width: 28rem;
    justify-self: center;
}

.section-centered {
    text-align: center;
}

/* Widened from 36rem so the copy above a window sets in two lines on desktop,
   while lines stay near 80 characters. */
.section-centered .feature-copy {
    max-width: 42rem;
    margin-left: auto;
    margin-right: auto;
}

.section-centered .screenshot {
    margin-top: 3rem;
}

/* Its floor gives way to 10vw only on a phone with enlarged text, so a long
   word still fits a line whole. */
.section-feature h2 {
    margin-top: 1rem;
    font-size: clamp(min(1.9rem, 10vw), 3.5vw, 2.6rem);
    font-weight: 700;
    letter-spacing: -.03em;
    line-height: 1.1;
    text-wrap: balance;
}

.feature-copy {
    margin-top: 1rem;
    font-size: 1.1rem;
    line-height: 1.6;
    color: var(--secondary);
    text-wrap: pretty;
}

/* Section labels are capsules filled with AccentColor, matching the download
   button. */
.chip {
    display: inline-flex;
    padding: .3rem .85rem;
    border-radius: 999px;
    background: var(--chip-bg);
    color: var(--chip-fg);
    font-size: .875rem;
    font-weight: 600;
    box-shadow:
        inset 0 0 0 1px rgba(255, 255, 255, .2),
        inset 0 1px 0 rgba(255, 255, 255, .3),
        0 1px 2px rgba(0, 0, 0, .1),
        0 .35rem .9rem -.35rem var(--chip-bg);
}

/* Exported pages --------------------------------------------------------- */

/* What File > Export as PDF and Export as HTML made of the hero's note, side
   by side as two sheets of one size. They stack once a phone, or enlarged
   text, would shrink them past reading. */
.export-pair {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2.5rem;
    max-width: 45rem;
    margin: 3rem auto 0;
}

/* Square-cornered renders, so the frame is drawn here: a hairline keeps the
   white PDF page's edge on the light page. */
.export-page img {
    width: 100%;
    aspect-ratio: 680 / 880;
    border: 1px solid var(--hairline);
    border-radius: .5rem;
    box-shadow:
        0 2px 4px rgba(0, 0, 0, .08),
        0 1.5rem 3rem -1rem var(--media-shadow),
        0 3rem 6rem -2rem var(--media-shadow);
}

.export-page figcaption {
    margin-top: 1.25rem;
    font-family: var(--mono);
    font-size: .875rem;
    color: var(--secondary);
}

/* Window excerpts -------------------------------------------------------- */

/* A corner cut from a window capture. Its two cut edges fade out, so it reads
   as part of a window rather than a cropped picture; the shadow sits on the
   wrapper, since a filter is applied before a mask and would fade with it
   otherwise. 28.125rem keeps the 900px crop at 2x. */
.excerpt {
    width: 100%;
    max-width: 28.125rem;
    justify-self: center;
    filter: drop-shadow(0 1px 2px var(--window-rim-shadow)) drop-shadow(0 1.25rem 2rem var(--media-shadow));
}

.excerpt img {
    width: 100%;
    aspect-ratio: 900 / 860;
    -webkit-mask-image:
        linear-gradient(to right, #000 56%, transparent 100%),
        linear-gradient(to bottom, #000 80%, transparent 100%);
    mask-image:
        linear-gradient(to right, #000 56%, transparent 100%),
        linear-gradient(to bottom, #000 80%, transparent 100%);
    -webkit-mask-composite: source-in;
    mask-composite: intersect;
}

/* Details ---------------------------------------------------------------- */

/* Plain columns between hairlines rather than cards: a glass surface reads as
   clickable, and none of these are links. Keep the descriptions about the
   same length so the columns wrap to the same height. */
.details {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    row-gap: 2.5rem;
    max-width: 56rem;
    margin: 0 auto;
}

.detail {
    padding: .25rem 1.5rem;
    text-align: center;
}

/* Every column but a row's first. */
.detail:not(:nth-child(3n + 1)) {
    border-left: 1px solid var(--hairline);
}

/* Undoes .section-feature h2, which this shares a specificity with. */
.detail h2 {
    margin-top: 0;
    font-size: 1.05rem;
    letter-spacing: normal;
    line-height: 1.5;
    color: var(--accent-text);
}

.detail p {
    margin-top: .35rem;
    font-size: .95rem;
    color: var(--secondary);
    text-wrap: pretty;
}

/* Footer ----------------------------------------------------------------- */

.site-footer {
    /* The scroll-to-top button is fixed over the bottom-right corner, and at
       narrow widths this text is wide enough to run under it once the page is
       scrolled to the end. Reserve the button's band plus a gap. */
    padding: 4rem 1.25rem calc(var(--fab-inset) + var(--fab-size) + 1rem);
    text-align: center;
    font-size: .875rem;
    color: var(--secondary);
}

.site-footer a {
    text-decoration: none;
}

@media (hover: hover) and (pointer: fine) {
    .site-footer a:hover {
        color: var(--accent-text);
        text-decoration: underline;
    }
}

/* Scroll-to-top ---------------------------------------------------------- */

/* Do NOT rename this to a generic "back to top" name (jump-to-top, back-to-top,
   scroll-to-top): ad-block cosmetic filters hide those id/class names, which
   makes the button vanish in browsers with a content blocker. Glass, like the
   ghost button. */
.overview-return {
    position: fixed;
    right: var(--fab-inset);
    bottom: var(--fab-inset);
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
    width: var(--fab-size);
    height: var(--fab-size);
    padding: 0;
    border: 1px solid var(--glass-border);
    border-radius: 50%;
    background: var(--glass);
    -webkit-backdrop-filter: blur(12px) saturate(160%);
    backdrop-filter: blur(12px) saturate(160%);
    color: var(--fg);
    box-shadow: 0 4px 16px var(--glass-shadow);
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transform: translateY(.5rem);
    transition: opacity .25s ease, transform .3s var(--spring), visibility .25s ease;
}

.overview-return.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

@media (hover: hover) and (pointer: fine) {
    .overview-return.visible:hover {
        transform: translateY(0) scale(1.05);
    }
}

/* Responsive ------------------------------------------------------------- */

@media (max-width: 820px) {
    .section-feature {
        padding: 4rem 0;
    }

    .feature-split {
        grid-template-columns: 1fr;
        gap: 2.5rem;
        text-align: center;
    }

    .feature-split-reverse .feature-text {
        order: 0;
    }

    .feature-text {
        max-width: 34rem;
    }

    .section-centered .screenshot {
        margin-top: 2.5rem;
    }
}

/* In em, so the columns also stack when enlarged text would squeeze them. */
@media (max-width: 45em) {
    .details {
        grid-template-columns: 1fr;
        row-gap: 0;
        max-width: 28rem;
    }

    .detail {
        padding: 1.25rem 0;
    }

    .detail:not(:nth-child(3n + 1)) {
        border-left: none;
    }

    .detail + .detail {
        border-top: 1px solid var(--hairline);
    }
}

/* In em, like the details, so enlarged text stacks them too. */
@media (max-width: 37.5em) {
    .export-pair {
        grid-template-columns: 1fr;
        max-width: 21.25rem;
    }
}

@media (max-width: 600px) {
    .section-hero {
        padding: 5rem 0 3.5rem;
    }

    .app-icon {
        width: 5.5rem;
    }

    .hero-media {
        margin-top: 3rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        transition-duration: .01ms !important;
        animation-duration: .01ms !important;
    }

    .btn-primary:hover,
    .btn-ghost:hover,
    .compare:hover .compare-handle,
    .overview-return.visible:hover {
        transform: none;
    }
}
