/*
  Elias-inspired (original) theme for Giulio Bucchi portfolio.
  Single-page layout, no external images.
*/

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

/* Prevent FOUC (Flash of Unstyled Content) */
html {
  opacity: 0;
  transition: opacity 0.2s ease;
}

html.loaded {
  opacity: 1;
}

:root {
  --primary: #1e3a8a;
  --secondary: #f97316;
  /* compatibility aliases and RGB helpers */
  --primary-color: var(--primary);
  --secondary-color: var(--secondary);
  --primary-rgb: 30,58,138;
  --secondary-rgb: 249,115,22;

  /* neutrals */
  --background: #ffffff;
  --white: #0f172a;
  --gray: #475569;
  --gray-2: #94a3b8;
  --border: rgba(15, 23, 42, 0.18);
  --border-strong: rgba(15, 23, 42, 0.28);

  /* “op” colors similar to reference but adapted */
  --primary-op: rgba(30, 58, 138, 0.12);
  --secondary-op: rgba(249, 115, 22, 0.14);
  --gray-op: rgba(71, 85, 105, 0.10);

  --desktop: 1024px;
  --tablet: 768px;
  --mobile: 500px;
}

.logo__img {
  width: 18px;
  height: 18px;
  display: block;
}

html,
body {
  background-color: var(--background);
  color: var(--white);
  font-family: "Fira Code", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  line-height: 1.5;
  text-rendering: optimizeSpeed;
  overflow-x: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

ul {
  list-style: none;
}

/* Layout */
.container {
  max-width: var(--desktop);
  margin: 0 auto;
  position: relative;
}

@media (max-width: 1024px) {
  .container {
    padding: 16px;
  }
}

.content {
  margin-top: 112px;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 84px;
}

/* Media header (left vertical icons) */
.media-header {
  position: fixed;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  left: 16px;
  gap: 8px;
  top: 0;
  z-index: 998;
}

@media (max-width: 1024px) {
  .media-header {
    display: none;
  }
}

.media-header__links {
  display: grid;
  grid-auto-columns: 1fr;
  gap: 8px;
}

.media-header__line {
  width: 1px;
  height: 33vh;
  background-color: var(--gray);
  display: block;
  opacity: 0.5;
}

.media {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  transition: 0.2s ease;
  color: var(--gray);
  background: transparent;
}

.media:hover {
  background: var(--secondary-op);
  border-color: var(--secondary);
  color: var(--secondary);
}

.media__icon {
  width: 18px;
  height: 18px;
  display: block;
  object-fit: contain;
  /* keep SVG color intact; don't invert */
}

/* Header */
.header {
  padding-top: 32px;
  padding-bottom: 8px;
  background-color: var(--background);
  position: fixed;
  top: 0;
  width: 100%;
  z-index: 999;
  border-bottom: 1px solid transparent;
}

.header.scrolled {
  border-bottom-color: var(--border);
  backdrop-filter: blur(8px);
  background-color: rgba(255, 255, 255, 0.92);
}

.header__inner {
  display: flex;
  width: 100%;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  position: relative;
}

.logo {
  display: flex;
  gap: 8px;
}

.logo__name {
  font-weight: 700;
  letter-spacing: -0.02em;
}

.header__links {
  margin-left: auto;
  display: flex;
  align-items: flex-start;
  gap: 32px;
}

.header__link {
  color: var(--gray);
}

.header__link::before {
  content: "#";
  color: var(--secondary);
  font-weight: 400;
  margin-right: 2px;
}

.header__link:hover {
  color: var(--primary);
}

/* Mobile hamburger */
.hamburger {
  width: 32px;
  margin: 0;
  aspect-ratio: 1;
  display: none;
  appearance: none;
  position: absolute;
  cursor: pointer;
  right: 8px;
  top: 32px;
  z-index: 9999;
}

.hamburger::before,
.hamburger::after {
  content: "";
  width: 100%;
  height: 2px;
  position: absolute;
  left: 0;
  background: var(--gray);
  transition: 0.2s ease;
}

.hamburger::before {
  top: 35%;
}

.hamburger::after {
  top: 65%;
}

@media (max-width: 1024px) {
  .hamburger {
    display: block;
  }

  .header__links {
    display: none;
    position: absolute;
    right: 0;
    bottom: -16px;
    transform: translateY(100%);
    flex-direction: column;
    gap: 16px;
    padding: 16px;
    border: 1px solid var(--border);
    background: var(--background);
    min-width: 220px;
  }

  .hamburger:checked ~ .container .header__links {
    display: flex;
  }
}

/* Components */
.button {
  display: inline-block;
  padding: 8px 16px;
  border: 1px solid var(--primary);
  font-weight: 500;
}

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

.button__primary {
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  color: #ffffff;
  border-color: transparent;
}

.button__primary:hover {
  filter: brightness(1.02);
}

.h2 {
  font-size: 32px;
  font-weight: 600;
  position: relative;
  display: inline-block;
}

.h2::before {
  content: "#";
  color: var(--secondary);
}

.h2::after {
  content: "";
  display: block;
  width: 10vw;
  height: 1px;
  background: linear-gradient(90deg, var(--secondary), var(--primary));
  position: absolute;
  transform: translate(100%, -50%);
  right: -16px;
  top: 50%;
}

/* Hero */
.hero {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 32px;
  flex-wrap: wrap;
}

.hero__content,
.hero__illustrations {
  flex: 1 1 0;
}

.hero__title {
  min-width: 300px;
  font-size: 32px;
  font-weight: 600;
}

.hero__title span {
  color: var(--primary);
}

.hero__description {
  color: var(--gray);
  margin-top: 32px;
  margin-bottom: 32px;
  max-width: 620px;
}

.hero__illustrations {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 300px;
}

.hero__image {
  width: min(360px, 100%);
  height: auto;
  aspect-ratio: 4/3;
  object-fit: cover;
  border: 1px solid var(--border);
  border-bottom: 1px solid var(--primary);
  background: linear-gradient(180deg, rgba(var(--primary-rgb), 0.06), rgba(var(--secondary-rgb), 0.06));
  position: relative;
  z-index: 2;
}

.hero__placeholder {
  display: none;
}

.hero__status {
  padding: 8px;
  border: 1px solid var(--border);
  color: var(--gray);
  margin: 0 auto;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  position: relative;
  top: -1px;
  z-index: 5;
  gap: 8px;
  font-weight: 500;
  width: fit-content;
}

.hero__status::before {
  content: "";
  display: inline-block;
  aspect-ratio: 1;
  width: 16px;
  background-color: var(--primary-op);
  border: 1px solid var(--primary);
}

/* Dots */
.dots {
  width: 10vmin;
  height: auto;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.dots span {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  display: block;
  background: var(--gray);
  opacity: 0.55;
}

.hero__illustrations .dots {
  position: absolute;
  top: 40%;
  width: 12vmin;
  left: 70%;
  z-index: 4;
}

/* Quote */
.quote {
  width: 100%;
  border: 1px solid var(--border);
  position: relative;
  margin: 0;
}

.quote::before,
.quote::after {
  content: '"';
  position: absolute;
  color: var(--gray);
  font-size: 64px;
  font-weight: 700;
  background-image: linear-gradient(var(--background), var(--background));
  background-size: 100% 40%;
  background-repeat: no-repeat;
}

.quote::before {
  top: -32px;
  left: 16px;
}

.quote::after {
  bottom: -64px;
  right: 16px;
}

.quote__text {
  padding: 32px;
  font-size: 24px;
  font-weight: 600;
  background-color: var(--background);
}

.quote__author {
  position: absolute;
  color: var(--gray);
  border: 1px solid var(--border);
  padding: 8px;
  right: -1px;
  font-size: 16px;
  background: var(--background);
}

.quote__author::before {
  content: "- ";
}

/* Projects */
.projects {
  width: 100%;
}

.projects__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 32px;
  gap: 16px;
}

.projects__link {
  text-decoration: underline;
  text-decoration-color: var(--secondary);
  text-underline-offset: 4px;
  color: var(--gray);
}

.projects__link:hover {
  color: var(--secondary);
}

/* Projects carousel (horizontal scroll for many projects) */
.projects-carousel {
  position: relative;
}

.project-list--scroll {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(320px, 1fr);
  gap: 16px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 8px 4px 12px;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

.project-list--scroll > .project {
  scroll-snap-align: start;
}

.project-list--scroll::-webkit-scrollbar {
  height: 8px;
}

.project-list--scroll::-webkit-scrollbar-track {
  background: transparent;
}

.project-list--scroll::-webkit-scrollbar-thumb {
  background: rgba(var(--primary-rgb), 0.22);
  border-radius: 999px;
}

.project-list--scroll::-webkit-scrollbar-thumb:hover {
  background: rgba(var(--secondary-rgb), 0.35);
}

.projects-carousel__btn {
  appearance: none;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.92);
  color: var(--primary);
  width: 44px;
  height: 44px;
  border-radius: 999px;
  display: none;
  place-items: center;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 5;
  cursor: pointer;
  transition: 0.2s ease;
}

.projects-carousel__btn:hover {
  background: var(--secondary-op);
  border-color: var(--secondary);
  color: var(--secondary);
}

.projects-carousel__btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.projects-carousel__btn--left {
  left: -18px;
}

.projects-carousel__btn--right {
  right: -18px;
}

@media (min-width: 1025px) {
  .projects-carousel__btn {
    display: grid;
  }
}

.project-list {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

@media (max-width: 1024px) {
  .project-list {
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  }
}

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

.project__techs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  color: var(--gray);
  padding: 8px;
  border-bottom: 1px solid var(--border);
}

.project__content {
  padding: 16px;
}

.project__name {
  font-size: 24px;
  font-weight: 600;
}

.project__description {
  color: var(--gray);
  margin: 16px 0;
}

.project__links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* Skills */
.skills {
  width: 100%;
}

.skills__content {
  display: flex;
  gap: 32px;
  flex-wrap: wrap;
  margin-top: 28px;
  align-items: flex-start;
}

.skills__illustrations,
.skills__list {
  flex: 1 1 0;
}

.illustrations {
  position: relative;
  min-width: 300px;
  min-height: 200px;
}

.illustrations__logo {
  width: 12vmin;
  height: 12vmin;
  top: 16%;
  position: absolute;
  left: 64%;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(var(--primary-rgb), 0.08), rgba(var(--secondary-rgb), 0.08));
}

