/* ==========================================================================
   Enzo V. Carrieri — portfolio
   Interface: Apple-flavoured (SF Pro, system materials, iOS controls)
   ========================================================================== */

:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
    "Helvetica Neue", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, monospace;

  --nav-h: 52px;
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 10px;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);

  /* dark appearance (default) */
  --bg: #000000;
  --bg-elevated: #1c1c1e;
  --bg-elevated-2: #2c2c2e;
  --nav-bg: rgba(22, 22, 23, 0.72);
  --fg: #f5f5f7;
  --fg-secondary: #a1a1a6;
  --fg-tertiary: #6e6e73;
  --separator: rgba(255, 255, 255, 0.11);
  --separator-strong: rgba(255, 255, 255, 0.18);
  --accent: #0a84ff;
  --green: #30d158;
  --fill: rgba(120, 120, 128, 0.24);
  --fill-hover: rgba(120, 120, 128, 0.16);
  --segment-thumb: #636366;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 8px 30px rgba(0, 0, 0, 0.55);
}

:root[data-theme="light"] {
  --bg: #fbfbfd;
  --bg-elevated: #ffffff;
  --bg-elevated-2: #f5f5f7;
  --nav-bg: rgba(251, 251, 253, 0.72);
  --fg: #1d1d1f;
  --fg-secondary: #6e6e73;
  --fg-tertiary: #86868b;
  --separator: rgba(0, 0, 0, 0.10);
  --separator-strong: rgba(0, 0, 0, 0.16);
  --accent: #0071e3;
  --green: #34c759;
  --fill: rgba(120, 120, 128, 0.12);
  --fill-hover: rgba(120, 120, 128, 0.08);
  --segment-thumb: #ffffff;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.10);
  --shadow-md: 0 8px 30px rgba(0, 0, 0, 0.10);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  letter-spacing: -0.01em;
  max-width: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body { min-height: 100vh; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

button { font-family: inherit; -webkit-tap-highlight-color: transparent; }
button:focus-visible,
a:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }

.shell {
  position: relative;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* --------------------------------------------------------------------------
   Navigation bar
   -------------------------------------------------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px;
  background: var(--nav-bg);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--separator);
  max-width: 100%;
}

.wordmark {
  margin-right: auto;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--fg);
  white-space: nowrap;
}
.wordmark:hover { text-decoration: none; opacity: 0.7; }

.sysinfo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--fg-tertiary);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.sysinfo-item:empty { display: none; }

/* pill button — Apple style */
.overview-btn {
  border: none;
  background: var(--fill);
  color: var(--fg);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: -0.01em;
  padding: 6px 14px;
  border-radius: 980px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s var(--ease), color 0.2s var(--ease);
}
.overview-btn:hover { background: var(--fill-hover); }
.overview-btn.active { background: var(--accent); color: #fff; }

/* iOS switch + play control */
.autoplay-control {
  display: flex;
  align-items: center;
  gap: 8px;
}

.autoplay-switch {
  width: 40px;
  height: 24px;
  padding: 0;
  border: none;
  border-radius: 999px;
  background: var(--fill);
  position: relative;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.25s var(--ease);
}
.autoplay-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.25), 0 0 1px rgba(0, 0, 0, 0.12);
  transition: transform 0.25s var(--ease);
}
.autoplay-switch[aria-pressed="true"] { background: var(--green); }
.autoplay-switch[aria-pressed="true"] .autoplay-knob { transform: translateX(16px); }

.autoplay-play,
.theme-toggle {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  border: none;
  border-radius: 50%;
  background: var(--fill);
  color: var(--fg);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 0.2s var(--ease);
}
.autoplay-play { font-size: 9px; line-height: 1; padding-left: 2px; }
.autoplay-play:hover,
.theme-toggle:hover { background: var(--fill-hover); }

.theme-toggle svg { display: block; }
.theme-toggle .icon-moon { display: none; }
:root[data-theme="light"] .theme-toggle .icon-sun { display: none; }
:root[data-theme="light"] .theme-toggle .icon-moon { display: block; }

