/* ============================================================
   Portfolio stylesheet.
   Colors and fonts live in the :root variables below — change
   them there and the whole site follows.
   ============================================================ */

:root {
    color-scheme: dark;           /* makes browser-drawn parts (scrollbars, form widgets) dark too */
    --color-bg: #12161c;
    --color-surface: #1b222b;
    --color-text: #e6ebf1;
    --color-muted: #9aa8b8;
    --color-accent: #4e9d73;      /* buttons, links, highlights — muted dark green */
    --color-accent-dark: #71bd94; /* hover shade — lighter, since the page is dark */
    --color-border: #2c3540;
    --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --radius: 10px;
    --shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: var(--font-body);
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
}

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

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

h1, h2, h3 { line-height: 1.25; }

code {
    background: var(--color-border);
    padding: 0.1em 0.35em;
    border-radius: 4px;
    font-size: 0.9em;
}

/* ---------- Header & navigation ---------- */

.site-header {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 10;
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
    flex-wrap: wrap;
}

.brand { text-decoration: none; color: var(--color-text); }
.brand-name { display: block; font-weight: 700; font-size: 1.15rem; }
.brand-tagline { display: block; font-size: 0.78rem; color: var(--color-muted); }

.site-nav ul {
    list-style: none;
    display: flex;
    gap: 1.25rem;
    margin: 0;
    padding: 0;
}

.site-nav a {
    text-decoration: none;
    color: var(--color-text);
    font-weight: 500;
    padding: 0.25rem 0;
    border-bottom: 2px solid transparent;
}

.site-nav a:hover { color: var(--color-accent); }
.site-nav a.active {
    color: var(--color-accent);
    border-bottom-color: var(--color-accent);
}

.nav-toggle {
    display: none;
    background: none;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-size: 1.3rem;
    padding: 0.15rem 0.55rem;
    cursor: pointer;
}

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

.hero {
    padding: 4rem 0 3rem;
    text-align: center;
}

.hero h1 { font-size: 2.4rem; margin: 0 0 1rem; }

.hero-lead {
    max-width: 640px;
    margin: 0 auto 1.75rem;
    color: var(--color-muted);
    font-size: 1.1rem;
}

.hero-actions { display: flex; gap: 0.75rem; justify-content: center; flex-wrap: wrap; }

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

.btn {
    display: inline-block;
    padding: 0.6rem 1.4rem;
    border-radius: var(--radius);
    text-decoration: none;
    font-weight: 600;
    border: 2px solid var(--color-accent);
    cursor: pointer;
    font-size: 1rem;
}

.btn-primary { background: var(--color-accent); color: #fff; }
.btn-primary:hover { background: var(--color-accent-dark); border-color: var(--color-accent-dark); color: #fff; }

.btn-secondary { background: transparent; color: var(--color-accent); }
.btn-secondary:hover { background: var(--color-accent); color: #fff; }

/* ---------- Sections & project cards ---------- */

.section { padding: 2.5rem 0; }
.page-lead { color: var(--color-muted); max-width: 640px; }

/* Section heading with a link beside it ("Featured projects · See all") */
.section-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin: 0 0 1.2rem;
}

.section-head h2 { margin: 0; }

.project-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.project-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    cursor: pointer; /* the whole card opens the expanded picture view */
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

/* grows a touch on hover as a hint that the card can be clicked open */
.project-card:hover {
    transform: scale(1.02);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5);
}

.project-card img {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    display: block;
    background: var(--color-border);
}

.project-body { padding: 1rem 1.25rem 1.25rem; }
.project-body h3 { margin: 0 0 0.5rem; }
.project-tools, .project-skills { font-size: 0.85rem; color: var(--color-muted); }

/* ---------- Services ---------- */

.services-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin: 1.5rem 0 2rem;
}

.service {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    box-shadow: var(--shadow);
}

.service h3 { margin-top: 0; }

/* ---------- About ---------- */

.about-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 2.5rem;
    align-items: start;
}

