:root {
    --bg: #07100d;
    --bg-deep: #040906;
    --surface: rgba(15, 30, 24, 0.78);
    --surface-strong: #10231b;
    --surface-soft: #132a21;
    --border: rgba(167, 243, 192, 0.16);
    --border-strong: rgba(167, 243, 192, 0.34);
    --text: #edf5ef;
    --text-muted: #aabbb0;
    --heading: #f8fbf8;
    --primary: #74c69d;
    --primary-strong: #52b788;
    --primary-soft: #b7e4c7;
    --accent-dark: #1b4332;
    --shadow: 0 24px 70px rgba(0, 0, 0, 0.32);
    --serif: "DM Serif Display", Georgia, serif;
    --sans: "DM Sans", system-ui, sans-serif;
    --mono: "DM Mono", ui-monospace, monospace;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    min-width: 280px;
    color: var(--text);
    background:
        radial-gradient(circle at 82% 3%, rgba(45, 106, 79, 0.28), transparent 34rem),
        radial-gradient(circle at 8% 30%, rgba(27, 67, 50, 0.2), transparent 28rem),
        linear-gradient(160deg, var(--bg-deep), var(--bg) 48%, #09140f);
    font-family: var(--sans);
    font-size: 16px;
    line-height: 1.65;
}

a {
    color: inherit;
}

a:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 4px;
}

.skip-link {
    position: fixed;
    z-index: 2000;
    top: 0.75rem;
    left: 0.75rem;
    padding: 0.65rem 0.9rem;
    color: #07100d;
    background: var(--primary-soft);
    border-radius: 0.25rem;
    font-weight: 600;
    transform: translateY(-160%);
}

.skip-link:focus {
    transform: translateY(0);
}

#page {
    width: min(1160px, calc(100% - 3rem));
    margin: 0 auto;
}

.site-nav {
    position: sticky;
    z-index: 1000;
    top: 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    min-height: 4rem;
    margin: 1rem 0 0;
    padding: 0.55rem 0.7rem;
    background: rgba(7, 16, 13, 0.82);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    box-shadow: 0 14px 40px rgba(0, 0, 0, 0.24);
    backdrop-filter: blur(16px);
}

.site-mark {
    display: grid;
    place-items: center;
    flex: 0 0 2.75rem;
    width: 2.75rem;
    height: 2.75rem;
    color: var(--bg-deep);
    background: var(--primary);
    border-radius: 0.28rem;
    font-family: var(--mono);
    font-size: 0.82rem;
    font-weight: 500;
    letter-spacing: 0.08em;
    text-decoration: none;
}

.desktop-nav {
    margin-left: auto;
}

.site-nav ul {
    display: flex;
    justify-content: flex-end;
    gap: 0.2rem;
    width: max-content;
    min-width: 100%;
    list-style: none;
}

.site-nav li {
    flex: none;
}

.site-nav li a {
    display: block;
    padding: 0.68rem 0.85rem;
    color: var(--text-muted);
    border-radius: 0.3rem;
    font-family: var(--mono);
    font-size: 0.78rem;
    letter-spacing: 0.06em;
    text-decoration: none;
    text-transform: uppercase;
    white-space: nowrap;
    transition: color 160ms ease, background-color 160ms ease;
}

.site-nav li a:hover,
.site-nav li a.active {
    color: var(--heading);
    background: rgba(116, 198, 157, 0.12);
}

.mobile-nav {
    display: none;
    position: relative;
    margin-left: auto;
}

.mobile-nav summary {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    min-height: 2.65rem;
    padding: 0.55rem 0.75rem;
    color: var(--heading);
    background: rgba(116, 198, 157, 0.08);
    border: 1px solid var(--border-strong);
    border-radius: 0.3rem;
    font-family: var(--mono);
    font-size: 0.75rem;
    letter-spacing: 0.06em;
    list-style: none;
    text-transform: uppercase;
    cursor: pointer;
    user-select: none;
}

.mobile-nav summary::-webkit-details-marker {
    display: none;
}

.mobile-nav summary:hover,
.mobile-nav summary:focus-visible {
    background: rgba(116, 198, 157, 0.15);
    border-color: var(--primary);
}

