/* ============================================================
   rivaldi.dev — editorial dark design system
   near-black · warm ink · muted colorful accents
   amber / clay / sage / steel — no gradients, no neon
   ============================================================ */

:root {
  --bg: #0f0f0d;
  --panel: #161614;
  --panel-soft: #1c1c19;
  --ink: #eae8e1;
  --dim: #98958d;
  --line: #2a2925;
  --amber: #d9a441;
  --clay: #d97757;
  --sage: #85b79d;
  --blue: #7fa9c9;
  --radius: 10px;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  --font-serif: "Fraunces", Georgia, serif;
  --font-sans: "Inter", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
}

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

html { scroll-behavior: smooth; }

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

::selection { background: #3a3527; color: var(--ink); }

/* ---------- dotted glow background ---------- */
/* base dot grid + a brighter amber layer revealed around the cursor */

body::before,
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: radial-gradient(var(--line) 1px, transparent 1.5px);
  background-size: 24px 24px;
}
body::before { z-index: -2; }
body::after {
  z-index: -1;
  background-image: radial-gradient(rgba(217, 164, 65, 0.55) 1px, transparent 1.5px);
  mask-image: radial-gradient(220px circle at var(--mx, -600px) var(--my, -600px), #000 30%, transparent 100%);
  -webkit-mask-image: radial-gradient(220px circle at var(--mx, -600px) var(--my, -600px), #000 30%, transparent 100%);
}

a { color: inherit; text-decoration: none; }
.mono { font-family: var(--font-mono); }

em { font-style: italic; }

/* ---------- nav ---------- */

.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: baseline;
  gap: 2rem;
  max-width: 960px;
  margin: 0 auto;
  padding: 1.4rem 1.5rem 1.1rem;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.nav__brand {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.nav__links {
  display: flex;
  gap: 1.6rem;
  margin-left: auto;
  font-size: 0.88rem;
  color: var(--dim);
}
.nav__links a { transition: color 150ms ease; }
.nav__links a:hover { color: var(--amber); }

.nav__tools { display: flex; gap: 0.5rem; align-items: center; }

.lang-toggle, .nav__cmdk {
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  padding: 0.3rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--dim);
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.lang-toggle:hover, .nav__cmdk:hover { color: var(--ink); border-color: var(--dim); }

/* ---------- hero ---------- */

.hero {
  max-width: 960px;
  margin: 0 auto;
  padding: clamp(5rem, 14vh, 9rem) 1.5rem 5rem;
}

.eyebrow {
  font-size: 0.72rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--amber);
  margin-bottom: 1.6rem;
}

.hero__title {
  font-family: var(--font-serif);
  font-size: clamp(2.5rem, 6.4vw, 4.4rem);
  font-weight: 500;
  line-height: 1.12;
  letter-spacing: -0.02em;
  text-wrap: balance;
  margin-bottom: 1.6rem;
  max-width: 22ch;
}
.hero__title em { color: var(--clay); }

.hero__role {
  font-size: 0.85rem;
  letter-spacing: 0.05em;
  color: var(--sage);
  margin-bottom: 1.8rem;
  min-height: 1.7em;
}

.scr-cursor {
  color: var(--amber);
  animation: cursor-blink 1.1s steps(1) infinite;
  margin-left: 2px;
}
@keyframes cursor-blink { 50% { opacity: 0; } }

.hero__lead {
  max-width: 54ch;
  color: var(--dim);
  margin-bottom: 2.6rem;
}
.hero__lead strong { color: var(--ink); font-weight: 600; }

.hero__cta { display: flex; flex-wrap: wrap; gap: 2rem; }

.link-btn {
  position: relative;
  display: inline-block;
  font-size: 0.95rem;
  font-weight: 500;
  padding-bottom: 3px;
  transition: color 150ms ease, transform 100ms var(--ease-out);
}
.link-btn::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  background: currentColor;
}
.link-btn:active { transform: translateY(1px); }
.link-btn--dim { color: var(--dim); }
.link-btn--dim::after { opacity: 0.45; }

@media (hover: hover) and (pointer: fine) {
  .link-btn:hover { color: var(--clay); }
  .link-btn:hover::after { animation: underline-swipe 450ms var(--ease-in-out); }
}
@keyframes underline-swipe {
  0%      { transform: scaleX(1); transform-origin: right; }
  50%     { transform: scaleX(0); transform-origin: right; }
  50.01%  { transform-origin: left; }
  100%    { transform: scaleX(1); transform-origin: left; }
}

/* ---------- ascii field ---------- */

.ascii-band {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 1.5rem 3.5rem;
}

#ascii {
  display: block;
  width: 100%;
  height: 240px;
  cursor: crosshair;
  touch-action: none;
}

