/* ----------------------------------------------------------------------------
   Shayan Gholami — site styles
   One stylesheet for every page (cv, blog index, posts). No frameworks.
---------------------------------------------------------------------------- */

:root {
  --bg: #f7f6f2;
  --surface: #ffffff;
  --text: #1d1d1b;
  --muted: #6b6a65;
  --line: #e4e2da;
  --accent: #1f6f5c;
  --accent-soft: #e3efe9;

  --sans: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --measure: 46rem;
  --gutter: 1.25rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151614;
    --surface: #1c1d1b;
    --text: #e8e6df;
    --muted: #9a988f;
    --line: #2d2e2b;
    --accent: #6cc3a7;
    --accent-soft: #1f2e29;
  }
}

/* Persian page: system fonts with Arabic-script coverage, no serif/mono swaps,
   and slightly more line height for the taller script. */
:root:lang(fa) {
  --sans: system-ui, -apple-system, "Segoe UI", Tahoma, "Noto Sans Arabic", sans-serif;
  --serif: var(--sans);
}
:lang(fa) body { line-height: 1.85; }
:lang(fa) h1 { font-weight: 700; letter-spacing: 0; }
:lang(fa) h2 { letter-spacing: 0; font-size: 0.85rem; }
:lang(fa) .entry .when, :lang(fa) .entry time { font-family: var(--sans); font-size: 0.85rem; }
:lang(fa) .now { letter-spacing: 0; }
:lang(fa) .stats strong { font-weight: 700; }
[dir="ltr"] { unicode-bidi: isolate; }
[dir="rtl"] .tech[dir="ltr"] { text-align: right; }

/* Reset ------------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
img { display: block; max-width: 100%; height: auto; }

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

body {
  background: var(--bg);
  color: var(--text);
  font: 400 1rem/1.65 var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: var(--line);
  text-underline-offset: 0.2em;
  transition: text-decoration-color 0.15s;
}
a:hover { text-decoration-color: var(--accent); }

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

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

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

.wrap {
  max-width: var(--measure);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding-block: 1.5rem;
  font-size: 0.9rem;
}

.site-header .home {
  font-weight: 600;
  text-decoration: none;
  letter-spacing: -0.01em;
}

.site-nav { display: flex; gap: 1.25rem; }
.site-nav a { color: var(--muted); text-decoration: none; }
.site-nav a:hover,
.site-nav a[aria-current="page"] { color: var(--text); }

main { padding-block: 2rem 4rem; }
.wrap > main:first-child { padding-top: 4rem; } /* pages without a header */

.site-footer {
  border-top: 1px solid var(--line);
  padding-block: 1.5rem 3rem;
  color: var(--muted);
  font-size: 0.85rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem;
}

/* Typography -------------------------------------------------------------- */

h1, h2, h3 { line-height: 1.25; font-weight: 600; }

h1 {
  font-family: var(--serif);
  font-size: clamp(2rem, 5vw, 2.75rem);
  font-weight: 500;
  letter-spacing: -0.015em;
}

h2 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin-bottom: 1.25rem;
}

h3 { font-size: 1.05rem; }

p + p { margin-top: 1em; }

h1, h2, h3 { text-wrap: balance; }
p, li { text-wrap: pretty; }

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

/* Intro ------------------------------------------------------------------- */

.intro {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 1.75rem;
  align-items: center;
  margin-bottom: 3.5rem;
}

.avatar {
  width: 112px;
  height: 112px;
  border-radius: 50%;
  object-fit: cover;
  object-position: 50% 30%;
  background: var(--line);
}

.role {
  margin-top: 0.35rem;
  font-size: 1.05rem;
  color: var(--muted);
}