.menu-icon {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 3px;
    width: 1rem;
    height: 1rem;
}

.menu-icon span {
    display: block;
    width: 100%;
    height: 1px;
    background: currentColor;
    transition: transform 160ms ease, opacity 160ms ease;
}

.mobile-nav[open] .menu-icon span:first-child {
    transform: translateY(4px) rotate(45deg);
}

.mobile-nav[open] .menu-icon span:nth-child(2) {
    opacity: 0;
}

.mobile-nav[open] .menu-icon span:last-child {
    transform: translateY(-4px) rotate(-45deg);
}

.mobile-nav-panel {
    position: absolute;
    top: calc(100% + 0.65rem);
    right: 0;
    width: min(19rem, calc(100vw - 1.25rem));
    padding: 0.45rem;
    background: rgba(7, 16, 13, 0.98);
    border: 1px solid var(--border-strong);
    border-radius: 0.45rem;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(18px);
}

.mobile-nav-panel ul {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    width: 100%;
    min-width: 0;
}

.mobile-nav-panel li a {
    width: 100%;
    padding: 0.8rem 0.85rem;
    font-size: 0.8rem;
    text-align: left;
}

main {
    width: 100%;
}

.hero {
    display: grid;
    grid-template-columns: minmax(0, 1.55fr) minmax(260px, 0.75fr);
    gap: clamp(2rem, 7vw, 6rem);
    align-items: end;
    min-height: 680px;
    padding: clamp(5rem, 12vw, 9rem) 0 clamp(4rem, 8vw, 7rem);
    border-bottom: 1px solid var(--border);
    scroll-margin-top: 6rem;
}

