/*
 * AFrenchWrench portfolio: shared styles for /en/ and /fa/.
 *
 * Layout uses logical properties (inline-start/end) so one ruleset serves
 * both LTR and RTL. Persian-specific typography lives in the
 * `:root:lang(fa)` token block and the "Persian typography" section at the end.
 */

/* ---------- Tokens ---------- */

:root {
  /* colour */
  --bg: #0d0f13;
  --bg-elev: #14171d;
  --bg-glass: rgba(20, 23, 29, 0.9);
  --backdrop: rgba(8, 9, 12, 0.72);
  --border: #262b33;
  --text: #eef0f2;
  --text-muted: #8a919c;
  --text-faint: #5b6169;
  --accent: #c9a227;
  --accent-hover: #dab631;
  --accent-soft: rgba(201, 162, 39, 0.14);
  --accent-glow: rgba(201, 162, 39, 0.07);
  --on-accent: #14120a;
  --pulse: #59d989;
  --pulse-ring: rgba(89, 217, 137, 0.15);

  /* type */
  --font-display: "Space Grotesk", sans-serif;
  --font-body: "Inter", sans-serif;
  --font-mono: "JetBrains Mono", monospace;
  --font-label: var(--font-mono); /* skill categories */
  --fs-label: var(--fs-2xs);

  --fs-2xs: 0.75rem; /* tags, stacks, dates */
  --fs-xs: 0.8rem; /* prompt, switcher, footer */
  --fs-sm: 0.85rem;
  --fs-md: 0.9rem;
  --fs-base: 0.93rem; /* list copy */
  --fs-lg: 1.05rem;

  --leading: 1.65;
  --leading-heading: 1.3;
  --leading-hero: 1.15;
  --fs-status: var(--fs-2xs);
  --fs-summary: var(--fs-md);

  /* shape */
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius: 12px;
  --radius-pill: 999px;

  --shadow-float: 0 10px 30px rgba(0, 0, 0, 0.25);
  --shadow-modal: 0 24px 60px rgba(0, 0, 0, 0.45);

  /* layout */
  --content-w: 820px;
  --gutter: 28px;
  --section-y: 64px;
  --card-pad: 24px;
  --stack-gap: 22px; /* between sibling cards / after intro copy */
  --float-inset: 20px;
  --glow-x: 15%;
  --dot-offset: 6px; /* optical centring of .status-dot against first line */

  --ease: 0.2s ease;
}

:root:lang(fa) {
  --font-display: "Vazirmatn", sans-serif;
  --font-body: "Vazirmatn", sans-serif;
  --font-label: var(--font-body);
  --fs-label: var(--fs-xs);
  --leading: 1.9;
  --leading-heading: 1.5;
  --leading-hero: 1.25;
  --fs-status: var(--fs-sm);
  --fs-summary: 1rem;
  --dot-offset: 8px;
}

:root[dir="rtl"] {
  --glow-x: 85%;
}

/* ---------- Base ---------- */

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(
      ellipse 900px 500px at var(--glow-x) -10%,
      var(--accent-glow),
      transparent 60%
    ),
    var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: var(--leading);
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
}

::selection {
  background: var(--accent-soft);
  color: var(--text);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: var(--radius-xs);
}

h1,
h2,
h3 {
  margin: 0;
  color: var(--text);
  font-family: var(--font-display);
  font-weight: 600;
}

h2 {
  margin-bottom: 24px;
  font-size: clamp(1.4rem, 3vw, 1.65rem);
  line-height: var(--leading-heading);
}

p {
  margin: 0 0 14px;
  color: var(--text);
}

p:last-child {
  margin-bottom: 0;
}

.muted {
  color: var(--text-muted);
}

.intro {
  margin-bottom: var(--stack-gap);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Layout ---------- */

.rail {
  width: min(100%, var(--content-w));
  margin: 0 auto;
  padding: 0 var(--gutter);
  border-inline: 1px solid var(--border);
}

section {
  padding: var(--section-y) 0;
  border-bottom: 1px solid var(--border);
}

section:last-of-type {
  border-bottom: 0;
}

footer {
  width: min(100%, var(--content-w));
  margin: 0 auto;
  padding: 26px var(--gutter) 48px;
  color: var(--text-faint);
  font-size: var(--fs-xs);
  text-align: center;
}

/* ---------- Language switcher ---------- */

.language-switcher {
  position: fixed;
  top: var(--float-inset);
  inset-inline-end: var(--float-inset);
  z-index: 100;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow-float);
}

.language-switcher a {
  min-width: 44px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-pill);
  color: var(--text-muted);
  text-decoration: none;
  font: 500 var(--fs-xs) var(--font-mono);
  transition: color var(--ease);
}

.language-switcher a:is(:hover, :focus-visible) {
  color: var(--text);
}

.language-switcher a.active {
  background: var(--accent);
  color: var(--on-accent);
}

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

.hero {
  padding-top: 88px;
}

