/* ============================================================
   Kiavash Samadi — personal site
   Clean surface, hidden depth. Auto light/dark via tokens.
   ============================================================ */

:root {
  /* Light theme (default) */
  --bg: #fbfbf9;
  --bg-elev: #ffffff;
  --text: #1a1a1c;
  --text-soft: #565659;
  --text-faint: #9a9a9e;
  --line: #e7e7e2;
  --accent: #2f7d5b;          /* muted green accent */
  --accent-soft: #e4f0ea;
  --link: #1a1a1c;
  --link-underline: #c9c9c2;

  /* Terminal palette */
  --term-bg: #11131a;
  --term-text: #d6dbe6;
  --term-dim: #6b7187;
  --term-accent: #6ee7a8;
  --term-prompt: #7aa2f7;

  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", "Menlo", monospace;

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

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #0c0d12;
    --bg-elev: #14161e;
    --text: #ecedf1;
    --text-soft: #a7a9b4;
    --text-faint: #5d6070;
    --line: #21232e;
    --accent: #6ee7a8;
    --accent-soft: #15291f;
    --link: #ecedf1;
    --link-underline: #3a3d4d;
  }
}

/* Manual overrides (set by the theme toggle) */
:root[data-theme="light"] {
  --bg: #fbfbf9; --bg-elev: #ffffff; --text: #1a1a1c; --text-soft: #565659;
  --text-faint: #9a9a9e; --line: #e7e7e2; --accent: #2f7d5b; --accent-soft: #e4f0ea;
  --link: #1a1a1c; --link-underline: #c9c9c2;
}
:root[data-theme="dark"] {
  --bg: #0c0d12; --bg-elev: #14161e; --text: #ecedf1; --text-soft: #a7a9b4;
  --text-faint: #5d6070; --line: #21232e; --accent: #6ee7a8; --accent-soft: #15291f;
  --link: #ecedf1; --link-underline: #3a3d4d;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 2rem 1.5rem;
  transition: background 0.4s var(--ease), color 0.4s var(--ease);
  overflow-x: hidden;
}

/* ---------- Hero ---------- */

.hero {
  max-width: var(--maxw);
  width: 100%;
  animation: rise 0.7s var(--ease) both;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.greeting {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  letter-spacing: 0.02em;
  color: var(--accent);
  margin-bottom: 1.25rem;
}

.name {
  font-size: clamp(2.4rem, 7vw, 3.6rem);
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.05;
  margin-bottom: 1.1rem;
}

.tagline {
  font-size: clamp(1.05rem, 2.4vw, 1.25rem);
  color: var(--text);
  font-weight: 500;
  margin-bottom: 1.25rem;
}

.felfel-name {
  color: var(--accent);
  font-weight: 600;
}

.blurb {
  font-size: 1rem;
  color: var(--text-soft);
  max-width: 34rem;
  margin-bottom: 2rem;
}

/* ---------- Links ---------- */

.links {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  margin-bottom: 3rem;
}

.links a {
  color: var(--link);
  text-decoration: none;
  font-size: 0.98rem;
  font-weight: 500;
  position: relative;
  padding-bottom: 2px;
  transition: color 0.2s var(--ease);
}

.links a::after {
  content: "";
  position: absolute;
  left: 0; bottom: 0;
  width: 100%; height: 1px;
  background: var(--link-underline);
  transform: scaleX(1);
  transform-origin: left;
  transition: background 0.2s var(--ease), transform 0.3s var(--ease);
}

.links a:hover { color: var(--accent); }
.links a:hover::after { background: var(--accent); }

/* ---------- Terminal hint ---------- */

.hint {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-faint);
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  cursor: pointer;
  user-select: none;
  transition: color 0.2s var(--ease);
}
.hint:hover { color: var(--text-soft); }

.hint__key {
  display: inline-grid;
  place-items: center;
  min-width: 1.4rem;
  height: 1.4rem;
  padding: 0 0.35rem;
  border: 1px solid var(--text);
  border-radius: 5px;
  /* Inverted against the page: light key on dark bg, dark key on light bg */
  background: var(--text);
  color: var(--bg);
  font-size: 0.85rem;
  line-height: 1;
  box-shadow: 0 1px 0 var(--line);
}

/* ---------- Theme toggle ---------- */

