/* ============================================================
   Tokyo Night — Mostafa Salem Portfolio
   ============================================================ */

:root {
  --bg:        #1a1b26;
  --bg-elev:   #24283b;
  --bg-soft:   #1f2335;
  --border:    #2f334d;
  --text:      #c0caf5;
  --text-dim:  #565f89;
  --cyan:      #7dcfff;
  --magenta:   #bb9af7;
  --green:     #9ece6a;
  --yellow:    #e0af68;
  --red:       #f7768e;

  --font-mono: 'Fira Code', ui-monospace, SFMono-Regular, Menlo, monospace;

  --max-w: 1040px;
  --pad-x: clamp(20px, 4vw, 64px);
  --radius: 10px;
}

/* ----- Reset ----- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
img { display: block; max-width: 100%; height: auto; }
a { color: inherit; text-decoration: none; }
button { font: inherit; }
ul { list-style: none; padding: 0; margin: 0; }

/* ----- Base ----- */
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.95rem;
  line-height: 1.65;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Subtle vignette so the page doesn't feel flat */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 50%, rgba(0,0,0,0.35) 100%);
  z-index: 0;
}

main { position: relative; z-index: 1; }

/* ----- Skip link / a11y ----- */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
}
.skip-link:focus {
  left: 16px;
  top: 16px;
  background: var(--bg-elev);
  color: var(--cyan);
  padding: 8px 12px;
  border-radius: 6px;
  z-index: 100;
}
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ----- Section heading (used everywhere) ----- */
.section {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 64px var(--pad-x);
}
.section-heading {
  color: var(--text);
  font-size: 1.4rem;
  font-weight: 600;
  margin: 0 0 28px 0;
  letter-spacing: 0.5px;
}
.section-heading .prompt {
  color: var(--cyan);
  margin-right: 8px;
}

/* ============================================================
   Header
   ============================================================ */

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 16px var(--pad-x);
  backdrop-filter: blur(8px);
  background: rgba(26, 27, 38, 0.78);
  border-bottom: 1px solid transparent;
}

.site-header.scrolled {
  border-bottom-color: var(--border);
}

.logo img {
  width: 40px;
  height: 40px;
  transition: transform 0.2s ease;
}
.logo:hover img {
  transform: rotate(1.5deg) scale(1.04);
}

.site-nav {
  display: flex;
  gap: 22px;
  flex-wrap: wrap;
}
.site-nav a {
  font-size: 0.9rem;
  color: var(--text);
  padding: 4px 0;
  border-bottom: 1px solid transparent;
  transition: color 0.2s ease, border-color 0.2s ease;
}
.site-nav a:hover {
  color: var(--cyan);
  border-bottom-color: var(--cyan);
}
.site-nav .nav-prefix {
  color: var(--magenta);
  margin-right: 4px;
}

html { scroll-behavior: smooth; }

/* ============================================================
   Hero terminal
   ============================================================ */

.hero {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 48px var(--pad-x) 32px;
}

.terminal {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0,0,0,0.45), 0 0 0 1px rgba(125,207,255,0.04);
  overflow: hidden;
  position: relative;
}

