/* =========================================================
   Chandra Liuswanto — portfolio
   Aesthetic: warm "engineering dossier" — paper + ink, a single
   terracotta accent, high-contrast serif display (Fraunces),
   grotesque body, monospace for data/metrics.
   ========================================================= */

:root {
  /* paper + ink */
  --paper:      #f2ece1;
  --paper-2:    #ece4d6;
  --card:       #f7f2e9;
  --ink:        #1c1813;
  --ink-soft:   #4a4337;
  --muted:      #837a6b;
  --hair:       #d8cfbe;       /* hairlines on paper */
  --hair-soft:  #e4ddcf;

  /* accent */
  --accent:     #bc3f1c;       /* terracotta */
  --accent-2:   #d96a3f;
  --accent-ink: #7d2a12;

  --maxw: 1120px;
  --gutter: clamp(20px, 5vw, 64px);

  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --sans:  "Hanken Grotesk", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono:  "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--sans);
  color: var(--ink);
  background-color: var(--paper);
  /* faint blueprint grid + warm vignette for atmosphere */
  background-image:
    radial-gradient(120% 90% at 50% -10%, rgba(255,255,255,0.55), transparent 60%),
    linear-gradient(var(--hair-soft) 1px, transparent 1px),
    linear-gradient(90deg, var(--hair-soft) 1px, transparent 1px);
  background-size: 100% 100%, 46px 46px, 46px 46px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

/* film grain overlay */
.grain {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0.4;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.5'/%3E%3C/svg%3E");
}

a { color: inherit; text-decoration: none; }
em { font-style: italic; }
code {
  font-family: var(--mono);
  font-size: 0.9em;
  background: var(--paper-2);
  padding: 1px 5px;
  border-radius: 4px;
}

main { position: relative; z-index: 2; }

/* ====================== NAV ====================== */
.nav {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 16px var(--gutter);
  background: color-mix(in srgb, var(--paper) 78%, transparent);
  backdrop-filter: blur(10px) saturate(120%);
  border-bottom: 1px solid var(--hair);
}
.nav__links {
  display: flex;
  align-items: center;
  gap: clamp(16px, 3vw, 34px);
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.nav__links a { color: var(--ink-soft); position: relative; padding: 4px 0; transition: color 0.2s; }
.nav__links a::after {
  content: "";
  position: absolute; left: 0; bottom: -1px;
  width: 0; height: 1.5px; background: var(--accent);
  transition: width 0.28s var(--ease);
}
.nav__links a:hover { color: var(--ink); }
.nav__links a:hover::after { width: 100%; }
.nav__resume { color: var(--accent) !important; font-weight: 500; }

/* ====================== LAYOUT ====================== */
.section {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: clamp(64px, 11vw, 132px) var(--gutter);
  border-top: 1px solid var(--hair);
}
.section__head { margin-bottom: clamp(36px, 6vw, 64px); max-width: 720px; }
.section__index {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--accent);
  letter-spacing: 0.1em;
  margin-bottom: 10px;
}
.section__index::before { content: "— "; color: var(--muted); }
.section__title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(2rem, 5vw, 3.1rem);
  line-height: 1.04;
  letter-spacing: -0.02em;
}
.section__note { color: var(--muted); margin-top: 14px; font-size: 1.02rem; max-width: 56ch; }

.eyebrow {
  font-family: var(--mono);
  font-size: 0.82rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
}
.prose { color: var(--ink-soft); max-width: 60ch; }

/* ====================== HERO ====================== */
.hero {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: clamp(72px, 13vw, 168px) var(--gutter) clamp(40px, 7vw, 80px);
}
.hero .eyebrow { margin-bottom: 22px; }
.hero__name {
  font-family: var(--serif);
  font-weight: 900;
  font-size: clamp(3.4rem, 15vw, 10.5rem);
  line-height: 0.86;
  letter-spacing: -0.035em;
  margin-bottom: clamp(26px, 4vw, 40px);
  font-optical-sizing: auto;
}
.hero__thesis {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(1.5rem, 3.4vw, 2.5rem);
  line-height: 1.18;
  letter-spacing: -0.01em;
  max-width: 20ch;
  margin-bottom: 26px;
}
.hero__thesis em { color: var(--accent); font-weight: 500; }
.hero__sub { color: var(--ink-soft); max-width: 52ch; font-size: 1.08rem; margin-bottom: 38px; }
.hero__cta { display: flex; flex-wrap: wrap; gap: 14px; }

