/* ==========================================================================
   Iago Santana — portfolio
   Visual language inspired by rog.ie: paper background, narrow column,
   serif display type, quiet list UI with tactile hover states.
   ========================================================================== */

@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600&family=Instrument+Serif:ital@0;1&family=Freeman&display=swap");

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

@view-transition { navigation: auto; }

:root {
  --color-text: rgba(0, 0, 0, 0.82);
  --color-text-secondary: #646048;
  --color-text-tertiary: #87836d;
  --color-bg: #fffdf5;
  --color-bg-secondary: #fff;
  --color-bg-inset: rgba(0, 0, 0, 0.05);
  --color-border: rgba(0, 0, 0, 0.1);
  --accent: #ff6a2b;
  --radius: 0.5rem;
  --shadow: 0 0 0 1px rgba(0, 0, 0, 0.05), 0 2.5px 2px -1px rgba(0, 0, 0, 0.075);
  --shadow-inset: inset 0 0 0 1px rgba(0, 0, 0, 0.05), 0 1px 0.5px rgba(255, 255, 255, 1);
  --shadow-media: 0 0 0 1px rgba(0, 0, 0, 0.06), 0 4px 2px -3px rgba(0, 0, 0, 0.1);
  --font-heading: "Freeman", "Arial Narrow", "Helvetica Neue", sans-serif;
  --font-serif: "Instrument Serif", Georgia, serif;
  --font-sans: "Poppins", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --column: 32rem; /* home */
  color-scheme: light only;
}

::selection { background: var(--color-text); color: var(--color-bg); }

html {
  background-color: var(--color-bg);
  /* paper grain */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1.3' numOctaves='4' stitchTiles='stitch'/%3E%3CfeColorMatrix type='matrix' values='0 0 0 0 0.35 0 0 0 0 0.32 0 0 0 0 0.2 0 0 0 0.09 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 140px 140px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  text-wrap: pretty;
  padding: 0 4rem;
  overflow-x: hidden;
}

body {
  font-family: var(--font-sans);
  font-size: 0.875rem;
  line-height: 1.6;
  color: var(--color-text-secondary);
  max-width: var(--column);
  margin: 0 auto;
  background: transparent; /* the paper texture lives on <html> */
  padding: 4rem 0 0;
}
body.case { --column: 41.6rem; } /* case pages: 32rem + 30% */

a {
  color: var(--color-text);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.12em;
  text-decoration-color: rgba(0, 0, 0, 0.3);
  transition: text-decoration-color 0.15s;
}
a:hover { text-decoration-color: var(--color-text); }

p { margin-bottom: 1rem; }

h1, h2, h3, strong, dt { font-weight: 400; color: var(--color-text); }
h1, h2 {
  font-family: var(--font-heading);
  letter-spacing: -0.8px;
  line-height: 1.15;
  text-wrap: balance;
}
.page-intro, blockquote {
  font-family: var(--font-serif);
  letter-spacing: -0.01em;
  line-height: 1.25;
}
h1 { font-size: 2rem; margin-bottom: 1rem; }
h2 { font-size: 1.5rem; margin-bottom: 0.5rem; }
h3 { font-size: 0.875rem; font-weight: 500; margin-bottom: 0.25rem; }

.page-intro { font-size: 1.3rem; color: var(--color-text); margin-bottom: 1rem; }
.page-intro a { font-weight: 400; }

section { margin-top: 3rem; }
section > p:last-child { margin-bottom: 0; }

.eyebrow {
  display: block;
  font-size: 0.75rem;
  color: var(--color-text-tertiary);
  margin-bottom: 0.25rem;
}

/* --------------------------------------------------------------------------
   Home header
   -------------------------------------------------------------------------- */

header.home { position: relative; }

/* illustration centered at the top of the home page */
.hero-illustration {
  display: block;
  width: min(14.4rem, 60%);
  margin: -1.5rem auto 3rem;
}
.hero-illustration img {
  display: block;
  width: 100%;
  height: auto;
}