.contact {
  list-style: none;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
  margin-top: 0.9rem;
  font-size: 0.9rem;
}
.contact li { display: inline-flex; align-items: center; gap: 0.4rem; }
.contact svg {
  width: 14px;
  height: 14px;
  flex: none;
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.summary {
  font-size: 1.1rem;
  max-width: 40rem;
  margin-bottom: 2.5rem;
}

strong { font-weight: 600; }

/* Four headline numbers under the summary. */
.stats {
  list-style: none;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.5rem;
  margin-bottom: 3.5rem;
  padding-block: 1.25rem;
  border-block: 1px solid var(--line);
  font-size: 0.85rem;
  line-height: 1.4;
  color: var(--muted);
}
.stats strong {
  display: block;
  margin-bottom: 0.2rem;
  font-family: var(--serif);
  font-size: 1.6rem;
  font-weight: 500;
  color: var(--text);
  letter-spacing: -0.01em;
}

/* Sections ---------------------------------------------------------------- */

section { margin-bottom: 3.5rem; }

/* A dated entry: date in the left column, content on the right.
   The content column carries a continuous timeline rail with a dot per entry. */
.entry {
  display: grid;
  grid-template-columns: 9.5rem 1fr;
  gap: 0.25rem 1.5rem;
}

.entry > div {
  position: relative;
  padding-block-end: 2rem;
  padding-inline-start: 1.5rem;
  border-inline-start: 1px solid var(--line);
}
.entry:last-child > div { padding-block-end: 0.5rem; }

.entry > div::before {
  content: "";
  position: absolute;
  inset-inline-start: -5px;
  top: 0.45rem;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--bg);
  border: 1.5px solid var(--muted);
  transition: border-color 0.2s, background-color 0.2s;
}
.entry:first-of-type > div::before {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.entry h3 { transition: color 0.2s; }

@media (hover: hover) {
  .entry:hover h3 { color: var(--accent); }
  .entry:hover > div::before { border-color: var(--accent); }
}

.entry time,
.entry .when {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--muted);
  padding-top: 0.2rem;
  white-space: nowrap;
}

.entry .org { font-weight: 400; }

.entry ul {
  margin-top: 0.5rem;
  padding-inline-start: 1.1rem;
  font-size: 0.96rem;
  line-height: 1.6;
}
.entry li + li { margin-top: 0.3rem; }
.entry li::marker { color: var(--accent); }

.entry p { margin-top: 0.25rem; }

.entry .tech {
  margin-top: 0.7rem;
  font-family: var(--mono);
  font-size: 0.78rem;
  line-height: 1.6;
  color: var(--muted);
}

.now {
  display: inline-block;
  margin-inline-start: 0.4rem;
  padding: 0 0.45rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-family: var(--sans);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  vertical-align: 1px;
}

/* Skills & languages ------------------------------------------------------ */

.columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: 0 3rem;
}

/* Same left column as .entry so everything lines up. */
.skills {
  display: grid;
  grid-template-columns: 9.5rem 1fr;
  gap: 0.6rem 1.5rem;
}
.skills dt { font-weight: 600; font-size: 0.9rem; padding-top: 0.05rem; }

.pairs {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.4rem 1.5rem;
}
.pairs dd { color: var(--muted); }

.stack dt { font-weight: 600; }
.stack dd { color: var(--muted); font-size: 0.9rem; }
.stack dd + dt { margin-top: 0.6rem; }

/* Blog -------------------------------------------------------------------- */

.post-list { list-style: none; padding: 0; }
.post-list li {
  display: grid;
  grid-template-columns: 7rem 1fr;
  gap: 1.5rem;
  padding-block: 0.75rem;
  border-top: 1px solid var(--line);
}
.post-list time { font-family: var(--mono); font-size: 0.8rem; color: var(--muted); padding-top: 0.2rem; }

.post header { margin-bottom: 2.5rem; }
.post header time { display: block; margin-top: 0.6rem; font-family: var(--mono); font-size: 0.85rem; color: var(--muted); }