.eyebrow,
.section-index,
.post-kicker,
.project-meta,
.timeline-date {
    color: var(--primary);
    font-family: var(--mono);
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.hero h1 {
    margin: 0.35rem 0 0;
    color: var(--heading);
    font-family: var(--serif);
    font-size: clamp(4.1rem, 10vw, 8.5rem);
    font-weight: 400;
    letter-spacing: -0.055em;
    line-height: 0.92;
}

.hero-title {
    max-width: 720px;
    margin-top: 1.6rem;
    color: var(--heading);
    font-size: clamp(1.3rem, 2.6vw, 2rem);
    font-weight: 400;
    line-height: 1.3;
}

.hero-intro {
    max-width: 720px;
    margin-top: 1.25rem;
    color: var(--text-muted);
    font-size: 1.03rem;
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 2rem;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.9rem;
    padding: 0.65rem 1rem;
    border: 1px solid var(--border-strong);
    border-radius: 0.28rem;
    font-family: var(--mono);
    font-size: 0.78rem;
    font-weight: 500;
    letter-spacing: 0.06em;
    text-decoration: none;
    text-transform: uppercase;
    transition: transform 160ms ease, background-color 160ms ease, border-color 160ms ease;
}

.button:hover {
    transform: translateY(-2px);
}

.button-primary {
    color: var(--bg-deep);
    background: var(--primary);
    border-color: var(--primary);
}

.button-primary:hover {
    background: var(--primary-soft);
    border-color: var(--primary-soft);
}

.button-secondary {
    color: var(--heading);
    background: transparent;
}

.button-secondary:hover {
    background: rgba(116, 198, 157, 0.09);
    border-color: var(--primary);
}

.availability-card {
    padding: 1.5rem;
    background: linear-gradient(145deg, rgba(19, 42, 33, 0.92), rgba(10, 24, 18, 0.94));
    border: 1px solid var(--border-strong);
    border-radius: 0.45rem;
    box-shadow: var(--shadow);
}

.availability-card .status {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    margin-bottom: 1.25rem;
    color: var(--primary-soft);
    font-family: var(--mono);
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.availability-card .status span {
    width: 0.55rem;
    height: 0.55rem;
    background: var(--primary);
    border-radius: 999px;
    box-shadow: 0 0 0 5px rgba(116, 198, 157, 0.1);
}

.availability-card dl {
    border-top: 1px solid var(--border);
}

.availability-card dl div {
    display: grid;
    grid-template-columns: 5.5rem 1fr;
    gap: 1rem;
    padding: 0.8rem 0;
    border-bottom: 1px solid var(--border);
}

.availability-card dt {
    color: var(--text-muted);
    font-family: var(--mono);
    font-size: 0.75rem;
    letter-spacing: 0.07em;
    text-transform: uppercase;
}

.availability-card dd {
    color: var(--heading);
    font-size: 0.86rem;
}

.availability-card > a {
    display: inline-block;
    margin-top: 1.25rem;
    color: var(--primary-soft);
    font-family: var(--mono);
    font-size: 0.82rem;
    text-decoration: none;
}

.section {
    padding: clamp(4rem, 8vw, 6rem) 0;
    border-bottom: 1px solid var(--border);
    scroll-margin-top: 6rem;
}

.section-heading {
    max-width: 760px;
    margin-bottom: 2.4rem;
}

.section-heading-row {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 2rem;
    max-width: none;
}

.section h2,
footer h2 {
    margin-top: 0.45rem;
    color: var(--heading);
    font-family: var(--serif);
    font-size: clamp(2.5rem, 4.5vw, 3.5rem);
    font-weight: 400;
    letter-spacing: -0.035em;
    line-height: 1.05;
}

.text-link,
.card-link {
    color: var(--primary-soft);
    font-family: var(--mono);
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    text-decoration: none;
    text-transform: uppercase;
}

.text-link:hover,
.card-link:hover {
    color: #fff;
}

.skill-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

.skill-grid article {
    padding: 2rem;
    border-right: 1px solid var(--border);
}

.skill-grid article:first-child {
    padding-left: 0;
}

.skill-grid article:last-child {
    padding-right: 0;
    border-right: 0;
}

.skill-number {
    color: var(--primary);
    font-family: var(--mono);
    font-size: 0.78rem;
}

.skill-grid h3,
.project-card h3,
.timeline h3,
.latest-post h3 {
    color: var(--heading);
    font-weight: 500;
}

.skill-grid h3 {
    margin-top: 2.5rem;
    font-size: 1.22rem;
}

.skill-grid article > p:last-child {
    margin-top: 0.55rem;
    color: var(--text-muted);
    font-size: 0.95rem;
}

.projects-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 1rem;
}

.project-card {
    display: flex;
    flex-direction: column;
    padding: clamp(1.5rem, 3vw, 2.25rem);
    background: rgba(15, 30, 24, 0.72);
    border: 1px solid var(--border);
    border-radius: 0.45rem;
    transition: transform 180ms ease, border-color 180ms ease, background-color 180ms ease;
}

.project-card:hover {
    background: var(--surface);
    border-color: var(--border-strong);
    transform: translateY(-3px);
}

.project-featured {
    background:
        linear-gradient(120deg, rgba(27, 67, 50, 0.9), rgba(15, 30, 24, 0.72)),
        var(--surface);
}

.project-meta {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    color: var(--primary);
}

.project-card h3 {
    max-width: 680px;
    padding-top: 2.25rem;
    font-family: var(--serif);
    font-size: clamp(1.85rem, 3.2vw, 2.6rem);
    font-weight: 400;
    letter-spacing: -0.025em;
    line-height: 1.06;
}

.project-body > p {
    max-width: 720px;
    margin-top: 0.9rem;
    color: var(--text-muted);
}

.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin-top: 1.5rem;
    list-style: none;
}

.tag-list li,
.project-tag {
    padding: 0.3rem 0.55rem;
    color: var(--primary-soft);
    background: rgba(116, 198, 157, 0.08);
    border: 1px solid var(--border);
    border-radius: 0.2rem;
    font-family: var(--mono);
    font-size: 0.75rem;
}

.project-media {
    margin-top: 1.75rem;
}

.project-media img {
    display: block;
    /* Allekkain asetellussa kortissa kuva ei veny koko leveydelle tableteilla. */
    max-width: min(100%, 30rem);
    height: auto;
    border: 1px solid var(--border);
    border-radius: 0.35rem;
}

