/* ── Tokens ──────────────────────────────────────────────────────────────── */
:root {
  --bg:        #18181b;
  --surface:   #212125;
  --border:    #3a3a40;
  --accent:     #B693ED;
  --accent-dim: #4B307F;
  --text:      #e8e2d9;
  --muted:     #bdb6ab;
  --mono:      'IBM Plex Mono', monospace;
  --serif:     'Lora', serif;
  --sans:      'Inter', sans-serif;
}

/* ── Reset ───────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-weight: 400;
  line-height: 1.6;
  overflow-x: hidden;
  position: relative;
}

/* ── Ambient background ─────────────────────────────────────────────────────
   Faint static dot-grid for structure (cheap, no motion). The animated layer
   (drifting Malayalam glyphs + code punctuation) is rendered on #bg-canvas,
   see static/js/main.js. */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background-image: radial-gradient(var(--border) 1px, transparent 1px);
  background-size: 28px 28px;
  opacity: 0.35;
}
#bg-canvas {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  width: 100%;
  height: 100%;
  display: block;
}
img { max-width: 100%; display: block; }
a { color: inherit; }

/* ── Nav ─────────────────────────────────────────────────────────────────── */
nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 2.5rem;
  background: linear-gradient(to bottom, rgba(14,14,14,0.97), transparent);
}
.nav-logo {
  font-family: var(--mono);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.08em;
  text-decoration: none;
}
.cursor-line {
  display: inline-block;
  width: 0.55em;
  height: 1em;
  background: var(--accent);
  margin-left: 2px;
  vertical-align: text-bottom;
  animation: blink 1.1s step-end infinite;
}
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0} }
.nav-links { display: flex; gap: 2rem; list-style: none; }
.nav-links a {
  font-family: var(--mono);
  font-size: 0.85rem;
  letter-spacing: 0.12em;
  color: var(--muted);
  text-decoration: none;
  text-transform: uppercase;
  transition: color 0.2s;
}
.nav-links a:hover,
.nav-links a.active { color: var(--text); }

/* ── Hero ────────────────────────────────────────────────────────────────── */
.hero {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 100vh;
}
.hero.no-photo {
  grid-template-columns: 1fr;
  min-height: 0;
}
.hero-photo {
  position: relative;
  overflow: hidden;
  background: #111;
}
.hero-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: saturate(0.6);
  display: block;
}
.hero-photo:has(img[src=""]),
.hero-photo:empty {
  display: none;
}
.hero-photo::after {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 3px; height: 100%;
  background: linear-gradient(to bottom, transparent, var(--accent), transparent);
}
.hero-photo-placeholder {
  width: 100%;
  height: 100%;
  min-height: 100vh;
  background: linear-gradient(160deg, #1a1208 0%, #2c1f0a 40%, #0e0e0e 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 4rem;
  opacity: 0.15;
}
.hero-text {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 7rem 4rem 4rem;
}
.hero-eyebrow {
  font-family: var(--mono);
  font-size: 0.86rem;
  color: var(--accent);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin-bottom: 1.5rem;
}
.hero-name {
  font-family: var(--mono);
  font-size: clamp(2rem, 3.5vw, 3.2rem);
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin-bottom: 1.25rem;
}
.hero-name span { color: var(--accent); }

/* ── Flip hero name (Sachin Nandakumar → സച്ചിൻ നന്ദകുമാർ) ───────────────── */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.name-flip {
  perspective: 1000px;
  margin-bottom: 1.25rem;
}
.name-flip-inner {
  position: relative;
  transform-style: preserve-3d;
  animation: flip-name 5.4s ease-in-out infinite;
}
.name-face {
  position: relative;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  margin-bottom: 0 !important;
}
.name-face.name-back {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  transform: rotateX(180deg);
  font-family: 'Manjari', 'Noto Sans Malayalam', sans-serif;
  color: var(--text);
}
.name-face.name-back .ml-accent { color: var(--accent); }
@keyframes flip-name {
  0%   { transform: rotateX(0deg); }
  59%  { transform: rotateX(0deg); }
  65%  { transform: rotateX(180deg); }
  94%  { transform: rotateX(180deg); }
  100% { transform: rotateX(360deg); }
}
@media (prefers-reduced-motion: reduce) {
  .name-flip-inner { animation: none; }
}
.hero-bio {
  font-family: var(--serif);
  font-size: 1.35rem;
  line-height: 1.8;
  color: var(--muted);
  max-width: 38ch;
  text-align: justify;
  margin-bottom: 2rem;
}
.hero-bio em { color: var(--text); font-style: italic; }
.hero-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 2.5rem;
}
.tag {
  font-family: var(--mono);
  font-size: 0.86rem;
  letter-spacing: 0.08em;
  padding: 0.3rem 0.7rem;
  border: 1px solid var(--border);
  color: var(--muted);
  text-transform: uppercase;
}
.tag.active { border-color: var(--accent-dim); color: var(--accent); }
.hero-cta { display: flex; gap: 1rem; flex-wrap: wrap; }
.btn {
  font-family: var(--mono);
  font-size: 0.86rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-decoration: none;
  padding: 0.75rem 1.5rem;
  transition: all 0.2s;
  cursor: pointer;
  display: inline-block;
}
.btn-primary {
  background: var(--accent);
  color: #1a0e2e;
  box-shadow: 0 0 0 rgba(182, 147, 237, 0);
  transition: all 0.25s;
}
.btn-primary:hover {
  background: #c97ff5;
  box-shadow: 0 0 24px 2px rgba(182, 147, 237, 0.45);
}
.btn-ghost { border: 1px solid var(--border); color: var(--muted); }
.btn-ghost:hover {
  border-color: var(--accent-dim);
  color: var(--text);
  box-shadow: 0 0 16px rgba(182, 147, 237, 0.15);
}

