/* ===================================
   PORTFOLIO — MAIN STYLESHEET
   =================================== */

@import url('https://fonts.googleapis.com/css2?family=EB+Garamond:ital,wght@0,400;0,500;0,600;1,400;1,500&family=DM+Mono:wght@400;500&display=swap');

/* ===================================
   VARIABLES
=================================== */
:root {
  --sp-1:  0.25rem;
  --sp-2:  0.5rem;
  --sp-3:  0.75rem;
  --sp-4:  1rem;
  --sp-5:  1.25rem;
  --sp-6:  1.5rem;
  --sp-8:  2rem;
  --sp-10: 2.5rem;
  --sp-12: 3rem;
  --sp-16: 4rem;
  --sp-20: 5rem;

  /* Layout — centered two-column */
  --sidebar-w:  240px;
  --content-w:  640px;
  --gap:        4rem;
  --page-max:   calc(var(--sidebar-w) + var(--gap) + var(--content-w) + 4rem);
  --nav-h:      52px;

  /* Colors */
  --bg:           #fafaf8;
  --bg-subtle:    #f3f2ef;
  --bg-hover:     #edecea;
  --text:         #1c1c1a;
  --text-2:       #4a4a44;
  --text-3:       #7a7a72;
  --text-4:       #b0afa8;
  --heading:      #0e0e0c;
  --link:         #1a56a0;
  --link-hov:     #0f3d7a;
  --border:       #e0ddd6;
  --border-2:     #cac6bc;
  --accent:       #1a56a0;
  --accent-warm:  #b5763a;

  /* Typography */
  --font-serif: 'EB Garamond', Georgia, 'Times New Roman', serif;
  --font-mono:  'DM Mono', 'Menlo', 'Monaco', monospace;
}

/* ===================================
   RESET
=================================== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-serif);
  font-size: 1.0625rem;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
  /* Prevent layout shift */
  overflow-x: hidden;
}

img { max-width: 100%; height: auto; display: block; }
ul, ol { padding-left: var(--sp-6); }
li { margin-bottom: var(--sp-1); line-height: 1.65; }

/* ===================================
   TYPOGRAPHY
=================================== */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-serif);
  font-weight: 600;
  color: var(--heading);
  line-height: 1.25;
  letter-spacing: -0.015em;
}

h1 { font-size: 2.25rem;   margin-bottom: var(--sp-5); }
h2 { font-size: 1.5rem;    margin-top: var(--sp-12); margin-bottom: var(--sp-4); padding-bottom: var(--sp-3); border-bottom: 1px solid var(--border); }
h3 { font-size: 1.25rem;   margin-top: var(--sp-10); margin-bottom: var(--sp-3); }
h4 { font-size: 1.0625rem; font-weight: 600; margin-top: var(--sp-6); margin-bottom: var(--sp-2); }

p { margin: 0 0 var(--sp-4) 0; line-height: 1.75; }

a { color: var(--link); text-decoration: none; transition: color 0.15s; }
a:hover { color: var(--link-hov); text-decoration: underline; text-underline-offset: 3px; }

/* ===================================
   LAYOUT — centered two-column
   The whole page is centered. Sidebar is
   a fixed column on the left of that center,
   content fills the right side.
=================================== */
.page-shell {
  max-width: var(--page-max);
  margin: 0 auto;
  min-height: 100vh;
  position: relative;
}

/* ===================================
   SIDEBAR
=================================== */
.sidebar {
  position: fixed;
  top: 0;
  /* center sidebar within page-max */
  left: max(0px, calc(50vw - var(--page-max) / 2));
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--bg);
  border-right: 1px solid var(--border);
  padding: var(--sp-10) var(--sp-6) var(--sp-8);
  overflow-y: auto;
  z-index: 100;
  display: flex;
  flex-direction: column;
  /* Optimasi rendering - menghilangkan flicker */
  will-change: contents;
  transform: translateZ(0);
  backface-visibility: hidden;
  -webkit-font-smoothing: subpixel-antialiased;
}

.profile-wrap { margin-bottom: var(--sp-6); }

.profile-photo {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid var(--border-2);
  margin-bottom: var(--sp-4);
  background: var(--bg-subtle);
  flex-shrink: 0;
  /* Prevent image flicker */
  transform: translateZ(0);
}

.profile-photo img  { 
  width: 100%; 
  height: 100%; 
  object-fit: cover;
  /* Prevent image flash on page load */
  image-rendering: crisp-edges;
  image-rendering: -webkit-optimize-contrast;
}

.profile-photo svg  { width: 100%; height: 100%; }

