/* ============================================
   Projects
   ============================================ */
.projects { padding-block: 100px; }

.projects__grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
  perspective: 1400px;
}

.project-card {
  display: flex;
  flex-direction: column;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  transform-style: preserve-3d;
}

.project-card.is-done {
  transition: transform 0.5s var(--ease), border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
  transition-delay: 0s;
}

.project-card:hover {
  border-color: var(--border-strong);
  box-shadow: 0 40px 70px -40px rgba(122, 60, 255, 0.55);
}

.project-card__thumb {
  aspect-ratio: 16 / 10;
  position: relative;
  display: block;
  width: 100%;
  overflow: hidden;
  background: #0d0f1a;
  cursor: zoom-in;
}

.project-card__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  transition: transform 0.8s var(--ease);
}

.project-card:hover .project-card__img { transform: scale(1.06); }

.project-card__overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, rgba(5, 6, 10, 0.1), rgba(5, 6, 10, 0.65));
  opacity: 0;
  transition: opacity var(--dur) var(--ease);
}

.project-card__chip {
  padding: 9px 18px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.22);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transform: translateY(10px) scale(0.96);
  transition: transform var(--dur) var(--ease);
}

.project-card__thumb:hover .project-card__overlay,
.project-card__thumb:focus-visible .project-card__overlay { opacity: 1; }

.project-card__thumb:hover .project-card__chip,
.project-card__thumb:focus-visible .project-card__chip { transform: none; }

.project-card__body {
  display: flex;
  flex-direction: column;
  flex: 1;
  padding: 24px;
}

.project-card__meta {
  font-family: var(--font-mono);
  font-size: 11.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.project-card__body h3 { font-size: 20px; margin-bottom: 10px; }

.project-card__body > p:not(.project-card__meta) {
  color: var(--text-muted);
  font-size: 14.5px;
  margin-bottom: 18px;
}

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

.tag {
  font-family: var(--font-mono);
  font-size: 11.5px;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.project-card__actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: auto;
  padding-top: 22px;
}

.link-arrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  transition: color var(--dur-fast) var(--ease);
}

.link-arrow span { display: inline-block; transition: transform var(--dur) var(--ease); }
.link-arrow:hover { color: var(--cyan); }
.link-arrow:hover span { transform: translate(3px, -3px); }

/* ============================================
   Modal de proyecto
   ============================================ */
.pmodal {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 24px;
  border: none;
  background: transparent;
  color: var(--text);
  display: none;
  align-items: center;
  justify-content: center;
  overscroll-behavior: contain;
}

.pmodal[open] { display: flex; }

.pmodal::backdrop {
  background: rgba(3, 4, 8, 0.72);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  animation: backdropIn var(--dur) var(--ease) both;
}

.pmodal.is-closing::backdrop { animation: backdropOut 220ms var(--ease) both; }

@keyframes backdropIn { from { opacity: 0; } }
@keyframes backdropOut { to { opacity: 0; } }

.pmodal__panel {
  position: relative;
  width: min(1080px, 100%);
  max-height: calc(100svh - 48px);
  overflow-y: auto;
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  border-radius: 28px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  box-shadow: 0 60px 120px -40px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.02) inset;
  animation: panelIn 420ms var(--ease) both;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

.pmodal.is-closing .pmodal__panel { animation: panelOut 220ms var(--ease) both; }

@keyframes panelIn {
  from { opacity: 0; transform: translateY(24px) scale(0.96); }
}

@keyframes panelOut {
  to { opacity: 0; transform: translateY(12px) scale(0.98); }
}

.pmodal__close {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 3;
  width: 40px;
  height: 40px;
  padding: 11px;
  border-radius: 50%;
  background: rgba(5, 6, 10, 0.6);
  border: 1px solid var(--border-strong);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: transform var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}

.pmodal__close:hover { transform: rotate(90deg); border-color: var(--magenta); }

/* Lado visual: compu + celular */
.pmodal__media {
  position: relative;
  padding: 40px 28px 56px 36px;
  background:
    radial-gradient(ellipse at 30% 20%, rgba(24, 217, 255, 0.14), transparent 60%),
    radial-gradient(ellipse at 80% 90%, rgba(239, 59, 240, 0.16), transparent 60%),
    var(--bg-soft);
  border-right: 1px solid var(--border);
  display: flex;
  align-items: center;
  min-height: 420px;
}

