/* ==========================================================================
   Home layout refresh — hero hierarchy, action previews and project carousel
   ========================================================================== */

body {
  overflow-x: hidden;
  overflow-y: auto;
}

.terminal-shell {
  min-height: 100vh;
  overflow: visible;
}

.terminal-screen {
  min-height: 100vh;
  padding: 0;
}

.hero-stage {
  position: relative;
  min-height: 100svh;
  padding: clamp(76px, 8vw, 112px) clamp(28px, 4vw, 58px) clamp(52px, 6vw, 86px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 28vw);
  align-items: center;
  gap: clamp(48px, 7vw, 120px);
}

.hero-stage .system-header {
  top: clamp(28px, 4vw, 58px);
  left: clamp(28px, 4vw, 58px);
}

.hero-main {
  width: min(100%, 900px);
  display: flex;
  flex-direction: column;
  gap: clamp(52px, 7vh, 86px);
}

/* Identity now precedes the dynamic skills/profile block. */
.hero-stage .identity,
.hero-stage .profile-panel {
  position: relative;
  inset: auto;
  width: 100%;
  transform: none;
}

.hero-stage .identity {
  order: 1;
}

.hero-stage .profile-panel {
  order: 2;
  max-width: 760px;
}

.hero-stage .name {
  font-size: clamp(54px, 7vw, 118px);
}

.hero-stage .profile-line {
  font-size: clamp(19px, 1.7vw, 30px);
}

/* Right side is now intentionally limited to the two primary actions. */
.hero-actions {
  position: relative;
  z-index: 8;
  width: 100%;
  display: grid;
  gap: 14px;
  justify-self: end;
}

.action-preview {
  position: relative;
}

.hero-action {
  position: relative;
  z-index: 3;
  width: 100%;
  min-height: 72px;
  padding: 18px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border: 1px solid rgba(111, 247, 255, 0.28);
  border-radius: 12px;
  background:
    linear-gradient(135deg, rgba(111, 247, 255, 0.075), rgba(140, 123, 255, 0.035)),
    rgba(8, 15, 24, 0.74);
  color: var(--cyan-strong);
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 12px;
  font-weight: 600;
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.14);
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.hero-action:hover,
.hero-action:focus-visible {
  outline: none;
  transform: translateX(-4px);
  border-color: rgba(111, 247, 255, 0.72);
  background:
    linear-gradient(135deg, rgba(111, 247, 255, 0.14), rgba(140, 123, 255, 0.07)),
    rgba(8, 15, 24, 0.9);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.18), 0 0 28px rgba(35, 217, 255, 0.08);
}

.hero-action__meta {
  color: var(--muted);
  font-size: 10px;
}

.hero-action--contact {
  border-color: rgba(111, 247, 255, 0.52);
}

.action-popover {
  position: absolute;
  top: 50%;
  right: calc(100% + 16px);
  z-index: 2;
  width: min(390px, 34vw);
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(7, 13, 21, 0.97);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.34);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translate(12px, -50%);
  transition: opacity 160ms ease, transform 160ms ease, visibility 160ms linear;
}

.action-preview:hover .action-popover,
.action-preview:focus-within .action-popover {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translate(0, -50%);
}

