/* ============================================================
   Matheus Teixeira — portfolio
   Direction: dark minimal, logistics vernacular.
   Three tones + one hi-vis signal. Hairlines, never cards.
   ============================================================ */

:root {
  /* Ground is a cool slate, text is warm chalk — the contrast
     between the two temperatures is what keeps pure-black flatness away. */
  --void: #0A0B0D;
  --raise: #101216;
  --rule: #1C1F24;
  --rule-lit: #2E333B;
  --chalk: #E9E7E2;
  --graphite: #767B83;

  /* The only accent on the page. Forklift beacons, hi-vis vests. */
  --signal: #F2B138;

  /* One deliberate exception to the signal-only rule: green reads
     universally as "live", amber doesn't carry that meaning. */
  --live: #3ECF6E;

  --display: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --sans: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Consolas, monospace;

  --gutter: clamp(1.5rem, 5vw, 3rem);

  /* The shell is wide so the hairlines and the date column carry the layout.
     Prose keeps its own, narrower measure — widening the container should not
     stretch paragraphs past a comfortable line length. */
  --measure: 64rem;
  --prose: 42rem;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--void);
  color: var(--chalk);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img {
  display: block;
  max-width: 100%;
  height: auto;
}

a {
  color: inherit;
}

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

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  padding: 0.75rem 1rem;
  background: var(--signal);
  color: var(--void);
  font-family: var(--mono);
  font-size: 0.75rem;
  text-decoration: none;
}

.skip-link:focus {
  left: 0;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* ---------- The mono data layer ----------
   Dates, tags, section metadata. Monospace is the native
   typeface of the systems this work actually runs on. */
.label {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.6875rem;
  font-weight: 500;
  line-height: 1.4;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--graphite);
}

.status-dot {
  position: relative;
  display: inline-block;
  width: 5px;
  height: 5px;
  margin-left: 0.9em;
  border-radius: 50%;
  background: var(--live);
  vertical-align: middle;
}

.status-dot::before {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  background: var(--live);
  opacity: 0.55;
  animation: status-pulse 1.8s ease-out infinite;
}

@keyframes status-pulse {
  0% {
    transform: scale(0.6);
    opacity: 0.55;
  }

  100% {
    transform: scale(1.9);
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .status-dot::before {
    animation: none;
    opacity: 0;
  }
}

/* ---------- Rail nav ----------
   Sticky top bar by default (phones through laptops), promoted to a
   fixed vertical rail once the viewport can spare a margin for it. */
.rail {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(10, 11, 13, 0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--rule);
}

/* Keeps the nav list and the language toggle as one row that's centred
   and capped like the rest of the page, while .rail's own background
   stays full-bleed behind it. */
.rail-inner {
  display: flex;
  align-items: center;
  max-width: var(--measure);
  margin: 0 auto;
}

.rail-list {
  display: flex;
  flex: 1 1 auto;
  /* Lets the list shrink below its content width instead of pushing the
     toggle off the edge — that's what makes it scrollable, not overlapped. */
  min-width: 0;
  gap: 1.4rem;
  margin: 0;
  padding: 0.95rem 1rem 0.95rem var(--gutter);
  list-style: none;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  /* Fades the edges so a scrollable nav reads as scrollable, not cut off. */
  -webkit-mask-image: linear-gradient(to right, transparent, black 1.25rem, black calc(100% - 1.25rem), transparent);
  mask-image: linear-gradient(to right, transparent, black 1.25rem, black calc(100% - 1.25rem), transparent);
}

.rail-list::-webkit-scrollbar {
  display: none;
}

.rail-list li {
  flex: none;
}

.rail-link {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--graphite);
  text-decoration: none;
  transition: color 0.2s ease, transform 0.2s ease;
}

.rail-link:hover {
  color: var(--chalk);
}

.rail-link.is-active {
  color: var(--signal);
}

/* ---------- Language toggle ---------- */
.lang-toggle {
  /* A normal flex sibling of the nav list inside the sticky bar — it never
     overlaps nav text this way. Goes back to a fixed, independent position
     once the rail becomes a floating sidebar (see the wide-viewport query). */
  flex: none;
  margin-right: var(--gutter);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.7rem;
  background: rgba(10, 11, 13, 0.75);
  backdrop-filter: blur(8px);
  border: 1px solid var(--rule);
  color: var(--graphite);
  font-family: var(--mono);
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  cursor: pointer;
  transition: border-color 0.2s ease;
}

