/* Zortcode landing — warm paper + ink design system */

@font-face {
  font-family: "Fraunces";
  src: url("fonts/fraunces-600.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

:root {
  --paper: #FAF6EF;
  --ink: #1A1F2B;
  --terracotta: #D96F32;
  --terracotta-dark: #B85A24;
  --terracotta-text: #A8501F;       /* AA on paper for normal text */
  --terracotta-text-hover: #8F441B;
  --sage: #5F6F63;
  --line: rgba(26, 31, 43, 0.12);
  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background-color: var(--paper);
  /* Subtle paper grain, inline so nothing external is fetched */
  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='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='0.025'/%3E%3C/svg%3E");
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.15; }

a { color: var(--terracotta-text); }
a:hover { color: var(--terracotta-text-hover); }

:focus-visible {
  outline: 3px solid var(--terracotta);
  outline-offset: 3px;
  border-radius: 2px;
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 0.85rem clamp(1rem, 4vw, 2.5rem);
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
}

.wordmark {
  font-family: var(--serif);
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: -0.01em;
}
.semi { color: var(--terracotta); }
.cursor {
  display: inline-block;
  width: 0.55em;
  height: 0.12em;
  margin-left: 0.08em;
  background: var(--terracotta);
  vertical-align: baseline;
  animation: blink 1.2s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.site-nav { display: none; gap: 1.4rem; margin-left: auto; }
.site-nav a {
  color: var(--ink);
  text-decoration: none;
  font-size: 0.95rem;
}
.site-nav a:hover { color: var(--terracotta-text); }

.lang-switch { margin-left: auto; display: flex; align-items: center; gap: 0.3rem; }
.lang-sep { color: var(--sage); }
.lang-btn {
  border: 0;
  background: none;
  padding: 0.25rem 0.35rem;
  font: inherit;
  font-size: 0.9rem;
  color: var(--sage);
  cursor: pointer;
}
.lang-btn[aria-pressed="true"] {
  color: var(--ink);
  font-weight: 700;
  text-decoration: underline;
  text-decoration-color: var(--terracotta);
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
}

/* Layout */
main { max-width: 68rem; margin: 0 auto; padding: 0 clamp(1rem, 4vw, 2.5rem); }
.section { padding: clamp(2.5rem, 7vw, 4.5rem) 0; border-top: 1px solid var(--line); scroll-margin-top: 5rem; }

/* Hero */
.hero { padding: clamp(3.5rem, 10vw, 7rem) 0 clamp(2.5rem, 7vw, 4.5rem); }
.hero h1 {
  margin: 0 0 1.2rem;
  font-size: clamp(2.1rem, 6vw, 3.6rem);
  max-width: 18ch;
}
.hero-sub-line { color: var(--sage); }
.hero-sub { max-width: 56ch; font-size: clamp(1.05rem, 2.2vw, 1.2rem); margin: 0 0 2rem; }
.hero-ctas { display: flex; flex-wrap: wrap; gap: 0.9rem; }

/* Buttons */
.btn {
  display: inline-block;
  padding: 0.75rem 1.5rem;
  border-radius: 999px;
  text-decoration: none;
  font-weight: 600;
  border: 2px solid transparent;
  transition: transform 0.15s ease, background-color 0.15s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--terracotta-text); color: var(--paper); }
.btn-primary:hover { background: var(--terracotta-text-hover); color: var(--paper); }
.btn-ghost { border-color: var(--ink); color: var(--ink); }
.btn-ghost:hover { border-color: var(--terracotta); color: var(--terracotta-text); }
.btn-mail { font-family: var(--serif); font-size: 1.15rem; }

/* Sections */
h2 { font-size: clamp(1.6rem, 4vw, 2.3rem); margin: 0 0 1.5rem; }
h3 { font-size: 1.25rem; margin: 0 0 0.6rem; }

.kicker {
  margin: 0 0 0.8rem;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--sage);
}

.cards { display: grid; gap: 1.2rem; grid-template-columns: 1fr; }
.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1.6rem;
}
.card p { margin: 0; }

/* Projects carousel.

   With JS the track is moved by `transform`, which is what makes an endless
   loop possible: the jump from a clone back to the real slide has to happen
   with no animation, and native scrolling fights that because scroll-snap
   re-adjusts the offset behind your back.

   Without JS the track falls back to a plain scrollable row (see the
   .carousel-track:not([data-live]) rule below), so the section still works. */