/* ── Section base ────────────────────────────────────────────────────────── */
.section {
  padding: 5rem 2.5rem;
  max-width: 1200px;
  margin: 0 auto;
}
.section-label {
  font-family: var(--mono);
  font-size: 0.86rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 2.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}
.section-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ── Instagram strip ─────────────────────────────────────────────────────── */
.instagram-strip {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  margin-top: 2rem;
  padding: 1.5rem 1.75rem;
  border: 1px solid var(--border);
  text-decoration: none;
  color: inherit;
  transition: border-color 0.25s, box-shadow 0.25s, background 0.25s;
}
.instagram-strip:hover {
  border-color: var(--accent-dim);
  box-shadow: 0 0 20px rgba(182, 147, 237, 0.12);
  background: var(--surface);
}
.instagram-strip-icon {
  width: 2rem;
  height: 2rem;
  flex-shrink: 0;
  color: var(--accent);
}
.instagram-strip-text {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  flex: 1;
}
.instagram-strip-handle {
  font-family: var(--mono);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}
.instagram-strip-tagline {
  font-family: var(--serif);
  font-size: 0.92rem;
  color: var(--muted);
}
.instagram-strip-arrow {
  font-family: var(--mono);
  font-size: 1.1rem;
  color: var(--muted);
  transition: transform 0.25s, color 0.25s;
}
.instagram-strip:hover .instagram-strip-arrow {
  color: var(--accent);
  transform: translateX(4px);
}
@media (max-width: 600px) {
  .instagram-strip-tagline { display: none; }
}

/* ── Photo grid (home) ───────────────────────────────────────────────────────
   Collage/masonry layout: CSS columns let each tile keep its photo's natural
   aspect ratio (mixed portrait/landscape) instead of forcing a uniform crop,
   which is what made the old fixed-ratio grid look inconsistent. */