.project-diagram {
    margin-top: 1.75rem;
}

.project-diagram figcaption {
    margin-top: 0.7rem;
    color: var(--text-muted);
    font-family: var(--mono);
    font-size: 0.75rem;
}

/* Kapealla näytöllä kaavio vieritetään vaakasuunnassa, jotta teksti pysyy luettavana. */
.network-diagram {
    overflow-x: auto;
    padding: 1rem;
    background: rgba(4, 9, 6, 0.45);
    border: 1px solid var(--border);
    border-radius: 0.35rem;
}

.network-diagram svg {
    display: block;
    width: 100%;
    min-width: 860px;
    height: auto;
}

/* Kaavio mahtuu kokonaan näkyviin noin 1005 px:n leveydestä alkaen (varaa selaimen vierityspalkille). */
@media (min-width: 1040px) {
    .scroll-hint {
        display: none;
    }
}

.nd-box {
    fill: var(--surface-strong);
    stroke: var(--border-strong);
}

.nd-box-key {
    stroke: var(--primary);
}

.nd-title {
    fill: var(--heading);
    font-family: var(--sans);
    font-size: 17px;
    font-weight: 500;
}

.nd-sub {
    fill: var(--text-muted);
    font-family: var(--mono);
    font-size: 12.5px;
}

.nd-label {
    fill: var(--primary);
    font-family: var(--mono);
    font-size: 12px;
    letter-spacing: 0.08em;
}

.nd-wire {
    fill: none;
    stroke: var(--text-muted);
    stroke-width: 1.5;
}

.nd-tunnel {
    fill: none;
    stroke: var(--primary);
    stroke-width: 1.75;
    stroke-dasharray: 7 6;
}

.nd-dot {
    fill: var(--primary);
}

@media (min-width: 900px) {
    /* Kuvallinen kortti: teksti vasemmalla, kuva oikealla koko kortin korkeudelta. */
    .project-has-media {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
        grid-template-rows: auto 1fr;
        column-gap: clamp(2rem, 4vw, 3.5rem);
    }

    .project-has-media .project-media {
        grid-column: 2;
        grid-row: 1 / span 2;
        align-self: center;
        justify-self: end;
        margin-top: 0;
    }

    .project-has-media .project-body {
        align-self: center;
    }

    .project-has-media .project-media img {
        max-width: 100%;
    }

    .project-has-media .project-diagram {
        grid-column: 1 / -1;
        margin-top: 2rem;
    }
}

.card-link {
    display: inline-block;
    margin-top: 1.35rem;
}

.card-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1.75rem;
    margin-top: 1.35rem;
}

.card-links .card-link {
    margin-top: 0;
}

.section-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem 2rem;
    margin-top: 2rem;
}

.timeline {
    border-top: 1px solid var(--border);
}

.timeline article {
    display: grid;
    grid-template-columns: minmax(110px, 0.25fr) 1fr;
    gap: 2rem;
    padding: 1.4rem 0;
    border-bottom: 1px solid var(--border);
}

.timeline h3 {
    font-size: 1.08rem;
}

.timeline article div p {
    margin-top: 0.25rem;
    color: var(--text-muted);
}

.latest-post {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 2rem;
    align-items: center;
    padding: clamp(1.5rem, 4vw, 2.5rem);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.45rem;
}

.latest-post h3 {
    margin-top: 0.5rem;
    font-family: var(--serif);
    font-size: clamp(1.75rem, 3.2vw, 2.6rem);
    font-weight: 400;
    line-height: 1.12;
}

.latest-post h3 a {
    text-decoration: none;
}

.latest-post h3 a:hover {
    color: var(--primary-soft);
}

.latest-post div > p:last-child {
    max-width: 760px;
    margin-top: 0.65rem;
    color: var(--text-muted);
}

.post-arrow {
    display: grid;
    place-items: center;
    width: 3.5rem;
    height: 3.5rem;
    color: var(--bg-deep);
    background: var(--primary);
    border-radius: 999px;
    font-size: 1.35rem;
    text-decoration: none;
    transition: transform 160ms ease, background-color 160ms ease;
}