/* ====================== BUTTONS ====================== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 0.85rem;
  letter-spacing: 0.03em;
  padding: 13px 22px;
  border-radius: 2px;
  border: 1.5px solid var(--ink);
  transition: transform 0.2s var(--ease), background 0.25s, color 0.25s, border-color 0.25s;
}
.btn--solid { background: var(--ink); color: var(--paper); }
.btn--solid:hover { background: var(--accent); border-color: var(--accent); transform: translateY(-2px); }
.btn--line { background: transparent; color: var(--ink); }
.btn--line:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-2px); }

/* ====================== STATS ====================== */
.stats {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 var(--gutter) clamp(40px, 7vw, 72px);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--hair);
  border: 1px solid var(--hair);
}
.stat {
  background: var(--paper);
  padding: clamp(22px, 3vw, 34px) clamp(18px, 2.4vw, 28px);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.stat__num {
  font-family: var(--serif);
  font-weight: 900;
  font-size: clamp(2.6rem, 6vw, 4rem);
  line-height: 0.9;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}
.stat__unit { color: var(--accent); }
.stat__label {
  font-family: var(--mono);
  font-size: 0.78rem;
  line-height: 1.45;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
}
.stat__sub { color: var(--muted); text-transform: none; letter-spacing: 0; }

/* ====================== TAGS ====================== */
.tag {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 4px 9px;
  border: 1px solid var(--hair);
  border-radius: 999px;
  color: var(--ink-soft);
  background: var(--paper);
  white-space: nowrap;
}
.tag--ai { border-color: var(--accent); color: var(--accent-ink); background: color-mix(in srgb, var(--accent) 9%, var(--paper)); }
.tag--lock { color: var(--muted); }
.tag--lock::before { content: "🔒 "; font-size: 0.85em; }

/* ====================== FEATURED PROJECT ====================== */
.projects { display: flex; flex-direction: column; gap: clamp(52px, 9vw, 104px); }
.featured {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(28px, 4vw, 56px);
  align-items: center;
}
.featured--flip .featured__media { order: 2; }
.featured__media { min-width: 0; }
.featured__body { min-width: 0; }
.featured__no {
  display: block;
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--muted);
  letter-spacing: 0.1em;
  margin-bottom: 14px;
}
.featured__no::before { content: "— "; color: var(--accent); }
.featured__tagrow { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.featured__name {
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(2rem, 4vw, 2.9rem);
  line-height: 1;
  letter-spacing: -0.02em;
}
.featured__line {
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.2rem;
  color: var(--accent-ink);
  margin: 8px 0 18px;
}

/* video + placeholder share the 16:9 frame */
.video, .video-ph {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid var(--hair);
  box-shadow: 14px 14px 0 -2px var(--paper-2), 14px 14px 0 -1px var(--hair);
}
.video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.video-ph {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background:
    repeating-linear-gradient(45deg, transparent 0 12px, rgba(188,63,28,0.04) 12px 24px),
    var(--card);
  color: var(--muted);
}
.video-ph__play {
  width: 58px; height: 58px;
  display: grid; place-items: center;
  border: 1.5px solid var(--accent);
  border-radius: 50%;
  color: var(--accent);
  font-size: 1.1rem;
  padding-left: 4px;
}
.video-ph__text {
  font-family: var(--mono);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.stackline {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  margin: 20px 0;
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--ink-soft);
}
.stackline li { position: relative; padding-left: 14px; }
.stackline li::before { content: "▸"; position: absolute; left: 0; color: var(--accent); }

.repo-link {
  font-family: var(--mono);
  font-size: 0.82rem;
  letter-spacing: 0.03em;
  color: var(--accent);
  border-bottom: 1.5px solid transparent;
  padding-bottom: 2px;
  transition: border-color 0.25s var(--ease);
}
.repo-link:hover { border-color: var(--accent); }

.work__foot {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--muted);
  text-align: center;
  margin-top: clamp(28px, 4vw, 44px);
}