/* segmented control — iOS style */
.lang-switch {
  display: flex;
  gap: 2px;
  padding: 2px;
  background: var(--fill);
  border-radius: 9px;
}
.lang-btn {
  border: none;
  background: transparent;
  color: var(--fg-secondary);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.01em;
  padding: 4px 9px;
  border-radius: 7px;
  cursor: pointer;
  transition: background 0.2s var(--ease), color 0.2s var(--ease);
}
.lang-btn:hover { color: var(--fg); }
.lang-btn.active {
  background: var(--segment-thumb);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
:root[data-theme="light"] .lang-btn.active { color: var(--fg); }

/* --------------------------------------------------------------------------
   Layout
   -------------------------------------------------------------------------- */

.wrap {
  flex: 1;
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  max-width: 1500px;
  width: 100%;
  margin: 0 auto;
  align-items: start;
  min-width: 0;
}

.col { min-width: 0; }

.col-sidebar {
  position: sticky;
  top: var(--nav-h);
  align-self: start;
  height: calc(100vh - var(--nav-h));
  overflow-y: auto;
  overflow-x: hidden;
  border-right: 1px solid var(--separator);
  padding: 26px 22px 36px;
}

.col-main {
  min-height: calc(100vh - var(--nav-h));
  min-width: 0;
  padding: 34px 40px 72px;
}

/* --------------------------------------------------------------------------
   Sidebar
   -------------------------------------------------------------------------- */

.ai-note {
  margin: 0 0 20px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--fg-tertiary);
  font-style: italic;
}

.ident {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.15;
  margin: 0 0 14px;
}
.ident-link { color: var(--fg); }
.ident-link:hover { color: var(--accent); text-decoration: none; }

.bio-block .bio {
  margin: 0 0 10px;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--fg-secondary);
}

.section-label {
  margin: 28px 0 10px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.055em;
  text-transform: uppercase;
  color: var(--fg-tertiary);
}

.dim { color: var(--fg-tertiary); }

.contact-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--bg-elevated);
  border: 1px solid var(--separator);
}
.contact-list li { border-bottom: 1px solid var(--separator); }
.contact-list li:last-child { border-bottom: none; }
.contact-list a {
  display: block;
  padding: 9px 12px;
  font-size: 13px;
  color: var(--fg);
  overflow-wrap: anywhere;
  transition: background 0.15s var(--ease);
}
.contact-list a:hover {
  background: var(--fill-hover);
  color: var(--accent);
  text-decoration: none;
}

.navlist {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.navlink {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--fg);
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}
.navlink::after {
  content: "›";
  font-size: 15px;
  color: var(--fg-tertiary);
  line-height: 1;
}
.navlink:hover { background: var(--fill-hover); text-decoration: none; }
.navlink.active { background: var(--fill); color: var(--accent); }
.navlink.active::after { color: var(--accent); }

/* project picker */
.project-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 420px;
  overflow-y: auto;
  margin: 0 -6px;
  padding: 0 4px;
}

.project-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 8px;
  border-radius: var(--radius-sm);
  transition: background 0.15s var(--ease);
}
.project-nav-item:hover { background: var(--fill-hover); text-decoration: none; }
.project-nav-item.active { background: var(--fill); }
.project-nav-item img {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--bg-elevated-2);
}
.project-nav-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.project-nav-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.012em;
}
.project-nav-item.active .project-nav-title { color: var(--accent); font-weight: 600; }
.project-nav-desc {
  font-size: 11.5px;
  color: var(--fg-tertiary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.project-nav-footer {
  margin: 12px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--separator);
  font-size: 11.5px;
  color: var(--fg-tertiary);
}

/* --------------------------------------------------------------------------
   Main — views
   -------------------------------------------------------------------------- */

.view { display: none; }
.view.active { display: block; }

.page-title {
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin: 0 0 10px;
}

.crumb {
  margin: 0 0 22px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--fg-tertiary);
}
.crumb-sep { margin: 0 5px; opacity: 0.6; }
#currentProjectSlug { color: var(--fg-secondary); }

/* project case study */
.project { display: none; }
.project.active-project { display: block; }

.media-frame {
  margin: 0 0 28px;
  padding: 0;
  border: 1px solid var(--separator);
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  overflow: hidden;
  max-width: 100%;
  box-shadow: var(--shadow-md);
}

.media-frame--phone { max-width: 260px; }

.media-frame img,
.media-frame video {
  display: block;
  width: 100%;
  height: auto;
}