.profile-name {
  font-size: 1rem;
  font-weight: 600;
  color: var(--heading);
  line-height: 1.3;
  margin-bottom: var(--sp-2);
  letter-spacing: -0.01em;
}

.profile-name a       { color: var(--heading); text-decoration: none; }
.profile-name a:hover { color: var(--link);    text-decoration: none; }

.profile-bio {
  font-size: 0.875rem;
  color: var(--text-3);
  line-height: 1.55;
  font-style: italic;
}

.sidebar hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: var(--sp-5) 0;
}

/* Nav */
.nav-menu { list-style: none; padding: 0; margin: 0 0 var(--sp-4) 0; }
.nav-menu li { margin: 0; }

.nav-menu a {
  display: block;
  padding: var(--sp-2) var(--sp-3);
  font-family: var(--font-serif);
  font-size: 0.9375rem;
  color: var(--text-2);
  border-radius: 4px;
  transition: background 0.15s, color 0.15s;
  text-decoration: none;
}

.nav-menu a:hover  { background: var(--bg-hover); color: var(--heading); text-decoration: none; }
.nav-menu a.active { background: var(--bg-subtle); color: var(--heading); font-weight: 600; }

/* Social links */
.social-links {
  margin-top: auto;
  padding-top: var(--sp-5);
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.social-links a {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  font-size: 0.875rem;
  font-family: var(--font-serif);
  color: var(--text-3);
  border-radius: 4px;
  text-decoration: none;
  transition: color 0.15s, background 0.15s;
}

.social-links a:hover { color: var(--link); background: var(--bg-hover); text-decoration: none; }

.social-links .ico {
  width: 14px; height: 14px;
  flex-shrink: 0; opacity: 0.6;
  transition: opacity 0.15s;
}

.social-links a:hover .ico { opacity: 1; }

/* ===================================
   MAIN CONTENT
=================================== */
.main-content {
  margin-left: var(--sidebar-w);
  padding: var(--sp-12) var(--sp-8) var(--sp-20) var(--gap);
  min-height: 100vh;
  /* Smooth content transitions */
  animation: fadeIn 0.2s ease-in;
}

@keyframes fadeIn {
  from { opacity: 0.95; }
  to { opacity: 1; }
}

.main-content > * { max-width: var(--content-w); }

/* ===================================
   TOPBAR (mobile)
=================================== */
.topbar {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--nav-h);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 0 var(--sp-5);
  z-index: 200;
  align-items: center;
  justify-content: space-between;
}

.topbar-title {
  font-family: var(--font-serif);
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--heading);
}

.topbar-title a { color: inherit; text-decoration: none; }

.hamburger {
  background: none; border: none;
  cursor: pointer; padding: var(--sp-2);
  display: flex; flex-direction: column; gap: 5px;
}

.hamburger span {
  display: block; width: 22px; height: 2px;
  background: var(--text-2); border-radius: 2px;
  transition: transform 0.2s, opacity 0.2s;
}

.hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.open span:nth-child(2) { opacity: 0; }
.hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.mobile-drawer {
  display: none;
  position: fixed;
  top: var(--nav-h); left: 0; right: 0;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: var(--sp-4) var(--sp-5) var(--sp-5);
  z-index: 199;
  box-shadow: 0 8px 24px rgba(0,0,0,0.07);
}

.mobile-drawer.open { display: block; }

.mobile-drawer .nav-menu a {
  font-size: 1rem;
  padding: var(--sp-3) var(--sp-2);
  border-bottom: 1px solid var(--border);
  border-radius: 0;
}

.mobile-drawer .nav-menu li:last-child a { border-bottom: none; }

.mobile-social {
  display: flex; gap: var(--sp-5);
  padding: var(--sp-4) var(--sp-2) 0;
  flex-wrap: wrap;
}

.mobile-social a {
  display: flex; align-items: center; gap: var(--sp-2);
  font-size: 0.875rem; color: var(--text-3); text-decoration: none;
}

.mobile-social a:hover { color: var(--link); }

/* ===================================
   PAGE HEADER
=================================== */
.page-label {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent-warm);
  margin-bottom: var(--sp-3);
  font-weight: 500;
}

.page-title {
  font-size: 2.25rem;
  margin-bottom: var(--sp-5);
  letter-spacing: -0.02em;
}

.page-intro {
  font-size: 1.0625rem;
  color: var(--text-2);
  line-height: 1.75;
  margin-bottom: var(--sp-10);
  max-width: 580px;
}

/* ===================================
   YEAR LABEL
=================================== */
.year-label {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-3);
  letter-spacing: 0.08em;
  margin: var(--sp-10) 0 var(--sp-1);
  padding-bottom: var(--sp-2);
  border-bottom: 1px solid var(--border);
}

