/* ============================================================================
   Ekzar — a quiet, nocturnal portfolio.
   Palette: warm near-black, Red-Room crimson, muted bone-white text.
   Mood: low contrast, serif display, monospace labels, film grain + vignette.
   ========================================================================== */

:root {
  --bg: #0a0908;
  --bg-soft: #100e0d;
  --surface: #121010;
  --surface-2: #171413;
  --text: #c9c4bb;
  --text-soft: #7a746c;
  --text-faint: #4a453f;
  --border: #201d1a;
  --red: #8e1c1c;
  --red-bright: #b64242;
  --red-dim: #4f1414;

  --font-display: ui-serif, Georgia, 'Iowan Old Style', 'Times New Roman', serif;
  --font-sans: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, 'SFMono-Regular', 'Cascadia Code', Menlo, Consolas, monospace;

  --radius: 4px;
  --maxw: 980px;
  color-scheme: dark;
  font-synthesis: none;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--text);
  background: var(--bg);
  line-height: 1.65;
  letter-spacing: 0.01em;
  -webkit-font-smoothing: antialiased;
  /* A slow vignette that keeps the edges in shadow. */
  background-image: radial-gradient(120% 90% at 50% -10%, #14100e 0%, var(--bg) 55%, #070605 100%);
  background-attachment: fixed;
  min-height: 100vh;
}

/* Film grain — a fixed, barely-there noise field over everything. */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  opacity: 0.04;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

a { color: var(--red-bright); text-decoration: none; }
a:hover { color: var(--text); }

::selection { background: var(--red-dim); color: #efe9e0; }

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px clamp(20px, 5vw, 48px);
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: saturate(120%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.logo {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 1.05rem;
  letter-spacing: 0.02em;
  color: var(--text);
}
.logo span { color: var(--red); }
.nav { display: flex; align-items: center; gap: clamp(16px, 3vw, 30px); }
.nav a {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: lowercase;
  letter-spacing: 0.08em;
  color: var(--text-soft);
}
.nav a:hover { color: var(--red-bright); }

/* ---------- Layout ---------- */
main { max-width: var(--maxw); margin: 0 auto; padding: 0 clamp(20px, 5vw, 48px); }
.section { padding: clamp(64px, 10vw, 120px) 0; border-top: 1px solid var(--border); }
.section-title {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.28em;
  color: var(--text-soft);
  margin: 0 0 36px;
}
.section-title::before { content: '— '; color: var(--red); }

/* ---------- Hero ---------- */
.hero {
  position: relative;
  padding: clamp(88px, 16vw, 168px) 0 clamp(64px, 10vw, 104px);
  overflow: hidden;
}
/* Faint red-curtain pleats behind the hero. */
.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  opacity: 0.5;
  background: repeating-linear-gradient(
    90deg,
    transparent 0,
    transparent 34px,
    rgba(142, 28, 28, 0.05) 34px,
    rgba(142, 28, 28, 0.05) 35px,
    transparent 35px,
    transparent 70px
  );
  mask-image: linear-gradient(180deg, #000 0%, transparent 78%);
}
/* A soft drifting glow so the revealed hero isn't flat black. */
.hero::after {
  content: '';
  position: absolute;
  z-index: -1;
  left: -8%;
  top: 8%;
  width: 62%;
  height: 68%;
  background: radial-gradient(closest-side, rgba(142, 28, 28, 0.11), rgba(142, 28, 28, 0) 72%);
  filter: blur(32px);
  pointer-events: none;
  animation: glow-drift 26s ease-in-out infinite;
}
.eyebrow {
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.3em;
  font-size: 0.7rem;
  color: var(--text-soft);
  margin: 0 0 22px;
}
.eyebrow::before {
  content: '';
  display: inline-block;
  width: 6px; height: 6px;
  margin-right: 12px;
  transform: rotate(45deg) translateY(-2px);
  background: var(--red);
}
.hero h1 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(2.1rem, 5.5vw, 3.5rem);
  line-height: 1.14;
  letter-spacing: -0.01em;
  margin: 0 0 26px;
  color: #ded8cf;
}
.lede {
  font-family: var(--font-display);
  font-size: clamp(1.05rem, 2vw, 1.3rem);
  font-style: italic;
  color: var(--text-soft);
  max-width: 54ch;
  line-height: 1.7;
}
.cta-row { display: flex; gap: 14px; margin-top: 40px; flex-wrap: wrap; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 24px;
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.4s ease, color 0.4s ease, border-color 0.4s ease, box-shadow 0.4s ease;
}
.btn:hover { color: inherit; }
.btn-primary {
  background: var(--red);
  color: #f0e7e2;
  box-shadow: 0 0 0 rgba(142, 28, 28, 0);
}
.btn-primary:hover {
  background: #a02323;
  color: #fff;
  box-shadow: 0 0 28px rgba(142, 28, 28, 0.35);
}
.btn-ghost {
  background: transparent;
  color: var(--text-soft);
  border-color: var(--border);
}
.btn-ghost:hover { color: var(--text); border-color: var(--red-dim); }

/* ---------- Cards ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(258px, 1fr));
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
}
.card {
  background: var(--surface);
  padding: 30px 28px;
  transition: background 0.4s ease;
}
.card:hover { background: var(--surface-2); }
.card-thumb {
  height: 96px;
  display: flex;
  align-items: flex-end;
  font-family: var(--font-display);
  font-size: 2.6rem;
  color: var(--text-faint);
  letter-spacing: 0.05em;
  margin-bottom: 22px;
  border-bottom: 1px solid var(--border);
  /* Black-Lodge chevron, buried in the dark. */
  background-image: repeating-linear-gradient(
    -45deg,
    rgba(255, 255, 255, 0.015) 0 10px,
    transparent 10px 20px
  );
}
.card:hover .card-thumb { color: var(--red); }
.card h3 {
  font-family: var(--font-display);
  font-weight: 500;
  margin: 0 0 10px;
  font-size: 1.25rem;
  color: #d8d2c9;
}
.card p { margin: 0 0 18px; color: var(--text-soft); font-size: 0.94rem; }
.tags { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }
.tags span {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  padding: 3px 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-faint);
}
.card-link {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-soft);
}
.card-link:hover { color: var(--red-bright); }

