/* ============================================================
   MAIN STYLESHEET  (css/style.css)
   ============================================================

   Aesthetic: refined editorial dark — ink-black background,
   warm off-white text, terracotta/amber accent.
   Typography: DM Serif Display (headings) + Source Serif 4 (body)

   CSS custom properties (variables) are at the top — tweak
   colors here to retheme the whole site.
   ============================================================ */

/* ── Fonts ──────────────────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=DM+Serif+Display:ital@0;1&family=Source+Serif+4:ital,opsz,wght@0,8..60,300..700;1,8..60,300..700&family=JetBrains+Mono:wght@400;500&display=swap');

/* ── Custom Properties ──────────────────────────────────────────────────── */
:root {
  /* Palette */
  --bg:           #f5f2ee;
  --bg-raised:    #ede9e3;
  --bg-card:      #e8e3db;
  --border:       #d0c9bf;
  --border-light: #b8b0a5;
  --text:         #1a1816;
  --text-muted:   #5a5650;
  --text-faint:   #9a9590;

  --accent:       #c97d4b;   /* terracotta */
  --accent-light: #e09b6e;
  --accent-dim:   #7a4b2d;
  --accent-bg:    rgba(201,125,75,0.08);

  --link:         #c97d4b;
  --link-hover:   #e09b6e;

  /* Typography */
  --font-display: 'DM Serif Display', Georgia, serif;
  --font-body:    'Source Serif 4', Georgia, serif;
  --font-mono:    'JetBrains Mono', monospace;

  /* Layout */
  --sidebar-w:    320px;
  --content-max:  860px;
  --gap:          2rem;
  --radius:       6px;
  --radius-lg:    12px;

  /* Transitions */
  --ease:         cubic-bezier(0.25, 0, 0.1, 1);
}

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

html { font-size: 16px; scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.75;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── Typography ─────────────────────────────────────────────────────────── */
h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 400;
  line-height: 1.2;
}

a {
  color: var(--link);
  text-decoration: none;
  transition: color 0.15s var(--ease);
}
a:hover { color: var(--link-hover); text-decoration: underline; }

strong { font-weight: 600; }
em     { font-style: italic; }

ul, ol { padding-left: 1.5rem; }
li     { margin-bottom: 0.25rem; }

/* ── Layout ─────────────────────────────────────────────────────────────── */
.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: auto 1fr auto;
  min-height: 100vh;
}

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
.sidebar {
  grid-column: 1;
  grid-row: 1 / -1;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  border-right: 1px solid var(--border);
  padding: 2.5rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
  background: var(--bg-raised);

  /* subtle noise texture */
  background-image:
    radial-gradient(ellipse at 20% 0%, rgba(201,125,75,0.04) 0%, transparent 60%),
    url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.03'/%3E%3C/svg%3E");
}

/* Scrollbar in sidebar */
.sidebar::-webkit-scrollbar        { width: 4px; }
.sidebar::-webkit-scrollbar-track  { background: transparent; }
.sidebar::-webkit-scrollbar-thumb  { background: var(--border); border-radius: 2px; }

/* Profile photo */
.profile-photo-wrap {
  position: relative;
  width: 120px;
  height: 120px;
}

.profile-photo-wrap::before {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  background: conic-gradient(var(--accent) 0deg, var(--accent-dim) 120deg, transparent 180deg);
  opacity: 0.6;
}

#profile-photo {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  position: relative;
  z-index: 1;
  background: var(--bg-card);
}

/* Name & title */
.sidebar-identity h1 {
  font-size: 1.45rem;
  letter-spacing: -0.01em;
  color: var(--text);
}
.sidebar-identity .site-title {
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 400;
  color: var(--text-muted);
  margin-top: 0.25rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.sidebar-identity .site-tagline {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-top: 0.6rem;
  line-height: 1.5;
  font-style: italic;
}

/* CV button */
.btn-cv {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1.1rem;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  transition: background 0.15s var(--ease), transform 0.1s;
  width: fit-content;
  text-decoration: none;
}
.btn-cv:hover {
  background: var(--accent-light);
  color: #fff;
  text-decoration: none;
  transform: translateY(-1px);
}

/* Social links */
.social-links {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.social-link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.45rem 0.6rem;
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 0.875rem;
  transition: background 0.12s, color 0.12s;
  text-decoration: none;
}
.social-link:hover {
  background: var(--accent-bg);
  color: var(--accent-light);
  text-decoration: none;
}
.social-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.75;
  display: flex;
  align-items: center;
}
.social-icon svg { width: 100%; height: 100%; }
.social-link:hover .social-icon { opacity: 1; }
.social-label { line-height: 1; }