/* ===================================
   ITEM LIST
=================================== */
.item-list { list-style: none; padding: 0; }

.item {
  padding: var(--sp-6) 0;
  border-bottom: 1px solid var(--border);
}

.item:last-child { border-bottom: none; padding-bottom: 0; }

.item-title {
  font-size: 1.0625rem;
  font-weight: 600;
  line-height: 1.35;
  margin-bottom: var(--sp-2);
}

.item-title a       { color: var(--link); text-decoration: none; }
.item-title a:hover { color: var(--link-hov); text-decoration: underline; text-underline-offset: 3px; }

.item-meta {
  font-size: 0.8125rem;
  color: var(--text-3);
  font-style: italic;
  margin-bottom: var(--sp-3);
  display: flex;
  gap: var(--sp-1);
  align-items: center;
  flex-wrap: wrap;
}

.item-meta .meta-sep { color: var(--border-2); margin: 0 2px; }

.item-meta svg {
  width: 12px; height: 12px;
  opacity: 0.55; flex-shrink: 0;
  vertical-align: middle;
  margin-right: 2px;
}

.item-excerpt {
  font-size: 0.9375rem;
  color: var(--text-2);
  line-height: 1.7;
  margin-bottom: var(--sp-3);
}

.item-links { display: flex; gap: var(--sp-3); margin-bottom: var(--sp-3); flex-wrap: wrap; }

.item-link {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--link);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 4px;
}

.item-link:hover { color: var(--link-hov); text-decoration: underline; }

.item-tags { display: flex; gap: var(--sp-2); flex-wrap: wrap; margin-top: var(--sp-2); }

/* ===================================
   TAGS
=================================== */
.tag {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border: 1px solid var(--border-2);
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.04em;
  color: var(--text-3);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
  text-decoration: none;
  background: transparent;
}

.tag:hover { border-color: var(--text); color: var(--heading); text-decoration: none; }
.tag.active { background: var(--heading); border-color: var(--heading); color: var(--bg); }

/* ===================================
   ABOUT / HOME — STATS
=================================== */
.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-4);
  margin: var(--sp-8) 0;
}

.stat-card {
  padding: var(--sp-5);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 5px;
  text-align: center;
}

.stat-number {
  font-size: 1.875rem;
  font-weight: 600;
  color: var(--heading);
  line-height: 1;
  margin-bottom: var(--sp-1);
  letter-spacing: -0.03em;
}

.stat-label {
  font-size: 0.8125rem;
  color: var(--text-3);
  font-style: italic;
}

/* ===================================
   CV PAGE
=================================== */
.cv-section { margin-bottom: var(--sp-10); }

.cv-item {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: var(--sp-6);
  padding: var(--sp-5) 0;
  border-bottom: 1px solid var(--border);
}

.cv-item:last-child { border-bottom: none; }

.cv-year {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--text-3);
  padding-top: 2px;
  letter-spacing: 0.04em;
}

.cv-content h4 { font-size: 1rem; font-weight: 600; margin: 0 0 var(--sp-1); color: var(--heading); }
.cv-institution { font-size: 0.875rem; color: var(--text-3); font-style: italic; margin-bottom: var(--sp-2); }
.cv-content p   { font-size: 0.9rem; color: var(--text-2); line-height: 1.6; margin: 0; }

/* ===================================
   BLOG POST PAGE
=================================== */
.post-wrap { max-width: var(--content-w); }

.post-header {
  margin-bottom: var(--sp-10);
  padding-bottom: var(--sp-8);
  border-bottom: 1px solid var(--border);
}

.post-header h1 {
  font-size: 2.125rem;
  margin-bottom: var(--sp-4);
  line-height: 1.2;
}

.post-header .post-meta {
  font-size: 0.875rem;
  color: var(--text-3);
  font-style: italic;
  display: flex;
  gap: var(--sp-4);
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: var(--sp-4);
}

.post-header .post-tags { margin-top: var(--sp-3); display: flex; gap: var(--sp-2); flex-wrap: wrap; }

.post-body { font-size: 1.0625rem; line-height: 1.8; color: var(--text); }
.post-body p { margin-bottom: var(--sp-5); }

.post-body h2 {
  font-size: 1.375rem;
  margin-top: var(--sp-12);
  margin-bottom: var(--sp-4);
  padding-bottom: var(--sp-3);
  border-bottom: 1px solid var(--border);
}

.post-body h3 { font-size: 1.125rem; margin-top: var(--sp-8); margin-bottom: var(--sp-3); }

