:root {
    color-scheme: dark;

    /* Navy gives the structure; teal identifies actions and technical details. */
    --background: #101d2b;
    --surface: #182a3a;
    --surface-hover: #1e3446;
    --text: #f4f7fa;
    --muted: #b4c2cf;
    --border: #344b5e;
    --accent: #77e0ce;
    --accent-hover: #a0eddf;
    --on-accent: #101d2b;
    --pattern-line: rgba(180, 194, 207, 0.045);

    --font-sans: "IBM Plex Sans", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
    --font-mono: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
    --content-width: 1100px;

    /* REPLACE HERO ART HERE: any transparent PNG, WebP, or SVG works.
       The image is only used at the 1100px breakpoint below. */
    --hero-art-image: url("../assets/images/floating-citadel.webp");
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    scroll-padding-top: 24px;
}

body {
    margin: 0;
    background: var(--background);
    color: var(--text);
    font-family: var(--font-sans);
    font-size: 1.0625rem;
    line-height: 1.65;
}

::selection {
    background: var(--accent);
    color: var(--on-accent);
}

a {
    color: var(--accent);
    text-decoration-thickness: 1px;
    text-underline-offset: 0.22em;
}

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

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 5px;
    border-radius: 3px;
}

.skip-link {
    position: absolute;
    top: 16px;
    left: 16px;
    z-index: 10;
    padding: 12px 20px;
    transform: translateY(calc(-100% - 24px));
    background: var(--accent);
    color: var(--on-accent);
    font-weight: 600;
}

.skip-link:focus {
    transform: translateY(0);
    color: var(--on-accent);
}

header,
main,
footer {
    width: min(var(--content-width), calc(100% - 64px));
    margin-inline: auto;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    padding-block: 24px;
    border-bottom: 1px solid var(--border);
}

.site-name {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    min-height: 44px;
    color: var(--text);
    font-size: 1.125rem;
    font-weight: 600;
    letter-spacing: -0.025em;
    text-decoration: none;
}

.site-logo {
    display: block;
    flex: 0 0 40px;
    width: 40px;
    height: 40px;
    object-fit: contain;
}

.site-name span {
    min-width: 0;
}

nav {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 28px;
}

nav a {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    color: var(--muted);
    font-size: 0.9375rem;
    font-weight: 500;
    text-decoration: none;
}

nav a:hover {
    color: var(--accent);
    text-decoration: underline;
}

section {
    padding-block: 80px;
    border-bottom: 1px solid var(--border);
}

.hero {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 620px;
    padding-block: 112px;
    /* Keep the engineering grid in the hero, away from longer reading. */
    background-image:
        linear-gradient(var(--pattern-line) 1px, transparent 1px),
        linear-gradient(90deg, var(--pattern-line) 1px, transparent 1px);
    background-size: 48px 48px;
}

