/* Journey, post and hire-me pages. Colors come from tokens.css. */

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--green);
  color: var(--light);
  font-family: var(--font-sans);
  font-size: 17px;
  line-height: 1.6;
}

a { color: inherit; }

.wrap {
  width: min(100% - 32px, 820px);
  margin: 0 auto;
  padding: 40px 0 72px;
}

/* ---------- top bar ---------- */

.top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 24px;
  padding: 14px max(16px, (100% - 820px) / 2);
  background: linear-gradient(var(--sky-top), var(--sky-bottom));
  color: var(--green);
}

.top__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 19px;
  font-weight: 500;
  text-decoration: none;
}

.top__logo {
  width: 18px;
  height: 18px;
  background: var(--lime);
  border: 3px solid var(--green);
}

.top__nav {
  display: flex;
  gap: 20px;
  font-family: var(--font-label);
  font-size: 14px;
  font-weight: 700;
}

.top__nav a { text-decoration: none; padding: 4px 6px; }
.top__nav a:hover, .top__nav a:focus-visible { background: var(--lime); outline: none; }
.top__brand:focus-visible { outline: 3px solid var(--green); outline-offset: 4px; }

.grass {
  height: 14px;
  background: repeating-linear-gradient(90deg,
    var(--lime) 0 14px, var(--lime-dark) 14px 28px);
}

/* ---------- shared pieces ---------- */

.title {
  margin: 0 0 36px;
  font-family: var(--font-display);
  font-size: clamp(34px, 8vw, 60px);
  font-weight: 900;
  line-height: 1.12;
  letter-spacing: -0.035em;
}

.title span { display: block; width: fit-content; }

.title__mark {
  margin-top: 4px;
  margin-inline-start: -8px;
  padding: 0 8px;
  background: var(--lime);
  color: var(--green);
}

/* a dialogue box with a name tag, like the card */
.box {
  position: relative;
  padding: 26px 22px 18px;
  background: var(--box);
  border: 4px solid var(--light);
}

.box__tag {
  position: absolute;
  top: -16px;
  inset-inline-start: 18px;
  padding: 5px 12px;
  background: var(--lime);
  color: var(--green);
  font-family: var(--font-label);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.06em;
}

.box p { margin: 0; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  font-family: var(--font-label);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  line-height: 1.5;
}

.badge--experiment { background: var(--lime); color: var(--green); }
.badge--study { background: var(--light); color: var(--green); }

.cursor { color: var(--lime); font-size: 0.8em; }

/* ---------- journey ---------- */

.now { margin-bottom: 36px; }

.filters { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 8px; }

.filter {
  padding: 6px 12px;
  background: none;
  border: 2px solid var(--muted);
  color: var(--muted);
  font-family: var(--font-label);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.filter[aria-pressed="true"] { background: var(--lime); border-color: var(--lime); color: var(--green); }
.filter:hover, .filter:focus-visible { border-color: var(--light); color: var(--light); outline: none; }
.filter[aria-pressed="true"]:hover, .filter[aria-pressed="true"]:focus-visible { color: var(--green); }

.entries { list-style: none; margin: 0; padding: 0; }

.entry { border-bottom: 2px solid rgb(from var(--light) r g b / 0.15); }
.entry[hidden] { display: none; }

.entry__link {
  position: relative;
  display: grid;
  gap: 4px;
  padding: 20px 8px;
  padding-inline-start: 30px;
  text-decoration: none;
}

.entry__link .cursor {
  position: absolute;
  inset-inline-start: 4px;
  top: 22px;
  visibility: hidden;
}

.entry__link:hover .cursor, .entry__link:focus-visible .cursor { visibility: visible; }
.entry__link:hover .entry__title, .entry__link:focus-visible .entry__title { color: var(--lime); }
.entry__link:focus-visible { outline: 2px solid var(--light); outline-offset: -2px; }

.entry__meta {
  display: flex;
  flex-wrap: wrap; /* on a phone the tags go to a second line, each kept whole */
  align-items: center;
  gap: 6px 10px;
  font-family: var(--font-label);
  font-size: 13px;
  color: var(--muted);
}

.entry__title { font-size: 22px; font-weight: 700; line-height: 1.4; }
.entry__summary { color: rgb(from var(--light) r g b / 0.75); }

.entry__facts {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 24px;
  margin-top: 4px;
  font-family: var(--font-label);
  font-size: 13px;
}

.entry__facts b { color: var(--lime); font-weight: 700; margin-inline-end: 6px; }

.empty { margin-top: 32px; font-family: var(--font-label); color: var(--muted); }

/* ---------- post ---------- */

.post {
  padding: clamp(20px, 5vw, 48px);
  background: var(--sky-top);
  color: var(--green);
  border: 4px solid var(--light);
}

.post__meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 14px;
  font-family: var(--font-label);
  font-size: 13px;
}

