/* =========================================================
   Sepehr Chahnavi — Portfolio
   Editorial poster design system: cream, ink, red accent —
   same palette and hard-edge/outline treatment as the hero.
   ========================================================= */

:root {
  /* Color — same cream/ink/red system as the hero */
  --bg: #efe8db;
  --bg-alt: #e7ded0;
  --surface: #f5f1e7;
  --surface-line: rgba(22, 19, 15, 0.16);
  --ink: #16130f;
  --ink-dim: rgba(22, 19, 15, 0.62);
  --red: #e33a2c;
  /* kept as aliases so nothing else has to change name */
  --cyan: var(--red);
  --magenta: var(--red);
  --green: var(--red);
  --amber: var(--red);

  /* Type */
  --font-display: 'Orbitron', 'Vazirmatn', sans-serif;
  --font-body: 'Rajdhani', 'Vazirmatn', sans-serif;
  --font-fa: 'Vazirmatn', 'Rajdhani', sans-serif;

  /* Layout */
  --content-w: 1120px;
  --edge: clamp(20px, 5vw, 64px);
  --radius: 2px;

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

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 90px; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

html[dir="rtl"] body,
body.lang-fa {
  font-family: var(--font-fa);
}

body.lang-fa .hero-headline,
body.lang-fa .section-title,
body.lang-fa .brand-name {
  font-family: var(--font-fa);
  letter-spacing: 0;
}

img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; margin: 0; padding: 0; }
button { font-family: inherit; cursor: pointer; }

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--red);
  color: #fff;
  padding: 10px 16px;
  z-index: 999;
}
.skip-link:focus { left: 12px; top: 12px; }

:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: 3px;
}

/* ---------- background texture ---------- */
.grid-overlay {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    linear-gradient(var(--surface-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--surface-line) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, #000 40%, transparent 100%);
  opacity: 0.5;
}

.noise-overlay {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.035;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='120' height='120'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
}

main, header, footer { position: relative; z-index: 1; }

/* ---------- header ---------- */
.site-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 50;
  background: rgba(239, 232, 219, 0.82);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--surface-line);
}

.header-inner {
  max-width: var(--content-w);
  margin: 0 auto;
  padding: 14px var(--edge);
  display: flex;
  align-items: center;
  gap: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-inline-end: auto;
}
.brand-logo { width: 34px; height: 34px; border-radius: 50%; filter: drop-shadow(0 0 6px rgba(227,58,44,0.35)); }
.brand-name { font-family: var(--font-display); font-size: 15px; letter-spacing: 0.5px; color: var(--ink); }
.brand-name b { color: var(--red); font-weight: 700; }

.main-nav {
  display: flex;
  gap: 26px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.3px;
}
.main-nav a {
  position: relative;
  color: var(--ink-dim);
  transition: color 0.2s var(--ease);
  padding: 4px 2px;
}
.main-nav a:hover, .main-nav a:focus-visible { color: var(--red); }
.main-nav a::after {
  content: "";
  position: absolute;
  left: 0; right: 100%;
  bottom: -2px;
  height: 2px;
  background: var(--red);
  transition: right 0.25s var(--ease);
}
.main-nav a:hover::after, .main-nav a.active::after { right: 0; }
.main-nav a.active { color: var(--red); }

.header-actions { display: flex; align-items: center; gap: 14px; }