.ascii-hint {
  margin-top: 0.6rem;
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--dim);
  text-align: right;
}

/* ---------- sections ---------- */

.section {
  max-width: 960px;
  margin: 0 auto;
  padding: clamp(3.5rem, 9vh, 6rem) 1.5rem;
  border-top: 1px solid var(--line);
}

/* one muted accent per section */
#about    { --sec: var(--amber); }
#projects { --sec: var(--sage); }
#terminal { --sec: var(--blue); }
#contact  { --sec: var(--clay); }

.section__index {
  font-size: 0.72rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--sec, --dim);
  margin-bottom: 1rem;
}

.section__title {
  font-family: var(--font-serif);
  font-size: clamp(1.7rem, 3.6vw, 2.5rem);
  font-weight: 500;
  letter-spacing: -0.015em;
  text-wrap: balance;
  margin-bottom: 0.9rem;
}
.section__title em { color: var(--sec, var(--amber)); }
.section__title--big {
  font-size: clamp(2.4rem, 6vw, 4rem);
  line-height: 1.1;
}

.section__sub {
  color: var(--dim);
  font-size: 0.95rem;
  max-width: 58ch;
  margin-bottom: 2.4rem;
}
.section__sub a { color: var(--sec, var(--ink)); text-decoration: underline; text-underline-offset: 3px; }
.section__sub code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  color: var(--sec, var(--ink));
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 0.1em 0.4em;
  border-radius: 5px;
}

/* ---------- about modes ---------- */

.modes {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2.5rem;
  margin-top: 2.6rem;
}

.mode__num {
  font-size: 0.72rem;
  border-bottom: 1px solid var(--line);
  padding-bottom: 0.8rem;
  margin-bottom: 1.1rem;
}
.mode:nth-child(1) .mode__num { color: var(--amber); }
.mode:nth-child(2) .mode__num { color: var(--sage); }
.mode:nth-child(3) .mode__num { color: var(--blue); }

.mode h3 {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 0.6rem;
}

.mode p:not(.mode__num) { color: var(--dim); font-size: 0.92rem; }

/* ---------- filters ---------- */

.filters { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 1.8rem; }

.chip {
  font-size: 0.78rem;
  padding: 0.4rem 1rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--dim);
  cursor: pointer;
  transition: color 150ms ease, border-color 150ms ease, background-color 150ms ease, transform 120ms var(--ease-out);
}
.chip:active { transform: scale(0.96); }
@media (hover: hover) and (pointer: fine) {
  .chip:hover { border-color: var(--dim); color: var(--ink); }
}
.chip.is-active {
  background: var(--sage);
  border-color: var(--sage);
  color: #10120f;
}

/* ---------- project grid ---------- */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
}

/* bento layout on wide screens */
@media (min-width: 900px) {
  .grid {
    grid-template-columns: repeat(4, 1fr);
    grid-auto-flow: dense;
  }
  .grid .proj:nth-child(1) { grid-column: span 2; grid-row: span 2; padding: 1.8rem; }
  .grid .proj:nth-child(1) .proj__name { font-size: 1.15rem; }
  .grid .proj:nth-child(2),
  .grid .proj:nth-child(3),
  .grid .proj:nth-child(8) { grid-column: span 2; }
}