.about-photo img {
    width: 100%;
    border-radius: var(--radius);
    border: 1px solid var(--color-border);
}

.skills-list { padding-left: 1.2rem; }
.skills-list li { margin-bottom: 0.4rem; }

/* ---------- Contact form ---------- */

.contact-form {
    max-width: 560px;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 1.5rem;
}

.contact-form label { display: flex; flex-direction: column; gap: 0.35rem; font-weight: 600; }

.contact-form input,
.contact-form textarea {
    font: inherit;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    background: var(--color-surface);
}

.contact-form input:focus,
.contact-form textarea:focus {
    outline: 2px solid var(--color-accent);
    border-color: var(--color-accent);
}

.contact-form button { align-self: flex-start; }

/* Honeypot field: moved off-screen so visitors never see it */
.hp-field { position: absolute; left: -9999px; }

.form-success {
    background: #14291c;
    border: 1px solid #2f6b45;
    color: #8fd8a8;
    padding: 0.85rem 1.1rem;
    border-radius: var(--radius);
}

.form-error {
    background: #331a1a;
    border: 1px solid #7a3535;
    color: #f2a0a0;
    padding: 0.85rem 1.1rem;
    border-radius: var(--radius);
}

/* ---------- 3D model viewer ---------- */

.view-3d-btn {
    font-size: 0.9rem;
    padding: 0.35rem 1rem;
}

.model-buttons {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.model-buttons-label {
    font-size: 0.85rem;
    color: var(--color-muted);
}

.model-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.72);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 1rem;
}

.model-dialog {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    width: min(900px, 94vw);
    overflow: hidden;
}

.model-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.6rem 1rem;
    border-bottom: 1px solid var(--color-border);
}

.model-close {
    background: none;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    color: var(--color-text);
    font-size: 1.2rem;
    line-height: 1;
    padding: 0.2rem 0.6rem;
    cursor: pointer;
}

.model-close:hover { border-color: var(--color-accent); color: var(--color-accent); }

/* "2 / 9" position indicator in the toolbar (hidden when there's one slide) */
.model-count {
    margin-left: auto;
    color: var(--color-muted);
    font-size: 0.9rem;
    white-space: nowrap;
}

.model-stage { position: relative; }

.model-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 5;
    background: rgba(27, 34, 43, 0.8);
    border: 1px solid var(--color-border);
    border-radius: 50%;
    color: var(--color-text);
    font-size: 1.6rem;
    line-height: 1;
    width: 2.4rem;
    height: 2.4rem;
    cursor: pointer;
}

.model-nav:hover { border-color: var(--color-accent); color: var(--color-accent); }
.model-nav-prev { left: 0.75rem; }
.model-nav-next { right: 0.75rem; }

.model-canvas-wrap {
    height: min(62vh, 540px);
    display: flex;
    align-items: center;
    justify-content: center;
}

.model-canvas-wrap canvas { display: block; width: 100%; height: 100%; }

.model-loading { color: var(--color-muted); }

/* Expanded card view — a card's picture shown big, description underneath.
   Reuses the .model-modal overlay, toolbar, and round nav arrows. */
.expanded-dialog {
    max-height: 92vh;
    display: flex;
    flex-direction: column;
}

/* The stage owns the slide height and everything inside fills it, so when a
   long description squeezes the dialog (phones) the picture/3D view shrinks
   with the stage instead of spilling over the text. */
.expanded-stage {
    position: relative;
    height: min(62vh, 540px);
    min-height: 220px;
    background: var(--color-bg);
}