.proj-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 6px 24px;
  margin-bottom: 16px;
}

.proj-head h2 {
  font-size: 32px;
  font-weight: 600;
  letter-spacing: -0.032em;
  line-height: 1.1;
  margin: 0;
  color: var(--fg);
  overflow-wrap: anywhere;
  min-width: 0;
}

.meta {
  font-size: 13px;
  font-weight: 500;
  color: var(--fg-secondary);
  white-space: nowrap;
}

.project .body p {
  margin: 0 0 14px;
  font-size: 15.5px;
  line-height: 1.6;
  color: var(--fg-secondary);
  max-width: 68ch;
  overflow-wrap: break-word;
}

/* challenge / solution cards */
.case-blocks {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-top: 4px;
}

.case-block {
  background: var(--bg-elevated);
  border: 1px solid var(--separator);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
}

.case-block h3 {
  margin: 0 0 12px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.055em;
  text-transform: uppercase;
  color: var(--fg-tertiary);
}

.case-block p {
  margin: 0 0 12px;
  font-size: 15px;
  line-height: 1.6;
  color: var(--fg-secondary);
}
.case-block p:last-child { margin-bottom: 0; }

/* stacked image blocks (scroll-through gallery) */
.case-gallery {
  display: flex;
  flex-direction: column;
  gap: 18px;
  margin-top: 18px;
}

/* Linhas justificadas e responsivas.
   flex-grow E flex-basis sao proporcionais a proporcao da imagem (--ar):
   a largura final fica sempre proporcional a --ar, logo as alturas casam
   em qualquer composicao. Como a base cresce junto, a linha quebra sozinha
   quando falta espaco — e cada linha resultante se rejustifica. */
.case-gallery { --shot-unit: 180px; }

.case-row {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  align-items: stretch;
  justify-content: center;
}

.case-shot {
  margin: 0;
  padding: 0;
  border: 1px solid var(--separator);
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  overflow: hidden;
  min-width: 0;
  flex: var(--ar, 1) 1 calc(var(--ar, 1) * var(--shot-unit));
}

.case-shot img,
.case-shot video {
  display: block;
  width: 100%;
  height: auto;
}

/* bloco reduzido: usado quando a peca e um complemento, nao o destaque */
.case-shot--small {
  flex: 0 0 auto !important;
  width: 100%;
  max-width: 340px;
}

.credits {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--separator);
  font-size: 12.5px;
  color: var(--fg-tertiary);
}
.credits:empty { display: none; }

/* --------------------------------------------------------------------------
   Overview
   -------------------------------------------------------------------------- */

.overview-intro {
  margin: 0 0 26px;
  font-size: 15px;
  color: var(--fg-secondary);
  max-width: 62ch;
}

.overview-grid {
  column-count: 3;
  column-gap: 16px;
}
.overview-item {
  display: block;
  position: relative;
  margin: 0 0 16px;
  break-inside: avoid;
  border-radius: var(--radius-md);
  border: 1px solid var(--separator);
  background: var(--bg-elevated);
  overflow: hidden;
  transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease);
}
.overview-item:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  text-decoration: none;
}
.overview-item img {
  display: block;
  width: 100%;
  height: auto;
  transition: transform 0.35s var(--ease);
}
.overview-item:hover img { transform: scale(1.04); }
.overview-caption {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 22px 12px 10px;
  font-size: 12px;
  font-weight: 500;
  color: #fff;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.78), transparent);
  opacity: 0;
  transition: opacity 0.2s var(--ease);
}
.overview-item:hover .overview-caption { opacity: 1; }

/* LAB — peças de experimentação; nao sao clicaveis, entao sem hover de link */
.lab-item { margin: 0 0 16px; }
.lab-item video {
  display: block;
  width: 100%;
  height: auto;
}
.lab-item:hover {
  transform: none;
  box-shadow: none;
}
.lab-item:hover img { transform: none; }

/* --------------------------------------------------------------------------
   About
   -------------------------------------------------------------------------- */

.about-lede {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 44px;
  align-items: start;
}

.about-lede-text p {
  margin: 0 0 14px;
  font-size: 16px;
  line-height: 1.6;
  color: var(--fg-secondary);
  max-width: 68ch;
}
.about-lede-text p:last-child { margin-bottom: 0; }