.lang-toggle {
  background: transparent;
  border: 1px solid var(--surface-line);
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 12px;
  letter-spacing: 1px;
  padding: 7px 12px;
  border-radius: var(--radius);
  display: flex;
  gap: 4px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.lang-toggle:hover { border-color: var(--red); box-shadow: 0 0 12px rgba(227,58,44,0.18); }
.lang-toggle-en, .lang-toggle-fa { opacity: 0.5; }
body.lang-en .lang-toggle-en,
body.lang-fa .lang-toggle-fa { opacity: 1; color: var(--red); }
.lang-toggle-sep { opacity: 0.3; }

.nav-burger {
  display: none;
  width: 34px; height: 34px;
  background: transparent;
  border: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
}
.nav-burger span {
  width: 20px; height: 2px;
  background: var(--ink);
  transition: transform 0.25s var(--ease), opacity 0.2s;
}

/* ---------- hero ---------- */
/* Local aliases kept for readability; same cream/ink/red values as :root. */
.hero {
  --hero-cream: #efe8db;
  --hero-ink: #16130f;
  --hero-red: #e33a2c;
  --hero-line: rgba(22, 19, 15, 0.16);
  position: relative;
  min-height: 100svh;
  background: var(--hero-cream);
  color: var(--hero-ink);
  padding: 128px var(--edge) 70px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.hero-corner {
  position: absolute;
  width: 26px; height: 26px;
  z-index: 2;
  pointer-events: none;
}
.hero-corner::before, .hero-corner::after {
  content: "";
  position: absolute;
  background: var(--hero-ink);
}
.hero-corner::before { width: 100%; height: 2px; top: 0; }
.hero-corner::after { width: 2px; height: 100%; left: 0; }
.hero-corner--tl { top: 24px; inset-inline-start: var(--edge); }
.hero-corner--tr { top: 24px; inset-inline-end: var(--edge); }
.hero-corner--tr::before { right: 0; }
.hero-corner--tr::after { left: auto; right: 0; }
.hero-corner--bl { bottom: 24px; inset-inline-start: var(--edge); }
.hero-corner--bl::before { bottom: 0; top: auto; }
.hero-corner--br { bottom: 24px; inset-inline-end: var(--edge); }
.hero-corner--br::before { bottom: 0; top: auto; right: 0; }
.hero-corner--br::after { left: auto; right: 0; }

.hero-vertical-tag {
  position: absolute;
  top: 50%;
  inset-inline-start: 22px;
  transform: translateY(-50%) rotate(-90deg);
  transform-origin: left center;
  font-family: var(--font-display);
  font-size: 11px;
  letter-spacing: 3px;
  color: var(--hero-red);
  white-space: nowrap;
  z-index: 2;
}

.hero-inner {
  position: relative;
  z-index: 1;
  max-width: var(--content-w);
  width: 100%;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 40px;
  align-items: center;
}

.hero-copy { padding-inline-start: 34px; }

.hero-eyebrow {
  display: inline-block;
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 2px;
  color: #fff;
  background: var(--hero-red);
  padding: 6px 14px;
  border-radius: 20px;
  margin: 0 0 22px;
}

.hero-name {
  margin: 0 0 22px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px 18px;
}
.hero-name-outline,
.hero-name-solid {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(2.4rem, 6.4vw, 4.4rem);
  line-height: 0.95;
  letter-spacing: 1px;
}
.hero-name-outline {
  color: transparent;
  -webkit-text-stroke: 2px var(--hero-ink);
  text-stroke: 2px var(--hero-ink);
}
.hero-name-solid { color: var(--hero-ink); }
.hero-name-badge {
  align-self: flex-start;
  margin-top: 6px;
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--hero-red);
  border: 1.5px solid var(--hero-red);
  border-radius: 20px;
  padding: 5px 12px;
  white-space: nowrap;
}

.hero-subhead {
  font-size: clamp(1rem, 1.4vw, 1.15rem);
  color: var(--hero-ink);
  opacity: 0.72;
  max-width: 46ch;
  margin: 0 0 34px;
}

.hero-cta-row { display: flex; gap: 16px; flex-wrap: wrap; }

.btn {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 13px 28px;
  font-family: var(--font-display);
  font-size: 14px;
  letter-spacing: 1px;
  border-radius: var(--radius);
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease), border-color 0.2s, background 0.2s, color 0.2s;
  border: 1.5px solid transparent;
}
.btn:hover { transform: translateY(-2px); }
.btn-primary {
  background: var(--red);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 8px 20px rgba(227,58,44,0.28);
  border-color: var(--red);
}
.btn-primary:hover { box-shadow: 0 10px 26px rgba(227,58,44,0.4); }
.btn-ghost {
  background: transparent;
  border-color: var(--ink);
  color: var(--ink);
}
.btn-ghost:hover { background: var(--ink); color: var(--bg); }
.btn-sub { font-family: var(--font-body); font-size: 11px; font-weight: 500; opacity: 0.75; letter-spacing: 0.3px; }

/* --- hero art column --- */
.hero-art {
  position: relative;
  min-height: 380px;
  display: flex;
  align-items: center;
  justify-content: center;
  perspective: 900px;
}

.hero-art-panel {
  position: absolute;
  top: 6%;
  inset-inline-end: -6%;
  width: 78%;
  height: 88%;
  background: var(--hero-red);
  clip-path: polygon(18% 0, 100% 0, 82% 100%, 0 100%);
  z-index: 0;
}

.hero-art-frame {
  position: relative;
  z-index: 1;
  width: min(70%, 300px);
  aspect-ratio: 1;
  will-change: transform;
  transform-style: preserve-3d;
  transition: transform 0.1s linear;
}
.hero-logo {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 18px 30px rgba(22,19,15,0.35));
}

.hero-quote {
  position: absolute;
  bottom: 4%;
  inset-inline-end: 2%;
  z-index: 2;
  max-width: 220px;
  background: var(--hero-cream);
  border: 1.5px solid var(--hero-ink);
  border-radius: var(--radius);
  padding: 12px 16px;
}
.hero-quote p {
  margin: 0;
  font-size: 12px;
  font-style: italic;
  line-height: 1.4;
}