.theme-toggle {
  position: fixed;
  top: 1.25rem; right: 1.25rem;
  width: 2.5rem; height: 2.5rem;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--bg-elev);
  cursor: pointer;
  display: grid;
  place-items: center;
  z-index: 30;
  overflow: hidden;
  transition: border-color 0.25s var(--ease), box-shadow 0.25s var(--ease),
    transform 0.2s var(--ease);
}
.theme-toggle:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.theme-toggle:active { transform: scale(0.9); }

/* The celestial body: a sun in light mode, a carved crescent in dark. */
.theme-toggle__icon {
  position: relative;
  width: 1rem; height: 1rem;
  border-radius: 50%;
  background: var(--text);
  /* inset carve (transparent in light, offset in dark to bite a crescent) */
  box-shadow: inset 0 0 0 0 var(--bg-elev);
  transition: transform 0.5s var(--ease), box-shadow 0.4s var(--ease),
    background 0.3s var(--ease);
}

/* Sun rays — eight dots that retract when switching to the moon. */
.theme-toggle__icon::after {
  content: "";
  position: absolute;
  top: 50%; left: 50%;
  width: 3px; height: 3px; margin: -1.5px;
  border-radius: 50%;
  box-shadow:
    0 -13px var(--text),  0 13px var(--text),
    -13px 0 var(--text),  13px 0 var(--text),
    9px -9px var(--text),  -9px 9px var(--text),
    9px 9px var(--text),  -9px -9px var(--text);
  transform: scale(1) rotate(0deg);
  opacity: 1;
  transition: transform 0.5s var(--ease), opacity 0.35s var(--ease);
}

/* Dark mode: spin in, carve the crescent, retract the rays. */
.theme-toggle.is-dark .theme-toggle__icon {
  box-shadow: inset -6px -3px 0 0 var(--bg-elev);
  transform: rotate(360deg);
}
.theme-toggle.is-dark .theme-toggle__icon::after {
  transform: scale(0) rotate(-120deg);
  opacity: 0;
}

/* ---------- Terminal ---------- */

.terminal {
  position: fixed;
  top: 16vh;
  left: 50%;
  width: min(680px, 92vw);
  height: min(440px, 70vh);
  background: var(--term-bg);
  border-radius: 12px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.06);
  z-index: 100;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-family: var(--font-mono);
}
.terminal[hidden] { display: none; }
.terminal--opening { animation: term-in 0.22s var(--ease) both; }
.terminal--dragging { user-select: none; }

@keyframes term-in {
  from { opacity: 0; transform: translateY(8px) scale(0.985); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.terminal__bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 0.85rem;
  background: rgba(255,255,255,0.03);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  cursor: grab;
  user-select: none;
}
.terminal--dragging .terminal__bar { cursor: grabbing; }
.terminal__dot {
  width: 13px; height: 13px;
  border-radius: 50%;
  border: none;
  padding: 0;
  cursor: pointer;
  position: relative;
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  line-height: 1;
  color: transparent;
  transition: filter 0.15s var(--ease);
}
.terminal__dot--red { background: #ff5f57; }
.terminal__dot--amber { background: #febc2e; }
.terminal__dot--green { background: #28c840; }
/* reveal the macOS glyphs when hovering anywhere over the lights */
.terminal__bar:hover .terminal__dot--red { color: #7a0a00; }
.terminal__bar:hover .terminal__dot--amber { color: #7a5200; }
.terminal__bar:hover .terminal__dot--green { color: #006500; }
.terminal__dot:hover { filter: brightness(1.08); }
.terminal__dot--red::after { content: "\00d7"; }      /* × */
.terminal__dot--amber::after { content: "\2212"; }    /* − */
.terminal__dot--green::after { content: "\002b"; }    /* + */
.terminal__dot::after { font-size: 9px; }
.terminal__title {
  margin-left: 0.5rem;
  color: var(--term-dim);
  font-size: 0.78rem;
}

/* minimized: collapse to just the title bar */
.terminal--min { height: auto !important; }
.terminal--min .terminal__body,
.terminal--min .terminal__prompt { display: none; }
.terminal--min .terminal__bar { cursor: pointer; }

/* maximized */
.terminal--max {
  width: min(960px, 95vw);
  height: min(660px, 88vh);
}

.terminal__body {
  flex: 1;
  overflow-y: auto;
  padding: 0.9rem 1rem;
  font-size: 0.85rem;
  line-height: 1.55;
  color: var(--term-text);
}
.terminal__body::-webkit-scrollbar { width: 8px; }
.terminal__body::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.12); border-radius: 4px;
}

.terminal__line { white-space: pre-wrap; word-break: break-word; }
.terminal__line--cmd { color: var(--term-text); }
.terminal__line--cmd .term-ps1 { color: var(--term-prompt); margin-right: 0.5rem; }
.term-accent { color: var(--term-accent); }
.term-dim { color: var(--term-dim); }
.term-link { color: var(--term-prompt); text-decoration: underline; }
.term-link:hover { color: var(--term-accent); }

.terminal__prompt {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1rem;
  border-top: 1px solid rgba(255,255,255,0.06);
}
.terminal__ps1 { color: var(--term-prompt); font-size: 0.85rem; white-space: nowrap; }
.terminal__input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--term-text);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  caret-color: var(--term-accent);
}

/* ---------- Konami rain of cats ---------- */

.felfel-rain {
  position: fixed;
  top: -60px;
  font-size: 2rem;
  z-index: 90;
  pointer-events: none;
  animation: fall linear forwards;
}
@keyframes fall {
  to { transform: translateY(110vh) rotate(360deg); }
}

/* ---------- Résumé page ---------- */

.resume-body {
  display: block;
  place-items: unset;
  padding: 0;
}

.resume {
  max-width: 46rem;
  margin: 0 auto;
  padding: 3rem 1.5rem 4rem;
  animation: rise 0.6s var(--ease) both;
}

.resume__nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2.5rem;
}
.resume__back {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-soft);
  text-decoration: none;
}
.resume__back:hover { color: var(--accent); }
.resume__print {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-soft);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.4rem 0.8rem;
  cursor: pointer;
  transition: border-color 0.2s var(--ease), color 0.2s var(--ease);
}
.resume__print:hover { border-color: var(--accent); color: var(--accent); }