.carousel { position: relative; overflow: hidden; }
.carousel-track {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  gap: 1.2rem;
}
.carousel-track:not([data-live]) {
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.carousel-track:not([data-live])::-webkit-scrollbar { display: none; }
.carousel-track:not([data-live]) > .carousel-slide { scroll-snap-align: center; }
/* Driven by JS: no transition while the finger is down, one while it settles. */
.carousel-track[data-live] {
  will-change: transform;
  touch-action: pan-y;
  cursor: grab;
}
.carousel-track[data-live][data-animating] {
  transition: transform 0.42s cubic-bezier(0.22, 0.61, 0.36, 1);
}
.carousel-track[data-live][data-dragging] { cursor: grabbing; }
/* A drag must not leave the browser's own image/link ghost behind. */
.carousel-track[data-live] img { -webkit-user-drag: none; user-select: none; }
.carousel-slide {
  flex: 0 0 88%;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
}
.project-info { padding: 1.3rem 1.6rem 1.6rem; }
.project-info h3 { margin-bottom: 0.5rem; }
.project-info p { margin: 0 0 0.9rem; max-width: 62ch; }

/* Wide screens: screenshot beside the text rather than above it.

   Stacked, a card runs past 1100px and the section no longer fits a 13"
   laptop; side by side it lands near 600px and uses width that was going
   spare. Below this breakpoint the stacked layout is the better shape. */
@media (min-width: 900px) {
  .carousel-slide {
    display: grid;
    grid-template-columns: 1.35fr 1fr;
    align-items: stretch;
  }
  .carousel-slide > .shots { height: 100%; }
  .shots-track > .carousel-slide { display: block; }
  .shots-track img {
    height: 100%;
    /* Caps the card's height on short, wide screens; the 16/10 aspect-ratio
       still governs on taller ones. */
    max-height: 58vh;
    object-fit: cover;
  }
  .project-info {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 1.6rem 2rem;
  }
  .project-info p { margin-bottom: 1.1rem; }
}
.carousel-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.1rem;
  margin-top: 1.1rem;
}
.carousel-controls[hidden] { display: none; }
.carousel-btn {
  width: 2.6rem;
  height: 2.6rem;
  border-radius: 50%;
  border: 2px solid var(--ink);
  background: none;
  color: var(--ink);
  font: inherit;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}
.carousel-btn:hover { border-color: var(--terracotta); color: var(--terracotta-text); }
.carousel-dots { display: flex; gap: 0.55rem; }
.carousel-dot {
  width: 0.7rem;
  height: 0.7rem;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--line);
  cursor: pointer;
}
.carousel-dot[aria-current="true"] { background: var(--terracotta); }

/* Inner carousel: the screenshots of a single project */
.shots { position: relative; background: #0a1410; overflow: hidden; }
.shots-track {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  /* Horizontal drags inside the image move only this track, never the outer
     one — the JS stops the gesture from propagating past this carousel. */
  touch-action: pan-y;
}
.shots-track > .carousel-slide {
  flex: 0 0 100%;
  scroll-snap-align: center;
  background: none;
  border: 0;
  border-radius: 0;
}
.shots-track img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  border-bottom: 1px solid var(--line);
}
/* The controls box is only a grouping element: its children position
   themselves against .shots. `display: contents` would break the `hidden`
   attribute in some engines, so keep a real box that covers nothing. */
.shot-controls {
  /* Overrides .carousel-controls, whose flex layout and margin belong to the
     outer carousel only. This block must come after it in the stylesheet. */
  position: absolute;
  inset: 0;
  display: block;
  margin: 0;
  pointer-events: none;
}
.shot-controls[hidden] { display: none; }
.shot-controls > * { pointer-events: auto; }
.shot-dots {
  position: absolute;
  left: 50%;
  bottom: 0.8rem;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.38rem 0.6rem;
  border-radius: 999px;
  background: rgba(10, 12, 16, 0.55);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
.shot-dot {
  width: 0.45rem;
  height: 0.45rem;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.45);
  cursor: pointer;
  transition: width 0.18s ease, background 0.18s ease;
}
.shot-dot[aria-current="true"] {
  width: 1.25rem;
  border-radius: 999px;
  background: #fff;
}
.shot-btn {
  /* Resets .carousel-btn's ink border and outer sizing. */
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 2.4rem;
  height: 2.4rem;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(10, 12, 16, 0.5);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  color: #fff;
  font: inherit;
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.18s ease;
}
.shots:hover .shot-btn { opacity: 1; }
.shot-btn:focus-visible { opacity: 1; }
/* Disabled arrows fade out entirely; on hover they linger as a faint hint
   that this is the first or last screenshot. */
.shot-btn[data-dir="-1"] { left: 0.7rem; }
.shot-btn[data-dir="1"] { right: 0.7rem; }
.more-note { color: var(--sage); font-style: italic; margin: 1.2rem 0 0; }

.about-body { max-width: 62ch; }

.section-contact { padding-bottom: clamp(3.5rem, 9vw, 6rem); }
.section-contact p { max-width: 56ch; margin-bottom: 1.6rem; }