.skills__list {
  column-gap: 16px;
  columns: 3;
  margin-top: 0;
}

@media (max-width: 768px) {
  .skills__list {
    columns: 2;
  }
}

@media (max-width: 500px) {
  .skills__list {
    columns: 1;
  }
}

.skill-block {
  border: 1px solid var(--border);
  display: inline-block;
  max-width: 300px;
  min-width: 200px;
  width: 100%;
  margin-bottom: 12px;
}

.skill-block__name {
  font-weight: 700;
  padding: 8px;
  border-bottom: 1px solid var(--border);
}

.skill-block__list {
  padding: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: start;
  align-items: start;
  color: var(--gray);
}

.skill-block__skill {
  border: 1px solid var(--gray-op);
  padding: 2px 6px;
}

/* About */
.about {
  display: flex;
  gap: 32px;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}

.about__content {
  flex: 1 1 0;
  min-width: 300px;
}

.about__text {
  margin-bottom: 32px;
  margin-top: 48px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.about__description {
  color: var(--gray);
}

.about__image {
  flex: 1 1 0;
  max-width: 340px;
  aspect-ratio: 4/5;
  width: 100%;
  height: auto;
  object-fit: cover;
  border-bottom: 1px solid var(--primary);
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  border-top: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(var(--primary-rgb), 0.06), rgba(var(--secondary-rgb), 0.06));
}