.hero .eyebrow {
    margin: 0 0 24px;
    color: var(--accent);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1.7;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

h1,
h2,
h3 {
    color: var(--text);
    font-weight: 600;
    text-wrap: balance;
    overflow-wrap: break-word;
}

.hero h1 {
    max-width: 1000px;
    margin: 0 0 24px;
    font-size: clamp(3rem, 7.2vw, 5.75rem);
    line-height: 1.08;
    letter-spacing: -0.045em;
}

.hero p {
    max-width: 580px;
    margin: 0 0 36px;
    font-size: 1.25rem;
    line-height: 1.65;
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
}

.hero-copy {
    position: relative;
    z-index: 1;
    min-width: 0;
}

.hero-art {
    display: none;
}

/* Wide-screen art breakpoint: keep this at 1100px or higher so the copy fits.
   The mobile layout neither displays nor requests the decorative image. */
@media (min-width: 1100px) {
    .hero {
        position: relative;
        isolation: isolate;
        display: grid;
        grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
        align-items: center;
        gap: 24px;
        min-height: 650px;
        padding-block: 72px;
    }

    .hero h1 {
        max-width: 11ch;
        font-size: clamp(4rem, 6vw, 5.5rem);
    }

    .hero-art {
        display: block;
        position: relative;
        isolation: isolate;
        width: 100%;
        aspect-ratio: 1;
        /* An elevated silhouette and a detached shadow create the floating effect. */
        transform: translateY(-12px);
        background: radial-gradient(ellipse at 50% 50%, rgba(71, 205, 219, 0.1), transparent 68%);
        pointer-events: none;
    }

    .hero-art::before {
        content: "";
        position: absolute;
        inset: 0;
        z-index: 1;
        background-image: var(--hero-art-image);
        background-position: center;
        background-size: contain;
        background-repeat: no-repeat;
        filter: drop-shadow(0 24px 20px rgba(0, 8, 18, 0.5));
    }

    .hero-art::after {
        content: "";
        position: absolute;
        inset: 86% 12% -4%;
        z-index: 0;
        border-radius: 50%;
        background: radial-gradient(ellipse, rgba(0, 8, 18, 0.65), rgba(53, 190, 209, 0.12) 45%, transparent 72%);
        filter: blur(14px);
    }
}

.button {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    gap: 24px;
    min-height: 50px;
    padding: 12px 22px;
    border: 1px solid var(--accent);
    border-radius: 4px;
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.5;
    text-decoration: none;
    font-family: inherit;
    cursor: pointer;
    transition: background-color 150ms ease, color 150ms ease, border-color 150ms ease;
}

.button-primary {
    background: var(--accent);
    color: var(--on-accent);
}

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

.button-secondary {
    border-color: var(--muted);
    color: var(--text);
}

.button-secondary:hover {
    border-color: var(--accent);
    background: var(--surface);
    color: var(--accent);
}

h2 {
    margin: 0 0 24px;
    font-size: clamp(1.875rem, 3.5vw, 2.75rem);
    line-height: 1.2;
    letter-spacing: -0.03em;
}

h3 {
    margin: 0 0 12px;
    font-size: 1.5rem;
    line-height: 1.35;
    letter-spacing: -0.015em;
}

p {
    max-width: 65ch;
    color: var(--muted);
}

section > p:last-child {
    margin-bottom: 0;
}

.project {
    max-width: 700px;
    margin-top: 32px;
    padding: 32px;
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    border-radius: 4px;
    background: var(--surface);
}

.project:hover,
.project:focus-within {
    background: var(--surface-hover);
}

.project h3 a {
    display: inline-block;
    padding-block: 6px;
    color: var(--text);
    text-decoration-color: var(--accent);
}

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

.project p {
    margin: 0;
}

#process ol {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    padding: 0;
    margin: 32px 0 0;
    /* Decimal markers retain ordered-list semantics in assistive technology. */
    list-style: decimal inside;
}

#process li {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    min-height: 280px;
    padding: 24px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background-color: var(--surface);
    /* The lower navy scrim protects the label even over a bright photo.
       Solid surface color remains a readable fallback if a photo cannot load. */
    background-image:
        linear-gradient(180deg, rgba(16, 29, 43, 0.16), rgba(16, 29, 43, 0.28) 35%, rgba(16, 29, 43, 0.94) 82%),
        var(--process-photo, none);
    background-size: cover;
    background-position: center, var(--process-photo-position, center);
    background-repeat: no-repeat;
    font-size: 1.125rem;
    font-weight: 500;
}

#process li::marker {
    font-size: 0;
}

.step-number {
    display: block;
    margin-bottom: 24px;
    color: var(--accent);
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    font-weight: 500;
    letter-spacing: 0.04em;
}

#process .step-number {
    position: absolute;
    top: 20px;
    left: 20px;
    margin: 0;
    padding: 4px 8px;
    border: 1px solid rgba(119, 224, 206, 0.25);
    border-radius: 3px;
    background: rgba(16, 29, 43, 0.9);
}

.process-label {
    color: var(--text);
    font-size: 1.375rem;
    font-weight: 600;
    line-height: 1.3;
    text-shadow: 0 2px 8px rgba(0, 8, 18, 0.4);
}

/* Keep the photos large enough to read before switching to the mobile layout. */
@media (min-width: 701px) and (max-width: 1000px) {
    #process ol {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* Process hover: short, restrained elevation inspired by Fluent motion guidance.
   https://fluent2.microsoft.design/motion
   These are informational cards: keep the normal cursor and list semantics. */
@media (hover: hover) and (pointer: fine) {
    #process li {
        transition:
            transform 180ms cubic-bezier(0.2, 0, 0, 1),
            background-color 180ms ease-out,
            border-color 180ms ease-out,
            box-shadow 180ms ease-out;
    }

    #process li:hover {
        transform: translateY(-3px);
        background-color: var(--surface-hover);
        border-color: var(--accent);
        box-shadow: 0 10px 24px rgba(0, 8, 18, 0.22);
    }
}

#contact {
    margin-top: 64px;
    padding: 56px;
    border: 1px solid var(--border);
    border-top: 3px solid var(--accent);
    border-radius: 4px;
    background: var(--surface);
}

