/* ===== FONTS ===== */
@font-face {
  font-family: 'Mg12';
  src: url('Mg¹²-Medium.woff2') format('woff2'),
       url('Mg¹²-Medium.woff') format('woff'),
       url('Mg¹²-Medium.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
}

/* ===== RESET & BASE ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  background: #e8e8e8;
  font-family: Arial, sans-serif;
  font-size: 13px;
  color: #111;
  overflow-x: hidden;
}

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

/* ===== SITE ===== */
#site {
  min-height: 100vh;
}

/* ===== HEADER ===== */
#header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  padding: 14px 18px 10px;
  background: transparent;
  pointer-events: none;
}

#header > * {
  pointer-events: auto;
}

#logo {
  font-family: 'Mg12', Arial, sans-serif;
  font-size: 13px;
  letter-spacing: 0.02em;
  line-height: 1.4;
  opacity: 0;
  transition: opacity 0.4s ease;
  cursor: pointer;
}

#logo.visible {
  opacity: 1;
}

#header-row2 {
  display: flex;
  align-items: baseline;
  gap: 0;
}

#nav-sub {
  font-size: 13px;
  line-height: 1.4;
  opacity: 0;
  transition: opacity 0.4s ease;
  flex: 1;
  min-width: 0;
}

#nav-sub.visible {
  opacity: 1;
}

#nav-sub-text {
  cursor: pointer;
}

#nav-sub-text:hover {
  opacity: 0.6;
}

/* ===== MAIN NAV ===== */
#nav-main {
  display: flex;
  flex: 1;
  justify-content: flex-start;
  align-items: baseline;
}

.nav-item {
  flex: 1;
  text-align: center;
  font-size: 13px;
  cursor: pointer;
  opacity: 0;
  max-width: 500px;
  white-space: nowrap;
  overflow: hidden;
  transition: opacity 0.4s ease, max-width 0.4s ease, flex 0.4s ease;
  padding: 0;
}

.nav-item.active-section {
  opacity: 0 !important;
  pointer-events: none;
  flex: 0;
  max-width: 0;
  overflow: hidden;
}

.nav-item:hover {
  opacity: 0.6 !important;
}

.nav-item.visible {
  opacity: 1;
}

/* ===== SECTIONS ===== */
.section {
  display: none;
  min-height: 100vh;
  padding-top: 60px;
  position: relative;
}

.section.active {
  display: block;
}

/* ===== LANDPAGE GRID ===== */
#grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  width: min(660px, 74vw);
  margin: 0 auto;
  padding-bottom: 80px;
  opacity: 0;
  transition: opacity 0.6s ease;
}

#grid.visible {
  opacity: 1;
}

.grid-item {
  position: relative;
  overflow: hidden;
  cursor: pointer;
  aspect-ratio: 3 / 4;
}

.grid-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: filter 0.3s ease;
}

.grid-item:hover img {
  filter: brightness(0.35);
}

.grid-item .project-label {
  position: absolute;
  bottom: 10px;
  right: 10px;
  color: #fff;
  font-size: 11px;
  text-align: right;
  line-height: 1.3;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.grid-item:hover .project-label {
  opacity: 1;
}

/* ===== ABOUT / INFRA / CLIENTS ===== */
.inner-content {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(860px, 88vw);
  padding: 0 18px;
}

.inner-content p {
  font-size: 13px;
  line-height: 1.55;
  margin-bottom: 20px;
}

/* back btn for content pages */
#section-about > .back-btn,
#section-infrastructure > .back-btn,
#section-clients > .back-btn {
  position: absolute;
  bottom: 80px;
  left: 18px;
  margin-top: 0;
}

/* ===== CONTACT ===== */
#section-contact {
  display: none;
  position: relative;
  min-height: 100vh;
  padding-top: 0;
}

#section-contact.active {
  display: block;
}

.contact-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.contact-center a {
  font-size: 13px;
  line-height: 1.6;
  cursor: pointer;
  transition: opacity 0.2s;
}

.contact-center a:hover {
  opacity: 0.5;
}

/* ===== BACK BUTTON ===== */
.back-btn {
  display: inline-block;
  font-size: 13px;
  cursor: pointer;
  transition: opacity 0.2s;
}

.back-btn:hover {
  opacity: 0.5;
}

#section-contact .back-btn {
  position: absolute;
  bottom: 80px;
  left: 18px;
}

/* ===== PROJECT DETAIL ===== */
#section-project {
  display: none;
  flex-direction: column;
  padding-top: 70px;
  min-height: 100vh;
}

#section-project.active {
  display: flex;
}

#project-scroll-container {
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  flex: 1;
  display: flex;
  align-items: center;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

#project-scroll-container::-webkit-scrollbar {
  display: none;
}

#project-scroll-track {
  display: flex;
  align-items: center;
  gap: 0;
  height: calc(100vh - 150px);
  padding: 0;
}

.proj-media {
  height: 100%;
  flex-shrink: 0;
  object-fit: cover;
  display: block;
}

.proj-media.landscape {
  /* 4:3 horizontal */
  aspect-ratio: 4 / 3;
  width: auto;
}

.proj-media.portrait {
  /* 3:4 vertical */
  aspect-ratio: 3 / 4;
  width: auto;
}

#project-footer {
  padding: 16px 18px 90px;
  display: flex;
  flex-direction: row;
  align-items: flex-end;
  justify-content: flex-end;
  gap: 20px;
}

#section-project .back-btn {
  position: fixed;
  bottom: 80px;
  left: 18px;
}

#project-description {
  font-size: 13px;
  line-height: 1.5;
  max-width: 500px;
  text-align: right;
  margin: 0;
}

/* ===== CLOCK ===== */
#clock-wrap {
  position: fixed;
  bottom: 14px;
  right: 18px;
  text-align: right;
  font-size: 11px;
  line-height: 1.5;
  z-index: 200;
  opacity: 0;
  transition: opacity 0.6s ease 0.2s;
  pointer-events: none;
}

#clock-wrap.visible {
  opacity: 1;
}

#clock-date {
  letter-spacing: 0.02em;
}

#clock-copy {
  letter-spacing: 0.02em;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  #header {
    padding: 10px 12px 8px;
  }

  #header-row2 {
    flex-direction: row;
    align-items: baseline;
    gap: 0;
  }

  #nav-sub {
    flex: 0 0 auto;
    min-width: 0;
  }

  #nav-main {
    width: auto;
    flex: 1;
  }

  #grid {
    width: 100vw;
    grid-template-columns: 1fr 1fr;
  }

  .inner-content {
    width: 92vw;
  }

  /* Project view: center slide + description as a block, back fixed bottom-left */
  #section-project.active {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 100vh;
    padding-top: 60px;
  }

  #project-scroll-container {
    flex: 0 0 auto;
  }

  #section-project #project-footer {
    padding: 6px 12px 0;
    flex-direction: column;
    align-items: flex-end;
    gap: 0;
  }

  /* todos los back buttons al mismo nivel que la última línea del reloj */
  .back-btn {
    position: fixed !important;
    bottom: 10px !important;
    left: 12px !important;
  }

  #project-description {
    max-width: 80vw;
    font-size: 12px;
  }

  #project-scroll-track {
    height: 56vw;
  }

  .contact-center {
    width: 90%;
  }

  #clock-wrap {
    right: 10px;
    bottom: 10px;
  }
}

@media (max-width: 480px) {
  #grid {
    grid-template-columns: 1fr 1fr;
  }
}