/* The shell prompt is Latin/ASCII and always reads left-to-right. */
.prompt {
  margin-bottom: 28px;
  color: var(--text-faint);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  direction: ltr;
  text-align: left;
  unicode-bidi: isolate;
}

.cursor {
  display: inline-block;
  width: 7px;
  height: 14px;
  margin-left: 4px;
  vertical-align: -2px;
  background: var(--pulse);
  animation: blink 1.1s steps(1) infinite;
}

@keyframes blink {
  0%,
  49% {
    opacity: 1;
  }

  50%,
  100% {
    opacity: 0;
  }
}

.hero-top {
  display: flex;
  align-items: center;
  gap: 22px;
  margin-bottom: 26px;
}

.avatar {
  width: 78px;
  height: 78px;
  flex: 0 0 78px;
  border: 2px solid var(--accent);
  border-radius: 50%;
  object-fit: cover;
}

.hero h1 {
  font-size: clamp(2rem, 6vw, 2.5rem);
  letter-spacing: -0.02em;
  line-height: var(--leading-hero);
}

.hero-title {
  margin-top: 7px;
  color: var(--accent);
  font-size: 1rem;
  font-weight: 500;
}

.status-line {
  display: flex;
  gap: 9px;
  margin-bottom: 22px;
  color: var(--text-muted);
  font-size: var(--fs-status);
}

.status-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 8px;
  border-radius: 50%;
  background: var(--pulse);
  box-shadow: 0 0 0 3px var(--pulse-ring);
  transform: translateY(var(--dot-offset));
}

.summary {
  max-width: 68ch;
  font-size: var(--fs-summary);
}

.cta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 28px;
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 20px;
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  font-size: var(--fs-md);
  font-weight: 600;
  text-decoration: none;
  transition:
    background var(--ease),
    border-color var(--ease),
    color var(--ease),
    transform var(--ease);
}

.btn:is(:hover, :focus-visible) {
  transform: translateY(-1px);
}

.btn-primary {
  background: var(--accent);
  color: var(--on-accent);
}

.btn-primary:is(:hover, :focus-visible) {
  background: var(--accent-hover);
}

.btn-ghost {
  border-color: var(--border);
  color: var(--text);
}

.btn-ghost:is(:hover, :focus-visible) {
  border-color: var(--accent);
  color: var(--accent);
}

/* ---------- Section label ---------- */

.path {
  margin-bottom: 18px;
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: var(--fs-2xs);
  letter-spacing: 0.02em;
}

.path::before {
  content: "~/";
  color: var(--text-faint);
}

/* ---------- Skills ---------- */

.skill-grid {
  display: grid;
  grid-template-columns: 130px minmax(0, 1fr);
  gap: 18px 22px;
}

.skill-cat {
  padding-top: 4px;
  color: var(--text-muted);
  font-family: var(--font-label);
  font-size: var(--fs-label);
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.tag {
  padding: 4px 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elev);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: var(--fs-2xs);
  direction: ltr;
}

/* ---------- Timeline (experience, education) ---------- */

.job {
  position: relative;
  padding-inline-start: 22px;
  margin-bottom: 36px;
}

.job:last-child {
  margin-bottom: 0;
}

.job::before {
  content: "";
  position: absolute;
  top: calc(var(--dot-offset) + 1px);
  inset-inline-start: 0;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}

.job::after {
  content: "";
  position: absolute;
  top: calc(var(--dot-offset) + 11px);
  bottom: -36px;
  inset-inline-start: 3px;
  width: 1px;
  background: var(--border);
}

.job:last-child::after {
  display: none;
}

.job-head,
.project-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px 16px;
  margin-bottom: 4px;
}

.job-role {
  font-family: var(--font-display);
  font-size: var(--fs-lg);
  font-weight: 600;
}

.job-org {
  color: var(--accent);
  font-weight: 500;
}

a.job-org {
  text-decoration: none;
  text-underline-offset: 3px;
}

a.job-org:is(:hover, :focus-visible) {
  text-decoration: underline;
}

a.job-org i {
  font-size: var(--fs-2xs);
}

.job-time {
  color: var(--text-faint);
  font-family: var(--font-mono);
  font-size: var(--fs-2xs);
  white-space: nowrap;
  direction: ltr;
}

/* Tech stacks are Latin lists: LTR text, aligned to the page's start edge. */
.job-stack,
.project-stack {
  margin-bottom: 10px;
  color: var(--text-faint);
  font-family: var(--font-mono);
  font-size: var(--fs-2xs);
  direction: ltr;
  text-align: left;
}

:root[dir="rtl"] .job-stack,
:root[dir="rtl"] .project-stack {
  text-align: right;
}

.job ul,
.project-card ul {
  margin: 0;
  padding-inline-start: 20px;
  color: var(--text-muted);
  font-size: var(--fs-base);
}

.job li,
.project-card li {
  margin-bottom: 7px;
}