.photo-grid {
  column-count: 3;
  column-gap: 0.75rem;
}
.photo-card {
  position: relative;
  overflow: hidden;
  background: var(--surface);
  text-decoration: none;
  display: block;
  break-inside: avoid;
  margin-bottom: 0.75rem;
  transition: box-shadow 0.3s;
}
.photo-card img {
  width: 100%;
  height: auto;
  filter: saturate(0.65);
  transition: filter 0.4s, transform 0.5s;
  display: block;
}
.photo-card .no-cover {
  width: 100%;
  aspect-ratio: 4/3;
  background:
    radial-gradient(circle at 30% 30%, color-mix(in srgb, var(--accent) 14%, transparent) 0%, transparent 60%),
    linear-gradient(135deg, var(--surface), #1e1e1e);
  position: relative;
}
.photo-card .no-cover::after {
  content: '◈';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  color: var(--accent-dim);
  opacity: 0.5;
}
.photo-card:hover img { filter: saturate(1); transform: scale(1.03); }
.photo-card:hover { box-shadow: 0 0 0 1px var(--accent-dim), 0 12px 32px rgba(0,0,0,0.4); }
.photo-card-meta {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  padding: 2rem 1.25rem 1.25rem;
  background: linear-gradient(to top, rgba(0,0,0,0.88), transparent);
  opacity: 0;
  transform: translateY(4px);
  transition: all 0.3s;
}
.photo-card:hover .photo-card-meta { opacity: 1; transform: translateY(0); }
.photo-card-title {
  font-family: var(--serif);
  font-size: 0.95rem;
  color: var(--text);
}
.photo-card-date {
  font-family: var(--mono);
  font-size: 0.62rem;
  color: var(--accent);
  margin-top: 0.25rem;
}

/* ── Projects grid (home) ────────────────────────────────────────────────── */
.projects-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--border);
}
.project-card {
  background: var(--bg);
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  transition: background 0.2s;
  text-decoration: none;
  color: inherit;
}
.project-card:hover { background: var(--surface); box-shadow: inset 0 0 0 1px var(--accent-dim); }
.project-icon { font-size: 1.4rem; line-height: 1; }
.project-logo { height: 2rem; display: flex; align-items: center; }
.project-logo img { height: 100%; width: auto; max-width: 160px; object-fit: contain; filter: brightness(0) invert(1); opacity: 0.85; transition: opacity 0.2s; }
.project-card:hover .project-logo img { opacity: 1; }
.project-name {
  font-family: var(--mono);
  font-size: 1.06rem;
  font-weight: 600;
  color: var(--text);
}
.project-status {
  font-family: var(--mono);
  font-size: 0.76rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}
.project-desc {
  font-family: var(--serif);
  font-size: 1.12rem;
  color: var(--muted);
  line-height: 1.6;
  flex: 1;
}
.project-link {
  font-family: var(--mono);
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  color: var(--muted);
  text-transform: uppercase;
  transition: color 0.2s;
}
.project-card:hover .project-link { color: var(--accent); }

/* ── Blog index ──────────────────────────────────────────────────────────── */
.blog-list { display: flex; flex-direction: column; gap: 1px; background: var(--border); }
.blog-card {
  display: grid;
  grid-template-columns: 280px 1fr;
  background: var(--bg);
  text-decoration: none;
  color: inherit;
  transition: background 0.2s;
}
.blog-card:hover { background: var(--surface); }
.blog-card-img { overflow: hidden; }
.blog-card-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  aspect-ratio: 4/3;
  filter: saturate(0.6);
  transition: filter 0.4s, transform 0.5s;
}
.blog-card:hover .blog-card-img img { filter: saturate(1); transform: scale(1.04); }
.blog-card-img .no-cover {
  width: 100%;
  aspect-ratio: 4/3;
  background:
    radial-gradient(circle at 30% 30%, color-mix(in srgb, var(--accent) 14%, transparent) 0%, transparent 60%),
    var(--surface);
  position: relative;
}
.blog-card-img .no-cover::after {
  content: '◈';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  color: var(--accent-dim);
  opacity: 0.5;
}
.blog-card-body {
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  justify-content: center;
}
.blog-card-date {
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  color: var(--accent);
  text-transform: uppercase;
}
.blog-card-title {
  font-family: var(--serif);
  font-size: 1.3rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text);
}
.blog-card-desc {
  font-family: var(--sans);
  font-size: 1.12rem;
  color: var(--muted);
  line-height: 1.6;
}
.blog-card-tags { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.5rem; }

