/* MelCAD download page (meldev.se/melcad). */
/* Same look as meldev.se and its subpages: cyan glass on near-black, Fraunces / Geist / Geist Mono. */
:root {
    --bg-0: #050608;
    --bg-1: #0a0c11;
    --bg-card: rgba(15, 20, 38, 0.55);
    --line: rgba(74, 216, 255, 0.10);
    --line-strong: rgba(74, 216, 255, 0.28);
    --text: #e8edf2;
    --text-soft: #c2c9d3;
    --text-dim: #8b95a3;
    --cyan: #4ad8ff;
    --cyan-soft: #7ee5ff;
    --cyan-bright: #b9efff;
    --violet: #8d72ff;              /* from the MelCAD icon */
    --ink: #04162a;
    --ok: #5fe3a1;
    --warn: #ffc66b;

    --sans: "Geist", "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
    --mono: "Geist Mono", "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    --display: "Fraunces", "Geist", Georgia, serif;

    --max-w: 1120px;
    --pad: clamp(1rem, 4vw, 2rem);
    --radius: 14px;
    color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
    margin: 0;
    background: var(--bg-0);
    color: var(--text);
    font-family: var(--sans);
    font-size: 17px;
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
    padding-top: calc(64px + env(safe-area-inset-top, 0px));
    min-height: 100vh;
    display: flex; flex-direction: column;
    overflow-x: hidden;
    overflow-wrap: break-word;
}
img { max-width: 100%; display: block; }
a { color: var(--cyan); text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 3px; }
a:hover { color: var(--cyan-soft); text-decoration-color: currentColor; }
::selection { background: var(--cyan); color: var(--ink); }
:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; border-radius: 4px; }

.grain {
    position: fixed; inset: 0; pointer-events: none; z-index: 200;
    opacity: 0.04; mix-blend-mode: overlay;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.92' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 0.6 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
    background-size: 180px 180px;
}

/* ---------- nav ---------- */
.nav {
    position: fixed; top: 0; left: 0; right: 0; z-index: 100;
    height: calc(64px + env(safe-area-inset-top, 0px));
    padding: env(safe-area-inset-top, 0px) var(--pad) 0;
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    background: linear-gradient(180deg, rgba(10,12,17,0.95), rgba(10,12,17,0.85));
    backdrop-filter: blur(14px) saturate(140%);
    -webkit-backdrop-filter: blur(14px) saturate(140%);
    border-bottom: 1px solid var(--line);
}
.nav-logo { display: flex; align-items: center; flex-shrink: 0; }
.nav-logo img {
    height: 26px; width: auto;
    filter: invert(1) brightness(1.05) drop-shadow(0 0 8px rgba(74,216,255,0.4));
}
.nav-links { display: flex; align-items: center; gap: clamp(0.9rem, 4vw, 1.6rem); }
.nav-links a {
    font-family: var(--mono); font-size: 0.74rem; letter-spacing: 0.12em; text-transform: uppercase;
    color: var(--text-dim); text-decoration: none; padding: 0.6rem 0;
    border-bottom: 1px solid transparent;
}
.nav-links a:hover { color: var(--cyan-bright); border-bottom-color: var(--cyan); }