/* Footer */
.site-footer {
  border-top: 1px solid var(--line);
  padding: 1.8rem clamp(1rem, 4vw, 2.5rem);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.8rem 2rem;
  font-size: 0.92rem;
  color: var(--sage);
}
.site-footer p { margin: 0; }
.site-footer .lang-switch { margin-left: auto; }

/* Wide screens: lay the prose and the form out across the available width
   instead of down the page, so each section fits a laptop viewport. */
@media (min-width: 900px) {
  .about-body { max-width: none; }
  #sobre { column-count: 2; column-gap: 3rem; }
  /* The heading must span both columns rather than sit inside the first. */
  #sobre h2 { column-span: all; }
  #sobre .about-body { break-inside: avoid; }

  .section-contact {
    display: grid;
    grid-template-columns: 1fr 1.15fr;
    /* Intro and e-mail take only the height they need; the spare space falls
       to a third, empty row so the two stay together at the top. */
    grid-template-rows: auto auto auto 1fr;
    column-gap: 3rem;
    /* The generous bottom padding is what pushes this past a 768px laptop. */
    padding-bottom: clamp(2rem, 5vw, 3.5rem);
  }
  /* The heading spans both columns, but its hand-drawn underline is sized to
     the element, so it must stay as wide as the words themselves. */
  .section-contact h2 { grid-column: 1 / -1; justify-self: start; }
  /* Intro and e-mail read as one block at the top of the left column rather
     than drifting apart across its full height. */
  .section-contact > p { grid-column: 1; align-self: start; margin-top: 0; margin-bottom: 0.9rem; }
  .section-contact .contact-form { grid-column: 2; grid-row: 2 / span 3; margin-bottom: 0; }
  .section-contact .contact-alt { align-self: start; margin-top: 0; }
}

/* Contact form */
.contact-form {
  display: grid;
  gap: 0.45rem;
  max-width: 34rem;
  margin-bottom: 1.6rem;
}
.contact-form label {
  font-weight: 600;
  font-size: 0.95rem;
  margin-top: 0.6rem;
}
.contact-form input,
.contact-form textarea {
  font: inherit;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.65rem 0.8rem;
}
.contact-form textarea { resize: vertical; }
.contact-form button {
  margin-top: 0.9rem;
  justify-self: start;
}
.contact-form button:disabled {
  opacity: 0.6;
  cursor: default;
  transform: none;
}
.cf-hp {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
}
#cf-status { margin: 0.4rem 0 0; min-height: 1.4em; }
.cf-ok { color: var(--sage); font-weight: 600; }
.cf-error { color: var(--terracotta-text); font-weight: 600; }
.contact-alt { color: var(--sage); font-size: 0.95rem; }

/* Imperfect artisan underline for section headings */
.section > h2 {
  display: table;
  position: relative;
}
.section > h2::after {
  content: "";
  position: absolute;
  left: -2px;
  right: -6px;
  bottom: 0.05em;
  height: 0.28em;
  background: var(--terracotta);
  opacity: 0.25;
  border-radius: 2px;
  transform: rotate(-0.6deg);
}

@media (min-width: 720px) {
  .site-nav { display: flex; }
  .cards { grid-template-columns: 1fr 1fr; }
  .site-nav ~ .lang-switch { margin-left: 0; }
}

/* Short viewports — laptops at 720/768px, phones in landscape. Section padding
   is sized from the viewport *width*, so on a wide-but-short screen it grows
   just where there is least room. Trim it so each section still fits. */
@media (max-height: 800px) and (min-width: 900px) {
  .section { padding: clamp(1.75rem, 4vh, 3rem) 0; }
  .section-contact { padding-bottom: clamp(1.5rem, 3vh, 2.5rem); }
  .shots-track img { max-height: 46vh; }
}

/* Section snapping: scrolling settles with a section's heading at the top
   rather than stranding the reader between two of them.

   Deliberately limited to wide screens. Snapping only helps when the section
   actually fits the viewport; where it does not — phones, where the prose
   sections legitimately run longer than a screen — an over-eager magnet
   traps the reader against content they cannot reach. `proximity` rather
   than `mandatory` for the same reason: it nudges, and it lets go if someone
   wants to stop mid-section. */
@media (min-width: 900px) {
  html { scroll-snap-type: y proximity; }
  .section, .hero { scroll-snap-align: start; }
  /* The sticky header would otherwise cover the heading a section snaps to. */
  .section, .hero { scroll-snap-margin-top: 4.5rem; scroll-margin-top: 4.5rem; }
  /* A section taller than the viewport must not be held by the magnet. */
  .site-footer { scroll-snap-align: end; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-snap-type: none; }
}

@media (max-width: 640px) {
  .carousel-slide { flex-basis: 92%; }
  /* Touch devices have no hover, so the inner arrows would never appear. */
  .shot-btn { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .cursor { animation: none; }
  .btn { transition: none; }
  .btn:hover { transform: none; }
  .carousel-track { scroll-behavior: auto; }
}