/* ---------- About ---------- */
.about p {
  max-width: 60ch;
  color: var(--text-soft);
  font-family: var(--font-display);
  font-size: 1.1rem;
  line-height: 1.8;
}
.skills {
  list-style: none;
  padding: 0;
  margin: 34px 0 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
}
.skills li {
  background: var(--surface);
  padding: 13px 16px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.03em;
  color: var(--text-soft);
}
.skills li::before { content: '· '; color: var(--red); }

/* ---------- Contact ---------- */
.contact p { color: var(--text-soft); font-family: var(--font-display); font-size: 1.1rem; }
.contact-form { display: grid; gap: 14px; max-width: 500px; margin-top: 28px; }
.contact-form input,
.contact-form textarea {
  width: 100%;
  padding: 13px 15px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-soft);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  resize: vertical;
  transition: border-color 0.4s ease;
}
.contact-form input::placeholder,
.contact-form textarea::placeholder { color: var(--text-faint); }
.contact-form input:focus,
.contact-form textarea:focus {
  outline: none;
  border-color: var(--red-dim);
}
.contact-form .btn { justify-content: center; }
.form-status {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  letter-spacing: 0.03em;
  margin: 4px 0 0;
  min-height: 1.2em;
}
.form-status.ok { color: var(--text-soft); }
.form-status.err { color: var(--red-bright); }
.social { display: flex; gap: 24px; margin-top: 34px; }
.social a {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-soft);
}
.social a:hover { color: var(--red-bright); }

/* ---------- Footer ---------- */
.site-footer {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 44px clamp(20px, 5vw, 48px) 80px;
  border-top: 1px solid var(--border);
  color: var(--text-faint);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
}
.privacy-note { margin-top: 8px; }
.privacy-note a { color: var(--text-soft); }
.privacy-note a:hover { color: var(--red-bright); }

/* ---------- The veil (dark-web landing) ---------- */

body.locked { overflow: hidden; }