.resume__head { margin-bottom: 1.5rem; }
.resume__name {
  font-size: clamp(1.9rem, 5vw, 2.4rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.resume__role {
  font-size: 1rem;
  color: var(--accent);
  font-weight: 500;
  margin-top: 0.25rem;
}
.resume__contact {
  margin-top: 0.6rem;
  font-size: 0.85rem;
  color: var(--text-faint);
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.5rem;
  align-items: center;
}
.resume__contact a { color: var(--text-soft); text-decoration: none; }
.resume__contact a:hover { color: var(--accent); }
.resume__contact span { color: var(--text-faint); }

.resume__summary {
  font-size: 1rem;
  color: var(--text-soft);
  line-height: 1.65;
  padding: 1.25rem 0;
  margin-bottom: 0.5rem;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.resume__section { margin-top: 2.25rem; }
.resume__h2 {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-faint);
  margin-bottom: 1.25rem;
}

.job { margin-bottom: 1.75rem; }
.job__top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  flex-wrap: wrap;
}
.job__title { font-size: 1.05rem; font-weight: 600; }
.job__meta { font-size: 0.9rem; color: var(--text-soft); text-align: right; }
.job__sub {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-faint);
  margin-top: 0.15rem;
  margin-bottom: 0.6rem;
}
.job__points { list-style: none; display: grid; gap: 0.5rem; }
.job__points li {
  position: relative;
  padding-left: 1.1rem;
  font-size: 0.94rem;
  color: var(--text-soft);
  line-height: 1.55;
}
.job__points li::before {
  content: "";
  position: absolute;
  left: 0; top: 0.62em;
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--accent);
}
.job__points strong { color: var(--text); font-weight: 600; }

.skills { display: grid; gap: 0.7rem; }
.skills__row {
  display: grid;
  grid-template-columns: 8.5rem 1fr;
  gap: 0.75rem;
  align-items: baseline;
}
.skills__row dt {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-faint);
}
.skills__row dd { font-size: 0.92rem; color: var(--text-soft); }

@media (max-width: 540px) {
  .skills__row { grid-template-columns: 1fr; gap: 0.15rem; }
  .job__meta { text-align: left; }
}

/* Print: clean black-on-white, hide chrome */
@media print {
  :root {
    --bg: #fff; --bg-elev: #fff; --text: #111; --text-soft: #333;
    --text-faint: #666; --line: #ccc; --accent: #1a6b48;
  }
  .no-print, .theme-toggle { display: none !important; }
  .resume { padding: 0; max-width: 100%; animation: none; }
  body { background: #fff; }
  a { color: #111 !important; text-decoration: none; }
  .job { break-inside: avoid; }
}

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
