/* ============================================
   WABI-SABI PORTFOLIO — Design System
   Inspired by sleep-well-creatives.com structure
   Wabi-Sabi aesthetic: earth tones, asymmetry,
   grain texture, slow transitions
   ============================================ */

/* --- Custom Properties --- */
:root {
  /* Palette — warm earth, low saturation */
  --bg:         #F4F0EA;
  --bg-alt:     #EAE6DF;
  --bg-deep:    #3B3A36;
  --text:       #2F2E2C;
  --text-soft:  #5C5955;
  --text-muted: #8A857F;
  --accent:     #4A4F44;
  --accent-warm:#6B5E53;
  --cream:      #FAF8F4;
  --border:     rgba(47, 46, 44, 0.12);

  /* Typography */
  --font-heading: 'Cormorant Garamond', 'Georgia', serif;
  --font-body:    'Source Serif 4', 'Georgia', serif;

  /* Spacing */
  --space-xs: 0.5rem;
  --space-sm: 1rem;
  --space-md: 2rem;
  --space-lg: 2.5rem;
  --space-xl: 3.5rem;

  /* Transitions — slow, deliberate */
  --ease: cubic-bezier(0.25, 0.1, 0.25, 1);
  --duration: 0.5s;
  --duration-slow: 0.8s;
}

/* --- Reset --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  scroll-behavior: smooth;
  overflow-x: hidden;
}

body {
  font-family: var(--font-body);
  color: var(--text);
  background: var(--bg);
  line-height: 1.7;
  font-size: 1.05rem;
  -webkit-font-smoothing: antialiased;
}

/* Paper grain texture overlay */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 200px 200px;
}

/* Aged-photobook vignette — darkens the edges like light falloff on old paper.
   Sits above content but below the fixed nav/indicator so their
   mix-blend-mode contrast trick stays intact. */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  background: radial-gradient(ellipse at center, transparent 60%, rgba(43, 32, 22, 0.1) 100%);
}

/* --- Typography --- */
h1, h2, h3, h4 {
  font-family: var(--font-heading);
  font-weight: 400;
  line-height: 1.15;
  letter-spacing: 0.04em;
}

h1 { font-size: clamp(3rem, 8vw, 7rem); }
h2 { font-size: clamp(2rem, 5vw, 4rem); }
h3 { font-size: clamp(1.3rem, 3vw, 2rem); }

p { max-width: 42ch; }

a {
  color: var(--accent-warm);
  text-decoration: none;
  transition: opacity var(--duration) var(--ease);
}
a:hover { opacity: 0.6; }

/* --- Sections --- */
.section {
  display: grid;
  justify-items: center;
  position: relative;
  padding: var(--space-lg) var(--space-md);
  overflow: hidden;
}

/* Alternating backgrounds */
.section--alt { background: var(--bg-alt); }
.section--dark {
  background: var(--bg-deep);
  color: var(--cream);
}
.section--dark .text-muted { color: rgba(250, 248, 244, 0.55); }
.section--dark a { color: var(--cream); }

/* --- Fixed Nav --- */
.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-sm) var(--space-md);
  mix-blend-mode: difference;
  color: var(--cream);
  pointer-events: none;
}
.nav > * { pointer-events: auto; }
.nav__name {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: inherit;
}
/* --- Section Indicator Dots --- */
.indicator {
  position: fixed;
  left: var(--space-md);
  top: 50%;
  transform: translateY(-50%);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 10px;
  mix-blend-mode: difference;
}
.indicator__dot {
  width: 18px;
  height: 2px;
  background: rgba(250, 248, 244, 0.35);
  border-radius: 1px;
  transition: all var(--duration) var(--ease);
  cursor: pointer;
  border: none;
  padding: 0;
}
.indicator__dot.active {
  width: 28px;
  background: var(--cream);
}
.indicator__dot:hover {
  background: var(--cream);
  width: 22px;
}
.indicator__dot.active:hover { width: 28px; }
.indicator__label {
  font-family: var(--font-heading);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(250, 248, 244, 0.5);
  writing-mode: vertical-lr;
  transform: rotate(180deg);
  margin-bottom: var(--space-xs);
}

/* --- Scroll Helper --- */
.scroll-hint {
  position: fixed;
  bottom: var(--space-md);
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  font-family: var(--font-heading);
  font-size: 0.75rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  mix-blend-mode: difference;
  color: rgba(250, 248, 244, 0.5);
  transition: opacity var(--duration) var(--ease);
}
.scroll-hint::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  animation: pulse-dot 2s var(--ease) infinite;
}
.scroll-hint.hidden { opacity: 0; pointer-events: none; }

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: translateY(0); }
  50% { opacity: 0.3; transform: translateY(4px); }
}

