/* ===== TOKENS ===== */
:root {
    --bg: #0b0b0d;
    --bg-soft: #131316;
    --bg-card: #16161a;
    --line: rgba(255, 255, 255, 0.08);
    --line-strong: rgba(255, 255, 255, 0.16);
    --text: #f5f1ea;
    --text-muted: #b1aea8;
    --text-dim: #6f6c66;
    --accent: #ffb464;
    --accent-2: #ff7a59;
    --accent-soft: rgba(255, 180, 100, 0.12);
    --serif: 'Fraunces', 'Times New Roman', serif;
    --sans: 'Inter', system-ui, -apple-system, sans-serif;
    --radius: 22px;
    --maxw: 1200px;

    /* ===== ANCHOR SCROLL OFFSETS =====
       Fine-tune where each CTA lands when clicked.
       Higher value = lands further DOWN (more space above the section).
       Lower value = lands further UP (closer to top of viewport).
       Tweak in 4–8px steps for "millimetric" adjustments. */
    --anchor-offset-work:    90px;  /* "Vedi i lavori" → #work */
    --anchor-offset-contact: 90px;  /* "Inizia un progetto" → #contact */
}

/* Apply the offsets to the anchored sections */
#work    { scroll-margin-top: var(--anchor-offset-work); }
#contact { scroll-margin-top: var(--anchor-offset-contact); }

/* Mobile gets a smaller default since the topbar is more compact */
@media (max-width: 600px) {
    :root {
        --anchor-offset-work:    70px;
        --anchor-offset-contact: 70px;
    }
}

/* ===== RESET ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }
html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
    background: var(--bg); /* fills iOS Safari safe areas (notch / home bar) */
    min-height: 100%;
}
body {
    font-family: var(--sans);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    overflow-x: hidden;
    min-height: 100vh;
    min-height: 100dvh; /* dynamic viewport — accounts for iOS Safari chrome */
    font-feature-settings: "ss01", "cv11";
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* HIDE SCROLLBAR ON ALL DEVICES */
html, body {
    scrollbar-width: none;
    -ms-overflow-style: none;
}
html::-webkit-scrollbar,
body::-webkit-scrollbar {
    width: 0;
    height: 0;
    display: none;
}
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
button { font: inherit; cursor: pointer; }

/* ===== ANIMATED BACKGROUND ===== */
.bg-blobs {
    position: fixed;
    inset: 0;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
}
.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(110px);
    opacity: 0.55;
    will-change: transform;
}
.blob-1 {
    width: 540px; height: 540px;
    background: radial-gradient(circle, #ff7a59 0%, transparent 70%);
    top: -180px; left: -120px;
    animation: drift1 22s ease-in-out infinite alternate;
}
.blob-2 {
    width: 620px; height: 620px;
    background: radial-gradient(circle, #ffb464 0%, transparent 70%);
    top: 30%; right: -160px;
    animation: drift2 28s ease-in-out infinite alternate;
}
.blob-3 {
    width: 480px; height: 480px;
    background: radial-gradient(circle, #5b6cff 0%, transparent 70%);
    bottom: -120px; left: 30%;
    opacity: 0.30;
    animation: drift3 34s ease-in-out infinite alternate;
}
@keyframes drift1 {
    from { transform: translate(0, 0) scale(1); }
    to   { transform: translate(120px, 80px) scale(1.15); }
}
@keyframes drift2 {
    from { transform: translate(0, 0) scale(1); }
    to   { transform: translate(-100px, 120px) scale(1.1); }
}
@keyframes drift3 {
    from { transform: translate(0, 0) scale(1); }
    to   { transform: translate(80px, -100px) scale(1.2); }
}
.grain {
    position: absolute;
    inset: 0;
    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.9' 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)' opacity='0.4'/></svg>");
    opacity: 0.08;
    mix-blend-mode: overlay;
}

/* ===== TOPBAR ===== */
.topbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 28px;
    /* respect iOS notch & landscape safe areas */
    padding-top: calc(18px + env(safe-area-inset-top));
    padding-left: calc(28px + env(safe-area-inset-left));
    padding-right: calc(28px + env(safe-area-inset-right));
    background: linear-gradient(180deg, rgba(11, 11, 13, 0.85), rgba(11, 11, 13, 0));
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}
.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    letter-spacing: 0.02em;
}
.brand-dot {
    width: 8px; height: 8px;
    background: var(--accent);
    border-radius: 50%;
    box-shadow: 0 0 12px var(--accent);
}
.brand-name { font-weight: 600; }
.brand-tag {
    color: var(--text-dim);
    font-size: 11px;
    border-left: 1px solid var(--line);
    padding-left: 10px;
    margin-left: 4px;
}

/* LANG SWITCHER */
.lang-switcher {
    display: flex;
    gap: 2px;
    background: rgba(20, 20, 22, 0.6);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 5px;
    border-radius: 999px;
    border: 1px solid var(--line);
}
.lang-btn {
    background: transparent;
    border: none;
    color: var(--text-dim);
    font-family: inherit;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.6px;
    padding: 6px 11px;
    border-radius: 999px;
    transition: background 0.2s ease, color 0.2s ease;
}
.lang-btn:hover { color: var(--text); }
.lang-btn.active {
    background: var(--text);
    color: var(--bg);
}

/* ===== LAYOUT WRAPPER ===== */
main { display: block; }
section {
    max-width: var(--maxw);
    margin: 0 auto;
    padding: 120px 28px;
    position: relative;
}
section + section { padding-top: 0; }

/* ===== TYPE ===== */
.serif { font-family: var(--serif); font-weight: 400; }
.italic { font-style: italic; }
.muted { color: var(--text-muted); }

.section-num {
    display: inline-block;
    font-family: var(--serif);
    font-size: 13px;
    color: var(--accent);
    letter-spacing: 0.18em;
    text-transform: uppercase;
    margin-bottom: 22px;
}

.section-title {
    font-family: var(--serif);
    font-weight: 400;
    font-size: clamp(2rem, 4vw + 0.5rem, 3.4rem);
    line-height: 1.05;
    letter-spacing: -0.02em;
    margin-bottom: 24px;
    color: var(--text);
}

.lead {
    font-size: clamp(1.05rem, 0.6vw + 0.95rem, 1.25rem);
    max-width: 640px;
    color: var(--text-muted);
    line-height: 1.65;
}

/* ===== HERO ===== */
.hero {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding-top: 140px;
    padding-bottom: 60px;
}
.hero-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: 12px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 8px 16px;
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.02);
    width: fit-content;
    margin-bottom: 36px;
}
.dot-pulse {
    width: 7px; height: 7px;
    background: var(--accent);
    border-radius: 50%;
    box-shadow: 0 0 0 0 var(--accent);
    animation: pulse 2s infinite;
}
@keyframes pulse {
    0%   { box-shadow: 0 0 0 0 rgba(255, 180, 100, 0.6); }
    70%  { box-shadow: 0 0 0 12px rgba(255, 180, 100, 0); }
    100% { box-shadow: 0 0 0 0 rgba(255, 180, 100, 0); }
}