/* ---------- hero: full-bleed Higgsfield render ---------- */
.hero {
    position: relative; isolation: isolate;
    min-height: clamp(560px, 82vh, 820px);
    display: flex; align-items: center;
    padding: clamp(3rem, 8vh, 5rem) var(--pad) clamp(9rem, 18vh, 12rem);
    overflow: hidden;
}
.hero-bg {
    position: absolute; inset: 0; z-index: -1;
    background: url("/melcad/hero.jpg") 68% 45% / cover no-repeat;
    animation: drift 28s ease-in-out infinite alternate;
    transform-origin: 70% 50%;
}
/* keep the text side dark, fade into the page at the bottom, soft grid on top */
.hero::before {
    content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
    background:
        linear-gradient(90deg, rgba(5,6,8,0.96) 0%, rgba(5,6,8,0.82) 32%, rgba(5,6,8,0.15) 62%, rgba(5,6,8,0) 100%),
        linear-gradient(180deg, rgba(5,6,8,0.55) 0%, rgba(5,6,8,0) 22%, rgba(5,6,8,0) 62%, var(--bg-0) 100%);
}
.hero::after {
    content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
    background-image:
        linear-gradient(rgba(74,216,255,0.045) 1px, transparent 1px),
        linear-gradient(90deg, rgba(74,216,255,0.045) 1px, transparent 1px);
    background-size: 56px 56px;
    mask-image: radial-gradient(ellipse at 18% 45%, #000 10%, transparent 60%);
    -webkit-mask-image: radial-gradient(ellipse at 18% 45%, #000 10%, transparent 60%);
}
@keyframes drift {
    from { transform: scale(1.02) translate3d(0, 0, 0); }
    to   { transform: scale(1.08) translate3d(-1.2%, -0.8%, 0); }
}
.hero-inner { width: 100%; max-width: var(--max-w); margin: 0 auto; }
.hero-inner > * { max-width: 560px; }

.brand { display: flex; align-items: center; gap: 0.9rem; }
.app-icon {
    width: 64px; height: 64px; flex-shrink: 0;
    border-radius: 22.37%;
    box-shadow:
        0 0 0 1px rgba(255,255,255,0.1),
        0 12px 28px rgba(0,0,0,0.5),
        0 0 32px rgba(141,114,255,0.35);
}
.brand-name { font-weight: 700; font-size: 1.35rem; letter-spacing: -0.01em; line-height: 1.1; }
.brand-ver { font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--cyan-bright); margin-top: 0.25rem; }

h1 {
    font-family: var(--display); font-weight: 500;
    font-size: clamp(2.8rem, 8vw, 5rem); line-height: 1.02; letter-spacing: -0.02em;
    margin: clamp(1.4rem, 4vh, 2rem) 0 0;
}
h1 em, h2 em {
    font-style: italic; color: var(--cyan);
    text-shadow: 0 0 28px rgba(74,216,255,0.35);
}
.lede { color: var(--text-soft); font-size: 1.1rem; margin: 1.3rem 0 0; }

.hero-cta { display: flex; flex-wrap: wrap; gap: 0.8rem; margin-top: 2rem; }
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.6rem;
    padding: 0.95rem 1.6rem;
    border-radius: 10px;
    font-weight: 700; font-size: 0.95rem; letter-spacing: 0.02em;
    text-decoration: none; cursor: pointer;
    border: 1px solid transparent;
    transition: transform .12s, box-shadow .2s, background .2s, border-color .2s, color .2s, filter .2s;
}
.btn svg { width: 18px; height: 18px; }
.btn-primary {
    background: linear-gradient(180deg, var(--cyan-soft), var(--cyan));
    color: var(--ink);
    border-color: var(--cyan);
    box-shadow: 0 0 0 1px rgba(74,216,255,0.4), 0 0 24px rgba(74,216,255,0.28), inset 0 1px 0 rgba(255,255,255,0.4);
}
.btn-primary:hover {
    color: var(--ink); filter: brightness(1.08); transform: translateY(-2px);
    box-shadow: 0 0 0 1px rgba(74,216,255,0.7), 0 0 36px rgba(74,216,255,0.5), inset 0 1px 0 rgba(255,255,255,0.5);
}
.btn-primary:active { transform: translateY(0); }
.btn-ghost { background: rgba(5,6,8,0.35); color: var(--text); border-color: var(--line-strong); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.btn-ghost:hover { background: rgba(74,216,255,0.06); border-color: var(--cyan); color: var(--cyan-bright); }
.hero-dl-size { font-family: var(--mono); font-size: 0.8rem; font-weight: 600; opacity: 0.7; }
.hero-note { font-family: var(--mono); font-size: 0.76rem; letter-spacing: 0.04em; color: var(--text-dim); margin: 1rem 0 0; }

/* entrance */
.rise { animation: rise .8s cubic-bezier(.2,.7,.2,1) both; }
.hero-inner .rise:nth-child(2) { animation-delay: .08s; }
.hero-inner .rise:nth-child(3) { animation-delay: .16s; }
.hero-inner .rise:nth-child(4) { animation-delay: .24s; }
.hero-inner .rise:nth-child(5) { animation-delay: .30s; }
.shot.rise { animation-delay: .35s; animation-duration: 1.1s; }
@keyframes rise { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }

/* ---------- page ---------- */
main { width: 100%; max-width: var(--max-w); margin: 0 auto; padding: 0 var(--pad) 4rem; flex: 1; }

/* ---------- screenshot in a window, tilted back a little ---------- */
.shot { position: relative; margin: clamp(-9rem, -16vh, -6rem) 0 0; perspective: 2200px; }
.shot-glow {
    position: absolute; inset: 8% 6% -4%; z-index: -1;
    background: radial-gradient(ellipse at 50% 40%, rgba(74,216,255,0.28), rgba(141,114,255,0.18) 45%, transparent 72%);
    filter: blur(40px);
}
.window {
    border-radius: 14px; overflow: hidden;
    background: #0b0d12;
    border: 1px solid rgba(74,216,255,0.22);
    box-shadow:
        0 0 0 1px rgba(255,255,255,0.04),
        0 40px 100px rgba(0,0,0,0.65),
        0 0 60px rgba(74,216,255,0.12);
    transform: rotateX(9deg) scale(0.98);
    transform-origin: 50% 0;
    transition: transform .8s cubic-bezier(.2,.7,.2,1);
}
.shot:hover .window { transform: rotateX(0) scale(1); }
.window-bar {
    display: flex; align-items: center; gap: 7px;
    height: 34px; padding: 0 14px;
    background: linear-gradient(180deg, #15181f, #101218);
    border-bottom: 1px solid rgba(255,255,255,0.06);
}
.window-bar i { width: 11px; height: 11px; border-radius: 50%; background: #3a3f4a; }
.window-bar i:nth-child(1) { background: #ff5f57; }
.window-bar i:nth-child(2) { background: #febc2e; }
.window-bar i:nth-child(3) { background: #28c840; }
.window-bar span { margin: 0 auto; padding-right: 50px; font-family: var(--mono); font-size: 0.7rem; color: var(--text-dim); letter-spacing: 0.05em; }
.window img { width: 100%; height: auto; }

.chip {
    position: absolute; z-index: 2;
    display: inline-flex; align-items: center; gap: 0.5rem;
    padding: 0.5rem 0.95rem;
    border-radius: 999px;
    border: 1px solid var(--line-strong);
    background: rgba(10,12,17,0.82);
    backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
    font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--cyan-bright);
    box-shadow: 0 12px 30px rgba(0,0,0,0.5);
    animation: float 6s ease-in-out infinite;
}
.chip .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 10px var(--cyan); }
.chip-a { left: -1.2rem; top: 34%; }
.chip-b { right: -1.2rem; top: 62%; animation-delay: -3s; }
.chip-b .dot { background: var(--violet); box-shadow: 0 0 10px var(--violet); }
@keyframes float { 50% { transform: translateY(-8px); } }

/* ---------- sections ---------- */
main > section { margin-top: clamp(3.5rem, 9vw, 6rem); scroll-margin-top: 84px; }
.section-tag { display: block; font-family: var(--mono); font-size: 0.76rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--cyan); margin-bottom: 0.7rem; }
h2 {
    font-family: var(--display); font-weight: 500;
    font-size: clamp(1.9rem, 4.6vw, 2.8rem); line-height: 1.1; letter-spacing: -0.015em;
    margin: 0 0 clamp(1.4rem, 3vw, 2rem);
}
h3 { font-size: 1.05rem; font-weight: 600; line-height: 1.35; margin: 0 0 0.4rem; color: var(--text); }
p { margin: 0 0 0.9rem; color: var(--text-soft); }
p:last-child { margin-bottom: 0; }
strong { color: var(--text); font-weight: 600; }

.card {
    position: relative;
    background: var(--bg-card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: clamp(1.1rem, 4vw, 1.6rem);
}
.card-accent { border-color: var(--line-strong); box-shadow: 0 0 40px rgba(74,216,255,0.06); }

/* ---------- features ---------- */
.feat-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
    border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
    background: var(--line); gap: 1px;
}
.feat {
    position: relative;
    background: linear-gradient(180deg, rgba(12,15,24,0.96), rgba(8,10,15,0.96));
    padding: clamp(1.3rem, 3vw, 1.8rem);
    transition: background .3s;
}
.feat:hover { background: linear-gradient(180deg, rgba(16,24,38,0.98), rgba(9,12,18,0.98)); }
.feat svg {
    width: 34px; height: 34px; margin-bottom: 1rem;
    fill: none; stroke: var(--cyan); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round;
    filter: drop-shadow(0 0 6px rgba(74,216,255,0.45));
}
.feat p { font-size: 0.95rem; line-height: 1.6; }

/* ---------- activation key note ---------- */
.key-note { display: flex; gap: 1rem; align-items: flex-start; margin-bottom: 1.1rem; }
.key-note h3 { margin-bottom: 0.25rem; }
.key-icon {
    width: 42px; height: 42px; flex-shrink: 0;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 12px; border: 1px solid var(--line-strong); background: rgba(74,216,255,0.06); color: var(--cyan-bright);
}
.key-icon svg { width: 22px; height: 22px; }
.card h3 + p + h3 { margin-top: 1rem; }

/* ---------- downloads ---------- */
.dl-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr)); gap: 1.1rem; }
.dl-card { display: flex; flex-direction: column; gap: 1.1rem; transition: border-color .3s, box-shadow .3s; }
.dl-card:target, .dl-card.is-yours {
    border-color: var(--line-strong);
    box-shadow: 0 0 0 1px rgba(74,216,255,0.15), 0 0 60px rgba(74,216,255,0.10);
}
.yours {
    display: none;
    position: absolute; top: -0.75rem; right: 1.2rem;
    padding: 0.25rem 0.7rem; border-radius: 999px;
    background: var(--cyan); color: var(--ink);
    font-family: var(--mono); font-size: 0.66rem; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase;
    box-shadow: 0 0 20px rgba(74,216,255,0.5);
}
.dl-card.is-yours .yours { display: inline-block; }