/* ── Post page ───────────────────────────────────────────────────────────── */
.post-header {
  padding: 7rem 2.5rem 2rem;
  max-width: 780px;
  margin: 0 auto;
}
.post-eyebrow {
  font-family: var(--mono);
  font-size: 0.65rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.post-eyebrow a {
  color: var(--muted);
  text-decoration: none;
  transition: color 0.2s;
}
.post-eyebrow a:hover { color: var(--accent); }
.post-title {
  font-family: var(--serif);
  font-size: clamp(1.8rem, 4vw, 2.8rem);
  font-weight: 600;
  line-height: 1.2;
  margin-bottom: 1rem;
}
.post-meta-tags { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 1rem; }
.post-cover {
  width: 100%;
  max-height: 520px;
  object-fit: cover;
  display: block;
  filter: saturate(0.7);
  margin-bottom: 0;
}
.post-body {
  max-width: 780px;
  margin: 0 auto;
  padding: 3rem 2.5rem 5rem;
  font-family: var(--serif);
  font-size: 1.08rem;
  line-height: 1.9;
  color: var(--text);
}
.post-body p { margin-bottom: 1.5rem; }
.post-body h2 {
  font-family: var(--mono);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--accent);
  margin: 2.5rem 0 1rem;
}
.post-body h3 {
  font-family: var(--serif);
  font-size: 1.2rem;
  font-weight: 600;
  margin: 2rem 0 0.75rem;
}
.post-body blockquote {
  border-left: 3px solid var(--accent);
  padding: 0.5rem 0 0.5rem 1.5rem;
  margin: 2rem 0;
  color: var(--muted);
  font-style: italic;
}
.post-body blockquote p { margin-bottom: 0; }
.post-body a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.post-body figure {
  margin: 2rem 0;
}
.post-body figure img {
  width: 100%;
  filter: saturate(0.75);
  transition: filter 0.4s;
}
.post-body figure img:hover { filter: saturate(1); }
.post-body figcaption {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-top: 0.6rem;
  text-align: center;
}
.post-body em { font-style: italic; }
.post-body strong { font-weight: 600; color: var(--text); }

/* ── Projects full page ──────────────────────────────────────────────────── */
.project-full-card {
  border: 1px solid var(--border);
  margin-bottom: 2rem;
  padding: 2rem;
}
.project-full-header {
  display: flex;
  align-items: flex-start;
  gap: 1.25rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}
.project-ext-link {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  text-decoration: none;
  margin-left: auto;
  border: 1px solid var(--accent-dim);
  padding: 0.4rem 0.9rem;
  transition: background 0.2s;
}
.project-ext-link:hover { background: var(--accent-dim); }
.project-full-body {
  font-family: var(--serif);
  font-size: 1rem;
  color: var(--muted);
  line-height: 1.8;
}

/* ── About ───────────────────────────────────────────────────────────────── */
.about-body {
  max-width: 680px;
  margin: 0 auto;
  padding: 7rem 2.5rem 5rem;
}
.about-body p {
  font-family: var(--serif);
  font-size: 1.1rem;
  line-height: 1.9;
  color: var(--muted);
  text-align: justify;
  margin-bottom: 1.5rem;
}
.about-body em { color: var(--text); font-style: italic; }
.about-body h2 {
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 2.5rem 0 1rem;
}

/* ── Page header (non-home) ──────────────────────────────────────────────── */
.page-header {
  padding: 7rem 2.5rem 3rem;
  max-width: 1200px;
  margin: 0 auto;
}
.page-title {
  font-family: var(--mono);
  font-size: clamp(1.8rem, 3vw, 2.5rem);
  font-weight: 600;
  letter-spacing: -0.02em;
}
.page-subtitle {
  font-family: var(--serif);
  font-size: 1.3rem;
  color: var(--muted);
  margin-top: 0.5rem;
}

/* ── Footer ──────────────────────────────────────────────────────────────── */
footer {
  border-top: 1px solid var(--border);
  padding: 2rem 2.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 4rem;
}
.footer-mono {
  font-family: var(--mono);
  font-size: 0.86rem;
  color: var(--muted);
  letter-spacing: 0.08em;
}
.footer-mono a { color: var(--accent); text-decoration: none; }

/* ── Scroll reveal ───────────────────────────────────────────────────────── */
.reveal {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}
.reveal.visible { opacity: 1; transform: translateY(0); }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; }
  .hero-photo { display: none; }
  .hero-text { padding: 6rem 1.5rem 3rem; }
  .photo-grid { column-count: 2; }
  .projects-grid { grid-template-columns: 1fr; }
  nav { padding: 1rem 1.25rem; }
  .nav-links { gap: 1.25rem; }
  .blog-card { grid-template-columns: 1fr; }
  .blog-card-img img { aspect-ratio: 16/7; }
  .section { padding: 3rem 1.5rem; }
  .post-header { padding: 6rem 1.5rem 1.5rem; }
  .post-body { padding: 2rem 1.5rem 4rem; }
}

@media (max-width: 480px) {
  .hero-name { font-size: 2rem; }
  .photo-grid { column-count: 1; }
  .projects-grid { grid-template-columns: 1fr; }
}