.terminal-chrome {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border);
}
.terminal-chrome .dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  display: inline-block;
}
.dot-red    { background: #ff5f57; }
.dot-yellow { background: #febc2e; }
.dot-green  { background: #28c840; }
.terminal-title {
  flex: 1;
  text-align: center;
  color: var(--text-dim);
  font-size: 0.8rem;
  letter-spacing: 0.4px;
}

.terminal-body {
  padding: 22px 22px 18px;
  min-height: 320px;
  font-size: 0.95rem;
  cursor: text;
  position: relative;
}

/* Output buffer — lines printed by commands */
.term-output {
  white-space: pre-wrap;
  word-break: break-word;
  margin-bottom: 8px;
}
.term-output .term-line { margin: 0 0 4px 0; }
.term-output .term-cmd  { color: var(--text); }
.term-output .term-cmd .prompt { color: var(--cyan); margin-right: 8px; }
.term-output .term-err  { color: var(--red); }
.term-output .term-info { color: var(--text-dim); }
.term-output .term-key  { color: var(--magenta); }
.term-output .term-str  { color: var(--green); }
.term-output .term-num  { color: var(--yellow); }
.term-output a          { color: var(--cyan); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.term-output a:hover    { text-shadow: 0 0 8px rgba(125,207,255,0.5); }

/* Input line — visible, sits at the bottom of the body */
.term-input-line {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.95rem;
}
.term-prompt {
  color: var(--cyan);
  flex-shrink: 0;
}
.term-typed {
  color: var(--text);
  white-space: pre;
}
.term-cursor {
  color: var(--text);
  animation: term-blink 1s steps(2, start) infinite;
  font-size: 0.85em;
  line-height: 1;
  transform: translateY(-1px);
}
@keyframes term-blink {
  to { visibility: hidden; }
}

/* The real input is invisible — keystrokes feed term-typed */
.term-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: transparent;
  border: 0;
  color: transparent;
  caret-color: transparent;
  outline: none;
  cursor: text;
  font: inherit;
}
.term-input:focus { outline: none; }

/* Hero socials beneath the terminal */
.hero-socials {
  display: flex;
  gap: 18px;
  margin-top: 22px;
  padding-left: 4px;
}
.hero-socials a {
  width: 26px;
  opacity: 0.78;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.hero-socials a:hover {
  opacity: 1;
  transform: translateY(-2px);
}
.hero-socials img { width: 26px; height: auto; }

/* ============================================================
   About + Experience
   ============================================================ */

.about-body p {
  margin: 0 0 16px 0;
  max-width: 72ch;
  color: var(--text);
}
.about-body p::before {
  content: "> ";
  color: var(--text-dim);
}

.experience-list {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  line-height: 1.9;
  white-space: pre;
  overflow-x: auto;
}
.experience-list li {
  display: block;
  color: var(--text);
}
.experience-list .xp-range   { color: var(--cyan); }
.experience-list .xp-role    { color: var(--magenta); margin-left: 8px; }
.experience-list .xp-at      { color: var(--text-dim); margin: 0 8px; }
.experience-list .xp-company { color: var(--green); }

.experience-more {
  display: inline-block;
  margin-top: 18px;
  color: var(--cyan);
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s ease, text-shadow 0.2s ease;
}
.experience-more:hover {
  border-bottom-color: var(--cyan);
  text-shadow: 0 0 8px rgba(125,207,255,0.4);
}

/* ============================================================
   Projects
   ============================================================ */

.project-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 22px;
}

.project-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: transform 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
  display: flex;
  flex-direction: column;
}
.project-card:hover {
  transform: translateY(-3px);
  border-color: var(--cyan);
  box-shadow: 0 10px 40px rgba(0,0,0,0.4), 0 0 0 1px rgba(125,207,255,0.15);
}

.project-chrome {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border);
}
.project-chrome .dot {
  width: 9px; height: 9px;
  border-radius: 50%;
}
.project-chrome .filename {
  margin-left: auto;
  font-size: 0.78rem;
  color: var(--text-dim);
}

.project-body {
  padding: 18px 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}
.project-name {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--magenta);
}
.project-desc {
  margin: 0;
  color: var(--text);
  line-height: 1.55;
  font-size: 0.92rem;
}
.project-stack {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}
.project-stack .chip {
  font-size: 0.72rem;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(224, 175, 104, 0.13);
  color: var(--yellow);
  border: 1px solid rgba(224, 175, 104, 0.28);
}
.project-stack .chip-comment {
  background: transparent;
  color: var(--text-dim);
  border: none;
  padding-left: 0;
}
.project-links {
  display: flex;
  gap: 14px;
  margin-top: 6px;
}
.project-links a {
  color: var(--cyan);
  font-size: 0.88rem;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s ease, text-shadow 0.2s ease;
}
.project-links a:hover {
  border-bottom-color: var(--cyan);
  text-shadow: 0 0 8px rgba(125,207,255,0.4);
}

/* Placeholder card */
.project-card.is-placeholder .project-name { color: var(--text-dim); }
.project-card.is-placeholder .project-desc { color: var(--text-dim); }
.project-pulse {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--green);
  margin-right: 6px;
  animation: pulse 1.6s ease-in-out infinite;
  vertical-align: middle;
}
@keyframes pulse {
  0%, 100% { opacity: 0.35; transform: scale(1); }
  50%      { opacity: 1;    transform: scale(1.3); }
}

/* ============================================================
   Footer
   ============================================================ */

.site-footer {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 48px var(--pad-x) 80px;
  border-top: 1px solid var(--border);
}
.site-footer .section-heading { margin-bottom: 18px; }

.contact-line {
  margin: 0 0 18px;
  color: var(--text);
  font-size: 0.95rem;
}
.contact-line .contact-key {
  color: var(--text-dim);
  margin-right: 8px;
}
.contact-line a {
  color: var(--cyan);
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s ease, text-shadow 0.2s ease;
}
.contact-line a:hover {
  border-bottom-color: var(--cyan);
  text-shadow: 0 0 8px rgba(125,207,255,0.4);
}

.footer-icons {
  display: flex;
  gap: 18px;
  margin: 12px 0 28px;
}
.footer-icons a {
  width: 24px;
  opacity: 0.75;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.footer-icons a:hover {
  opacity: 1;
  transform: translateY(-2px);
}

.signoff {
  color: var(--text-dim);
  font-size: 0.88rem;
  margin: 0;
}
.signoff::after {
  content: "▌";
  color: var(--text);
  margin-left: 6px;
  animation: term-blink 1s steps(2, start) infinite;
}

/* ============================================================
   Responsive
   ============================================================ */

/* Tablet ≥640px: projects 2-up */
@media (min-width: 640px) {
  .project-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Desktop ≥960px: projects 3-up */
@media (min-width: 960px) {
  .project-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* Mobile ≤520px: tighten everything */
@media (max-width: 520px) {
  body { font-size: 0.88rem; }

  .site-header {
    padding: 12px var(--pad-x);
    flex-wrap: wrap;
    gap: 8px;
  }
  .site-nav {
    gap: 12px;
    width: 100%;
    justify-content: flex-start;
    font-size: 0.82rem;
  }
  .site-nav a { font-size: 0.82rem; }

  .hero { padding-top: 24px; }
  .terminal-body { padding: 16px; min-height: 240px; }
  .terminal-title { font-size: 0.72rem; }

  .section { padding: 48px var(--pad-x); }
  .section-heading { font-size: 1.15rem; margin-bottom: 20px; }

  .experience-list { font-size: 0.85rem; line-height: 1.85; }

  .project-body { padding: 14px 14px 12px; }
  .project-name { font-size: 0.98rem; }

  .signoff { font-size: 0.82rem; }
}

/* ============================================================
   Reduced motion
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }

  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .term-cursor,
  .signoff::after {
    animation: none;
    visibility: visible;
  }

  .project-pulse {
    animation: none;
    opacity: 1;
  }
}
