/* =========================
   RICARDO FREITAS — Editorial System
   Spec: Anton / Inter / IBM Plex Mono
   Colors: Ink #1A1A1A, Paper #F2F2EF, Accent #9E1C1C
   Grid: max content 1320, site 1440, outer margins 24/48/96
   Spacing: 8px system, section ~144px (desktop)
   ========================= */

/* =========================
   1) TOKENS
   ========================= */
:root {
  /* Colors */
  --rf-ink: #414042;
  --rf-paper: #F2F2EF;
  --rf-red: #c02126;
  --rf-mid: #8C8C8C;
  --rf-line: #D6D6D6;

  /* Fonts */
  --rf-font-display: "Anton", Impact, "Arial Black", sans-serif;
  --rf-font-body: "Inter", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  --rf-font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  /* Type */
  --rf-base: 16px;

  /* Layout */
  --rf-max-site: 1600px;
  --rf-max-content: 1400px;

  /* Outer margins */
  --rf-outer-mobile: 24px;
  --rf-outer-tablet: 48px;
  --rf-outer-desktop: 96px;

  /* Inner gutter */
  --rf-gutter-mobile: 16px;
  --rf-gutter-tablet: 20px;
  --rf-gutter-desktop: 24px;

  /* Spacing scale */
  --rf-8: 8px;
  --rf-16: 16px;
  --rf-24: 24px;
  --rf-32: 32px;
  --rf-48: 48px;
  --rf-64: 64px;
  --rf-96: 96px;
  --rf-128: 128px;
  --rf-144: 144px;
  --rf-160: 160px;

  /* UI */
  --rf-radius: 0px;
  --rf-shadow: none;

  /* Sticky / anchors */
  --rf-header-h: 80px;
  --rf-header-h-scrolled: 64px;
  --rf-anchor-gap: 16px;
  --rf-scroll-offset: 96px;
}

@media (min-width: 992px) {
  :root {
    --rf-anchor-gap: 8px;
  }
}

/* =========================
   2) BASE
   ========================= */
html {
  font-size: var(--rf-base);
  scroll-padding-top: var(--rf-scroll-offset);
}