/* ====================== EXPERIENCE ====================== */
.timeline { display: flex; flex-direction: column; }
.entry {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: clamp(20px, 4vw, 56px);
  padding: clamp(28px, 4vw, 44px) 0;
  border-top: 1px solid var(--hair);
}
.entry:first-child { border-top: 0; padding-top: 0; }
.entry__meta { display: flex; flex-direction: column; gap: 4px; }
.entry__date {
  font-family: var(--mono);
  font-size: 0.84rem;
  letter-spacing: 0.02em;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.entry__place { font-family: var(--mono); font-size: 0.76rem; color: var(--muted); }
.entry__role {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.5rem;
  line-height: 1.15;
  letter-spacing: -0.01em;
}
.entry__lvl { font-weight: 400; font-style: italic; color: var(--muted); font-size: 1.05rem; }
.entry__org { font-family: var(--mono); font-size: 0.85rem; color: var(--accent); margin: 4px 0 16px; letter-spacing: 0.03em; }
.entry__points { list-style: none; display: flex; flex-direction: column; gap: 12px; }
.entry__points li { position: relative; padding-left: 22px; color: var(--ink-soft); }
.entry__points li::before {
  content: ""; position: absolute; left: 0; top: 0.6em;
  width: 8px; height: 8px; border: 1.5px solid var(--accent); border-radius: 2px;
}
.entry__points li strong { color: var(--ink); font-weight: 600; }
.entry__points--plain { padding-left: 0; }
.entry__points--plain { color: var(--ink-soft); }

/* ====================== ABOUT / SKILLS ====================== */
.about__lead {
  font-family: var(--serif);
  font-size: clamp(1.3rem, 2.6vw, 1.85rem);
  line-height: 1.45;
  font-weight: 400;
  max-width: 30ch;
  letter-spacing: -0.01em;
  margin-bottom: clamp(40px, 6vw, 64px);
  max-width: 38ch;
}
.skills {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--hair);
  border: 1px solid var(--hair);
}
.skillgroup { background: var(--paper); padding: clamp(20px, 2.6vw, 28px); }
.skillgroup__title {
  font-family: var(--mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin-bottom: 14px;
}
.skillgroup ul { list-style: none; display: flex; flex-direction: column; gap: 7px; }
.skillgroup li { color: var(--ink-soft); font-size: 0.95rem; }

/* ====================== CONTACT ====================== */
.section--contact { text-align: center; }
.section--contact .section__head { margin-left: auto; margin-right: auto; }
.contact__lead {
  font-family: var(--serif);
  font-size: clamp(1.3rem, 2.6vw, 1.7rem);
  line-height: 1.4;
  max-width: 30ch;
  margin: 0 auto clamp(32px, 5vw, 44px);
}
.contact__links { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; }

/* ====================== FOOTER ====================== */
.footer {
  position: relative;
  z-index: 2;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 34px var(--gutter) 56px;
  border-top: 1px solid var(--hair);
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-family: var(--mono);
  font-size: 0.76rem;
  color: var(--muted);
  letter-spacing: 0.02em;
}
.footer__dot { color: var(--accent); }

/* ====================== MOTION ====================== */
.reveal {
  opacity: 0;
  transform: translateY(18px);
  animation: rise 0.85s var(--ease) forwards;
  animation-delay: calc(var(--d, 0) * 110ms + 80ms);
}
@keyframes rise { to { opacity: 1; transform: none; } }

/* Hidden state only applies when JS is on — no-JS visitors see content. */
.reveal-up {
  transition: opacity 0.7s var(--ease), transform 0.7s var(--ease);
  transition-delay: calc(var(--d, 0) * 90ms);
}
.js .reveal-up { opacity: 0; transform: translateY(26px); }
.js .reveal-up.is-in { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal, .reveal-up { animation: none; transition: none; opacity: 1; transform: none; }
  .btn:hover, .card:hover { transform: none; }
}

/* ====================== RESPONSIVE ====================== */
@media (max-width: 880px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .featured { grid-template-columns: 1fr; }
  .featured__media, .featured--flip .featured__media { order: -1; }
  .skills { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 620px) {
  body { background-size: 100% 100%, 36px 36px, 36px 36px; }
  .entry { grid-template-columns: 1fr; gap: 12px; }
  .entry__meta { flex-direction: row; align-items: baseline; gap: 12px; }
  .skills { grid-template-columns: 1fr; }
  .nav__links { gap: 14px; font-size: 0.7rem; }
  .nav__links a[href="#about"] { display: none; }
}
@media (max-width: 420px) {
  .stats { grid-template-columns: 1fr; }
}