.greeting { display: inline-block; min-width: 2.2ch; }

/* playful wave text ("building with AI") */
.vibe {
  font-style: italic;
  color: var(--color-text);
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32' viewBox='0 0 32 32'%3E%3Ctext x='4' y='24' font-size='22'%3E%E2%9C%A8%3C/text%3E%3C/svg%3E") 8 8, auto;
  white-space: nowrap;
}
.vibe span { display: inline-block; transition: color 0.3s; }
.vibe:hover span {
  animation: wave 0.9s ease-in-out infinite;
  animation-delay: calc(var(--i) * 60ms);
  color: hsl(calc(var(--i) * 32 + 10) 90% 50%);
}
@keyframes wave {
  0%, 100% { translate: 0 0; }
  30% { translate: 0 -0.22em; }
  60% { translate: 0 0.05em; }
}

/* --------------------------------------------------------------------------
   Post list (projects)
   -------------------------------------------------------------------------- */

.post-list { list-style: none; }
.post-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  margin: 0 -0.75rem;
  border-radius: var(--radius);
  text-decoration: none;
  white-space: nowrap;
}
.post-link:hover { background: var(--color-bg-secondary); box-shadow: var(--shadow); }
.post-link:active { background: var(--color-bg-inset); box-shadow: var(--shadow-inset); }
.post-icon {
  flex-shrink: 0;
  width: 1.25rem;
  height: 1.25rem;
  color: var(--color-text);
  opacity: 0.35;
  transition: opacity 0.15s;
}
.post-link:hover .post-icon { opacity: 0.8; }
.post-title { font-size: 0.875rem; font-weight: 400; margin: 0; }
.post-type { display: none; margin-left: -0.25rem; color: var(--color-text-tertiary); }
.post-link:hover .post-type { display: inline; }
.post-separator { flex: 1; height: 1px; background: var(--color-border); }
.post-meta { color: var(--color-text-tertiary); }
.post-link[target="_blank"] .post-meta::after { content: " ↗"; }

/* floating preview that follows the cursor over the list */
.hover-preview {
  position: fixed;
  top: 0;
  left: 0;
  width: 15rem;
  aspect-ratio: 4 / 3;
  border-radius: var(--radius);
  overflow: hidden;
  pointer-events: none;
  z-index: 50;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.06), 0 12px 24px -8px rgba(0, 0, 0, 0.25);
  opacity: 0;
  scale: 0.9;
  transition: opacity 0.2s, scale 0.25s cubic-bezier(0.3, 1.4, 0.5, 1);
  background: var(--color-bg-secondary);
}
.hover-preview.is-visible { opacity: 1; scale: 1; }
.hover-preview img, .hover-preview video { width: 100%; height: 100%; object-fit: cover; display: block; }
@media (hover: none) { .hover-preview { display: none; } }

/* --------------------------------------------------------------------------
   Media
   -------------------------------------------------------------------------- */

.media {
  display: block;
  position: relative;
  margin: 1.5rem 0;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--color-bg-secondary);
  box-shadow: var(--shadow-media);
}
.media img, .media video { display: block; width: 100%; height: auto; }
.media.zoomable { cursor: zoom-in; }
figcaption, .caption {
  display: block;
  font-size: 0.75rem;
  color: var(--color-text-tertiary);
  text-align: center;
  margin: -0.75rem 0 1.5rem;
}

.media.narrow { max-width: 18rem; margin-inline: auto; }
/* sits straight on the page paper: no card */
.media.bare { background: none; box-shadow: none; border-radius: 0; overflow: visible; }

/* media stays inside the same column as the home page */
.wide { width: 100%; }

.grid { display: grid; gap: 0.75rem; margin: 1.5rem 0; }
.grid .media { margin: 0; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 560px) { .grid-3 { grid-template-columns: repeat(2, 1fr); } }