body.rf {
  background: var(--rf-paper);
  color: var(--rf-ink);
  font-family: var(--rf-font-body);
  font-weight: 400;
  line-height: 1.65;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

* {
  border-radius: var(--rf-radius) !important;
}

img {
  max-width: 100%;
  height: auto;
}

a {
  color: inherit;
}

::selection {
  background: rgba(158, 28, 28, 0.18);
}

.btn,
.offcanvas,
.dropdown-menu,
.modal-content,
.card {
  box-shadow: var(--rf-shadow) !important;
}

main [id] {
  scroll-margin-top: var(--rf-scroll-offset);
}

/* =========================
   3) CONTAINER / GRID
   ========================= */
.rf-container {
  max-width: var(--rf-max-site);
  padding-left: var(--rf-outer-mobile);
  padding-right: var(--rf-outer-mobile);
  margin-left: auto;
  margin-right: auto;
}

@media (min-width: 992px) {
  .container {
    padding-left: var(--rf-outer-desktop);
    padding-right: var(--rf-outer-desktop);
  }
}

@media (min-width: 768px) and (max-width: 991.98px) {
  .container {
    padding-left: var(--rf-outer-tablet);
    padding-right: var(--rf-outer-tablet);
  }
}

.row {
  --bs-gutter-x: var(--rf-gutter-mobile);
}

@media (min-width: 768px) {
  .row {
    --bs-gutter-x: var(--rf-gutter-tablet);
  }
}

@media (min-width: 992px) {
  .row {
    --bs-gutter-x: var(--rf-gutter-desktop);
  }
}

/* =========================
   4) TYPOGRAPHY
   ========================= */
h1,
h2 {
  font-family: var(--rf-font-display);
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: -0.02em;
  line-height: 1;
  margin: 0;
}

h3,
h4,
h5,
h6 {
  font-family: var(--rf-font-body);
  letter-spacing: 0;
  margin: 0;
}

h3 {
  font-weight: 600;
  line-height: 1.2;
}

.rf h1 {
  font-size: clamp(2.25rem, 5vw, 4.5rem);
}

.rf h2 {
  font-size: clamp(2rem, 3.5vw, 3.25rem);
}

.rf h3.h4,
.rf h3 {
  font-size: clamp(1.5rem, 2.2vw, 2rem);
}

.rf p,
.rf li,
.rf a,
.rf button {
  font-size: clamp(1rem, 0.35vw + 0.95rem, 1.125rem);
}

.small,
small {
  font-size: clamp(0.8125rem, 0.2vw + 0.78rem, 0.875rem);
}

.rf .rf-meta,
.rf .rf-project-index,
.rf .rf-project-meta {
  font-family: var(--rf-font-mono);
  font-weight: 400;
  font-size: clamp(0.6875rem, 0.15vw + 0.66rem, 0.75rem);
  line-height: 1.4;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.tracking-wide {
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* =========================
   5) DIVIDERS / BORDERS
   ========================= */
.border-top,
.border-bottom,
.rf-line {
  border-color: var(--rf-line) !important;
}

hr {
  border-color: var(--rf-line);
  opacity: 1;
}

/* =========================
   6) SPACING RHYTHM
   ========================= */
.pt-header {
  padding-top: 72px;
}

@media (min-width: 992px) {
  .pt-header {
    padding-top: 80px;
  }
}

.rf-section {
  padding-top: var(--rf-64);
  padding-bottom: var(--rf-64);
}

@media (min-width: 992px) {
  .rf-section {
    padding-top: var(--rf-96);
    padding-bottom: var(--rf-96);
  }
}

.rf .rf-title-gap {
  margin-bottom: var(--rf-32);
}

@media (min-width: 992px) {
  .rf .rf-title-gap {
    margin-bottom: var(--rf-48);
  }
}

.rf p {
  margin-bottom: var(--rf-16);
}

.rf p:last-child {
  margin-bottom: 0;
}

/* =========================
   7) LINKS / FOCUS
   ========================= */
.rf a {
  text-decoration: none;
  color: var(--rf-ink);
}

.rf a:hover {
  color: var(--rf-red);
}

.rf a:focus-visible,
.rf button:focus-visible {
  outline: 2px solid var(--rf-red);
  outline-offset: 3px;
}

/* =========================
   8) REVEAL MOTION
   ========================= */
.rf-reveal {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.7s ease, transform 0.7s ease;
  will-change: opacity, transform;
}

.rf-reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
  .rf-reveal {
    opacity: 1;
    transform: none;
    transition: none;
  }
}

/* =========================
   9) HEADER
   ========================= */
.rf-header {
  position: sticky;
  top: 0;
  background: var(--rf-paper) !important;
  border-bottom: 1px solid var(--rf-line) !important;
  z-index: 1030;
}

.rf-header .navbar {
  min-height: var(--rf-header-h);
  transition: min-height 180ms ease;
}

.rf-header.rf-is-scrolled .navbar {
  min-height: var(--rf-header-h-scrolled);
}

/* =========================
   10) NAV
   ========================= */
.rf-header .nav-link {
  font-family: var(--rf-font-body);
  font-weight: 600;
  font-size: 0.875rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--rf-ink);
  padding-left: 0.75rem;
  padding-right: 0.75rem;
}

.rf-header .nav-link:hover {
  color: var(--rf-red);
  text-decoration: underline;
  text-decoration-color: var(--rf-red);
  text-underline-offset: 4px;
}

.offcanvas {
  background: var(--rf-paper);
  color: var(--rf-ink);
  border-left: 1px solid var(--rf-line);
}

.offcanvas-header {
  border-bottom: 1px solid var(--rf-line) !important;
}

.btn-close {
  filter: none;
  opacity: 0.6;
}

.btn-close:hover {
  opacity: 1;
}