.hero-title {
    font-family: var(--serif);
    font-weight: 400;
    font-size: clamp(2.6rem, 7vw + 0.5rem, 6.4rem);
    line-height: 0.98;
    letter-spacing: -0.035em;
    margin-bottom: 32px;
    max-width: 1100px;
}
.hero-title .line {
    display: block;
    overflow: hidden;
}
.hero-title .serif.italic {
    background: linear-gradient(90deg, var(--accent) 0%, var(--accent-2) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero-sub {
    max-width: 600px;
    font-size: clamp(1rem, 0.4vw + 0.95rem, 1.15rem);
    color: var(--text-muted);
    margin-bottom: 44px;
}
.hero-actions {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
}

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 14px 26px;
    border-radius: 999px;
    font-weight: 500;
    font-size: 0.97rem;
    letter-spacing: 0.01em;
    transition: transform 0.25s ease, background 0.25s ease, color 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
    border: 1px solid transparent;
    line-height: 1;
}
.btn-primary {
    background: var(--text);
    color: var(--bg);
    box-shadow: 0 12px 32px rgba(255, 180, 100, 0.18), 0 1px 0 rgba(255, 255, 255, 0.4) inset;
}
.btn-primary:hover {
    transform: translateY(-2px);
    background: var(--accent);
    color: #1a1106;
    box-shadow: 0 18px 38px rgba(255, 180, 100, 0.35);
}
.btn-ghost {
    color: var(--text);
    border-color: var(--line-strong);
    background: rgba(255, 255, 255, 0.02);
}
.btn-ghost:hover {
    border-color: var(--accent);
    color: var(--accent);
    transform: translateY(-2px);
}

/* ===== MARQUEE ===== */
.marquee {
    overflow: hidden;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    padding: 22px 0;
    background: rgba(255, 255, 255, 0.02);
    margin-top: -20px;
}
.marquee-track {
    display: inline-flex;
    gap: 36px;
    align-items: center;
    white-space: nowrap;
    animation: marquee 32s linear infinite;
    font-family: var(--serif);
    font-size: 1.4rem;
    color: var(--text);
    padding-left: 36px;
}
.marquee-track .sep {
    color: var(--accent);
    font-size: 0.9rem;
}
@keyframes marquee {
    from { transform: translateX(0); }
    to   { transform: translateX(-50%); }
}

/* ===== ABOUT ===== */
.about .lead {
    font-size: clamp(1.15rem, 0.8vw + 1rem, 1.5rem);
    color: var(--text);
    line-height: 1.55;
    max-width: 820px;
    font-weight: 300;
}
.about .section-title { max-width: 880px; }

/* ===== SERVICES ===== */
.service-list {
    list-style: none;
    margin-top: 30px;
    border-top: 1px solid var(--line);
}
.service-row {
    display: grid;
    grid-template-columns: 110px 1fr;
    gap: 30px;
    padding: 32px 0;
    border-bottom: 1px solid var(--line);
    align-items: baseline;
    transition: background 0.3s ease, padding 0.3s ease;
}
.service-row:hover {
    background: linear-gradient(90deg, var(--accent-soft), transparent 60%);
    padding-left: 18px;
    padding-right: 18px;
    border-radius: 4px;
}
.row-num {
    font-family: var(--serif);
    font-size: 1rem;
    color: var(--accent);
    letter-spacing: 0.16em;
}
.row-body h3 {
    font-family: var(--serif);
    font-weight: 400;
    font-size: clamp(1.4rem, 1.2vw + 1rem, 2rem);
    margin-bottom: 8px;
    letter-spacing: -0.01em;
}
.row-body p {
    color: var(--text-muted);
    max-width: 640px;
}

/* ===== WORK ===== */
.work-grid {
    margin-top: 50px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
    gap: 22px;
}
.work-card {
    display: block;
    background: var(--bg-card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
    transition: transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1), border-color 0.3s ease;
    position: relative;
}
.work-card:hover {
    transform: translateY(-8px);
    border-color: var(--accent);
}
.work-image {
    aspect-ratio: 4 / 3;
    overflow: hidden;
    background: #1d1d22;
    padding: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
}
/* Per-card icon background (matches the icon's own background color) */
.work-image-light { background: #ffffff; }
.work-image-dark  { background: #000000; }

.work-image img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    transition: transform 0.7s ease, filter 0.5s ease;
    filter: saturate(0.85);
}
/* Blend modes + edge mask hide JPG compression seams around icons.
   - blend mode merges most off-white/off-black pixels with the background
   - the mask fades the very bottom of the image into transparent so any
     remaining horizontal seam blends into the wrapper background */
.work-image-light img { mix-blend-mode: multiply; }
.work-image-dark  img { mix-blend-mode: screen; }

.work-image img {
    -webkit-mask-image: linear-gradient(to bottom,
        #000 0,
        #000 calc(100% - 6px),
        transparent 100%);
    mask-image: linear-gradient(to bottom,
        #000 0,
        #000 calc(100% - 6px),
        transparent 100%);
}

.work-card:hover .work-image img {
    transform: scale(1.04);
    filter: saturate(1);
}
.work-meta {
    padding: 20px 22px 24px;
    position: relative;
}
.work-meta h3 {
    font-family: var(--serif);
    font-weight: 400;
    font-size: 1.35rem;
    margin-bottom: 4px;
    letter-spacing: -0.01em;
}
.work-tag {
    color: var(--text-dim);
    font-size: 0.85rem;
}
.work-arrow {
    position: absolute;
    top: 20px; right: 22px;
    font-size: 1.3rem;
    color: var(--text-dim);
    transition: transform 0.3s ease, color 0.3s ease;
}
.work-card:hover .work-arrow {
    color: var(--accent);
    transform: translate(4px, -4px);
}

/* ===== REVIEWS ===== */
.reviews-grid {
    margin-top: 40px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 22px;
}
.review-card {
    position: relative;
    background: var(--bg-card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 36px 28px 30px;
    overflow: hidden;
}
.review-card.placeholder {
    border-style: dashed;
    border-color: var(--line-strong);
    background: transparent;
    text-align: center;
}
.quote-mark {
    font-family: var(--serif);
    font-size: 4rem;
    line-height: 0.8;
    color: var(--accent);
    opacity: 0.6;
    display: block;
    margin-bottom: 8px;
}
.review-text {
    font-family: var(--serif);
    font-style: italic;
    font-size: 1.1rem;
    color: var(--text);
    line-height: 1.55;
    margin-bottom: 14px;
}
.review-author {
    color: var(--text-dim);
    font-size: 0.85rem;
}

/* ===== CONTACT FORM ===== */
.contact .section-title { max-width: 720px; }

.contact-form {
    margin-top: 50px;
    max-width: 720px;
    background: var(--bg-card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 36px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}
.field {
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-muted);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
.field input,
.field textarea {
    font-family: var(--sans);
    font-size: 1rem;
    color: var(--text);
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 13px 16px;
    outline: none;
    transition: border-color 0.25s ease, background 0.25s ease, box-shadow 0.25s ease;
    text-transform: none;
    letter-spacing: 0;
    resize: vertical;
}
.field textarea { min-height: 120px; }
.field input:focus,
.field textarea:focus {
    border-color: var(--accent);
    background: rgba(255, 180, 100, 0.04);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
.form-actions {
    display: flex;
    align-items: center;
    gap: 22px;
    flex-wrap: wrap;
    margin-top: 6px;
}
.form-alt {
    color: var(--text-dim);
    font-size: 0.92rem;
    text-decoration: underline;
    text-decoration-color: var(--line-strong);
    text-underline-offset: 4px;
    transition: color 0.25s ease;
}
.form-alt:hover { color: var(--accent); }
.form-status {
    font-size: 0.92rem;
    color: var(--text-muted);
    min-height: 1.2em;
}
.form-status.success { color: #7fd99a; }
.form-status.error { color: #ff7d7d; }

/* ===== FOOTER ===== */
.footer {
    border-top: 1px solid var(--line);
    padding: 50px 28px;
    /* respect iOS home indicator safe area at bottom */
    padding-bottom: calc(50px + env(safe-area-inset-bottom));
    padding-left: calc(28px + env(safe-area-inset-left));
    padding-right: calc(28px + env(safe-area-inset-right));
    text-align: center;
    color: var(--text-dim);
    font-size: 0.88rem;
    background: var(--bg);
    position: relative;
    z-index: 1;
}
.footer-line {
    display: inline-flex;
    gap: 8px;
    align-items: baseline;
    margin-bottom: 6px;
}
.footer-name {
    color: var(--text-muted);
    border-bottom: 1px solid var(--line-strong);
    padding-bottom: 1px;
    transition: color 0.25s ease, border-color 0.25s ease;
}
.footer-name:hover {
    color: var(--accent);
    border-color: var(--accent);
}
.footer-meta {
    color: var(--text-dim);
    font-size: 0.82rem;
}
.footer-links {
    margin-top: 12px;
    font-size: 0.78rem;
}
.footer-links a {
    color: var(--text-muted);
    border-bottom: 1px solid var(--line-strong);
    padding-bottom: 1px;
    transition: color 0.25s ease, border-color 0.25s ease;
}
.footer-links a:hover {
    color: var(--accent);
    border-color: var(--accent);
}

/* ===== REVEAL ANIMATIONS ===== */
.reveal {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.9s ease, transform 0.9s ease;
}
.reveal.visible {
    opacity: 1;
    transform: translateY(0);
}

/* ===== TABLET ===== */
@media (max-width: 900px) {
    section { padding: 90px 24px; }
    .hero { padding-top: 130px; min-height: 92vh; }
    .topbar { padding: 14px 20px; }
    .brand-tag { display: none; }
    .marquee-track { font-size: 1.15rem; gap: 28px; padding-left: 28px; }
    .service-row { grid-template-columns: 70px 1fr; gap: 18px; padding: 26px 0; }
    .contact-form { padding: 28px; }
}

/* ===== MOBILE ===== */
@media (max-width: 600px) {
    section { padding: 70px 20px; }
    .hero { padding-top: 120px; min-height: 88vh; padding-bottom: 40px; }
    .hero-eyebrow { font-size: 10px; padding: 7px 13px; margin-bottom: 28px; }
    .hero-actions { flex-direction: column; align-items: stretch; }
    .btn { justify-content: center; padding: 14px 22px; }

    .topbar { padding: 12px 14px; }
    .brand-name { display: none; }
    .lang-btn { padding: 5px 9px; font-size: 10.5px; }

    .marquee { padding: 16px 0; }
    .marquee-track { font-size: 1rem; gap: 22px; padding-left: 22px; }

    .service-row {
        grid-template-columns: 1fr;
        gap: 8px;
        padding: 22px 0;
    }
    .service-row:hover { padding-left: 8px; padding-right: 8px; }
    .row-num { font-size: 0.85rem; }

    .contact-form { padding: 22px; }
    .form-row { grid-template-columns: 1fr; gap: 18px; }
    .form-actions { gap: 14px; }

    .quote-mark { font-size: 3rem; }
    .review-text { font-size: 1rem; }

    .blob { filter: blur(80px); opacity: 0.45; }
}

/* ===== REDUCED MOTION ===== */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    .reveal { opacity: 1; transform: none; }
}