.post-body blockquote {
  margin: var(--sp-8) 0;
  padding: var(--sp-4) var(--sp-6);
  border-left: 3px solid var(--accent-warm);
  background: var(--bg-subtle);
  color: var(--text-2);
  font-style: italic;
  border-radius: 0 4px 4px 0;
}

.post-body blockquote p:last-child { margin-bottom: 0; }
.post-body img { max-width: 100%; margin: var(--sp-8) 0; border: 1px solid var(--border); border-radius: 5px; }
.post-body ul, .post-body ol { margin: var(--sp-5) 0; padding-left: var(--sp-8); }
.post-body li { margin-bottom: var(--sp-2); line-height: 1.7; }

/* Post nav */
.post-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-5);
  margin-top: var(--sp-16);
  padding-top: var(--sp-8);
  border-top: 1px solid var(--border);
  max-width: var(--content-w);
}

.post-nav-link {
  padding: var(--sp-5);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 5px;
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s;
}

.post-nav-link:hover { border-color: var(--border-2); text-decoration: none; }
.post-nav-label { font-family: var(--font-mono); font-size: 0.6875rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-4); }
.post-nav-title { font-size: 0.9375rem; font-weight: 600; color: var(--heading); line-height: 1.35; }
.post-nav-next { text-align: right; }

/* ===================================
   SEARCH
=================================== */
.search-wrap { position: relative; margin-bottom: var(--sp-8); max-width: var(--content-w); }

.search-input {
  width: 100%;
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-serif);
  font-size: 0.9375rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(26,86,160,0.08);
}

.search-input::placeholder { color: var(--text-4); font-style: italic; }

.search-results {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0;
  background: var(--bg); border: 1px solid var(--border); border-radius: 5px;
  max-height: 360px; overflow-y: auto; display: none;
  box-shadow: 0 8px 24px rgba(0,0,0,0.09); z-index: 10;
}

.search-results.active { display: block; }

.search-result-item {
  padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--border);
  display: block; color: var(--text); transition: background 0.1s; text-decoration: none;
}

.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: var(--bg-subtle); }
.search-result-item .res-title { font-weight: 600; color: var(--link); font-size: 0.9375rem; margin-bottom: 2px; }
.search-result-item .res-meta  { font-size: 0.8125rem; color: var(--text-3); font-style: italic; }

/* ===================================
   CODE
=================================== */
pre, code { font-family: var(--font-mono); font-size: 0.875rem; }

code {
  background: var(--bg-subtle);
  padding: 0.15em 0.4em;
  border-radius: 3px;
  color: var(--text);
  border: 1px solid var(--border);
}

pre {
  background: var(--bg-subtle);
  padding: var(--sp-5);
  border-radius: 5px;
  overflow-x: auto;
  margin: var(--sp-6) 0;
  border: 1px solid var(--border);
  line-height: 1.6;
}

pre code { background: none; padding: 0; border: none; }

/* ===================================
   FOOTER
=================================== */
footer {
  max-width: none !important;
  margin-top: var(--sp-16);
  padding-top: var(--sp-6);
  border-top: 1px solid var(--border);
  font-size: 0.8125rem;
  color: var(--text-4);
  font-style: italic;
}

/* ===================================
   UTILS
=================================== */
.sr-only { position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; border-width:0; }

*:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

mark {
  background: rgba(26,86,160,0.1);
  color: var(--heading);
  padding: 0.1em 0.25em;
  border-radius: 2px;
}

/* ===================================
   RESPONSIVE
=================================== */
@media (max-width: 1000px) {
  :root {
    --gap: 2.5rem;
    --sidebar-w: 200px;
    --content-w: 580px;
  }
}

@media (max-width: 768px) {
  .sidebar  { display: none; }
  .topbar   { display: flex; }

  .main-content {
    margin-left: 0;
    margin-top: var(--nav-h);
    padding: var(--sp-8) var(--sp-5) var(--sp-12);
  }

  .main-content > * { max-width: 100%; }

  .page-title { font-size: 1.875rem; }
  .stats-row  { grid-template-columns: 1fr 1fr; }
  .cv-item    { grid-template-columns: 1fr; gap: var(--sp-2); }
  .post-nav   { grid-template-columns: 1fr; }
  .post-nav-next { text-align: left; }
}

@media (max-width: 480px) {
  .stats-row { grid-template-columns: 1fr; }
  h1 { font-size: 1.75rem; }
}

/* ===================================
   PRINT
=================================== */
@media print {
  .sidebar, .topbar, .search-wrap { display: none !important; }
  .main-content { margin-left: 0; padding: 0; }
}