.rf-cta {
  display: inline-flex;
  align-items: center;
  gap: var(--rf-8);
  padding: 10px 14px;
  border: 1px solid var(--rf-line);
  background: transparent;
  color: var(--rf-ink);
  font-family: var(--rf-font-body);
  font-weight: 600;
  font-size: 0.875rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.rf-cta::after {
  content: "—";
  color: var(--rf-red);
  transform: translateY(-1px);
}

.rf-cta:hover {
  border-color: var(--rf-ink);
  color: var(--rf-ink);
}

/* =========================
   11) HERO
   ========================= */
.rf-mark {
  color: var(--rf-red);
  font-size: 1.25rem;
  line-height: 1;
}

.rf-lead,
.rf-about,
.rf-final {
  font-family: var(--rf-font-body);
  font-weight: 400;
  letter-spacing: 0;
  max-width: 52ch;
}

@media (max-width: 575.98px) {
  .rf-lead,
  .rf-about,
  .rf-final {
    max-width: 36ch;
  }
}

.rf-lead {
  color: var(--rf-ink);
  line-height: 1.55;
}

/* Hero background images — desktop/tablet */
.rf-hero {
  position: relative;
  background-image: url("../img/hero-home.webp");
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

.rf-hero-services {
  position: relative;
  background-image: url("../img/hero-services.webp");
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

.rf-hero-projects {
  position: relative;
  background-image: url("../img/hero-projects.webp");
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

.rf-hero-about {
  position: relative;
  background-image: url("../img/hero-about.webp");
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

.rf-hero-contact {
  position: relative;
  background-image: url("../img/hero-contact.webp");
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

/* Hero global height */
.rf-hero,
.rf .rf-page-hero {
  display: flex;
  align-items: center;
  min-height: 520px;
}

@media (min-width: 992px) {
  .rf-hero,
  .rf .rf-page-hero {
    min-height: 85vh;
  }
}

/* Hero mobile — image on top, text below */
@media (max-width: 767.98px) {
  .rf-hero,
  .rf-hero-services,
  .rf-hero-projects,
  .rf-hero-about,
  .rf-hero-contact {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    min-height: auto;
    padding-top: 0;
    background-image: none;
  }

  .rf-hero::before,
  .rf-hero-services::before,
  .rf-hero-projects::before,
  .rf-hero-about::before,
  .rf-hero-contact::before {
    content: "";
    display: block;
    width: 100%;
    height: 42vh;
    min-height: 260px;
    max-height: 420px;
    flex: 0 0 auto;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
  }

  .rf-hero::before {
    background-image: url("../img/hero-home.webp");
  }

  .rf-hero-services::before {
    background-image: url("../img/hero-services.webp");
  }

  .rf-hero-projects::before {
    background-image: url("../img/hero-projects.webp");
  }

  .rf-hero-about::before {
    background-image: url("../img/hero-about.webp");
  }

  .rf-hero-contact::before {
    background-image: url("../img/hero-contact.webp");
  }

  .rf-hero > .container,
  .rf-hero-services > .container,
  .rf-hero-projects > .container,
  .rf-hero-about > .container,
  .rf-hero-contact > .container {
    width: 100%;
    padding-top: var(--rf-32);
  }

  .rf-hero .row,
  .rf-hero-services .row,
  .rf-hero-projects .row,
  .rf-hero-about .row,
  .rf-hero-contact .row {
    display: block;
  }

  .rf-hero [class*="col-"],
  .rf-hero-services [class*="col-"],
  .rf-hero-projects [class*="col-"],
  .rf-hero-about [class*="col-"],
  .rf-hero-contact [class*="col-"] {
    width: 100%;
    max-width: 100%;
  }

  .rf-hero .col-lg-5,
  .rf-hero-services .col-lg-5,
  .rf-hero-projects .col-lg-5,
  .rf-hero-about .col-lg-5,
  .rf-hero-contact .col-lg-5 {
    display: none;
  }
}

/* =========================
   12) PROJECTS
   ========================= */
.rf-projects {
  border-top: 1px solid var(--rf-line);
}

.rf-project {
  border-bottom: 1px solid var(--rf-line);
}

.rf-project-link {
  display: grid;
  grid-template-columns: 3.5rem 1fr auto;
  gap: var(--rf-24);
  align-items: baseline;
  padding: var(--rf-16) 0;
  color: var(--rf-ink);
  position: relative;
}

.rf-project-title {
  font-family: var(--rf-font-body);
  font-weight: 400;
  font-size: clamp(1rem, 0.35vw + 0.95rem, 1.125rem);
  line-height: 1.55;
}

.rf-project-meta {
  color: var(--rf-mid);
}

.rf-project-link::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 10px;
  width: 0;
  height: 1px;
  background: var(--rf-red);
  transition: width 160ms ease;
}

.rf-project-link:hover::after,
.rf-project-link:focus-visible::after {
  width: 48px;
}

@media (max-width: 575.98px) {
  .rf-project-link {
    grid-template-columns: 2.75rem 1fr;
    gap: var(--rf-16);
    row-gap: 6px;
  }

  .rf-project-meta {
    grid-column: 2 / -1;
  }
}

.rf-featured-media {
  border: 1px solid var(--rf-line);
  background: #e9e9e6;
}

.rf-project-card {
  width: 100%;
  border: 0;
  padding: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.rf-project-thumb {
  display: block;
  border: 1px solid var(--rf-line);
  background: #e9e9e6;
  position: relative;
  overflow: hidden;
}

.rf-project-caption {
  display: grid;
  grid-template-columns: 2.75rem 1fr;
  gap: 8px 12px;
  align-items: baseline;
  padding-top: 12px;
}

@media (min-width: 992px) {
  .rf-project-caption {
    grid-template-columns: 3.5rem 1fr;
  }
}

.rf-project-caption .rf-project-meta {
  grid-column: 2 / -1;
  color: var(--rf-mid);
}

.rf-project-card:focus-visible {
  outline: 2px solid var(--rf-red);
  outline-offset: 3px;
}

.rf-project-thumb::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 0;
  height: 2px;
  background: var(--rf-red);
  transition: width 160ms ease;
}

.rf-project-card:hover .rf-project-thumb::after,
.rf-project-card:focus-visible .rf-project-thumb::after {
  width: 48px;
}

.rf-carousel .rf-carousel-control {
  width: 48px;
  opacity: 0.7;
}

.rf-carousel .rf-carousel-control:hover {
  opacity: 1;
}

.rf-carousel .carousel-control-prev-icon,
.rf-carousel .carousel-control-next-icon {
  filter: invert(1);
  opacity: 0.9;
}

/* =========================
   13) FOOTER
   ========================= */
footer {
  background: var(--rf-paper);
}

.rf-footer-link {
  font-family: var(--rf-font-body);
  font-weight: 400;
  font-size: 0.875rem;
  color: var(--rf-ink);
}

.rf-footer-link:hover {
  color: var(--rf-red);
  text-decoration: underline;
  text-decoration-color: var(--rf-red);
  text-underline-offset: 4px;
}

footer a {
  text-decoration: none;
}

footer .bi {
  font-size: 1.2rem;
  color: var(--rf-ink);
  transition: opacity 0.2s ease;
}

footer .bi:hover {
  opacity: 0.6;
}

/* =========================
   14) MODALS
   ========================= */
.rf-modal {
  background: var(--rf-paper);
  color: var(--rf-ink);
  border: 1px solid var(--rf-line);
  border-radius: 0;
  box-shadow: none;
}

.modal-header,
.modal-footer {
  border-color: var(--rf-line) !important;
}

.modal-header {
  align-items: flex-start;
  gap: var(--rf-24);
}

@media (max-width: 575.98px) {
  .modal-body {
    padding: 16px;
  }

  .modal-header,
  .modal-footer {
    padding: 16px;
  }
}

.rf-display-2 {
  font-family: var(--rf-font-display);
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: -0.02em;
  line-height: 1;
  font-size: clamp(2.25rem, 5vw, 4.5rem);
  margin: 0;
}

.rf-h3 {
  font-family: var(--rf-font-body);
  font-weight: 600;
  line-height: 1.2;
  font-size: clamp(1.75rem, 2.2vw, 2rem);
  margin: 0;
}

.rf-modal .modal-header {
  display: flex;
}

.rf-modal .modal-header > *:last-child {
  margin-left: auto;
}

.rf-close {
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  background: transparent;
  position: relative;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.rf-close span {
  position: absolute;
  width: 22px;
  height: 2px;
  background: var(--rf-ink);
  transition: background-color 120ms ease, transform 180ms ease;
  transform-origin: center;
}

.rf-close span:nth-child(1) {
  transform: rotate(45deg);
}

.rf-close span:nth-child(2) {
  transform: rotate(-45deg);
}

.rf-close:hover span {
  background: var(--rf-red);
}

.rf-close:focus-visible {
  outline: 2px solid var(--rf-red);
  outline-offset: 4px;
}

/* =========================
   15) CTA BUTTONS
   ========================= */
.rf .btn-primary {
  background-color: var(--rf-red);
  border-color: var(--rf-red);
  color: #fff;
}

.rf .btn-primary:hover,
.rf .btn-primary:focus,
.rf .btn-primary:active {
  background-color: var(--rf-red);
  border-color: var(--rf-red);
  color: #fff;
}

.rf .btn-primary:focus-visible {
  box-shadow: 0 0 0 .2rem rgba(192, 33, 38, .25);
}

.rf .btn-outline-secondary {
  color: var(--rf-ink);
  border-color: var(--rf-line);
  background-color: transparent;
}

.rf .btn-outline-secondary:hover,
.rf .btn-outline-secondary:focus,
.rf .btn-outline-secondary:active {
  color: #fff;
  background-color: var(--rf-red);
  border-color: var(--rf-red);
}

.rf .btn-outline-secondary:focus-visible {
  box-shadow: 0 0 0 .2rem rgba(192, 33, 38, .25);
}

/* =========================
   16) SPACING UTILITIES
   ========================= */
.py-6 {
  padding-top: var(--rf-64) !important;
  padding-bottom: var(--rf-64) !important;
}

@media (min-width: 992px) {
  .py-6 {
    padding-top: var(--rf-96) !important;
    padding-bottom: var(--rf-96) !important;
  }
}

/* =========================
   17) KPIs
   ========================= */
#prova .h3 {
  font-family: var(--rf-font-display);
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 1;
  margin-bottom: 12px;
}

#prova .h3::after {
  content: "";
  display: block;
  width: 32px;
  height: 2px;
  background: var(--rf-red);
  margin-top: 8px;
}

#prova {
  background: linear-gradient(
    to bottom,
    #F2F2EF 0%,
    #ECEBE7 100%
  );
}