.post__meta .badge--study { background: var(--green); color: var(--light); }

.post__title {
  margin: 0 0 28px;
  font-family: var(--font-display);
  font-size: clamp(28px, 6vw, 44px);
  font-weight: 900;
  line-height: 1.3;
}

.post[lang="en"] .post__title { letter-spacing: -0.03em; line-height: 1.15; }

.stats { margin: 30px 0 34px; color: var(--light); text-align: start; }
.stats dl { display: grid; gap: 10px; margin: 0; }
.stats div { display: grid; grid-template-columns: 150px 1fr; gap: 12px; align-items: baseline; }

.stats dt {
  color: var(--lime);
  font-family: var(--font-label);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.stats dd { margin: 0; overflow-wrap: anywhere; }

.post__body { max-width: 68ch; font-size: 18px; line-height: 1.75; overflow-wrap: break-word; }
.post[lang="ar"] .post__body { font-size: 19px; line-height: 2; }

.post__body > :first-child { margin-top: 0; }
.post__body > :last-child { margin-bottom: 0; }
.post__body h2 { margin: 1.8em 0 0.5em; font-size: 1.45em; font-weight: 700; line-height: 1.4; }
.post__body h3 { margin: 1.5em 0 0.4em; font-size: 1.2em; font-weight: 700; }
.post__body p, .post__body ul, .post__body ol { margin: 0 0 1.1em; }
.post__body ul, .post__body ol { padding-inline-start: 1.4em; }
.post__body a { color: var(--green); text-decoration-thickness: 2px; text-decoration-color: var(--lime-dark); }
.post__body img { display: block; max-width: 100%; height: auto; margin: 1.6em auto; border: 3px solid var(--green); }

.post__body blockquote {
  margin: 1.4em 0;
  padding: 0.4em 1em;
  border-inline-start: 6px solid var(--lime-dark);
  background: var(--sky-bottom);
}

.post__body blockquote p { margin: 0; }

.post__body code {
  padding: 0.1em 0.35em;
  background: var(--sky-bottom);
  font-family: var(--font-mono);
  font-size: 0.85em;
  direction: ltr;
  unicode-bidi: isolate;
}

.post__body table {
  display: block;
  width: max-content;
  max-width: 100%;
  overflow-x: auto;
  margin: 1.4em 0;
  border-collapse: collapse;
  font-size: 0.9em;
  line-height: 1.5;
}

.post__body th, .post__body td { padding: 8px 14px; border: 2px solid var(--green); text-align: start; }
.post__body th { background: var(--green); color: var(--light); font-family: var(--font-label); font-size: 0.85em; }

.post-nav { display: grid; gap: 12px; margin-top: 32px; }

.post-nav__link {
  display: grid;
  gap: 2px;
  padding: 12px 16px;
  border: 2px solid rgb(from var(--light) r g b / 0.3);
  text-decoration: none;
}

.post-nav__link:hover, .post-nav__link:focus-visible { border-color: var(--lime); outline: none; }
.post-nav__label { font-family: var(--font-label); font-size: 12px; font-weight: 700; color: var(--lime); }

.post-nav__back {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  width: fit-content;
  margin-top: 8px;
  padding: 6px 4px;
  font-family: var(--font-label);
  font-size: 14px;
  font-weight: 700;
  color: var(--lime);
  text-decoration: none;
}

.post-nav__back:hover, .post-nav__back:focus-visible { background: var(--lime); color: var(--green); outline: none; }
.post-nav__back:hover .cursor, .post-nav__back:focus-visible .cursor { color: var(--green); }

@media (max-width: 480px) {
  .stats div { grid-template-columns: 1fr; gap: 0; }
}

/* ---------- hire me: character sheet ---------- */

.sheet {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 28px;
  align-items: center;
  padding: 34px 26px 26px;
}

.sheet__portrait {
  align-self: stretch;
  display: grid;
  align-items: end;
  justify-items: center;
  padding: 14px 22px 0;
  background: linear-gradient(var(--sky-top), var(--sky-bottom));
  border-bottom: 12px solid var(--lime);
}

.sheet__portrait img {
  display: block;
  width: 134px;
  height: 234px;
  margin-bottom: -6px;
  image-rendering: pixelated;
}

.sheet__name {
  margin: 0 0 10px;
  font-size: clamp(30px, 6vw, 46px);
  font-weight: 900;
  line-height: 1.08;
  letter-spacing: -0.035em;
}

.sheet__class {
  margin: 0 0 14px;
  font-family: var(--font-label);
  font-size: 16px;
  font-weight: 700;
  color: var(--lime);
}

.sheet__class span { margin-right: 10px; color: var(--muted); }
.box .sheet__bio { margin: 0 0 18px; max-width: 52ch; }

.button {
  display: inline-block;
  padding: 10px 16px;
  background: var(--lime);
  color: var(--green);
  font-family: var(--font-label);
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
}

.button:hover, .button:focus-visible { background: var(--light); outline: none; }

.sheet-section { margin-top: 40px; }

.sheet__h {
  margin: 0 0 16px;
  padding-bottom: 8px;
  border-bottom: 4px solid var(--lime);
  font-family: var(--font-label);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--lime);
}