.dl-head { display: flex; align-items: center; gap: 0.9rem; }
.os-mark {
    width: 46px; height: 46px; flex-shrink: 0;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 12px;
    border: 1px solid var(--line-strong);
    background: rgba(74,216,255,0.05);
    color: var(--cyan-bright);
}
.os-mark svg { width: 22px; height: 22px; }
.dl-head h3 { font-size: 1.3rem; margin: 0; }
.dl-req { font-family: var(--mono); font-size: 0.74rem; letter-spacing: 0.04em; color: var(--text-dim); margin: 0.1rem 0 0; }

.dl-btn {
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    padding: 0.95rem 1.25rem;
    border-radius: 12px;
    background: linear-gradient(180deg, var(--cyan-soft), var(--cyan));
    border: 1px solid var(--cyan);
    color: var(--ink);
    text-decoration: none;
    box-shadow: 0 0 0 1px rgba(74,216,255,0.4), 0 0 24px rgba(74,216,255,0.28), inset 0 1px 0 rgba(255,255,255,0.4);
    transition: transform .12s, box-shadow .2s, filter .2s;
}
.dl-btn:hover {
    color: var(--ink); filter: brightness(1.08); transform: translateY(-2px);
    box-shadow: 0 0 0 1px rgba(74,216,255,0.7), 0 0 36px rgba(74,216,255,0.5), inset 0 1px 0 rgba(255,255,255,0.5);
}
.dl-btn:active { transform: translateY(0); }
.dl-btn-text { display: grid; line-height: 1; }
.dl-btn-text em {
    font-family: var(--mono); font-style: normal;
    font-size: 0.65rem; letter-spacing: 0.18em; text-transform: uppercase;
    color: rgba(4,22,42,0.7); margin-bottom: 5px;
}
.dl-btn-text strong { color: var(--ink); font-weight: 700; font-size: 1.12rem; letter-spacing: -0.01em; }
.dl-btn-side { display: flex; align-items: center; gap: 0.55rem; font-family: var(--mono); font-size: 0.8rem; font-weight: 600; }
.dl-btn-side svg { width: 20px; height: 20px; }