/* Sidebar footer (version/credits) */
.sidebar-footer {
  margin-top: auto;
  font-size: 0.72rem;
  color: var(--text-faint);
  line-height: 1.5;
}

/* ── Main content ────────────────────────────────────────────────────────── */
.main-content {
  grid-column: 2;
  grid-row: 1;
  max-width: var(--content-max);
  padding: 4rem 3.5rem;
}

/* Section headings */
.section-heading {
  font-family: var(--font-display);
  font-size: 1.6rem;
  color: var(--text);
  margin-bottom: 1.75rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.section-heading::before {
  content: "";
  display: inline-block;
  width: 4px;
  height: 1.3em;
  background: var(--accent);
  border-radius: 2px;
  flex-shrink: 0;
}

section + section {
  margin-top: 4rem;
}

/* ── Bio section ─────────────────────────────────────────────────────────── */
#bio p {
  color: var(--text);
  margin-bottom: 1em;
}
#bio a {
  border-bottom: 1px solid var(--accent-dim);
  padding-bottom: 1px;
}
#bio a:hover {
  border-color: var(--accent-light);
  text-decoration: none;
}

/* ── News feed ───────────────────────────────────────────────────────────── */
.news-item {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 0 1.5rem;
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
  align-items: start;
}
.news-item:last-child { border-bottom: none; }

#news-feed {
  max-height: 400px;
  overflow-y: auto;
  padding-right: 0.5rem;
}
#news-feed::-webkit-scrollbar        { width: 4px; }
#news-feed::-webkit-scrollbar-track  { background: transparent; }
#news-feed::-webkit-scrollbar-thumb  { background: var(--border); border-radius: 2px; }
.news-date {
  text-align: center;
  font-family: var(--font-mono);
  line-height: 1.2;
  padding-top: 0.15rem;
}
.news-month {
  display: block;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  font-weight: 500;
}
.news-day {
  display: block;
  font-size: 1.4rem;
  font-weight: 400;
  color: var(--text);
  line-height: 1;
}
.news-year {
  display: block;
  font-size: 0.65rem;
  color: var(--text-faint);
  letter-spacing: 0.05em;
}

.news-text {
  font-size: 0.95rem;
  line-height: 1.65;
  color: var(--text);
  padding-top: 0.1rem;
}
.news-text p { margin: 0; }
.news-text a { border-bottom: 1px solid var(--accent-dim); }
.news-text a:hover { border-color: var(--accent-light); text-decoration: none; }

/* ── Project cards ───────────────────────────────────────────────────────── */
.projects-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  max-height: 800px;
  overflow-y: auto;
  padding-right: 0.5rem;
}
.projects-grid::-webkit-scrollbar        { width: 4px; }
.projects-grid::-webkit-scrollbar-track  { background: transparent; }
.projects-grid::-webkit-scrollbar-thumb  { background: var(--border); border-radius: 2px; }

.project-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: grid;
  grid-template-columns: 1fr;
  transition: border-color 0.2s var(--ease), transform 0.2s var(--ease);
}
.project-card:hover {
  border-color: var(--border-light);
  transform: translateY(-2px);
}

/* Cards with media get a side-by-side layout on wider screens */
@media (min-width: 680px) {
  .project-card:has(.card-media) {
    grid-template-columns: 1fr;
  }
}

.card-media {
  position: relative;
  overflow: hidden;
  cursor: pointer;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
}
.card-media img {
  width: 100%;
  height: auto;
  max-height: 400px;
  object-fit: contain;
  display: block;
  transition: transform 0.4s var(--ease);
}
.card-media:hover img { transform: scale(1.04); }

.media-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.5) 0%, transparent 50%);
  opacity: 0;
  transition: opacity 0.2s;
  display: flex;
  align-items: flex-end;
  padding: 0.75rem;
}
.card-media:hover .media-overlay { opacity: 1; }
.media-overlay-hint {
  font-size: 0.72rem;
  color: rgba(255,255,255,0.8);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-family: var(--font-mono);
}