.prose { font-size: 1.075rem; line-height: 1.75; }
.prose > * + * { margin-top: 1.2em; }
.prose h2 {
  font-size: 1.35rem;
  text-transform: none;
  letter-spacing: -0.01em;
  color: var(--text);
  margin: 2.2em 0 0;
}
.prose ul, .prose ol { padding-inline-start: 1.3rem; }
.prose blockquote {
  border-inline-start: 2px solid var(--accent);
  padding-inline-start: 1rem;
  color: var(--muted);
}
.prose code {
  font-family: var(--mono);
  font-size: 0.88em;
  background: var(--accent-soft);
  padding: 0.1em 0.35em;
  border-radius: 3px;
}
.prose pre {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 1rem;
  overflow-x: auto;
  font-size: 0.875rem;
  line-height: 1.55;
}
.prose pre code { background: none; padding: 0; }

/* Motion: CSS only, skipped for people who ask for less motion ------------- */

@media (prefers-reduced-motion: no-preference) {
  @keyframes rise {
    from { opacity: 0; transform: translateY(10px); }
  }

  /* The top of the page settles in once, in sequence. */
  .intro,
  .summary,
  .stats { animation: rise 0.6s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
  .summary { animation-delay: 0.08s; }
  .stats { animation-delay: 0.16s; }

  /* Further down, entries rise as they scroll into view
     (browsers without scroll timelines just show them). */
  @supports (animation-timeline: view()) {
    .entry,
    .skills,
    .columns {
      animation: rise linear both;
      animation-timeline: view();
      animation-range: entry 0 entry 6rem;
    }
  }
}

/* Large screens: scale everything up a touch ------------------------------ */

@media (min-width: 1600px) {
  html { font-size: 112.5%; }
}

/* Small screens ----------------------------------------------------------- */

@media (max-width: 600px) {
  .intro { grid-template-columns: 1fr; gap: 1.25rem; }
  .avatar { width: 88px; height: 88px; }
  .entry,
  .skills,
  .post-list li { grid-template-columns: 1fr; gap: 0.15rem; }
  .skills dd + dt { margin-top: 0.6rem; }
  .stats { grid-template-columns: repeat(2, 1fr); }

  /* Dates stack above the content, so the rail moves to the whole entry. */
  .entry {
    position: relative;
    padding-block-end: 1.75rem;
    padding-inline-start: 1.25rem;
    border-inline-start: 1px solid var(--line);
  }
  .entry > div { position: static; padding: 0; border: 0; }
  .entry:last-child { padding-block-end: 0.5rem; }
}

/* Print: the CV should come out clean on paper / PDF ---------------------- */

@media print {
  :root {
    --bg: #fff;
    --surface: #fff;
    --text: #000;
    --muted: #444;
    --line: #ccc;
    --accent: #000;
    --accent-soft: #eee;
  }
  @page { margin: 12mm 14mm; }
  /* Everything is sized in rem, so shrinking the root scales the whole page. */
  html { font-size: 8pt; }
  body { line-height: 1.45; }
  h2 { margin-bottom: 0.6rem; }
  .wrap, .summary { max-width: none; padding: 0; }
  .entry { grid-template-columns: 9.5rem 1fr; gap: 0 1.25rem; }
  .entry ul { margin-top: 0.25rem; }
  .entry li + li { margin-top: 0.1rem; }
  .entry .tech { margin-top: 0.3rem; }
  .entry li, .entry h3 { break-inside: avoid; }
  .entry h3 { break-after: avoid; }
  .skills { grid-template-columns: 9.5rem 1fr; gap: 0.2rem 1.25rem; }
  .site-header, .site-footer, .no-print, .avatar { display: none; }
  .intro { grid-template-columns: 1fr; }
  .stats { padding-block: 0.6rem; }
  .stats strong { font-size: 1.25rem; }
  main { padding: 0; }
  section, .summary, .intro { margin-bottom: 1.25rem; }
  .entry > div { padding-block-end: 0.9rem; }
  *, *::before { animation: none !important; transition: none !important; }
  a { text-decoration: none; }
}