.post-arrow:hover {
    background: var(--primary-soft);
    transform: translate(2px, -2px);
}

.about-section > p {
    max-width: 840px;
    color: var(--text-muted);
    font-size: clamp(1.05rem, 2.2vw, 1.35rem);
}

footer {
    display: grid;
    grid-template-columns: 1.2fr 0.8fr;
    gap: 2rem;
    align-items: end;
    padding: clamp(4rem, 8vw, 6rem) 0 2rem;
    scroll-margin-top: 6rem;
}

.footer-links {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.55rem;
}

.footer-links a {
    color: var(--primary-soft);
    font-family: var(--mono);
    font-size: 0.82rem;
    text-decoration: none;
}

.footer-links a:hover {
    color: #fff;
}

.footer-note {
    grid-column: 1 / -1;
    margin-top: 3rem;
    padding-top: 1rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
    font-family: var(--mono);
    font-size: 0.75rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

/* Shared blog and article foundations */
.blog-shell {
    padding: clamp(4rem, 9vw, 7rem) 0 2rem;
}

.blog-shell > h1 {
    color: var(--heading);
    font-family: var(--serif);
    font-size: clamp(3.5rem, 9vw, 7rem);
    font-weight: 400;
    letter-spacing: -0.05em;
    line-height: 0.95;
}

.blog-shell > p {
    max-width: 700px;
    margin-top: 1.25rem;
    color: var(--text-muted);
    font-size: 1.08rem;
}

p a {
    color: var(--primary-soft);
}

@media (max-width: 850px) {
    #page {
        width: min(100% - 2rem, 1160px);
    }

    .hero {
        grid-template-columns: 1fr;
        min-height: auto;
        padding-top: 6rem;
    }

    .availability-card {
        max-width: 540px;
    }

    .skill-grid {
        grid-template-columns: 1fr;
    }

    .skill-grid article,
    .skill-grid article:first-child,
    .skill-grid article:last-child {
        padding: 1.5rem 0;
        border-right: 0;
        border-bottom: 1px solid var(--border);
    }

    .skill-grid article:last-child {
        border-bottom: 0;
    }

    .skill-grid h3 {
        margin-top: 1rem;
    }
}

@media (max-width: 640px) {
    #page {
        width: min(100% - 1.25rem, 1160px);
    }

    .site-nav {
        top: 0.35rem;
        gap: 0.45rem;
        min-height: 3.55rem;
        margin-top: 0.35rem;
        padding: 0.35rem;
    }

    .site-mark {
        flex-basis: 2.65rem;
        width: 2.65rem;
        height: 2.65rem;
    }

    .desktop-nav {
        display: none;
    }

    .mobile-nav {
        display: block;
    }

    .hero {
        gap: 2.5rem;
        padding: 4.5rem 0 4rem;
    }

    .hero h1 {
        font-size: clamp(3.6rem, 19vw, 5rem);
    }

    .hero-title {
        font-size: 1.25rem;
    }

    .hero-intro {
        font-size: 0.96rem;
    }

    .hero-actions {
        flex-direction: column;
    }

    .button {
        width: 100%;
    }

    .section {
        padding: 4rem 0;
    }

    .section-heading-row {
        display: block;
    }

    .section-heading-row .text-link {
        display: inline-block;
        margin-top: 1rem;
    }

    /* 12vw: alatunnisteen pisin sana (käytännönläheistä) mahtuu 320–430 px näytöille. */
    .section h2,
    footer h2 {
        font-size: clamp(2.35rem, 12vw, 3rem);
    }

    .project-card h3 {
        padding-top: 1.75rem;
        font-size: 2rem;
    }

    .project-meta {
        display: block;
    }

    .project-meta span {
        display: block;
    }

    .timeline article {
        grid-template-columns: 1fr;
        gap: 0.6rem;
    }

    .latest-post {
        grid-template-columns: 1fr;
    }

    .post-arrow {
        width: 3rem;
        height: 3rem;
    }

    footer {
        grid-template-columns: 1fr;
    }

    .footer-links {
        align-items: flex-start;
    }
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        transition-duration: 0.01ms !important;
    }
}