.skills { display: grid; gap: 14px; margin: 0; }
.skills div { display: grid; grid-template-columns: 200px 1fr; gap: 8px 16px; align-items: baseline; }
.skills dt { font-family: var(--font-label); font-size: 14px; font-weight: 700; }
.skills dd { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; }
.skills dd span { padding: 3px 10px; border: 2px solid var(--muted); font-size: 15px; }

.timeline { display: grid; gap: 22px; list-style: none; margin: 0; padding: 0; }
.timeline > li { display: grid; gap: 2px; }
.timeline__main { font-size: 19px; font-weight: 700; }
.timeline__where { font-family: var(--font-label); font-size: 13px; color: var(--muted); }
.timeline__notes { margin: 8px 0 0; padding-left: 1.2em; color: rgb(from var(--light) r g b / 0.85); }

.contact { display: grid; gap: 4px; list-style: none; margin: 0; padding: 0; font-family: var(--font-label); font-weight: 700; }

.contact a {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 6px 10px 6px 0;
  color: var(--muted);
  text-decoration: none;
  overflow-wrap: anywhere;
}

.contact .cursor { visibility: hidden; }
.contact a:hover, .contact a:focus-visible { color: var(--lime); outline: none; }
.contact a:hover .cursor, .contact a:focus-visible .cursor { visibility: visible; }

@media (max-width: 560px) {
  .sheet { grid-template-columns: 1fr; }
  .sheet__portrait { justify-self: start; }
  .skills div { grid-template-columns: 1fr; }
}

/* ---------- topics ---------- */

.topics {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
}

.topics__label {
  margin-inline-end: 6px;
  font-family: var(--font-label);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--lime);
}

.topic {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding-block: 6px;
  padding-inline: 14px 8px;
  border: 2px solid var(--light);
  font-weight: 700;
  text-decoration: none;
}

.topic b {
  min-width: 26px;
  padding: 1px 6px;
  background: var(--lime);
  color: var(--green);
  font-family: var(--font-label);
  font-size: 13px;
  text-align: center;
}

.topic:hover, .topic:focus-visible { background: var(--light); color: var(--green); outline: none; }

.entry__topic, .post__topic {
  padding: 1px 8px;
  border: 2px solid currentColor;
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.5;
}

.entry__topic { color: var(--light); }
.post__topic { color: var(--green); text-decoration: none; }
.post__topic:hover, .post__topic:focus-visible { background: var(--green); color: var(--light); outline: none; }

.crumb {
  margin: 0 0 18px;
  font-family: var(--font-label);
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
}

.crumb a { display: inline-flex; align-items: center; gap: 8px; color: var(--lime); text-decoration: none; }
.crumb a:hover, .crumb a:focus-visible { background: var(--lime); color: var(--green); outline: none; }
.crumb a:hover .cursor, .crumb a:focus-visible .cursor { color: var(--green); }

.title:has(+ .topic-about), .title:has(+ .topic-count) { margin-bottom: 18px; }
.topic-about { margin: 0 0 10px; max-width: 60ch; font-size: 19px; }
.topic-count { margin: 0 0 12px; text-transform: uppercase; font-family: var(--font-label); font-size: 13px; font-weight: 700; color: var(--muted); }

/* a topic's posts are a numbered series */
.entries--series { counter-reset: part; }
.entries--series .entry { counter-increment: part; }
.entries--series .entry__link { padding-inline-start: 64px; }
.entries--series .entry__link .cursor { inset-inline-start: 40px; }

.entries--series .entry__link::before {
  content: counter(part, decimal-leading-zero);
  position: absolute;
  inset-inline-start: 4px;
  top: 18px;
  font-family: var(--font-label);
  font-size: 20px;
  font-weight: 700;
  color: var(--lime);
}

/* ---------- hire me: projects ---------- */