/* horizontal shots strip, kept inside the content column */
.shots {
  display: flex;
  gap: 0.75rem;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding: 0.5rem 2px 1rem;
  margin: 1rem -2px 0;
  scroll-padding-inline: 2px;
  scrollbar-width: none;
}
.shots::-webkit-scrollbar { display: none; }
.shots .media {
  flex: 0 0 auto;
  width: min(26rem, 85%);
  margin: 0;
  scroll-snap-align: start;
  transition: rotate 0.3s cubic-bezier(0.3, 1.6, 0.5, 1), translate 0.3s cubic-bezier(0.3, 1.6, 0.5, 1);
}
.shots .media:nth-child(odd):hover { rotate: -1.5deg; translate: 0 -4px; }
.shots .media:nth-child(even):hover { rotate: 1.5deg; translate: 0 -4px; }
.shots .media img { aspect-ratio: 16 / 9; object-fit: cover; }

/* --------------------------------------------------------------------------
   About / definition lists
   -------------------------------------------------------------------------- */

.facts { display: grid; grid-template-columns: 6.5rem 1fr; gap: 0.6rem 1rem; margin: 1rem 0; }
.facts dt { color: var(--color-text); }
.facts dd { color: var(--color-text-secondary); }

.photo {
  rotate: 1.5deg;
  border: 0.375rem solid var(--color-bg-secondary);
  transition: rotate 0.4s cubic-bezier(0.3, 1.6, 0.5, 1);
}
.photo:hover { rotate: -1deg; }

/* --------------------------------------------------------------------------
   Case study pages
   -------------------------------------------------------------------------- */

header.page-header { position: relative; margin-bottom: 1rem; }
header.page-header h1 { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.5rem; }
header.page-header h1 svg { width: 1.5rem; height: 1.5rem; opacity: 0.45; flex-shrink: 0; }

.back {
  position: absolute;
  left: -3.25rem;
  top: 0.1rem;
  width: 2rem;
  height: 2rem;
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  color: var(--color-text-tertiary);
  text-decoration: none;
}
.back:hover { background: var(--color-bg-secondary); box-shadow: var(--shadow); color: var(--color-text); }
.back:active { background: var(--color-bg-inset); box-shadow: var(--shadow-inset); }
.back svg { width: 1rem; height: 1rem; }

.overview {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem 1.5rem;
  padding: 1.25rem 0;
  margin: 1.5rem 0;
  border-top: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
}
.overview dt { font-size: 0.75rem; color: var(--color-text-tertiary); margin-bottom: 0.15rem; }
.overview dd { color: var(--color-text); }

ul.bullets { list-style: none; margin: 0 0 1rem; }
ul.bullets li { position: relative; padding-left: 1.1rem; margin-bottom: 0.4rem; }
ul.bullets li::before {
  content: "";
  position: absolute;
  left: 0.15rem;
  top: 0.62em;
  width: 0.35rem;
  height: 0.35rem;
  border-radius: 50%;
  background: var(--color-text-tertiary);
  opacity: 0.6;
}

blockquote {
  position: relative;
  font-size: 1.4rem;
  color: var(--color-text);
  margin: 2rem 0;
  hanging-punctuation: first last;
}
blockquote::before {
  content: "“";
  position: absolute;
  right: calc(100% + 0.4rem);
  top: -0.1em;
  font-size: 3rem;
  line-height: 1;
  color: var(--color-text-tertiary);
  opacity: 0.5;
}
blockquote cite {
  display: block;
  margin-top: 0.4rem;
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  font-style: normal;
  color: var(--color-text-tertiary);
}
blockquote cite::before { content: "~ "; }

.cards { display: grid; gap: 0.75rem; margin: 1.5rem 0; }
.card {
  background: var(--color-bg-secondary);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem;
}
.card p { margin: 0; }
.card h3 { margin-bottom: 0.2rem; }