.dl-file { font-family: var(--mono); font-size: 0.74rem; color: var(--text-dim); margin: -0.5rem 0 0; }

.badge {
    display: inline-flex; align-items: center; gap: 0.5rem; align-self: flex-start;
    padding: 0.3rem 0.75rem;
    border-radius: 999px;
    font-family: var(--mono); font-size: 0.7rem; letter-spacing: 0.08em; text-transform: uppercase;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; box-shadow: 0 0 8px currentColor; }
.badge-ok { color: var(--ok); border: 1px solid rgba(95,227,161,0.3); background: rgba(95,227,161,0.06); }
.badge-warn { color: var(--warn); border: 1px solid rgba(255,198,107,0.3); background: rgba(255,198,107,0.06); }

.steps { margin: 0; padding: 0; list-style: none; counter-reset: step; }
.steps li { position: relative; padding-left: 2.1rem; color: var(--text-soft); font-size: 0.95rem; line-height: 1.55; }
.steps li + li { margin-top: 0.6rem; }
.steps li::before {
    counter-increment: step; content: counter(step);
    position: absolute; left: 0; top: 0.05rem;
    width: 1.45rem; height: 1.45rem; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid var(--line-strong); background: rgba(74,216,255,0.05);
    font-family: var(--mono); font-size: 0.7rem; color: var(--cyan-bright);
}
.steps b { color: var(--text); font-weight: 600; }