.lang-toggle:hover {
  border-color: var(--rule-lit);
}

.lang-current {
  color: var(--chalk);
}

.lang-sep,
.lang-other {
  color: var(--graphite);
}

/* ---------- Shell ---------- */
.shell {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

/* Anchors must clear the sticky bar. */
main section[id] {
  scroll-margin-top: 4.25rem;
}

/* ---------- Intro ---------- */
.intro {
  padding: clamp(3.5rem, 12vh, 6.5rem) 0 clamp(3.5rem, 9vh, 5.5rem);
}

.wordmark {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(3rem, 11vw, 5.75rem);
  font-weight: 800;
  line-height: 0.88;
  letter-spacing: -0.04em;
}

.role {
  margin: 1.5rem 0 0;
  min-height: 1.4em;
  font-family: var(--display);
  font-size: clamp(1.125rem, 3.2vw, 1.625rem);
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.015em;
  color: var(--signal);
}

/* Split-flap: each glyph is its own cell, like a dispatch board. */
.flip {
  display: inline-block;
  white-space: pre;
}

/* Keeps a word's cells on one line — the line can still wrap between
   words, just never in the middle of one. */
.flip-word {
  display: inline-block;
  white-space: nowrap;
}

.flip.is-settling {
  color: var(--graphite);
}

.bio {
  max-width: var(--prose);
  margin: 2rem 0 0;
  font-size: 1.0625rem;
  line-height: 1.7;
  color: #B9B7B2;
}

/* Word-level settle behind the flip line */
.bio .word {
  display: inline-block;
  white-space: pre;
}

/* ---------- Actions ---------- */
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 2.25rem;
}

.action {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.7rem 1.15rem;
  border: 1px solid var(--rule-lit);
  color: var(--chalk);
  font-family: var(--mono);
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-decoration: none;
  transition: border-color 0.18s ease, color 0.18s ease, background-color 0.18s ease;
}

.action svg {
  width: 14px;
  height: 14px;
  flex: none;
}

.action:hover {
  border-color: var(--signal);
  color: var(--signal);
}

.action-primary {
  background: var(--chalk);
  border-color: var(--chalk);
  color: var(--void);
}

.action-primary:hover {
  background: var(--signal);
  border-color: var(--signal);
  color: var(--void);
}

/* ---------- Sections ---------- */
.section {
  padding: clamp(3rem, 8vh, 4.5rem) 0 0;
}

/* Scroll reveal. The section carries the coarse fade; each ledger row and
   project then settles on its own as you reach it, so a long section
   keeps moving instead of arriving all at once. */