/* Contacts */
.contacts {
  width: 100%;
}

.contacts__content {
  display: flex;
  justify-content: space-between;
  align-items: start;
  flex-wrap: wrap;
  gap: 32px;
  margin-top: 28px;
}

@media (max-width: 768px) {
  .content {
    gap: 64px;
  }

  .hero__description {
    margin-top: 20px;
    margin-bottom: 20px;
  }
}

.contacts__title {
  font-weight: 700;
}

.contacts__media {
  border: 1px solid var(--border);
  padding: 16px;
  min-width: min(420px, 100%);
}

@media (max-width: 768px) {
  .skills__content {
    gap: 20px;
  }

  .skills__illustrations {
    min-width: 100%;
  }

  .contacts__content {
    gap: 20px;
  }

  .contacts__media {
    width: 100%;
  }
}

.contacts__description {
  color: var(--gray);
  max-width: 600px;
}

.contact {
  display: flex;
  gap: 8px;
  color: var(--gray);
  align-items: center;
  margin-top: 8px;
}

.contact:hover {
  color: var(--primary);
}

.contact__icon {
  width: 22px;
  height: 22px;
  display: block;
  object-fit: contain;
  border: 1px solid var(--border);
  padding: 3px;
}

/* Footer */
.footer {
  max-width: inherit;
  width: 100%;
  border-top: 1px solid var(--border);
  padding-top: 32px;
  margin-bottom: 16px;
}

.footer__copyright {
  color: var(--gray);
  text-align: center;
}

.footer__header {
  display: flex;
  gap: 32px;
  align-items: center;
  flex-wrap: wrap;
}

.footer__email {
  color: var(--gray);
  text-decoration: underline;
}

.footer__email:hover {
  color: var(--primary);
}

.footer__description {
  margin-top: 16px;
  color: var(--gray);
}

.footer__inner {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 32px;
  margin-bottom: 48px;
}

.footer__list {
  display: flex;
  gap: 8px;
}

.footer__title {
  font-weight: 600;
  font-size: 20px;
}

/* Fade-in */
.fade-in {
  opacity: 0;
  transform: translateY(12px);
  transition: 0.5s ease;
}

.fade-in.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Accessibility improvements */
a:focus,
button:focus {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

/* Reduced motion for accessibility */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}