/* --- Hero + Sobre mí (merged) --- */
.hero {
  min-height: 100vh;
  padding: var(--space-xl) var(--space-lg);
}
.hero__inner {
  display: grid;
  grid-template-columns: minmax(240px, 340px) minmax(0, 680px);
  gap: var(--space-xl);
  align-items: center;
  justify-content: center;
}
.hero__photo-frame {
  position: relative;
  width: 100%;
  border-radius: 4px 20px 4px 4px; /* partial, imperfect borders */
  overflow: hidden;
  transform: rotate(-1.1deg);
  box-shadow:
    0 0 0 8px var(--cream),
    0 0 0 9px var(--border),
    0 22px 44px -16px rgba(47, 46, 44, 0.4);
  transition: transform var(--duration-slow) var(--ease);
}
.hero__photo-frame:hover { transform: rotate(-1.1deg) scale(1.02); }
.hero__photo-frame::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.07;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 160px 160px;
}
.hero__photo {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  filter: grayscale(0.15) contrast(0.95);
  transition: filter var(--duration-slow) var(--ease);
}
.hero__photo-frame:hover .hero__photo {
  filter: grayscale(0) contrast(1);
}

.hero__content { max-width: none; }
.hero__content p { max-width: none; }
.hero__subtitle {
  font-family: var(--font-heading);
  font-size: 0.8rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: var(--space-sm);
  text-wrap: balance;
}
.hero__name {
  font-size: clamp(2.2rem, 4.5vw, 3.8rem);
  margin-bottom: var(--space-sm);
  color: var(--text);
}
.hero__name span {
  display: block;
}
.hero__tagline {
  font-size: 1.1rem;
  color: var(--text-soft);
  font-style: italic;
  margin-bottom: var(--space-md);
}
.hero__divider {
  width: 48px;
  height: 1px;
  background: var(--border);
  margin-bottom: var(--space-md);
}
.hero__about-title {
  font-size: clamp(1.3rem, 2.5vw, 1.8rem);
  margin-bottom: var(--space-sm);
}
.hero__about-text p {
  margin-bottom: var(--space-sm);
  color: var(--text-soft);
}

/* --- Project Sections --- */
.project {
  align-items: center;
  padding: var(--space-xl) var(--space-lg);
}
.project__inner {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-lg);
  align-items: start;
  max-width: 1100px;
  width: 100%;
}
.project__inner--reverse { direction: rtl; }
.project__inner--reverse > * { direction: ltr; }

.project__number {
  font-family: var(--font-heading);
  font-size: 0.75rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: var(--space-xs);
}
.section--dark .project__number { color: rgba(250, 248, 244, 0.4); }

.project__title {
  margin-bottom: var(--space-sm);
}
.project__desc {
  color: var(--text-soft);
  margin-bottom: var(--space-md);
}
.section--dark .project__desc { color: rgba(250, 248, 244, 0.65); }

.project__tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
  list-style: none;
}
.project__tag {
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  padding: 0.3em 0.8em;
  border: 1px solid var(--border);
  border-radius: 2px;
  color: var(--text-muted);
  text-transform: uppercase;
  font-family: var(--font-heading);
  transition: transform var(--duration) var(--ease),
              border-color var(--duration) var(--ease),
              color var(--duration) var(--ease);
}
.project__tag:hover {
  transform: translateY(-2px);
  border-color: var(--accent-warm);
  color: var(--text);
}
.section--dark .project__tag {
  border-color: rgba(250, 248, 244, 0.15);
  color: rgba(250, 248, 244, 0.5);
}
.section--dark .project__tag:hover {
  border-color: var(--cream);
  color: var(--cream);
}

/* Every project visual reads as a print pinned to the page: a cream
   mat, a soft warm shadow, a hint of grain, a touch of imperfect tilt. */
.project__visual {
  position: relative;
  border-radius: 4px 4px 20px 4px;
  overflow: hidden;
  background: var(--bg-alt);
  aspect-ratio: 4 / 3;
  display: grid;
  place-items: center;
  transform: rotate(0.6deg);
  box-shadow:
    0 0 0 8px var(--cream),
    0 0 0 9px var(--border),
    0 22px 44px -16px rgba(47, 46, 44, 0.4);
  transition: transform var(--duration-slow) var(--ease);
}
#project-crm .project__visual { transform: rotate(-0.6deg); }
#project-eudreams .project__visual { transform: rotate(0.9deg); }
.project__visual:hover { transform: rotate(0.6deg) scale(1.015); }
#project-crm .project__visual:hover { transform: rotate(-0.6deg) scale(1.015); }
#project-eudreams .project__visual:hover { transform: rotate(0.9deg) scale(1.015); }

.project__visual::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.06;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 160px 160px;
}
.section--dark .project__visual {
  background: rgba(250, 248, 244, 0.06);
}

.project__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--duration-slow) var(--ease);
}
.project__visual:hover .project__img {
  transform: scale(1.04);
}

/* Portrait screenshots (app UI) need their own frame — a 4:3
   landscape box crops the content into an unreadable slice */
.project__visual--portrait {
  aspect-ratio: 2 / 3;
  max-width: 300px;
  margin: 0 auto;
}