.proj {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 1.4rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  transition: border-color 180ms ease, transform 220ms var(--ease-out);
  animation: proj-in 500ms var(--ease-out) backwards;
  animation-delay: calc(var(--i, 0) * 45ms);
}
@media (hover: hover) and (pointer: fine) {
  a.proj:hover {
    border-color: var(--dim);
    transform: translateY(-2px);
  }
}
a.proj:active { transform: scale(0.99); }

@keyframes proj-in {
  from { opacity: 0; transform: translateY(10px); }
}

.proj__head { display: flex; align-items: baseline; gap: 0.6rem; }
.proj__name {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: 500;
}
.proj__badge {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 0.64rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.proj__badge--web3 { color: var(--clay); }
.proj__badge--ai   { color: var(--amber); }
.proj__badge--web  { color: var(--blue); }

.proj__desc { color: var(--dim); font-size: 0.88rem; flex: 1; }

.proj__meta {
  display: flex;
  gap: 1.1rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--dim);
  padding-top: 0.7rem;
  border-top: 1px solid var(--line);
}

.proj--skeleton {
  min-height: 150px;
  background: linear-gradient(100deg, var(--panel) 40%, var(--panel-soft) 50%, var(--panel) 60%);
  background-size: 300% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }

.grid__error {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--dim);
  font-size: 0.9rem;
  padding: 2rem;
}
.grid__error a { text-decoration: underline; text-underline-offset: 3px; }

/* ---------- carousel ---------- */

.carousel { margin-bottom: 2.4rem; }

.carousel__track {
  display: flex;
  gap: 1rem;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  border-radius: var(--radius);
}
.carousel__track::-webkit-scrollbar { display: none; }

.slide {
  flex: 0 0 100%;
  scroll-snap-align: start;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  padding: clamp(1.6rem, 4vw, 2.6rem);
  min-height: 210px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  transition: border-color 180ms ease;
}
@media (hover: hover) and (pointer: fine) {
  .slide:hover { border-color: var(--dim); }
}

.slide__badge {
  font-size: 0.64rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.slide h3 {
  font-family: var(--font-serif);
  font-size: clamp(1.5rem, 3.4vw, 2.1rem);
  font-weight: 500;
  letter-spacing: -0.015em;
  text-transform: capitalize;
}
.slide p { color: var(--dim); font-size: 0.92rem; max-width: 56ch; flex: 1; }
.slide__meta { font-size: 0.72rem; color: var(--dim); }

.carousel__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.9rem;
}

.carousel__dots { display: flex; gap: 0.45rem; }
.carousel__dot {
  width: 6px;
  height: 6px;
  border-radius: 3px;
  border: 0;
  padding: 0;
  background: var(--line);
  cursor: pointer;
  transition: background-color 200ms ease, width 250ms var(--ease-out);
}
.carousel__dot.is-active { background: var(--sage); width: 18px; }

.carousel__btns { display: flex; gap: 0.4rem; }
.car-btn {
  font-size: 0.8rem;
  padding: 0.25rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  color: var(--dim);
  cursor: pointer;
  transition: color 150ms ease, border-color 150ms ease, transform 120ms var(--ease-out);
}
.car-btn:hover { color: var(--ink); border-color: var(--dim); }
.car-btn:active { transform: scale(0.94); }

/* ---------- colorful text ---------- */

.cf {
  color: var(--cfc, var(--amber));
  display: inline-block;
  transition: color 700ms ease;
  animation: cf-in 500ms var(--ease-out) both;
}
@keyframes cf-in {
  from { opacity: 0; transform: translateY(6px); }
}

/* ---------- terminal ---------- */

.term {
  max-width: 720px;
  border-radius: var(--radius);
  background: #131311;
  color: #d7d4cb;
  overflow: hidden;
  border: 1px solid var(--line);
}

.term__bar {
  padding: 0.65rem 1.1rem;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  color: var(--dim);
  border-bottom: 1px solid var(--line);
}