.js .section {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.js .section.is-visible {
  opacity: 1;
  transform: none;
}

.js .ledger>li,
.js .projects>li {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.js .ledger>li.is-visible,
.js .projects>li.is-visible {
  opacity: 1;
  transform: none;
}

.js .about,
.js .socials {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.js .about.is-visible,
.js .socials.is-visible {
  opacity: 1;
  transform: none;
}

.rule-head {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--rule-lit);
}

.sub-head {
  margin-top: 3rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--rule);
}

/* ---------- Projects ----------
   A sparse index: hairline, number, name, one line of what it is.
   The whole row is the link, so the arrow is affordance, not a target. */
/* Each row carries its own product's accent, taken from that product's live site:
   Aura's --primary (hsl 217 91% 60%), Diffluent's --accent, Postlight's --accent.
   All three clear 3:1 against the page ground, so they can carry the hover state. */
.project[data-accent="aura"] {
  --project-accent: #3C83F6;
}

.project[data-accent="diffluent"] {
  --project-accent: #FB923C;
}

.project[data-accent="postlight"] {
  --project-accent: #F5B040;
}

.projects {
  margin: 0;
  padding: 0;
  list-style: none;
}

.projects>li+li .project {
  border-top: 1px solid var(--rule);
}

.project {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 0.5rem 1.5rem;
  padding: clamp(1.75rem, 4.5vh, 2.75rem) 0;
  text-decoration: none;
  color: inherit;
}

.project-key {
  grid-column: 1 / -1;
}

.project-name {
  grid-column: 1;
}

.project-arrow {
  grid-column: 2;
  grid-row: 2;
}

.project-note {
  grid-column: 1 / -1;
}

.project-num {
  color: var(--project-accent, #565A61);
}

.project-name {
  margin: 0.35rem 0 0;
  font-family: var(--display);
  font-size: clamp(1.875rem, 6vw, 3.25rem);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.035em;
  transition: color 0.25s ease;
}

.project-note {
  margin: 0.6rem 0 0;
  max-width: 30rem;
  font-size: 0.9062rem;
  line-height: 1.55;
  color: var(--graphite);
}

.project-arrow {
  align-self: center;
  font-size: 1.125rem;
  line-height: 1;
  color: var(--graphite);
  transition: transform 0.25s ease, color 0.25s ease;
}

.project:hover .project-name,
.project:focus-visible .project-name,
.project:hover .project-arrow,
.project:focus-visible .project-arrow {
  color: var(--project-accent, var(--signal));
}

.project:hover .project-arrow,
.project:focus-visible .project-arrow {
  transform: translateX(0.35rem);
}

/* ---------- Ledger ---------- */
.ledger {
  margin: 0;
  padding: 0;
  list-style: none;
}

.entry {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
  padding: 1.75rem 0;
}

.entry+.entry {
  border-top: 1px solid var(--rule);
}

.entry-key {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem;
}

.entry-key .now {
  color: var(--signal);
}

.entry-body {
  min-width: 0;
}

.entry-title {
  margin: 0;
  font-family: var(--display);
  font-size: 1.375rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.entry-title-sm {
  font-size: 1.0625rem;
}

.entry-title a {
  text-decoration: none;
  background-image: linear-gradient(var(--signal), var(--signal));
  background-size: 0 1px;
  background-repeat: no-repeat;
  background-position: 0 100%;
  transition: background-size 0.25s ease, color 0.25s ease;
}

.entry-title a:hover {
  color: var(--signal);
  background-size: 100% 1px;
}

.entry-role {
  margin: 0.3rem 0 0;
  font-size: 0.9375rem;
  color: var(--graphite);
}

.entry-desc {
  margin: 0.75rem 0 0;
  max-width: var(--prose);
  font-size: 0.9688rem;
  line-height: 1.65;
  color: #B0AEA9;
}

.entry-bullets {
  margin: 0.6rem 0 0;
  padding: 0;
  max-width: var(--prose);
  list-style: none;
}

.entry-bullets li {
  position: relative;
  padding-left: 1.1rem;
  font-size: 0.9688rem;
  line-height: 1.65;
  color: #B0AEA9;
}

.entry-bullets li+li {
  margin-top: 0.5rem;
}

.entry-bullets li::before {
  content: '';
  position: absolute;
  left: 2px;
  top: 0.6em;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--signal);
}

.stack {
  margin: 0.85rem 0 0;
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.02em;
  color: var(--graphite);
}

/* ---------- Entry expand ("see more") ---------- */
.entry-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0.85rem 0 0;
  padding: 0;
  background: none;
  border: 0;
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--graphite);
  cursor: pointer;
  transition: color 0.18s ease;
}

.entry-toggle:hover {
  color: var(--signal);
}

.entry-more-wrap {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.35s ease;
}

.entry-more-wrap.is-open {
  grid-template-rows: 1fr;
}

@media (prefers-reduced-motion: reduce) {
  .entry-more-wrap {
    transition: none;
  }
}

.entry-more {
  overflow: hidden;
}

.more-role+.more-role {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
}

.more-role-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem;
  margin: 1.25rem 0 0;
}

.more-role:first-child .more-role-head {
  margin-top: 1rem;
}

.more-role-title {
  font-family: var(--sans);
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--chalk);
}

.more-role-date {
  font-family: var(--mono);
  font-size: 0.6875rem;
  letter-spacing: 0.08em;
  color: var(--graphite);
}

.more-item {
  margin: 1rem 0 0;
}

.more-role>.more-item:first-of-type {
  margin-top: 0.6rem;
}

.more-item-title {
  margin: 0;
  font-family: var(--sans);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--chalk);
}