.about-portrait { margin: 0; }
.about-portrait img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--radius-lg);
}
.about-portrait .photo-caption {
  margin: 10px 2px 0;
  font-size: 12px;
  color: var(--fg-tertiary);
}

.rule {
  height: 0;
  margin: 30px 0;
  border-top: 1px solid var(--separator);
}

.about-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  margin-top: 22px;
}

.about-block {
  background: var(--bg-elevated);
  border: 1px solid var(--separator);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
}

.about-block h3 {
  margin: 0 0 12px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.055em;
  text-transform: uppercase;
  color: var(--fg-tertiary);
}
.about-block h3.sub { margin-top: 22px; }

.about-block ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
.about-block li {
  margin: 0;
  padding: 9px 0;
  border-top: 1px solid var(--separator);
  font-size: 13.5px;
  line-height: 1.45;
  color: var(--fg);
  max-width: 60ch;
}
.about-block li:first-child { border-top: none; padding-top: 0; }
.about-block li:last-child { padding-bottom: 0; }

/* --------------------------------------------------------------------------
   Reveal on scroll — fade + subida leve quando o elemento entra na tela.
   A classe .reveal so e aplicada via JS; sem JS, nada fica escondido.
   -------------------------------------------------------------------------- */

.reveal {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.55s var(--ease), transform 0.55s var(--ease);
}
.reveal.revealed {
  opacity: 1;
  transform: none;
}

@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; }
}

/* --------------------------------------------------------------------------
   Chrome
   -------------------------------------------------------------------------- */

::selection {
  background: var(--accent);
  color: #fff;
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--fill);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover { background: var(--separator-strong); }

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

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */

@media (max-width: 1100px) {
  .wrap { grid-template-columns: 300px minmax(0, 1fr); }
  .col-main { padding: 30px 28px 64px; }
}

@media (max-width: 860px) {
  .wrap { grid-template-columns: minmax(0, 1fr); }
  .col-sidebar {
    position: relative;
    top: 0;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--separator);
  }
  .col-main { padding: 26px 22px 56px; }
  .about-grid { grid-template-columns: minmax(0, 1fr); }
  .case-blocks { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .case-gallery { gap: 14px; }
  .case-row { gap: 14px; }
  .case-gallery { --shot-unit: 230px; }
  .about-lede {
    grid-template-columns: minmax(0, 1fr);
    gap: 26px;
  }
  .about-portrait { max-width: 340px; }
  .project-nav { max-height: 320px; }
  .overview-grid { column-count: 2; }
  .proj-head h2 { font-size: 27px; }
  .page-title { font-size: 26px; }
}

@media (max-width: 720px) {
  .topbar {
    height: auto;
    padding: 9px 16px;
    flex-wrap: wrap;
    row-gap: 9px;
  }
  .wordmark { order: 0; }
  .overview-btn { order: 1; }
  .autoplay-control { order: 2; }
  .lang-switch { order: 3; }
  .theme-toggle { order: 4; }
  .sysinfo {
    order: 5;
    flex-basis: 100%;
    justify-content: flex-start;
    gap: 6px;
    font-size: 11.5px;
  }
}

@media (max-width: 520px) {
  .wordmark { flex-basis: 100%; margin-right: 0; }
  .overview-btn { margin-right: auto; }
}

@media (max-width: 480px) {
  .col-sidebar { padding: 22px 18px 28px; }
  .col-main { padding: 22px 18px 48px; }
  .ident { font-size: 21px; }
  .proj-head h2 { font-size: 23px; }
  .page-title { font-size: 23px; }
  .proj-head { gap: 4px 14px; }
  .meta { white-space: normal; }
  .media-frame { max-width: 100%; border-radius: var(--radius-md); }
  .project .body p { font-size: 15px; }
  .overview-grid { column-count: 1; }
  .overview-caption { opacity: 1; }
  .about-block { padding: 18px 20px; }
  .case-block { padding: 18px 20px; }
  .case-shot { border-radius: var(--radius-md); }
  .case-row { gap: 12px; }
  .case-gallery { --shot-unit: 330px; }
  .case-block p { font-size: 14.5px; }
  .about-portrait { max-width: 100%; }
}