.projects { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); gap: 16px; list-style: none; margin: 0; padding: 0; }

.project {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 18px;
  background: var(--box);
  border: 2px solid rgb(from var(--light) r g b / 0.35);
}

.project__name { margin: 0; font-size: 19px; font-weight: 700; line-height: 1.3; }
.project__tech { display: flex; flex-wrap: wrap; gap: 4px 12px; margin: 0; font-family: var(--font-label); font-size: 12px; color: var(--lime); }
.project .timeline__notes { margin: 0; font-size: 15px; }

.project__link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  width: fit-content;
  margin-top: auto;
  padding: 4px 6px 4px 0;
  font-family: var(--font-label);
  font-size: 13px;
  font-weight: 700;
  color: var(--lime);
  text-decoration: none;
}

.project__link:hover, .project__link:focus-visible { background: var(--lime); color: var(--green); outline: none; }
.project__link:hover .cursor, .project__link:focus-visible .cursor { color: var(--green); }

/* ---------- hire me: certificates ---------- */

.certificates { display: grid; gap: 2px; justify-items: start; list-style: none; margin: 0; padding: 0; }
.certificates a, .certificates span { display: inline-flex; align-items: baseline; gap: 10px; padding: 5px 8px 5px 0; text-decoration: none; }
.certificates span { padding-left: 24px; }
.certificates .cursor { color: var(--lime); }
.certificates a:hover, .certificates a:focus-visible { color: var(--lime); outline: none; text-decoration: underline; }

/* ---------- Arabic ----------
   Small labels are set a little larger in Arabic, and heavy titles need more
   room between lines than Latin capitals do. */

:lang(ar).title { line-height: 1.45; }
:lang(ar).title__mark { margin-top: 8px; }
:lang(ar).badge { font-size: 13px; }
:lang(ar).top__nav { font-size: 16px; }

:lang(ar):is(.box__tag, .filter, .topics__label, .post-nav__back) { font-size: 15px; }
:lang(ar):is(.entry__meta, .entry__facts, .post__meta, .stats dt, .post-nav__label, .crumb, .topic-count) { font-size: 14px; }

/* ---------- two languages ---------- */

/* On the English pages: a post that has no English version yet. */
.badge--only { background: var(--muted); color: var(--box); }
.badge, .entry__meta time { white-space: nowrap; }

/* The link to the other language is written in that language, so it takes
   that language's font and sits apart from the page's own menu. */
.top__lang { margin-inline-start: 8px; border: 2px solid var(--green); }
.top__lang:lang(ar) { font-family: "IBM Plex Sans Arabic", sans-serif; }
.top__lang:lang(en) { font-family: var(--font-mono); font-size: 14px; }

/* ---------- the character on the journey and hire-me pages ---------- */

/* Journey: he stands in a small piece of the card's sky, next to the title,
   writing in his notebook and looking up now and then. */
.hero {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px 24px;
  margin-bottom: 36px;
}
.hero .title { margin-bottom: 0; }

.guide {
  position: relative;
  flex: none;
  width: 134px;
  height: 234px;
  box-sizing: content-box;
  padding: 14px 20px 0;
  background: linear-gradient(var(--sky-top), var(--sky-bottom));
  border-bottom: 12px solid var(--lime);
}
.guide__frame {
  position: absolute;
  inset: auto 20px -6px;
  width: 134px;
  height: 234px;
  image-rendering: pixelated;
}
[dir="rtl"] .guide__frame { transform: scaleX(-1); } /* he faces the title */

/* stepped, like a game sprite: writing most of the time, then a look up */
.guide__frame--look { visibility: hidden; }
.guide__frame--write { animation: guide-write 3s steps(1, end) infinite; }
.guide__frame--look { animation: guide-look 3s steps(1, end) infinite; }
@keyframes guide-write { 0% { visibility: visible; } 60% { visibility: hidden; } }
@keyframes guide-look { 0% { visibility: hidden; } 60% { visibility: visible; } }

/* Hire-me: a small idle bob, one pixel step at a time. */
.sheet__portrait img { animation: portrait-bob 2s steps(1, end) infinite; }
@keyframes portrait-bob { 0% { transform: translateY(0); } 50% { transform: translateY(-2px); } }

@media (max-width: 560px) {
  /* half size keeps the pixels square (2 art pixels to 1) and leaves room for the title */
  .guide { width: 67px; height: 117px; padding: 8px 12px 0; border-bottom-width: 8px; }
  .guide__frame { inset: auto 12px -3px; width: 67px; height: 117px; }
}

@media (prefers-reduced-motion: reduce) {
  .guide__frame, .sheet__portrait img { animation: none; }
}