.term__body {
  padding: 1.1rem 1.2rem;
  font-size: 0.82rem;
  line-height: 1.8;
  min-height: 200px;
  max-height: 320px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

.term__body > div { animation: line-in 200ms var(--ease-out) both; }
.term__body .t-art {
  display: block;
  white-space: pre;
  overflow-x: auto;
  line-height: 1.3;
  font-size: 0.72rem;
}
@keyframes line-in {
  from { opacity: 0; transform: translateY(4px); }
}

.term__body .t-hi { color: var(--ink); }
.term__body .t-dim { color: var(--dim); }
.term__body .t-ok { color: var(--sage); }
.term__body a { color: var(--blue); text-decoration: underline; text-underline-offset: 3px; }

.term__input {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  padding: 0.75rem 1.2rem;
  border-top: 1px solid var(--line);
  font-size: 0.84rem;
}
.term__input label { color: var(--sage); }
.term__input input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--ink);
  font: inherit;
  caret-color: var(--amber);
}

/* ---------- contact / footer ---------- */

.section--contact { padding-bottom: 5rem; }
.section--contact .hero__cta { margin-top: 2rem; }

.footer-big {
  overflow: hidden;
  padding: 3rem 1.5rem 0;
}
.footer-big a {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  max-width: 1200px;
  margin: 0 auto;
}
.footer-big span {
  display: inline-block;
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: clamp(3.2rem, 15vw, 10.5rem);
  line-height: 0.95;
  letter-spacing: -0.02em;
  color: var(--line);
  transform: translateY(110%);
  transition: transform 200ms var(--ease-out), color 350ms ease;
}
.footer-big.is-in span {
  transform: none;
  animation: letter-rise 700ms var(--ease-out) backwards;
}
@keyframes letter-rise {
  from { transform: translateY(110%); }
}
.footer-big.is-in span:nth-child(2) { animation-delay: 50ms; }
.footer-big.is-in span:nth-child(3) { animation-delay: 100ms; }
.footer-big.is-in span:nth-child(4) { animation-delay: 150ms; }
.footer-big.is-in span:nth-child(5) { animation-delay: 200ms; }
.footer-big.is-in span:nth-child(6) { animation-delay: 250ms; }
.footer-big.is-in span:nth-child(7) { animation-delay: 300ms; }

@media (hover: hover) and (pointer: fine) {
  .footer-big span:hover { transform: translateY(-4px); }
  .footer-big span:nth-child(4n+1):hover { color: var(--amber); }
  .footer-big span:nth-child(4n+2):hover { color: var(--clay); }
  .footer-big span:nth-child(4n+3):hover { color: var(--sage); }
  .footer-big span:nth-child(4n+4):hover { color: var(--blue); }
}

.footer {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: space-between;
  max-width: 960px;
  margin: 0 auto;
  padding: 1.8rem 1.5rem 2.4rem;
  border-top: 1px solid var(--line);
  font-size: 0.72rem;
  color: var(--dim);
}

/* ---------- command palette ---------- */

.palette {
  width: min(520px, 92vw);
  margin: 14vh auto auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  color: var(--ink);
  padding: 0;
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.5);
}
.palette::backdrop { background: rgba(5, 5, 4, 0.55); }

.palette__input {
  width: 100%;
  padding: 1rem 1.2rem;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--line);
  outline: none;
  color: var(--ink);
  font-size: 0.92rem;
  caret-color: var(--amber);
}

.palette__list { list-style: none; max-height: 300px; overflow-y: auto; padding: 0.4rem; }
.palette__list li {
  display: flex;
  justify-content: space-between;
  padding: 0.6rem 0.9rem;
  border-radius: 8px;
  font-size: 0.84rem;
  cursor: pointer;
  color: var(--dim);
}
.palette__list li .k { font-size: 0.68rem; color: var(--amber); }
.palette__list li.is-sel, .palette__list li:hover {
  background: var(--panel-soft);
  color: var(--ink);
}