.popover-kicker {
  display: block;
  margin-bottom: 12px;
  color: var(--cyan);
  font-size: 9px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.about-popover p {
  margin: 0;
  color: var(--text);
  font-size: 12px;
  line-height: 1.75;
}

.popover-hint {
  display: block;
  margin-top: 14px;
  color: var(--muted);
  font-size: 8px;
  line-height: 1.5;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.quick-contact-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: stretch;
  gap: 8px;
  padding: 8px 0;
  border-top: 1px solid var(--line);
}

.quick-contact-row:last-of-type {
  border-bottom: 1px solid var(--line);
}

.quick-contact-value,
.quick-copy-button {
  border: 0;
  font: inherit;
  cursor: pointer;
}

.quick-contact-value {
  min-width: 0;
  padding: 8px 4px;
  display: grid;
  gap: 4px;
  justify-items: start;
  background: transparent;
  color: var(--text);
  text-align: left;
  font-size: 10px;
  overflow-wrap: anywhere;
}

.quick-contact-type {
  color: var(--muted);
  font-size: 8px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.quick-contact-value:hover,
.quick-contact-value:focus-visible {
  color: var(--cyan-strong);
  outline: none;
}

.quick-copy-button {
  align-self: center;
  padding: 8px 9px;
  border: 1px solid rgba(111, 247, 255, 0.22);
  border-radius: 7px;
  background: rgba(111, 247, 255, 0.04);
  color: var(--muted);
  font-size: 8px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.quick-copy-button:hover,
.quick-copy-button:focus-visible {
  color: var(--cyan-strong);
  border-color: rgba(111, 247, 255, 0.56);
  outline: none;
}

/* Projects are now a separate horizontal carousel below the hero. */
.projects-carousel-section {
  position: relative;
  z-index: 2;
  padding: clamp(44px, 6vw, 82px) clamp(28px, 4vw, 58px) clamp(72px, 8vw, 120px);
  border-top: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(111, 247, 255, 0.015), transparent 22%),
    rgba(4, 8, 14, 0.32);
}

.projects-carousel-header {
  max-width: 1520px;
  margin: 0 auto 24px;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
}

.projects-carousel-kicker {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.projects-carousel-header h2 {
  margin: 0;
  color: var(--cyan-strong);
  font-family: "Orbitron", "IBM Plex Mono", monospace;
  font-size: clamp(24px, 3vw, 44px);
  line-height: 1.05;
  text-transform: uppercase;
  letter-spacing: 0.035em;
}

.carousel-controls {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.carousel-button {
  width: 42px;
  height: 42px;
  border: 1px solid rgba(111, 247, 255, 0.24);
  border-radius: 9px;
  background: rgba(8, 15, 24, 0.74);
  color: var(--cyan);
  font: inherit;
  cursor: pointer;
}

.carousel-button:hover,
.carousel-button:focus-visible {
  border-color: rgba(111, 247, 255, 0.64);
  color: var(--cyan-strong);
  outline: none;
}

.carousel-button:disabled {
  opacity: 0.35;
  cursor: default;
}

.carousel-counter {
  min-width: 66px;
  text-align: center;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.12em;
}

.projects-carousel {
  max-width: 1520px;
  margin: 0 auto;
  display: flex;
  gap: 18px;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  padding: 4px 2px 18px;
}

.projects-carousel::-webkit-scrollbar {
  display: none;
}

.project-card {
  flex: 0 0 min(74vw, 520px);
  min-width: 0;
  scroll-snap-align: start;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  background: rgba(9, 16, 25, 0.78);
  color: inherit;
  text-decoration: none;
  box-shadow: 0 20px 54px rgba(0, 0, 0, 0.16);
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.project-card:hover,
.project-card:focus-visible {
  transform: translateY(-4px);
  border-color: rgba(111, 247, 255, 0.55);
  box-shadow: 0 26px 64px rgba(0, 0, 0, 0.22), 0 0 28px rgba(35, 217, 255, 0.06);
  outline: none;
}

.project-card__media {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
}

.project-card__media::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 55%, rgba(4, 9, 14, 0.32));
  pointer-events: none;
}

.project-card__media img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  transition: transform 260ms ease;
}

.project-card:hover .project-card__media img,
.project-card:focus-visible .project-card__media img {
  transform: scale(1.025);
}

.project-card__index {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 2;
  min-width: 34px;
  padding: 6px 8px;
  border: 1px solid rgba(111, 247, 255, 0.28);
  border-radius: 7px;
  background: rgba(5, 10, 17, 0.78);
  color: var(--cyan-strong);
  font-size: 9px;
  text-align: center;
  backdrop-filter: blur(8px);
}

.project-card__body {
  padding: 18px 20px 20px;
}

.project-card__body h3 {
  margin: 0;
  color: var(--cyan-strong);
  font-size: clamp(18px, 1.5vw, 25px);
  line-height: 1.2;
}

.project-card__body p {
  margin: 7px 0 18px;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.6;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.project-card__open {
  color: var(--cyan);
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* Light theme */
html[data-theme="light"] .hero-action,
html[data-theme="light"] .action-popover,
html[data-theme="light"] .project-card,
html[data-theme="light"] .carousel-button {
  background: rgba(255, 255, 255, 0.9);
  border-color: rgba(0, 95, 105, 0.2);
}

html[data-theme="light"] .hero-action {
  color: #153f46;
}

html[data-theme="light"] .hero-action:hover,
html[data-theme="light"] .hero-action:focus-visible {
  border-color: rgba(0, 95, 105, 0.48);
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 18px 44px rgba(26, 64, 70, 0.12);
}

html[data-theme="light"] .about-popover p,
html[data-theme="light"] .quick-contact-value,
html[data-theme="light"] .project-card__body h3 {
  color: #17383e;
}

html[data-theme="light"] .quick-copy-button {
  color: #35575d;
  border-color: rgba(0, 95, 105, 0.2);
  background: rgba(0, 95, 105, 0.035);
}

html[data-theme="light"] .projects-carousel-section {
  background:
    linear-gradient(180deg, rgba(0, 111, 123, 0.02), transparent 22%),
    rgba(244, 249, 250, 0.72);
}

html[data-theme="light"] .projects-carousel-header h2,
html[data-theme="light"] .project-card__open,
html[data-theme="light"] .carousel-button {
  color: #064f59;
}

html[data-theme="light"] .project-card__media {
  background: #eaf1f3;
}

@media (max-width: 980px) {
  .terminal-screen {
    display: block;
    padding: 0;
  }

  .hero-stage {
    min-height: auto;
    padding: 110px 22px 58px;
    grid-template-columns: 1fr;
    gap: 52px;
  }

  .hero-stage .system-header {
    position: absolute;
    top: 26px;
    left: 22px;
    width: auto;
  }

  .hero-main {
    gap: 46px;
  }

  .hero-actions {
    width: min(100%, 620px);
    justify-self: start;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .action-popover {
    top: calc(100% + 10px);
    left: 0;
    right: auto;
    width: min(430px, 82vw);
    transform: translateY(-8px);
  }

  .action-preview:last-child .action-popover {
    left: auto;
    right: 0;
  }

  .action-preview:hover .action-popover,
  .action-preview:focus-within .action-popover {
    transform: translateY(0);
  }
}

@media (max-width: 620px) {
  .hero-stage {
    padding: 100px 16px 46px;
    gap: 42px;
  }

  .hero-stage .system-header {
    top: 62px;
    left: 16px;
  }

  .hero-stage .name {
    font-size: clamp(40px, 13.5vw, 66px);
  }

  .hero-main {
    gap: 38px;
  }

  .hero-stage .profile-line {
    font-size: clamp(17px, 5.2vw, 24px);
  }

  .hero-actions {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .hero-action {
    min-height: 58px;
    padding: 15px 16px;
  }

  .action-popover {
    width: min(100%, calc(100vw - 32px));
    left: 0 !important;
    right: auto !important;
  }

  /* Touch users still navigate on tap; previews remain a hover/focus enhancement. */
  @media (hover: none) {
    .action-popover {
      display: none;
    }
  }

  .projects-carousel-section {
    padding: 40px 16px 72px;
  }

  .projects-carousel-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 18px;
  }

  .carousel-controls {
    align-self: stretch;
    justify-content: space-between;
  }

  .project-card {
    flex-basis: 88vw;
  }
}

@media (prefers-reduced-motion: reduce) {
  .hero-action,
  .action-popover,
  .project-card,
  .project-card__media img {
    transition: none;
  }

  .projects-carousel {
    scroll-behavior: auto;
  }
}
