/* ---------- tokens ---------- */
:root {
  --bg: #D3CECB;
  --ink: #371900;
  --accent: #872F00;
  --line: 1px solid var(--ink);
  --frame-pad: 28px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Bitter', Georgia, serif;
  font-weight: 400;
  font-size: 15px;
  line-height: 1.5;            /* paragraphs at 150% of font size */
}

a { color: inherit; text-decoration: none; }

/* ---------- frame ---------- */
.page {
  background: var(--bg);
  margin: 0;
  padding: 22px;
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.inner {
  border: var(--line);
  display: grid;
  grid-template-rows: auto auto auto auto;
}

/* ---------- header ---------- */
.masthead {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  padding: 18px 28px;
  border-bottom: var(--line);
}

.masthead .brand {
  font-family: 'Bitter', Georgia, serif;
  font-weight: 300;
  font-size: 44px;
  letter-spacing: 0.02em;
  line-height: 1;
}

.masthead-nav {
  justify-self: end;
  display: flex;
  gap: 28px;
  align-items: center;
}

.masthead .nav {
  font-size: 18px;
  letter-spacing: 0.18em;
  color: var(--ink);
  text-decoration: none;
  transition: color 0.15s ease, opacity 0.15s ease;
}

.masthead .nav:hover { color: var(--accent); }

.masthead .nav.is-active {
  opacity: 0.4;
  pointer-events: none;
}

/* ---------- main row: bio + featured ---------- */
.main-row {
  display: grid;
  grid-template-columns: 1fr 2fr;
  border-bottom: var(--line);
}

.bio {
  padding: 18px 22px;
  border-right: var(--line);
  color: var(--accent);
}

.bio .arabic {
  font-family: 'Noto Naskh Arabic', 'Amiri', serif;
  font-size: 17px;
  margin: 0 0 4px 0;
  direction: rtl;
  text-align: left;
}

.bio p {
  margin: 0 0 16px 0;
  font-size: 16px;
  line-height: 1.5;
}

.cat-list {
  display: grid;
  grid-template-columns: max-content;
  gap: 10px;
  list-style: none;
  padding: 0;
  margin: 0;
}

.cat-btn {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--accent);
  padding: 8px 14px;
  font-size: 15px;
  letter-spacing: 0.14em;
  border-radius: 2px;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.cat-btn:hover {
  background: rgba(135, 47, 0, 0.08);
}

.cat-btn.is-active {
  background: var(--accent);
  color: var(--bg);
}

/* ---------- featured project ---------- */
.featured {
  padding: 26px 40px 32px 40px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.featured-head {
  display: flex;
  align-items: center;
  gap: 14px;
}

.featured-head .title {
  font-weight: 900;
  font-size: 22px;
  letter-spacing: 0.06em;
  margin: 0;
}

.tag-row {
  display: flex;
  gap: 8px;
  flex: 1;
}

.tag {
  border: 1px solid var(--accent);
  color: var(--accent);
  padding: 4px 10px;
  font-size: 13px;
  letter-spacing: 0.14em;
  border-radius: 2px;
}

.date {
  color: var(--accent);
  font-size: 13px;
  margin-left: auto;
  white-space: nowrap;
}

.featured-image {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 2;
  object-fit: cover;
  background: transparent;
}

.featured-caption {
  font-size: 13px;
  line-height: 1.5;
  margin: 16px 0 0 0;
}

/* ---------- secondary row: two cards ---------- */
.secondary-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-bottom: var(--line);
}

.card {
  padding: 24px 32px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.card + .card { border-left: var(--line); }

.card-head {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  border-top: var(--line);
  border-bottom: var(--line);
  padding-top: 10px;
  padding-bottom: 10px;
}

.card-head .title {
  font-weight: 900;
  font-size: 17px;
  letter-spacing: 0.05em;
  margin: 0;
}

.card-head .date {
  margin-left: 0;
}

.card-image {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: transparent;
}

/* ---------- footer ---------- */
.footer {
  padding: 18px 28px;
  display: flex;
  justify-content: flex-end;
  align-items: center;
}

.footer .archive-link {
  font-size: 22px;
  letter-spacing: 0.12em;
}

/* ---------- empty scaffold pages ---------- */
.scaffold-body {
  padding: 60px 28px;
  text-align: center;
  color: var(--accent);
  font-size: 13px;
  letter-spacing: 0.12em;
}

/* ---------- project detail page ---------- */
.project-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 28px;
  border-bottom: var(--line);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 5;
}

.project-header .title {
  font-weight: 900;
  font-size: 22px;
  letter-spacing: 0.06em;
  margin: 0;
}

.project-header .tag-row { flex: 0 1 auto; }

.project-body {
  display: grid;
  grid-template-columns: 2fr 1fr;
}

.project-images {
  padding: 26px 40px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.project-images img {
  display: block;
  width: 100%;
  height: auto;
  background: transparent;
}

.project-side {
  padding: 26px 30px;
  border-left: var(--line);
}

.project-description {
  position: sticky;
  top: 88px;
  font-size: 17px;
  line-height: 1.5;
}

.project-description p { margin: 0 0 12px 0; }
.project-description p:last-child { margin-bottom: 0; }

/* ---------- archive page ---------- */
.archive-row {
  display: grid;
  grid-template-columns: max-content 1fr;
}

.archive-side {
  padding: 26px 18px 26px 28px;
  position: sticky;
  top: 0;
  align-self: start;
  background: var(--bg);
  z-index: 5;
}

.archive-cat-list .cat-btn {
  font-size: 13px;
  padding: 6px 12px;
}

.archive-list {
  padding: 12px 28px 32px 24px;
  display: flex;
  flex-direction: column;
  border-left: var(--line);
}

.archive-item {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 0;
  border-bottom: var(--line);
  color: var(--ink);
  text-decoration: none;
  transition: opacity 0.2s ease;
}

.archive-item:last-child { border-bottom: none; }

.archive-item .archive-title {
  font-weight: 900;
  font-size: 20px;
  letter-spacing: 0.04em;
}

.archive-item .archive-date {
  color: var(--accent);
  font-size: 16px;
  white-space: nowrap;
}

.archive-item.dim { opacity: 0.28; }
.archive-item:hover:not(.dim) .archive-title { color: var(--accent); }

/* ---------- about page ---------- */
.about-row {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 40px;
  padding: 32px 40px;
}

.about-image img {
  width: 100%;
  height: auto;
  display: block;
}

.about-content {
  display: flex;
  flex-direction: column;
  gap: 16px;
  color: var(--accent);
  font-size: 16px;
  line-height: 1.6;
}

.about-content .arabic {
  font-family: 'Noto Naskh Arabic', 'Amiri', serif;
  font-size: 22px;
  margin: 0;
  direction: rtl;
  text-align: left;
}

.about-content p { margin: 0; }

.socials {
  list-style: none;
  padding: 0;
  margin: 12px 0 0 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 14px;
  letter-spacing: 0.1em;
}

.socials a,
.socials .muted {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.15s ease;
}

.socials a:hover { color: var(--ink); }
.socials .muted { opacity: 0.55; }

/* ---------- shared site footer (copyright) ---------- */
.site-footer {
  padding: 14px 28px;
  border-top: var(--line);
  color: var(--accent);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-align: center;
}

/* ---------- back-to-top button (project pages) ---------- */
.back-to-top {
  display: inline-block;
  margin-top: 18px;
  padding: 0;
  background: transparent;
  border: none;
  color: var(--accent);
  font-family: inherit;
  font-size: 12px;
  letter-spacing: 0.14em;
  cursor: pointer;
  transition: color 0.15s ease;
}

.back-to-top:hover { color: var(--ink); }

/* ---------- 404 page ---------- */
.not-found {
  padding: 80px 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
}

.not-found-code {
  font-family: 'Bitter', Georgia, serif;
  font-weight: 300;
  font-size: 140px;
  line-height: 1;
  color: var(--ink);
  margin: 0;
  letter-spacing: 0.02em;
}

.not-found-title {
  font-size: 22px;
  font-weight: 700;
  margin: 14px 0 4px 0;
  color: var(--ink);
}

.not-found-sub {
  font-size: 15px;
  color: var(--accent);
  margin: 0 0 20px 0;
}

.not-found-link {
  font-size: 14px;
  letter-spacing: 0.14em;
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid var(--accent);
  padding-bottom: 2px;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.not-found-link:hover { color: var(--ink); border-color: var(--ink); }

/* ---------- preloader (full page + per-image) ---------- */
.preloader-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 100;
  transition: opacity 0.35s ease;
}
.preloader-overlay.is-hidden {
  opacity: 0;
  pointer-events: none;
}

.image-wrap {
  position: relative;
  display: block;
  width: 100%;
}

.preloader-image {
  position: absolute;
  inset: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  display: block;
}
.preloader-image.is-hidden {
  opacity: 0;
}

/* ---------- mobile (≤768px) ---------- */
@media (max-width: 768px) {
  /* stack the two main grids into single columns */
  .main-row { grid-template-columns: 1fr; }
  .secondary-row { grid-template-columns: 1fr; }

  /* flip dividers from vertical to horizontal */
  .bio { border-right: none; border-bottom: var(--line); }
  .card + .card { border-left: none; border-top: var(--line); }

  /* featured collapses to look like the bottom cards: no caption,
     matching paddings, matching title size */
  .featured-caption { display: none; }
  .featured { padding: 22px; gap: 12px; }
  .card { padding: 22px; gap: 12px; }
  .featured-head .title { font-size: 17px; letter-spacing: 0.05em; }

  /* tighten masthead */
  .masthead { padding: 14px 22px; }
  .masthead .brand { font-size: 32px; }
  .masthead .nav { font-size: 14px; letter-spacing: 0.15em; }
  .masthead-nav { gap: 16px; }

  /* shrink 404 hero on small screens */
  .not-found { padding: 60px 22px; }
  .not-found-code { font-size: 96px; }
  .not-found-title { font-size: 18px; }

  /* tighten bio + footer to match new padding language */
  .bio { padding: 20px 22px; }
  .footer { padding: 16px 22px; }
  .footer .archive-link { font-size: 18px; }

  /* outer page padding eats less of the narrow viewport */
  .page { padding: 12px; }

  /* category buttons stop spanning the whole sidebar width — wrap as
     content-sized pills instead so FABRICATION (and the others) don't
     stretch into giant full-row banners. Override the desktop grid
     back to a flex row that wraps. */
  .cat-list {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
  }
  .cat-btn {
    display: inline-block;
    width: auto;
  }

  /* if a card-head wraps, keep the tag row shrink-to-content so it
     doesn't stretch its lone line edge-to-edge */
  .tag-row { flex: 0 1 auto; }

  /* featured-head must also wrap so a long title + multiple tags
     don't overflow the viewport (e.g. KEEP REFRIGERATED. with three
     tags as the FABRICATION featured slot). On mobile featured is
     visually a card too, so give it the same top+bottom rule frame
     as .card-head. */
  .featured-head {
    flex-wrap: wrap;
    border-top: var(--line);
    border-bottom: var(--line);
    padding-top: 10px;
    padding-bottom: 10px;
  }

  /* featured image matches the cards' 4:3 crop on mobile, since the
     featured slot is styled like a card here (the desktop-only 4:2
     short crop would feel cramped on a narrow stacked viewport) */
  .featured-image { aspect-ratio: 4 / 3; }

  /* project detail page collapses to single column; description sits
     above the image stack and stops being sticky (no value on a phone
     that's already showing one column at a time) */
  .project-header { padding: 14px 22px; flex-wrap: wrap; }
  .project-header .title { font-size: 18px; }
  .project-body { grid-template-columns: 1fr; }
  .project-side {
    order: -1;
    border-left: none;
    border-bottom: var(--line);
    padding: 22px;
  }
  .project-images { padding: 22px; gap: 14px; }
  .project-description { position: static; top: auto; }

  /* archive page collapses to single column too */
  .archive-row { grid-template-columns: 1fr; }
  .archive-side {
    border-bottom: var(--line);
    padding: 18px 22px;
    position: static;
  }
  .archive-list {
    padding: 14px 22px 22px 22px;
    border-left: none;
  }
  .archive-item .archive-title { font-size: 16px; }
  .archive-item .archive-date { font-size: 14px; }

  /* about page: image above bio on small screens */
  .about-row {
    grid-template-columns: 1fr;
    gap: 24px;
    padding: 22px;
  }
  .about-content { font-size: 15px; }
  .about-content .arabic { font-size: 18px; }
}

/* ---------- very narrow (≤420px) ---------- */
@media (max-width: 420px) {
  .masthead .brand { font-size: 26px; }
  .featured-head .title,
  .card-head .title { font-size: 15px; }
  .tag { font-size: 10px; padding: 3px 8px; }
  .date { font-size: 12px; }
}