#contact h2 {
    margin-bottom: 16px;
}

footer {
    padding-block: 32px;
}

footer p {
    margin: 0;
    font-size: 0.875rem;
}

/* Contact dialog: native modal behavior, styled with the site's palette. */
body.contact-is-open {
    overflow: hidden;
}

.contact-dialog {
    width: min(680px, calc(100% - 32px));
    max-height: calc(100vh - 32px);
    max-height: calc(100dvh - 32px);
    margin: auto;
    padding: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-top: 3px solid var(--accent);
    border-radius: 10px;
    box-shadow: 0 24px 90px rgba(0, 0, 0, 0.5);
}

.contact-dialog::backdrop {
    background: rgba(5, 12, 20, 0.8);
    backdrop-filter: blur(5px);
}

.dialog-content {
    padding: 32px;
}

.dialog-close {
    position: sticky;
    top: 12px;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    margin: 12px 12px -56px auto;
    padding: 0;
    color: var(--muted);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    font: 1.75rem/1 var(--font-sans);
    cursor: pointer;
}

.dialog-close:hover {
    color: var(--accent);
    background: var(--surface-hover);
    border-color: var(--accent);
}

.form-eyebrow {
    margin: 0 44px 12px 0;
    color: var(--accent);
    font: 500 0.75rem/1.7 var(--font-mono);
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.contact-dialog h2 {
    padding-right: 24px;
    margin-bottom: 12px;
    font-size: clamp(1.75rem, 5vw, 2.25rem);
}

#contact-intro {
    margin: 0 0 12px;
    font-size: 1rem;
}

.form-note,
.field-hint {
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 0.8125rem;
    line-height: 1.6;
}

.contact-fields {
    display: grid;
    gap: 20px;
    min-width: 0;
    margin: 24px 0 0;
    padding: 0;
    border: 0;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
}

.form-field {
    min-width: 0;
}

.form-field label {
    display: block;
    margin-bottom: 7px;
    font-size: 0.9375rem;
    font-weight: 500;
}

.form-field label span {
    color: var(--muted);
    font-size: 0.8125rem;
    font-weight: 400;
}

.form-field input,
.form-field select,
.form-field textarea {
    display: block;
    width: 100%;
    min-height: 48px;
    padding: 10px 12px;
    color: var(--text);
    background: var(--background);
    border: 1px solid #71879a;
    border-radius: 4px;
    font: 1rem/1.5 var(--font-sans);
}

.form-field textarea {
    min-height: 128px;
    resize: vertical;
}

.form-field input::placeholder,
.form-field textarea::placeholder {
    color: var(--muted);
    opacity: 1;
}

.form-field input:hover,
.form-field select:hover,
.form-field textarea:hover {
    border-color: var(--muted);
}

.contact-fields:disabled {
    opacity: 0.7;
}

.button:disabled {
    cursor: wait;
}

#contact-submit {
    justify-self: start;
}

.form-status {
    margin: 16px 0;
    padding: 12px 16px;
    border: 1px solid var(--accent);
    border-radius: 4px;
    background: var(--background);
    color: var(--text);
    font-size: 0.9375rem;
}

.form-status:empty {
    display: none;
}

.form-status[data-state="error"] {
    border-color: #ffc2b5;
    color: #ffc2b5;
}

.direct-email a {
    overflow-wrap: anywhere;
}

.visually-hidden,
.form-trap {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

@media (max-width: 540px) {
    .dialog-content {
        padding: 24px 20px;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    #contact-submit {
        width: 100%;
    }
}

@media (max-width: 700px) {
    header,
    main,
    footer {
        width: calc(100% - 40px);
    }

    header {
        align-items: flex-start;
        flex-direction: column;
        gap: 10px;
        padding-block: 18px;
    }

    nav {
        gap: 4px 24px;
    }

    section {
        padding-block: 56px;
    }

    .hero {
        min-height: auto;
        padding-block: 72px;
    }

    .hero h1 {
        font-size: clamp(2.5rem, 11vw, 4.5rem);
    }

    .hero p {
        font-size: 1.125rem;
    }

    #process ol {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .project,
    #process li {
        padding: 24px;
    }

    #contact {
        margin-top: 40px;
        padding: 32px 24px;
    }
}

@media (max-width: 380px) {
    nav {
        gap: 4px 18px;
    }

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

    #process ol {
        grid-template-columns: 1fr;
    }
}

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

    .button {
        transition: none;
    }

    #process li,
    #process li:hover {
        transform: none;
        transition: none;
    }
}