.sha { margin-top: auto; border-top: 1px solid var(--line); padding-top: 0.9rem; }
.sha summary {
    cursor: pointer; list-style: none;
    font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-dim);
}
.sha summary::-webkit-details-marker { display: none; }
.sha summary::before { content: "+ "; color: var(--cyan); }
.sha[open] summary::before { content: "\2212  "; }
.sha summary:hover { color: var(--cyan-bright); }
.sha code {
    display: block; margin-top: 0.6rem;
    font-family: var(--mono); font-size: 0.72rem; line-height: 1.5; color: var(--text-soft);
    word-break: break-all; user-select: all;
}

/* ---------- help ---------- */
.help-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); gap: 1.1rem; }
.mail { display: inline-block; margin-top: 0.3rem; font-family: var(--mono); font-size: 1.02rem; color: var(--cyan-bright); }

/* ---------- footer ---------- */
.foot {
    border-top: 1px solid var(--line);
    padding: 1.5rem var(--pad) calc(1.5rem + env(safe-area-inset-bottom, 0px));
    display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 0.4rem 1.4rem;
    font-family: var(--mono); font-size: 0.78rem; color: var(--text-dim);
}
.foot a { color: var(--text-dim); text-decoration: none; }
.foot a:hover { color: var(--cyan-bright); }

/* ---------- small screens: the render becomes a backdrop behind the text ---------- */
@media (max-width: 760px) {
    .hero { min-height: 0; align-items: flex-start; padding-top: 2.5rem; padding-bottom: 7rem; }
    .hero-bg { background-position: 72% 30%; opacity: 0.6; }
    .hero::before {
        background: linear-gradient(180deg, rgba(5,6,8,0.5) 0%, rgba(5,6,8,0.86) 42%, var(--bg-0) 100%);
    }
    .shot { margin-top: -4.5rem; }
    .window { transform: none; }
    .window-bar span { display: none; }
    .chip { font-size: 0.62rem; padding: 0.4rem 0.7rem; }
    .chip-a { left: 0.5rem; top: auto; bottom: -1rem; }
    .chip-b { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    .hero-bg, .chip, .rise { animation: none; }
    .window, .dl-btn, .btn { transition: none; }
}

/* ---------- previews (screen recordings) ---------- */
.vid-grid { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(1rem, 3vw, 1.6rem); }
.vid { margin: 0; }
.vid-main { grid-column: 1 / -1; }
.vid .window { transform: none; }
.vid video { display: block; width: 100%; height: auto; aspect-ratio: 1440 / 900; background: #0b0d12; }
.vid figcaption { padding: 0.95rem 0.2rem 0; }
.vid figcaption p { font-size: 0.95rem; line-height: 1.6; }
.vid-main figcaption { max-width: 44rem; }
@media (max-width: 760px) { .vid-grid { grid-template-columns: 1fr; } }
.vid .window { position: relative; cursor: zoom-in; }
.vid-expand {
    position: absolute; right: 12px; bottom: 12px; z-index: 2;
    display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.38rem 0.7rem; border-radius: 999px;
    border: 1px solid var(--line-strong); background: rgba(10,12,17,0.78);
    backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
    font-family: var(--mono); font-size: 0.66rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--cyan-bright);
    opacity: 0; transform: translateY(4px); transition: opacity .25s, transform .25s; pointer-events: none;
}
.vid-expand svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.vid .window:hover .vid-expand, .vid .window:focus-within .vid-expand { opacity: 1; transform: none; }
@media (hover: none) { .vid-expand { opacity: 1; transform: none; } }
/* the featured recording on top, the others in a row below */
.vid-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 1000px) { .vid-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 760px) { .vid-grid { grid-template-columns: 1fr; } }