.pmodal__browser {
  width: 88%;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  box-shadow: 0 30px 60px -30px rgba(0, 0, 0, 0.8);
  animation: mediaIn 700ms var(--ease) 120ms both;
}

.pmodal__browser-bar {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
}

.pmodal__browser-bar > span { width: 7px; height: 7px; border-radius: 50%; background: var(--border-strong); }

.pmodal__browser-url {
  margin-left: 10px;
  padding: 2px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pmodal__browser img { width: 100%; height: auto; aspect-ratio: 16 / 10; object-fit: cover; object-position: top; }

.pmodal__phone {
  position: absolute;
  right: 22px;
  bottom: 28px;
  width: 27%;
  padding: 6px;
  border-radius: 26px;
  background: #0b0c12;
  border: 1px solid var(--border-strong);
  box-shadow: 0 30px 60px -20px rgba(0, 0, 0, 0.9), 0 0 0 4px rgba(255, 255, 255, 0.03);
  animation: phoneIn 800ms var(--ease) 260ms both;
}

.pmodal__phone img {
  width: 100%;
  height: auto;
  aspect-ratio: 9 / 19;
  object-fit: cover;
  object-position: top;
  border-radius: 20px;
}

@keyframes mediaIn {
  from { opacity: 0; transform: translateY(16px); }
}

@keyframes phoneIn {
  from { opacity: 0; transform: translate(16px, 28px) rotate(4deg); }
}

/* Lado de texto */
.pmodal__info {
  padding: 48px 40px 40px;
  display: flex;
  flex-direction: column;
}

.pmodal__info > * { animation: infoIn 600ms var(--ease) both; }
.pmodal__info > :nth-child(1) { animation-delay: 140ms; }
.pmodal__info > :nth-child(2) { animation-delay: 190ms; }
.pmodal__info > :nth-child(3) { animation-delay: 240ms; }
.pmodal__info > :nth-child(4) { animation-delay: 290ms; }
.pmodal__info > :nth-child(5) { animation-delay: 320ms; }
.pmodal__info > :nth-child(6) { animation-delay: 350ms; }
.pmodal__info > :nth-child(7) { animation-delay: 380ms; }

@keyframes infoIn {
  from { opacity: 0; transform: translateY(12px); }
}

.pmodal__title {
  font-size: clamp(28px, 3.4vw, 38px);
  letter-spacing: -0.03em;
  margin-bottom: 14px;
}

.pmodal__desc { color: var(--text-muted); font-size: 15.5px; margin-bottom: 26px; }

.pmodal__subtitle {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 12px;
}

.pmodal__features { display: grid; gap: 10px; margin-bottom: 24px; }

.pmodal__features li {
  display: flex;
  gap: 10px;
  font-size: 14.5px;
  line-height: 1.5;
}

.pmodal__features li::before {
  content: "";
  flex-shrink: 0;
  width: 6px;
  height: 6px;
  margin-top: 8px;
  border-radius: 50%;
  background: var(--gradient);
  box-shadow: 0 0 8px rgba(24, 217, 255, 0.6);
}

.pmodal__actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: auto;
  padding-top: 30px;
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 980px) {
  .projects__grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 860px) {
  .pmodal { padding: 0; align-items: flex-end; }
  .pmodal__panel {
    grid-template-columns: 1fr;
    max-height: 92svh;
    border-radius: 24px 24px 0 0;
    animation-name: sheetIn;
  }
  .pmodal.is-closing .pmodal__panel { animation-name: sheetOut; }
  .pmodal__media { border-right: none; border-bottom: 1px solid var(--border); min-height: 0; padding: 56px 20px 36px; }
  .pmodal__info { padding: 28px 22px 0; }
  .pmodal__actions {
    position: sticky;
    bottom: 0;
    margin-inline: -22px;
    padding: 16px 22px calc(16px + env(safe-area-inset-bottom));
    background: linear-gradient(180deg, rgba(16, 18, 27, 0.6), var(--surface) 35%);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
  }
  .pmodal__actions .btn { flex: 1; }
}

@keyframes sheetIn { from { transform: translateY(100%); } }
@keyframes sheetOut { to { transform: translateY(100%); } }

@media (max-width: 760px) {
  .projects__grid { grid-template-columns: 1fr; max-width: 480px; margin-inline: auto; }
}

@media (prefers-reduced-motion: reduce) {
  .pmodal__panel, .pmodal__browser, .pmodal__phone, .pmodal__info > * { animation: none !important; }
}