.hero-info-card {
  position: absolute;
  bottom: -6%;
  inset-inline-start: -6%;
  z-index: 2;
  width: 210px;
  background: var(--hero-cream);
  border: 1.5px solid var(--hero-ink);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: 6px 6px 0 var(--hero-ink);
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.hero-info-card:hover { transform: translate(-3px, -3px); box-shadow: 9px 9px 0 var(--hero-red); }
.hero-info-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 13px;
  color: var(--hero-red);
  margin-bottom: 6px;
}
.hero-info-text { display: block; font-size: 12px; color: var(--hero-ink); opacity: 0.75; }

.hero-scroll-cue {
  position: absolute;
  bottom: 26px; left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  font-family: var(--font-display);
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--hero-ink);
  opacity: 0.6;
  z-index: 2;
}
.hero-scroll-cue i {
  width: 1px; height: 34px;
  background: linear-gradient(var(--hero-red), transparent);
  position: relative;
  overflow: hidden;
}
.hero-scroll-cue i::after {
  content: "";
  position: absolute;
  left: 0; top: -100%;
  width: 100%; height: 100%;
  background: var(--hero-red);
  animation: scroll-drip 1.8s ease-in-out infinite;
}
@keyframes scroll-drip { to { top: 100%; } }

/* ---------- sections ---------- */
.section { padding: 110px var(--edge); position: relative; }
.section--alt { background: var(--bg-alt); border-top: 1px solid var(--surface-line); border-bottom: 1px solid var(--surface-line); }
.section-inner { max-width: var(--content-w); margin: 0 auto; }

.section-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.7rem, 3vw, 2.3rem);
  margin: 0 0 8px;
  position: relative;
  padding-inline-start: 20px;
  border-inline-start: 3px solid var(--red);
}
.section-kicker { color: var(--cyan); font-family: var(--font-display); font-size: 12px; letter-spacing: 1.5px; margin: 0 0 40px; padding-inline-start: 23px; }

/* about */
.about-inner {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 64px;
  align-items: start;
}
.about-media { position: relative; }
.about-image { width: 100%; aspect-ratio: 4/4.5; object-fit: cover; border-radius: var(--radius); position: relative; z-index: 1; }
.about-media-frame {
  position: absolute;
  inset: 14px -14px -14px 14px;
  border: 1px solid var(--cyan);
  z-index: 0;
}
.about-copy .section-title, .about-copy .section-kicker { padding-inline-start: 0; border: none; }
.about-paragraphs p { color: var(--ink-dim); margin: 0 0 18px; max-width: 62ch; }

/* timeline */
.timeline { position: relative; padding-inline-start: 28px; border-inline-start: 1px solid var(--surface-line); }
.timeline-item { position: relative; padding-bottom: 48px; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-item::before {
  content: "";
  position: absolute;
  inset-inline-start: -33px;
  top: 4px;
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--bg);
  border: 2px solid var(--red);
  box-shadow: 0 0 10px rgba(227,58,44,0.35);
}
.timeline-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px 16px; margin-bottom: 6px; }
.timeline-role { font-family: var(--font-display); font-size: 17px; color: var(--ink); }
.timeline-company { color: var(--cyan); font-weight: 600; }
.timeline-period { margin-inline-start: auto; font-size: 13px; color: var(--ink-dim); font-family: var(--font-display); letter-spacing: 0.5px; }
.timeline-meta { font-size: 13px; color: var(--ink-dim); margin: 0 0 10px; }
.timeline-bullets li { position: relative; padding-inline-start: 18px; color: var(--ink-dim); margin-bottom: 6px; }
.timeline-bullets li::before { content: "▸"; position: absolute; inset-inline-start: 0; color: var(--green); }
.timeline-link { display: inline-block; margin-top: 8px; font-size: 13px; color: var(--magenta); border-bottom: 1px dashed currentColor; }

/* skills */
.skills-grid { display: flex; flex-wrap: wrap; gap: 12px; }
.skills-grid li {
  padding: 9px 16px;
  border: 1px solid var(--surface-line);
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-dim);
  transition: border-color 0.2s, color 0.2s, transform 0.2s;
}
.skills-grid li:hover { border-color: var(--cyan); color: var(--cyan); transform: translateY(-2px); }

