/* ── fonts ───────────────────────────────────────────────────────────────── */
@font-face {
  font-family: 'Amiri';
  src: url('fonts/Amiri-Regular.woff2') format('woff2'),
       url('fonts/Amiri-Regular.ttf')   format('truetype');
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: 'Amiri';
  src: url('fonts/Amiri-Bold.woff2') format('woff2'),
       url('fonts/Amiri-Bold.ttf')   format('truetype');
  font-weight: 700;
  font-display: swap;
}

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

/* ── dark mode ───────────────────────────────────────────────────────────── */
:root,
[data-theme="dark"] {
  --bg:         #111;
  --bg-glass:   rgba(17,17,17,0.9);
  --text:       #c4c4c4;
  --text-dim:   #555;
  --line:       #282828;
  --border:     #2e2e2e;
  --tooltip-bg: #191919;
  --panel-bg:   #181818;
}

/* ── light mode ──────────────────────────────────────────────────────────── */
[data-theme="light"] {
  --bg:         #f0ebe1;
  --bg-glass:   rgba(240,235,225,0.9);
  --text:       #2e2820;
  --text-dim:   #9a8f82;
  --line:       #d4ccc0;
  --border:     #c8bfb2;
  --tooltip-bg: #e8e2d8;
  --panel-bg:   #e8e2d8;
}

html, body {
  width: 100%;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Courier New', Courier, monospace;
  overflow: hidden;
  transition: background 0.3s, color 0.3s;
}

/* ── header ──────────────────────────────────────────────────────────────── */
header {
  position: fixed;
  top: 0; left: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 1.4rem 1.75rem;
  background: linear-gradient(to bottom, var(--bg-glass) 60%, transparent);
  z-index: 30;
  transition: background 0.3s;
}

#site-title {
  font-size: 0.78rem;
  letter-spacing: 0.18em;
  color: var(--text-dim);
  text-decoration: none;
  transition: color 0.15s;
}

#site-title:hover { color: var(--text); }

#header-ui {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  position: relative;
}

#back {
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  text-decoration: none;
  margin-right: 0.5rem;
  transition: color 0.15s;
}
#back:hover { color: var(--text); }

#theme-btn,
#socials-btn {
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  background: var(--panel-bg);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: color 0.15s, background 0.3s;
  line-height: 1;
}

#theme-btn {
  width: 5.5rem;
  padding: 0.45rem 0;
  text-align: center;
}

#socials-btn {
  font-size: 1rem;
  padding: 0.4rem 0.7rem;
}

#theme-btn:hover,
#socials-btn:hover { color: var(--text); }

#socials-panel {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 0.5rem;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.55rem;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  padding: 0.9rem 1rem;
  transition: background 0.3s;
  z-index: 25;
}

#socials-panel.hidden { display: none; }

#socials-panel a {
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  color: var(--text-dim);
  text-decoration: none;
  transition: color 0.15s;
  white-space: nowrap;
}

#socials-panel a:hover { color: var(--text); }

/* ── graph ───────────────────────────────────────────────────────────────── */
#graph {
  width: 100vw;
  height: 100vh;
  display: block;
  cursor: grab;
  touch-action: none;
}

#graph:active { cursor: grabbing; }

.link {
  stroke: var(--line);
  stroke-width: 1.2px;
}

.link.lit { stroke-width: 1.8px; }

.node-circle {
  stroke-width: 2px;
}

.node-circle.unread {
  animation: twinkle 3.4s ease-in-out infinite;
}

@keyframes twinkle {
  0%, 100% { opacity: 0.55; }
  50%      { opacity: 1; }
}

.node-label {
  font-family: 'Courier New', Courier, monospace;
  fill: var(--text-dim);
  pointer-events: none;
}

/* ── tooltip ─────────────────────────────────────────────────────────────── */
#tooltip {
  position: fixed;
  pointer-events: none;
  background: var(--tooltip-bg);
  border: 1px solid var(--border);
  padding: 0.4rem 0.75rem;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  color: var(--text);
  opacity: 0;
  transition: opacity 0.12s;
  white-space: nowrap;
  z-index: 100;
}

#tooltip.on { opacity: 1; }

.tip-cluster {
  color: var(--text-dim);
}

/* ── hint ────────────────────────────────────────────────────────────────── */
#hint {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.65rem;
  letter-spacing: 0.2em;
  color: var(--text-dim);
  opacity: 0.6;
  z-index: 10;
  pointer-events: none;
  transition: opacity 1s ease;
}

#hint.faded { opacity: 0; }

/* ── farsi ───────────────────────────────────────────────────────────────── */
[lang="fa"] {
  font-family: 'Amiri', serif;
  direction: rtl;
  line-height: 2;
  font-size: 1.05rem;
}

/* ── fade in ─────────────────────────────────────────────────────────────── */
body {
  opacity: 0;
  animation: fadein 0.4s ease forwards;
}

@keyframes fadein { to { opacity: 1; } }

/* ── mobile header adjustments ──────────────────────────────────────────── */
@media (max-width: 768px) {
  header { padding: 1.1rem 1.25rem; }
  #site-title { font-size: 0.7rem; }
  #theme-btn { width: 4.6rem; font-size: 0.62rem; }
  #socials-btn { font-size: 0.9rem; }
  #hint { font-size: 0.6rem; bottom: 1.1rem; }
}