.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.75rem; margin: 1.5rem 0; }
.stat {
  background: var(--color-bg-secondary);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem;
}
.stat strong {
  display: block;
  font-family: var(--font-heading);
  letter-spacing: -0.8px;
  font-size: 2.25rem;
  line-height: 1;
  margin-bottom: 0.4rem;
  color: var(--color-text);
}
.stat small { display: block; font-size: 0.75rem; color: var(--color-text-tertiary); margin-bottom: 0.1rem; }
.stat p { margin: 0; font-size: 0.8125rem; }

/* feature tiles (image + copy) */
.features { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.5rem 1rem; margin: 1.5rem 0; }
.feature .media { margin: 0 0 0.75rem; }
.feature p { margin: 0; font-size: 0.8125rem; }
@media (max-width: 480px) { .features { grid-template-columns: 1fr; } }

/* link tiles (e.g. chart libraries) */
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.75rem; margin: 1.5rem 0; }
.tile {
  display: block;
  text-decoration: none;
  border-radius: var(--radius);
  padding: 0.5rem 0.5rem 0.6rem;
  text-align: center;
  font-size: 0.8125rem;
}
.tile:hover { background: var(--color-bg-secondary); box-shadow: var(--shadow); }
.tile img { width: 100%; border-radius: calc(var(--radius) - 2px); display: block; margin-bottom: 0.4rem; box-shadow: var(--shadow-media); }
@media (max-width: 480px) { .tiles { grid-template-columns: repeat(2, 1fr); } }

.button {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 1rem;
  border-radius: 999px;
  background: var(--color-text);
  color: var(--color-bg);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.8125rem;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.2);
  transition: translate 0.15s, box-shadow 0.15s;
}
.button:hover { translate: 0 -1px; box-shadow: 0 3px 0 rgba(0, 0, 0, 0.2); color: var(--color-bg); }
.button:active { translate: 0 1px; box-shadow: none; }
.button svg { width: 1rem; height: 1rem; }

.next {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--color-border);
}

/* --------------------------------------------------------------------------
   Footer
   -------------------------------------------------------------------------- */

footer {
  margin-top: 4rem;
  padding: 2rem 0 3rem;
  border-top: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.25rem;
}
footer .signature { font-family: var(--font-heading); letter-spacing: -0.8px; font-size: 1.4rem; color: var(--color-text); }
footer .social { display: inline-flex; gap: 1rem; margin-top: 0.75rem; list-style: none; }
footer .social a { display: grid; place-items: center; width: 1.25rem; height: 1.25rem; color: var(--color-text-tertiary); }
footer .social a:hover { color: var(--color-text); }
footer .social svg { width: 1rem; height: 1rem; }
footer small { color: var(--color-text-tertiary); font-size: 0.75rem; margin-top: 0.5rem; }

/* --------------------------------------------------------------------------
   Lightbox
   -------------------------------------------------------------------------- */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  /* fixed track sizes so max-height: 100% resolves against the viewport,
     not against the image's own height */
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  place-items: center;
  padding: max(2rem, env(safe-area-inset-top, 0px)) max(2rem, env(safe-area-inset-right, 0px))
    max(2rem, env(safe-area-inset-bottom, 0px)) max(2rem, env(safe-area-inset-left, 0px));
  background: rgba(255, 253, 245, 0.92);
  backdrop-filter: blur(6px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  cursor: zoom-out;
}
.lightbox.is-open { opacity: 1; pointer-events: auto; }
.lightbox img, .lightbox video {
  width: auto;
  height: auto;
  object-fit: contain;
  max-width: 100%;
  max-height: 100%;
  border-radius: var(--radius);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.06), 0 24px 48px -12px rgba(0, 0, 0, 0.3);
  scale: 0.96;
  transition: scale 0.25s cubic-bezier(0.3, 1.4, 0.5, 1);
}
.lightbox.is-open img, .lightbox.is-open video { scale: 1; }

/* --------------------------------------------------------------------------
   Small screens
   -------------------------------------------------------------------------- */

@media (max-width: 640px) {
  html { padding: 0 1.5rem; }
  body { padding-top: 2.5rem; }
  .back { position: static; margin: 0 0 0.75rem -0.5rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