.palette__hint {
  padding: 0.55rem 1.2rem;
  border-top: 1px solid var(--line);
  font-size: 0.68rem;
  color: var(--dim);
}

/* ---------- scroll reveal ---------- */

.reveal {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 550ms ease, transform 550ms var(--ease-out);
}
.reveal.is-in { opacity: 1; transform: none; }

/* staggered entrances: hero on load, modes on scroll */
.hero > .reveal:nth-child(2) { transition-delay: 70ms; }
.hero > .reveal:nth-child(3) { transition-delay: 140ms; }
.hero > .reveal:nth-child(4) { transition-delay: 210ms; }
.hero > .reveal:nth-child(5) { transition-delay: 280ms; }
.modes .mode:nth-child(2) { transition-delay: 80ms; }
.modes .mode:nth-child(3) { transition-delay: 160ms; }

/* language switch crossfade (View Transition API) */
::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 220ms;
  animation-timing-function: ease;
}

/* ---------- responsive ---------- */

@media (max-width: 820px) {
  .modes { grid-template-columns: 1fr; gap: 1.8rem; }
  .nav__links { display: none; }
}

/* ---------- reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001s !important;
    animation-delay: 0s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001s !important;
    transition-delay: 0s !important;
  }
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; }
}

/* ============ featured showcase (curated case studies) ============ */
.feats { display: grid; gap: 1rem; margin-top: 2.2rem; }

.feat {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.6rem;
  padding: clamp(1.5rem, 4vw, 2.4rem);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  transition: border-color 180ms ease;
}
@media (hover: hover) and (pointer: fine) {
  .feat:hover { border-color: var(--dim); }
}
@media (min-width: 900px) {
  .feat { grid-template-columns: minmax(0, 1fr) 280px; gap: 2.4rem; }
  .feat__side { border-left: 1px solid var(--line); padding-left: 2rem; }
}
@media (max-width: 899px) {
  .feat__side { border-top: 1px solid var(--line); padding-top: 1.4rem; }
}

.feat__main { display: flex; flex-direction: column; gap: 0.9rem; min-width: 0; }
.feat__top { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.feat__logo {
  width: 44px; height: 44px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel-soft);
  margin-right: 0.3rem;
}
.feat__badge {
  font-family: var(--font-mono);
  font-size: 0.64rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--dim);
  padding: 0.22rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 999px;
}
.feat__badge--web3 { color: var(--clay); border-color: #4a3128; }
.feat__badge--ai   { color: var(--amber); border-color: #4a3d1f; }
.feat__badge--web  { color: var(--blue); border-color: #2c3a46; }

.feat h3 {
  font-family: var(--font-serif);
  font-size: clamp(1.7rem, 3.6vw, 2.3rem);
  font-weight: 500;
  letter-spacing: -0.015em;
  line-height: 1.12;
}
.feat__tag { font-size: 1.02rem; color: var(--ink); max-width: 60ch; }
.feat__desc { color: var(--dim); font-size: 0.92rem; max-width: 66ch; }

.feat__list { list-style: none; display: grid; gap: 0.45rem; font-size: 0.88rem; color: var(--dim); max-width: 70ch; }
.feat__list li { padding-left: 1.2rem; position: relative; }
.feat__list li::before {
  content: "▸";
  position: absolute; left: 0;
  color: var(--sage);
  font-family: var(--font-mono);
}

.feat__stack { display: flex; flex-wrap: wrap; gap: 0.4rem; padding-top: 0.4rem; }
.feat__chip {
  font-size: 0.7rem;
  padding: 0.18rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--dim);
  background: var(--panel-soft);
}

.feat__side { display: flex; flex-direction: column; gap: 1.3rem; }
.feat__facts {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.4rem 1rem;
  font-size: 0.72rem;
  margin: 0;
}
.feat__facts dt { color: var(--dim); text-transform: uppercase; letter-spacing: 0.08em; }
.feat__facts dd { color: var(--ink); margin: 0; }
.feat__links { display: flex; flex-direction: column; gap: 0.5rem; align-items: flex-start; }