/* projects */
.projects-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 28px; }
.project-card {
  background: var(--surface);
  border: 1.5px solid var(--surface-line);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.25s, transform 0.25s, box-shadow 0.25s;
}
.project-card:hover {
  border-color: var(--ink);
  transform: translate(-3px, -3px);
  box-shadow: 6px 6px 0 var(--red);
}
.project-media { aspect-ratio: 16/10; overflow: hidden; }
.project-media img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.4s var(--ease); }
.project-card:hover .project-media img { transform: scale(1.05); }
.project-body { padding: 20px 22px 24px; }
.project-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.project-title { font-family: var(--font-display); font-size: 16px; margin: 0; }
.project-year { font-size: 12px; color: var(--cyan); font-family: var(--font-display); }
.project-desc { color: var(--ink-dim); font-size: 14px; margin: 10px 0 14px; }
.project-tags { display: flex; gap: 8px; flex-wrap: wrap; }
.project-tags span { font-size: 11px; padding: 4px 10px; border: 1px solid var(--surface-line); border-radius: 20px; color: var(--ink-dim); }

/* education */
.education-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 28px; }
.education-item {
  padding: 24px;
  border: 1.5px solid var(--surface-line);
  border-radius: var(--radius);
  background: var(--surface);
  transition: border-color 0.25s, transform 0.25s, box-shadow 0.25s;
}
.education-item:hover {
  border-color: var(--ink);
  transform: translate(-3px, -3px);
  box-shadow: 6px 6px 0 var(--red);
}
.education-degree { font-family: var(--font-display); font-size: 16px; margin: 0 0 4px; }
.education-school { color: var(--cyan); font-weight: 600; margin: 0 0 4px; }
.education-period { font-size: 13px; color: var(--ink-dim); margin: 0 0 14px; }
.education-courses li { font-size: 13px; color: var(--ink-dim); padding-inline-start: 16px; position: relative; margin-bottom: 5px; }
.education-courses li::before { content: "–"; position: absolute; inset-inline-start: 0; color: var(--green); }

/* contact */
.section--contact { text-align: center; }
.contact-inner { max-width: 640px; }
.contact-inner .section-title { padding-inline-start: 0; border: none; }
.contact-text { color: var(--ink-dim); margin: 0 0 36px; }
.contact-actions { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; }

/* footer */
.site-footer { border-top: 1px solid var(--surface-line); padding: 32px var(--edge) 40px; }
.footer-inner { max-width: var(--content-w); margin: 0 auto; display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px; font-size: 13px; color: var(--ink-dim); }
.footer-built a { color: var(--cyan); border-bottom: 1px dashed currentColor; }

/* glitch trigger (single load-time moment, not looping) */
[data-glitch] { position: relative; }
[data-glitch].glitch-play {
  animation: glitch-shift 0.6s steps(3, end) 1;
}
@keyframes glitch-shift {
  0% { clip-path: inset(0 0 88% 0); transform: translate(-5px, 0); text-shadow: 2px 0 var(--red), -2px 0 var(--bg); }
  25% { clip-path: inset(55% 0 8% 0); transform: translate(5px, 0); }
  50% { clip-path: inset(15% 0 55% 0); transform: translate(-4px, 0); text-shadow: -2px 0 var(--red), 2px 0 var(--bg); }
  75% { clip-path: inset(70% 0 3% 0); transform: translate(3px, 0); }
  100% { clip-path: inset(0 0 0 0); transform: translate(0, 0); text-shadow: none; }
}

/* reduced motion */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .hero-scroll-cue i::after {
    animation: none !important;
  }
}

/* ---------- responsive ---------- */
@media (max-width: 860px) {
  .main-nav { display: none; }
  .nav-burger { display: flex; }
  .header-inner.open .main-nav {
    display: flex;
    position: absolute;
    top: 100%; left: 0; right: 0;
    flex-direction: column;
    background: rgba(239, 232, 219, 0.97);
    border-bottom: 1px solid var(--surface-line);
    padding: 18px var(--edge) 26px;
    gap: 18px;
  }
  .about-inner { grid-template-columns: 1fr; }
  .about-media { max-width: 320px; margin: 0 auto; }
  .projects-grid { grid-template-columns: 1fr; }
  .education-list { grid-template-columns: 1fr; }
  .timeline-period { margin-inline-start: 0; }

  .hero-inner { grid-template-columns: 1fr; gap: 80px; }
  .hero-copy { padding-inline-start: 0; order: 1; text-align: center; }
  .hero-eyebrow { margin-inline: auto 0; }
  .hero-name { justify-content: center; }
  .hero-subhead { margin-inline: auto; }
  .hero-cta-row { justify-content: center; }
  .hero-art { order: 0; min-height: 300px; margin-top: 20px; }
  .hero-vertical-tag { display: none; }
}

@media (max-width: 520px) {
  .section { padding: 80px var(--edge); }
  .hero { padding-top: 110px; }
  .btn { padding: 12px 22px; }
  .hero-corner { width: 18px; height: 18px; }
  .hero-art { min-height: 260px; }
  .hero-info-card { width: 170px; padding: 11px 13px; inset-inline-start: 0; }
  .hero-quote { max-width: 170px; inset-inline-end: 0; }
}