.veil {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  cursor: pointer;
  background: radial-gradient(120% 90% at 50% 45%, #100d0c 0%, #070605 70%, #030202 100%);
  transition: opacity 1.1s ease, visibility 1.1s ease;
}
.veil.open { opacity: 0; visibility: hidden; }
.veil-inner {
  position: relative;
  z-index: 3;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
  padding: 24px;
}

/* Drifting warm glow — a soft light that breathes behind the diamond. */
.veil::before {
  content: '';
  position: absolute;
  inset: -25%;
  z-index: 0;
  pointer-events: none;
  background: radial-gradient(38% 38% at 50% 50%, rgba(142, 28, 28, 0.16), rgba(142, 28, 28, 0) 70%);
  filter: blur(34px);
  animation: glow-drift 24s ease-in-out infinite;
}
@keyframes glow-drift {
  0%, 100% { transform: translate(-7%, -5%) scale(1); opacity: 0.65; }
  50% { transform: translate(8%, 6%) scale(1.28); opacity: 1; }
}

/* Faint signal grid, slowly falling, faded at the edges. */
.veil::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(201, 196, 187, 0.028) 1px, transparent 1px),
    linear-gradient(90deg, rgba(201, 196, 187, 0.028) 1px, transparent 1px);
  background-size: 46px 46px;
  -webkit-mask-image: radial-gradient(120% 100% at 50% 50%, #000 38%, transparent 84%);
  mask-image: radial-gradient(120% 100% at 50% 50%, #000 38%, transparent 84%);
  animation: grid-fall 44s linear infinite;
}
@keyframes grid-fall { to { background-position: 0 46px, 0 46px; } }

/* Dust motes drift here. */
.dust { position: absolute; inset: 0; z-index: 1; pointer-events: none; }

/* A small, dim, slowly-breathing diamond — the only mark on the page. */
.diamond {
  width: 34px;
  height: 34px;
  color: var(--red-dim);
  animation: breathe 5.5s ease-in-out infinite;
}
@keyframes breathe {
  0%, 100% { opacity: 0.35; color: var(--red-dim); }
  50% { opacity: 0.85; color: var(--red); }
}

/* Node / coordinate readout — a machine talking to itself. */
.node {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.16em;
  color: var(--text-faint);
  margin: 0;
}
.node #clock { color: var(--text-soft); }

/* Terminal prompt. Fades in late, so at first there's almost nothing. */
.prompt {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  color: var(--text-soft);
  margin: 0;
  opacity: 0;
  animation: surface 2s ease forwards;
  animation-delay: 3.5s;
}
.prompt .chev { color: var(--red); margin-right: 8px; }
@keyframes surface { to { opacity: 1; } }

/* Blinking caret. */
.caret {
  display: inline-block;
  width: 7px;
  height: 1.05em;
  margin-left: 4px;
  vertical-align: -2px;
  background: var(--red);
  animation: blink 1.1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* A larger block caret to sit beside the hero headline. */
.hero h1 .caret {
  width: 0.5ch;
  height: 0.92em;
  margin-left: 12px;
  vertical-align: -1px;
}

/* ---------- Revealed site fades up from the dark ---------- */
.site { opacity: 0; transition: opacity 1.4s ease; }
.site.revealed { opacity: 1; }

/* The wordmark flickers with a faint chromatic split — mostly still. */
.glitch { position: relative; }
.glitch::before,
.glitch::after {
  content: attr(data-text);
  position: absolute;
  left: 0;
  top: 0;
  color: var(--text);
  opacity: 0;
  pointer-events: none;
}
.glitch::before { color: var(--red-bright); }
.glitch::after { color: #3a6f6f; }
.glitch:hover::before,
.glitch:hover::after,
.glitch.flicker::before,
.glitch.flicker::after { opacity: 0.7; }
.glitch:hover::before,
.glitch.flicker::before { transform: translate(-1.5px, 0.5px); }
.glitch:hover::after,
.glitch.flicker::after { transform: translate(1.5px, -0.5px); }

/* Encoded clue in the footer. */
.cipher {
  margin-top: 22px;
  color: var(--text-faint);
  font-size: 0.68rem;
  letter-spacing: 0.05em;
  user-select: all;
  opacity: 0.5;
  transition: opacity 0.4s ease, color 0.4s ease;
}
.cipher:hover { opacity: 1; color: var(--red-dim); }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
  .caret,
  .veil::before,
  .veil::after,
  .hero::after { animation: none; }
}