.more-item-desc {
  margin: 0.3rem 0 0;
  max-width: var(--prose);
  font-size: 0.9375rem;
  line-height: 1.65;
  color: #B0AEA9;
}

.more-item-stack {
  margin: 0.6rem 0 0;
  font-family: var(--mono);
  font-size: 0.75rem;
  line-height: 1.6;
  letter-spacing: 0.02em;
  color: var(--graphite);
}

.more-item-stack span {
  display: block;
}

.state {
  margin-top: 0.85rem;
}

.state-live {
  color: var(--signal);
}

/* Featured shot — only the lead entry earns an image. */
.shot {
  margin: 1.5rem 0 0;
  border: 1px solid var(--rule);
  overflow: hidden;
}

.shot img {
  width: 100%;
  filter: grayscale(1) contrast(1.05);
  transition: filter 0.45s ease;
}

.entry-lead:hover .shot img {
  filter: none;
}

/* ---------- About ---------- */
.about {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.75rem;
  padding-top: 3.5rem;
}

.about>img {
  width: 190px;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 50%;
  justify-self: center;
  align-self: center;
}

.about-copy p {
  margin: 0 0 1.1rem;
  max-width: var(--prose);
  font-size: 1rem;
  line-height: 1.7;
  color: #B0AEA9;
}

.about-copy p:last-child {
  margin-bottom: 0;
}


/* ---------- Contact ---------- */
.socials {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  margin: 2.25rem 0 0;
  padding: 0;
  list-style: none;
}

.socials a {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--mono);
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--graphite);
  text-decoration: none;
  transition: color 0.18s ease;
}

.socials a:hover {
  color: var(--signal);
}

.socials svg {
  width: 15px;
  height: 15px;
  flex: none;
}

/* ---------- Footer ---------- */
.foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 40px;
  padding: 1.25rem 0 2.5rem;
  border-top: 1px solid var(--rule);
}

.foot-top {
  text-decoration: none;
  transition: color 0.18s ease;
}

.foot-top:hover {
  color: var(--signal);
}

/* ---------- Wider viewports ---------- */
@media (min-width: 40rem) {
  .entry {
    grid-template-columns: 11rem 1fr;
    gap: 2.5rem;
  }

  .entry-key {
    flex-wrap: nowrap;
    gap: 0.4rem;
    padding-top: 0.35rem;
    white-space: nowrap;
  }

  /* Index, name, note and arrow settle into columns. */
  .project {
    grid-template-columns: 9rem minmax(0, 1.6fr) minmax(0, 1fr) 1.25rem;
    align-items: center;
    gap: 2rem;
  }

  .project-key,
  .project-name,
  .project-note,
  .project-arrow {
    grid-column: auto;
    grid-row: auto;
  }

  .project-name,
  .project-note {
    margin: 0;
  }

  .about {
    grid-template-columns: 190px 1fr;
    gap: 3rem;
  }
}

/* Wide enough for the shell plus a margin the rail can live in. */
@media (min-width: 84rem) {
  .rail {
    /* Centred with flex rather than a transform — a transformed ancestor
       would redefine the containing block for .lang-toggle's
       position:fixed, since it's nested inside .rail on narrower screens.
       This box spans the full viewport height to center its content, so
       pointer-events is disabled on the empty space above/below it. */
    position: fixed;
    left: 2rem;
    top: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    pointer-events: none;
    background: none;
    backdrop-filter: none;
    border-bottom: 0;
  }

  .rail-inner {
    pointer-events: auto;
    display: block;
    max-width: none;
    margin: 0;
  }

  .rail-list {
    flex-direction: column;
    gap: 0.9rem;
    max-width: none;
    margin: 0;
    padding: 0;
    overflow: visible;
    -webkit-mask-image: none;
    mask-image: none;
  }

  .rail-link.is-active {
    transform: translateX(4px);
  }

  .lang-toggle {
    position: fixed;
    top: 1.5rem;
    right: var(--gutter);
    z-index: 50;
    margin-right: 0;
  }

  main section[id] {
    scroll-margin-top: 2rem;
  }
}

/* ---------- Motion preferences ---------- */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }

  .js .section,
  .js .ledger>li,
  .js .projects>li,
  .js .about,
  .js .socials {
    opacity: 1;
    transform: none;
    transition-delay: 0ms !important;
  }
}