/* ---------- tokens ---------- */
:root{
  --paper: #FAF8F3;
  --paper-2: #F1EEE5;
  --ink: #1C1B17;
  --ink-2: #5B584E;
  --ink-3: #8C8878;
  --accent: #8C3B2E;
  --accent-soft: #F3E4E0;
  --rule: #DDD6C4;
  --rule-strong: #B9B09A;
  --radius: 3px;
  --font-display: 'Space Grotesk', var(--font-fa), sans-serif;
  --font-sans: 'IBM Plex Sans', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, monospace;
  --font-fa: 'Vazirmatn', 'IBM Plex Sans', system-ui, sans-serif;
  --maxw: 720px;
}

html.dark{
  --paper: #161512;
  --paper-2: #1E1C18;
  --ink: #EDEAE0;
  --ink-2: #B0AB9A;
  --ink-3: #7C7868;
  --accent: #E0836B;
  --accent-soft: #2B211D;
  --rule: #322F27;
  --rule-strong: #454136;
}

*{ box-sizing: border-box; }

@media (prefers-reduced-motion: reduce){
  *{ animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

body{
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  transition: background .25s ease, color .25s ease;
}

html[dir="rtl"] body{ font-family: var(--font-fa); }

a{ color: var(--accent); text-decoration: none; }
a:hover{ text-decoration: underline; }
a:focus-visible, button:focus-visible{
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- corner controls ---------- */
.controls{
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 8px;
}
html[dir="rtl"] .controls{ right: auto; left: 18px; }

.controls a{
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-2);
  background: var(--paper);
  border: 1px solid var(--rule-strong);
  border-radius: 20px;
  padding: 5px 12px;
}
html[dir="rtl"] .controls a{ font-family: var(--font-fa); }
.controls a:hover{ color: var(--accent); border-color: var(--accent); text-decoration: none; }

.pill-btn{
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .04em;
  color: var(--ink-2);
  background: var(--paper);
  border: 1px solid var(--rule-strong);
  border-radius: 20px;
  padding: 5px 12px;
  cursor: pointer;
}
.pill-btn:hover{ color: var(--accent); border-color: var(--accent); }
.icon-btn{
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  color: var(--ink-2);
  background: var(--paper);
  border: 1px solid var(--rule-strong);
  border-radius: 50%;
  cursor: pointer;
}
.icon-btn:hover{ color: var(--accent); border-color: var(--accent); }

/* ---------- page ---------- */
.ledger-page{
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 64px 24px 56px;
}

/* ---------- letterhead ---------- */
.letterhead{
  display: flex;
  align-items: center;
  gap: 22px;
  padding-bottom: 28px;
  border-bottom: 2px solid var(--ink);
  margin-bottom: 36px;
}
.letterhead__photo{
  width: 200px;
  height: 200px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 2px solid var(--paper);
  box-shadow: 0 0 0 1.5px var(--rule-strong);
}
.letterhead__body{ text-align: left; }
html[dir="rtl"] .letterhead__body{ text-align: right; }

.letterhead__eyebrow{
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 6px;
}
html[dir="rtl"] .letterhead__eyebrow{ font-family: var(--font-fa); text-transform: none; letter-spacing: 0; }

.letterhead__name{
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  margin: 0 0 6px;
  letter-spacing: -.01em;
}
.letterhead__role{
  color: var(--ink-2);
  font-size: 14px;
  margin: 0;
  max-width: 460px;
}

@media (max-width: 480px){
  .letterhead{ flex-direction: column; text-align: center; }
  .letterhead__body{ text-align: center; }
  html[dir="rtl"] .letterhead__body{ text-align: center; }
}

/* ---------- contact list ---------- */
.letterhead__contact{
  list-style: none;
  margin: 18px 0 0;
  padding: 0;
  display: grid;
  gap: 6px;
  font-size: 13px;
}
.letterhead__contact li{ display: flex; gap: 10px; }
.letterhead__contact .k{
  font-family: var(--font-mono);
  color: var(--ink-3);
  min-width: 68px;
}
html[dir="rtl"] .letterhead__contact .k{ font-family: var(--font-fa); min-width: 56px; }
.letterhead__contact .v{ color: var(--ink); }

/* ---------- sections ---------- */
.ledger-section{ margin-bottom: 36px; }
.section-label{
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ink);
  margin: 0 0 16px;
}
html[dir="rtl"] .section-label{ text-transform: none; letter-spacing: 0; }
.section-label .tab{
  width: 18px;
  height: 2px;
  background: var(--accent);
  display: inline-block;
}
.section-intro{
  color: var(--ink-2);
  font-size: 14px;
  margin: -8px 0 18px;
}
.summary-text{
  color: var(--ink-2);
  font-size: 15.5px;
  margin: 0;
}
.summary-text--muted{ color: var(--ink-3); font-style: italic; }

.about-body p{ margin: 0 0 14px; color: var(--ink-2); font-size: 15px; }
.about-body p:first-child{ color: var(--ink); font-size: 16.5px; }

/* ---------- experience: company groups + timeline ---------- */
.company-group{ margin-bottom: 30px; }
.company-group:last-child{ margin-bottom: 0; }
.company-heading{
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
  background: var(--paper-2);
  display: inline-block;
  padding: 4px 10px;
  border-radius: var(--radius);
  margin: 0 0 16px;
}
html[dir="rtl"] .company-heading{ font-family: var(--font-fa); }

.timeline{ position: relative; }
.timeline__entry{
  position: relative;
  padding: 0 0 26px 22px;
  border-left: 1.5px solid var(--rule);
}
html[dir="rtl"] .timeline__entry{ border-left: none; border-right: 1.5px solid var(--rule); padding: 0 22px 26px 0; }
.timeline__entry:last-child{ padding-bottom: 0; border-color: transparent; }
.timeline__marker{
  position: absolute;
  left: -5px;
  top: 4px;
  width: 8px;
  height: 8px;
  background: var(--accent);
  border-radius: 50%;
}
html[dir="rtl"] .timeline__marker{ left: auto; right: -5px; }

.timeline__head{
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.timeline__head h3{ font-size: 16px; font-weight: 600; margin: 0; }
.timeline__date{
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-3);
  white-space: nowrap;
}
html[dir="rtl"] .timeline__date{ font-family: var(--font-fa); }
.timeline__org{ color: var(--ink-2); font-size: 14px; margin: 0 0 14px; }

.proj{ margin: 0 0 14px; }
.proj:last-child{ margin-bottom: 0; }
.proj-name{
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
  margin: 0 0 2px;
}
html[dir="rtl"] .proj-name{ font-family: var(--font-fa); }
.proj-stack{ font-size: 11.5px; color: var(--ink-3); margin: 0 0 8px; }

.timeline__list{ margin: 0; padding: 0; list-style: none; }
.timeline__list li{
  position: relative;
  padding-left: 14px;
  margin-bottom: 6px;
  color: var(--ink-2);
  font-size: 14px;
}
html[dir="rtl"] .timeline__list li{ padding-left: 0; padding-right: 14px; }
.timeline__list li::before{
  content: "–";
  position: absolute;
  left: 0;
  color: var(--ink-3);
}
html[dir="rtl"] .timeline__list li::before{ left: auto; right: 0; }

/* ---------- skills (tag rows) ---------- */
.skill-group{ margin-bottom: 14px; }
.skill-group:last-child{ margin-bottom: 0; }
.skill-group-label{
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--ink-3);
  margin: 0 0 7px;
}
html[dir="rtl"] .skill-group-label{ font-family: var(--font-fa); }
.tag-row{
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.tag-row li{
  font-size: 12.5px;
  color: var(--ink-2);
  background: var(--paper-2);
  border: 1px solid var(--rule);
  border-radius: 20px;
  padding: 4px 11px;
}

/* ---------- notes (on their own page) ---------- */
.notes-list{ display: grid; gap: 14px; }
.note{
  background: var(--paper-2);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 18px 20px;
  break-inside: avoid;
}
.note-title{ font-weight: 600; font-size: 15px; margin: 0 0 8px; }
.note-body{ color: var(--ink-2); font-size: 14px; margin: 0; }
.notes-title{
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 10px;
}

/* ---------- education / languages ---------- */
.edu-item{ display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.edu-degree{ font-weight: 600; margin: 0; }
.edu-school{ color: var(--ink-2); font-size: 14px; margin: 2px 0 0; }
.edu-date{ font-family: var(--font-mono); font-size: 12px; color: var(--ink-3); white-space: nowrap; }
html[dir="rtl"] .edu-date{ font-family: var(--font-fa); }

.lang-item{ display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--rule); }
.lang-item:last-child{ border-bottom: none; }
.lang-name{ font-weight: 600; }
.lang-level{ color: var(--ink-2); font-size: 14px; text-align: right; max-width: 60%; }
html[dir="rtl"] .lang-level{ text-align: left; }

/* ---------- closing / footer ---------- */
.closing-note{
  font-size: 14.5px;
  color: var(--ink-2);
  font-style: italic;
  border-top: 1px solid var(--rule);
  padding-top: 22px;
  margin: 8px 0 0;
}
.ledger-footer{
  margin-top: 32px;
  font-size: 11.5px;
  font-family: var(--font-mono);
  color: var(--ink-3);
}
html[dir="rtl"] .ledger-footer{ font-family: var(--font-fa); }

@media (max-width: 480px){
  .ledger-page{ padding: 88px 20px 40px; }
}

/* ---------- print ---------- */
@media print{
  .controls{ display: none !important; }
  html, html.dark{
    --paper: #FFFFFF;
    --paper-2: #FFFFFF;
    --ink: #000000;
    --ink-2: #222222;
    --ink-3: #444444;
    --accent: #000000;
    --rule: #CCCCCC;
    --rule-strong: #999999;
  }
  body{ font-size: 12px; }
  .ledger-page{ padding: 0; max-width: 100%; }
  .ledger-section{ break-inside: avoid; margin-bottom: 18px; }
  .company-group{ break-inside: avoid; }
  .timeline__entry{ break-inside: avoid; }
  .note{ border: 1px solid #999; background: none; }
  .tag-row li{ border: 1px solid #999; background: none; }
  a{ color: #000; text-decoration: underline; }
}