.video-thumb {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}
.play-icon { width: 40px; height: 40px; }
.play-icon svg { width: 100%; height: 100%; }

.card-body {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.card-tags { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.tag {
  font-size: 0.7rem;
  font-family: var(--font-mono);
  color: var(--accent);
  background: var(--accent-bg);
  border: 1px solid var(--accent-dim);
  border-radius: 3px;
  padding: 0.15rem 0.5rem;
  letter-spacing: 0.03em;
}

.card-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  color: var(--text);
  line-height: 1.3;
}

.card-description {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.65;
}
.card-description p  { margin-bottom: 0.5em; }
.card-description p:last-child { margin-bottom: 0; }
.card-description ul { margin: 0.5em 0; }
.card-description strong { color: var(--text); }

.card-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; margin-top: 0.25rem; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.9rem;
  border-radius: var(--radius);
  font-size: 0.82rem;
  font-family: var(--font-body);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s var(--ease);
  text-decoration: none;
}
.btn svg { width: 14px; height: 14px; flex-shrink: 0; }
.btn-ghost {
  border: 1px solid var(--border-light);
  color: var(--text-muted);
  background: transparent;
}
.btn-ghost:hover {
  border-color: var(--accent);
  color: var(--accent-light);
  text-decoration: none;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
  border: 1px solid transparent;
}
.btn-primary:hover {
  background: var(--accent-light);
  color: #fff;
  text-decoration: none;
  transform: translateY(-1px);
}

/* ── Empty states ────────────────────────────────────────────────────────── */
.empty {
  color: var(--text-faint);
  font-style: italic;
  font-size: 0.9rem;
}

/* ── Media modal ─────────────────────────────────────────────────────────── */
#media-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.9);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  backdrop-filter: blur(4px);
}
#media-modal.open { display: flex; }

#modal-inner {
  position: relative;
  max-width: min(90vw, 1200px);
  max-height: 85vh;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
#modal-inner img,
#modal-inner video,
#modal-inner iframe {
  max-width: 100%;
  max-height: 85vh;
  border-radius: var(--radius-lg);
  display: block;
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: contain;
}
#modal-inner img {
  aspect-ratio: auto;
  object-fit: contain;
}

#modal-close {
  position: fixed;
  top: 1.5rem;
  right: 1.5rem;
  background: rgba(255,255,255,0.1);
  border: none;
  color: white;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 1.25rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  z-index: 1001;
}
#modal-close:hover { background: rgba(255,255,255,0.2); }

/* ── Footer ──────────────────────────────────────────────────────────────── */
.site-footer {
  grid-column: 2;
  grid-row: 2;
  border-top: 1px solid var(--border);
  padding: 1.5rem 3.5rem;
  font-size: 0.78rem;
  color: var(--text-faint);
}

/* ── Animations ──────────────────────────────────────────────────────────── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

.main-content > section {
  animation: fadeUp 0.5s var(--ease) both;
}
.main-content > section:nth-child(1) { animation-delay: 0.05s; }
.main-content > section:nth-child(2) { animation-delay: 0.12s; }
.main-content > section:nth-child(3) { animation-delay: 0.19s; }
.main-content > section:nth-child(4) { animation-delay: 0.26s; }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  :root { --sidebar-w: 260px; }
  .main-content { padding: 3rem 2rem; }
}

@media (max-width: 680px) {
  .layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr auto;
  }

  .sidebar {
    grid-column: 1;
    grid-row: 1;
    position: static;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 2rem 1.5rem;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: flex-start;
  }

  .profile-photo-wrap { width: 80px; height: 80px; flex-shrink: 0; }
  #profile-photo { width: 80px; height: 80px; }
  .sidebar-identity { flex: 1; min-width: 160px; }
  .social-links { flex-direction: row; flex-wrap: wrap; }

  .main-content {
    grid-column: 1;
    grid-row: 2;
    padding: 2rem 1.25rem;
  }

  .site-footer {
    grid-column: 1;
    grid-row: 3;
    padding: 1rem 1.25rem;
  }

  .project-card:has(.card-media) {
    grid-template-columns: 1fr;
  }
  .card-media { min-height: 200px; }

  .news-item { grid-template-columns: 56px 1fr; gap: 0 1rem; }
}

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