/* Code snippet display inside project card */
.project__code {
  font-family: 'Courier New', monospace;
  font-size: 0.78rem;
  line-height: 1.6;
  color: var(--accent);
  white-space: pre;
  padding: var(--space-md);
  width: 100%;
  overflow-x: auto;
}
.section--dark .project__code { color: rgba(250, 248, 244, 0.7); }

/* --- Skills Section --- */
.skills {
  place-items: center;
  padding: var(--space-xl) var(--space-md);
}
.skills__inner {
  max-width: 900px;
  width: 100%;
}
.skills__inner h2 {
  margin-bottom: var(--space-lg);
  text-align: center;
}
.skills__grid {
  display: grid;
  /* Fukinsei — not a rigid grid, varied columns */
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-md);
}
.skills__group h3 {
  font-size: 0.8rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: var(--space-sm);
  font-family: var(--font-heading);
}
.skills__list {
  list-style: none;
}
.skills__list li {
  padding: 0.4em 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.95rem;
  color: var(--text-soft);
  transition: color var(--duration) var(--ease),
              transform var(--duration) var(--ease),
              border-color var(--duration) var(--ease);
}
.skills__list li:hover {
  color: var(--text);
  border-color: var(--accent-warm);
  transform: translateX(6px);
}

/* --- Contact / Footer --- */
.contact {
  place-items: center;
  text-align: center;
}
.contact__inner { max-width: 600px; }
.contact__inner h2 { margin-bottom: var(--space-sm); }
.contact__tagline {
  color: var(--text-muted);
  font-style: italic;
  margin: 0 auto var(--space-lg);
  font-size: 1.1rem;
}
.contact__links {
  display: flex;
  justify-content: center;
  gap: var(--space-md);
  list-style: none;
  margin-bottom: var(--space-lg);
}
.contact__link {
  position: relative;
  font-family: var(--font-heading);
  font-size: 0.8rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-soft);
  padding-bottom: 2px;
  transition: color var(--duration) var(--ease);
}
.contact__link::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 1px;
  background: var(--accent-warm);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform var(--duration-slow) var(--ease);
}
.contact__link:hover {
  opacity: 1;
  color: var(--text);
}
.contact__link:hover::after { transform: scaleX(1); }
.contact__email {
  display: inline-block;
  font-family: var(--font-heading);
  font-size: clamp(1.2rem, 3vw, 1.8rem);
  letter-spacing: 0.06em;
  color: var(--accent-warm);
  border: 1.5px solid var(--border);
  border-radius: 40px;
  padding: 0.6em 1.8em;
  transition: all var(--duration) var(--ease);
}
.contact__email:hover {
  opacity: 1;
  transform: scale(1.03);
  background: var(--accent-warm);
  color: var(--cream);
  border-color: var(--accent-warm);
}
.contact__footer {
  margin: var(--space-xl) auto 0;
  font-size: 0.75rem;
  color: var(--text-muted);
  letter-spacing: 0.08em;
}

/* --- Scroll-triggered reveal animations ---
   Signature motion: content "develops" into view like a print
   surfacing in a tray — soft-focus and sepia settle into place. */
.reveal {
  opacity: 0;
  transform: translateY(26px) scale(0.97);
  filter: blur(6px) sepia(0.45) saturate(0.7);
  transition: opacity 1s var(--ease),
              transform 1s var(--ease),
              filter 1.1s var(--ease);
}
.reveal.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  filter: blur(0) sepia(0) saturate(1);
}
/* Stagger children */
.reveal-stagger > .reveal:nth-child(2) { transition-delay: 0.1s; }
.reveal-stagger > .reveal:nth-child(3) { transition-delay: 0.2s; }
.reveal-stagger > .reveal:nth-child(4) { transition-delay: 0.3s; }
.reveal-stagger > .reveal:nth-child(5) { transition-delay: 0.4s; }

/* --- Responsive --- */
@media (max-width: 768px) {
  .nav { padding: var(--space-xs) var(--space-sm); }
  .indicator { display: none; }

  .hero {
    padding: var(--space-lg) var(--space-sm);
    text-align: center;
  }
  .hero__inner {
    grid-template-columns: 1fr;
    justify-items: center;
  }
  .hero__photo-frame {
    max-width: 240px;
    margin: 0 auto;
  }
  .hero__content { max-width: 100%; }

  .project { padding: var(--space-lg) var(--space-sm); }
  .project__inner,
  .project__inner--reverse {
    grid-template-columns: 1fr;
    direction: ltr;
  }

  .skills { padding: var(--space-lg) var(--space-sm); }
  .skills__grid { grid-template-columns: 1fr 1fr; }

  .contact { padding: var(--space-lg) var(--space-sm); }
  .contact__links { flex-direction: column; align-items: center; }

  .section { padding: var(--space-lg) var(--space-sm); }
}

@media (max-width: 480px) {
  .skills__grid { grid-template-columns: 1fr; }
  h1 { font-size: 2.4rem; }
}

/* --- Respect reduced-motion preference --- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .reveal { opacity: 1; transform: none; filter: none; }
}