.job li:last-child,
.project-card li:last-child {
  margin-bottom: 0;
}

/* ---------- Projects ---------- */

.project-card {
  padding: var(--card-pad);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elev);
}

.project-card + .project-card {
  margin-top: var(--stack-gap);
}

.project-head a {
  color: var(--text);
  font-family: var(--font-display);
  font-size: var(--fs-lg);
  font-weight: 600;
  text-decoration: none;
  transition: color var(--ease);
}

.project-head a:is(:hover, :focus-visible) {
  color: var(--accent);
}

.project-head a i {
  font-size: var(--fs-2xs);
}

/* ---------- Achievements / certifications ---------- */

.ach-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.ach-list li {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  font-size: var(--fs-base);
}

.ach-list li:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.ach-list a {
  color: var(--text);
  text-decoration: none;
  transition: color var(--ease);
}

.ach-list a:is(:hover, :focus-visible) {
  color: var(--accent);
}

.ach-year {
  color: var(--text-faint);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  white-space: nowrap;
  direction: ltr;
}

/* ---------- Languages ---------- */

.lang-row {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 32px;
}

.lang-item .lvl {
  color: var(--text-muted);
  font-size: var(--fs-sm);
}

/* ---------- Contact ---------- */

.contact-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 28px;
  margin-bottom: 26px;
}

.contact-item {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--text);
  font-size: var(--fs-base);
  text-decoration: none;
  transition: color var(--ease);
}

.contact-item i {
  color: var(--accent);
  font-size: 1rem;
}

a.contact-item:is(:hover, :focus-visible) {
  color: var(--accent);
}

.social-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.social-row a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--text-muted);
  font-size: var(--fs-lg);
  text-decoration: none;
  transition:
    border-color var(--ease),
    color var(--ease);
}

.social-row a:is(:hover, :focus-visible) {
  border-color: var(--accent);
  color: var(--accent);
}

.social-row i {
  line-height: 0;
}

/* ---------- Certificate modal ---------- */

.cert-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.cert-modal.open {
  display: flex;
}

.cert-modal-backdrop {
  position: absolute;
  inset: 0;
  background: var(--backdrop);
  backdrop-filter: blur(4px);
}

.cert-modal-box {
  position: relative;
  width: min(100%, 460px);
  max-height: 88vh;
  overflow-y: auto;
  padding: 28px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elev);
  box-shadow: var(--shadow-modal);
}

.cert-modal-close {
  position: absolute;
  top: 14px;
  inset-inline-end: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: transparent;
  color: var(--text-muted);
  font-size: var(--fs-md);
  cursor: pointer;
  transition:
    border-color var(--ease),
    color var(--ease);
}

.cert-modal-close:is(:hover, :focus-visible) {
  border-color: var(--accent);
  color: var(--accent);
}

.cert-modal-title {
  margin: 0 0 16px;
  margin-inline-end: 34px;
  color: var(--text);
  font-family: var(--font-display);
  font-size: var(--fs-lg);
  font-weight: 600;
}

.cert-modal-img {
  display: block;
  width: 100%;
  margin-bottom: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.cert-modal-note {
  margin-bottom: 20px;
  color: var(--text-muted);
  font-size: var(--fs-sm);
}

.cert-modal-verify {
  width: 100%;
}

/* ---------- Responsive ---------- */

@media (max-width: 640px) {
  :root {
    --gutter: 20px;
    --section-y: 48px;
    --card-pad: 20px;
    --float-inset: 12px;
  }

  .rail {
    border-inline: 0;
  }

  .hero {
    padding-top: 84px;
  }

  .hero-top {
    align-items: flex-start;
    gap: 16px;
  }

  .avatar {
    width: 64px;
    height: 64px;
    flex-basis: 64px;
  }

  .hero-title {
    font-size: var(--fs-md);
    line-height: 1.6;
  }

  .status-line {
    align-items: flex-start;
  }

  .cta-row {
    display: grid;
    grid-template-columns: 1fr;
  }

  .btn {
    width: 100%;
  }

  .skill-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .skill-cat {
    padding-top: 0;
    margin-top: 8px;
  }

  .job-head,
  .project-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .job-time {
    white-space: normal;
  }

  .ach-list li {
    align-items: flex-start;
    flex-direction: column;
    gap: 3px;
  }
}

@media (max-width: 390px) {
  :root {
    --gutter: 16px;
    --card-pad: 17px;
  }

  .hero-top {
    gap: 13px;
  }

  .avatar {
    width: 56px;
    height: 56px;
    flex-basis: 56px;
  }

  .hero h1 {
    font-size: 1.8rem;
  }
}

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

  .cursor {
    animation: none;
  }

  .btn:is(:hover, :focus-visible) {
    transform: none;
  }
}

/* ---------- Persian typography ---------- */

/* Latin-only content inside the Persian page keeps its LTR reading order. */
:root:lang(fa) .contact-item {
  direction: ltr;
}