.expanded-img,
.expanded-video {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.expanded-stage .model-canvas-wrap { height: 100%; }

.expanded-caption {
    margin: 0;
    padding: 0.85rem 1.25rem 1rem;
    border-top: 1px solid var(--color-border);
    color: var(--color-muted);
    font-size: 0.95rem;
    overflow-y: auto; /* scrolls if the dialog runs out of room (phones) */
}

.expanded-caption p { margin: 0 0 0.35rem; }
.expanded-caption p:last-child { margin-bottom: 0; }

/* Per-photo caption, overlaid on the bottom of the picture. Revealed on
   hover; touch screens can't hover, so there it always shows. */
.expanded-photo-caption {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    margin: 0;
    padding: 0.5rem 1rem;
    background: rgba(18, 22, 28, 0.78);
    font-size: 0.9rem;
    text-align: center;
    opacity: 0;
    transition: opacity 0.15s ease;
    pointer-events: none;
}

.expanded-stage:hover .expanded-photo-caption { opacity: 1; }
@media (hover: none) { .expanded-photo-caption { opacity: 1; } }

.photo-nav-prev { left: 0.75rem; }
.photo-nav-next { right: 0.75rem; }

/* ---------- Printable portfolio (print.php — unlisted) ----------
   A white "sheet" on screen; when printed, the site chrome disappears and
   the sheet becomes the page itself. */

.print-sheet {
    position: relative; /* anchors the print button in the corner */
    background: #fff;
    color: #222;
    padding: 2rem 2.25rem;
    border-radius: var(--radius);
}

/* Just the print button, floating in the sheet's top-right corner so it
   takes no room of its own. */
.print-toolbar {
    position: absolute;
    top: 2rem;
    right: 2.25rem;
}

.print-header { border-bottom: 2px solid var(--color-accent); padding-bottom: 0.6rem; }
.print-header h1 { margin: 0; color: #111; }
.print-header p { margin: 0.1rem 0; color: #555; }

.print-project {
    break-inside: avoid;
    page-break-inside: avoid; /* older browsers */
    padding: 1rem 0;
    border-bottom: 1px solid #ddd;
}

.print-project h2 { margin: 0 0 0.4rem; font-size: 1.15rem; color: #111; }
.print-project p { margin: 0.3rem 0; color: #333; }
.print-meta { font-size: 0.85rem; color: #555 !important; }

.print-photos { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.4rem 0; }
.print-photos img { height: 220px; width: auto; max-width: 100%; border: 1px solid #eee; }

@media print {
    /* Zero page margin removes the browser's own header/footer (page title,
       URL, date) — the sheet's padding below becomes the page margin. */
    @page { margin: 0; }

    .site-header, .site-footer, .print-toolbar { display: none !important; }
    html, body { background: #fff; margin: 0; }
    main.container { max-width: none; padding: 0; margin: 0; }
    /* no trailing padding/border — leftover space after the last project
       otherwise spills onto an empty extra page */
    .section.print-sheet { padding: 14mm 16mm 0; border-radius: 0; }
    .print-project:last-child { border-bottom: none; padding-bottom: 0; }
}

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

.site-footer {
    border-top: 1px solid var(--color-border);
    background: var(--color-surface);
    margin-top: 3rem;
}

.footer-inner {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    padding-top: 1rem;
    padding-bottom: 1rem;
    color: var(--color-muted);
    font-size: 0.9rem;
}

/* ---------- Mobile ---------- */

@media (max-width: 700px) {
    .nav-toggle { display: block; }

    .site-nav {
        display: none;
        width: 100%;
    }

    .site-nav.open { display: block; }

    .site-nav ul {
        flex-direction: column;
        gap: 0;
        padding: 0.5rem 0;
    }

    .site-nav a { display: block; padding: 0.6rem 0; }

    .hero h1 { font-size: 1.8rem; }

    .about-grid { grid-template-columns: 1fr; }
    .about-photo { order: -1; max-width: 280px; }

    /* Phones: the expanded view uses nearly the whole screen, the picture/3D
       stage keeps its full height, and the description scrolls in whatever
       room is left — bigger models without drawing over the text. */
    .model-modal { padding: 0.5rem; }
    .model-dialog { width: 100%; }
    .expanded-dialog { max-height: 97vh; }
    .expanded-stage { flex-shrink: 0; }
}
