/* ------------------------------------------------------------------
   Muneeb Almoliky — portfolio
   Hand-written CSS. No framework, no reset beyond the few lines below.
   Palette: warm paper, near-black ink, one oxide-red accent.
   ------------------------------------------------------------------ */

:root {
  --paper:  #f4f0e6;
  --ink:    #1b1712;
  --soft:   #5c554a;             /* secondary text */
  --hair:   rgba(27, 23, 18, .18); /* hairline rules */
  --hair-soft: rgba(27, 23, 18, .08);
  --accent: #a03d22;             /* oxide red */
  --status: #2b7a4b;             /* available green */
  --serif:  "Newsreader", Georgia, "Times New Roman", serif;
  --mono:   "IBM Plex Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  --measure: 34em;
}

/* Dark: same paper-and-ink idea, lights off. Follows the system unless
   the masthead toggle has set an explicit choice. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper:  #191511;
    --ink:    #e9e2d2;
    --soft:   #a49a89;
    --hair:   rgba(233, 226, 210, .2);
    --hair-soft: rgba(233, 226, 210, .1);
    --accent: #c96f4e;
    --status: #48b870;
  }
}

:root[data-theme="dark"] {
  --paper:  #191511;
  --ink:    #e9e2d2;
  --soft:   #a49a89;
  --hair:   rgba(233, 226, 210, .2);
  --hair-soft: rgba(233, 226, 210, .1);
  --accent: #c96f4e;
  --status: #48b870;
}

* { box-sizing: border-box; margin: 0; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  padding: 0 clamp(1.25rem, 4vw, 3rem);
  transition: background-color .25s ease, color .25s ease;
}

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

main, .masthead, .colophon {
  max-width: 68rem;
  margin-inline: auto;
}

/* ---- type utilities ---------------------------------------------- */

.mono, .mono-label { font-family: var(--mono); }

.mono-label {
  font-size: .6875rem;           /* 11px */
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--soft);
}

sup { font-size: .65em; color: var(--accent); }

/* ---- links -------------------------------------------------------- */

a {
  color: inherit;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-decoration-color: var(--hair);
  text-underline-offset: .2em;
  transition: color .15s ease, text-decoration-color .15s ease;
}

a:hover { color: var(--accent); text-decoration-color: var(--accent); }

.arrow {
  display: inline-block;
  font-size: .55em;
  vertical-align: .55em;
  margin-left: .35em;
  color: var(--accent);
  transition: transform .2s ease;
}

h2 a:hover .arrow { transform: translate(2px, -2px); }

/* ---- masthead / colophon ------------------------------------------ */

.masthead {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--paper);
  border-bottom: 1px solid var(--hair);
  padding: 1.1rem 0;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 1rem;
}

.masthead-name {
  grid-column: 1;
  text-decoration: none;
  justify-self: start;
  white-space: nowrap;
}

.masthead-time,
.masthead-nav,
.mobile-nav-btn {
  grid-column: 2;
  justify-self: center;
}

.masthead-nav {
  display: none;
  align-items: center;
  gap: 1.25rem;
}

.masthead.is-scrolled .masthead-time { display: none; }
.masthead.is-scrolled .masthead-nav { display: flex; }

.masthead-nav a {
  text-decoration: none;
  color: var(--soft);
  font-size: .6875rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  transition: color .15s ease;
  white-space: nowrap;
}

.masthead-nav a span:first-child {
  color: var(--accent);
  margin-right: .35em;
}

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

.masthead-nav a[aria-current="true"] {
  color: var(--ink);
}

.masthead-nav a[aria-current="true"] .nav-text {
  border-bottom: 1px solid var(--accent);
}

.masthead-right {
  grid-column: 3;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  justify-self: end;
  white-space: nowrap;
}

/* Anchors land clear of the sticky masthead. */
.section, .intro { scroll-margin-top: 3.75rem; }

.colophon {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1.1rem 0;
  border-top: 1px solid var(--hair);
  margin-top: 6rem;
}

.masthead > :first-child { color: var(--ink); }

.theme-toggle {
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

.theme-toggle:hover { color: var(--accent); }

.masthead-status::before {
  content: "";
  display: inline-block;
  width: .5em; height: .5em;
  background: var(--status);
  border-radius: 50%;
  margin-right: .55em;
  animation: pulse 2.5s infinite ease-in-out;
}

/* ---- intro --------------------------------------------------------- */

.intro { padding: clamp(4rem, 10vw, 7.5rem) 0 clamp(3rem, 7vw, 5rem); }

h1 {
  font-weight: 300;
  font-size: clamp(2.6rem, 7.5vw, 5.75rem);
  line-height: 1.04;
  letter-spacing: -.015em;
}

h1 em {
  font-style: italic;
  color: var(--accent);
}

.intro-cols {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(14rem, 1fr);
  gap: clamp(2rem, 6vw, 6rem);
  margin-top: clamp(2.5rem, 5vw, 4rem);
  align-items: start;
}

.intro-lede {
  font-size: clamp(1.15rem, 2vw, 1.35rem);
  line-height: 1.5;
  max-width: var(--measure);
}

.intro-lede + .intro-lede {
  margin-top: 1.15rem;
}

.intro-index { display: flex; flex-direction: column; }

.intro-index a {
  font-size: .8125rem;
  padding: .65rem 0;
  border-top: 1px solid var(--hair);
  text-decoration: none;
}

.intro-index a:last-child { border-bottom: 1px solid var(--hair); }

.intro-index span { color: var(--accent); margin-right: .75em; }

/* ---- sections ------------------------------------------------------ */

.section { border-top: 1px solid var(--ink); padding: 1rem 0 3.5rem; }

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 3rem;
}

.section-head .mono-label:first-child { color: var(--ink); }

/* ---- projects ------------------------------------------------------ */

.project {
  display: grid;
  grid-template-columns: 6rem minmax(0, 1fr);
  gap: 1rem;
  padding: 1.75rem 0;
}

.project + .project { border-top: 1px solid var(--hair); }

.project-no {
  font-style: italic;
  font-size: 1.5rem;
  font-weight: 300;
  color: var(--accent);
  line-height: 1.2;
}

.project h2 {
  font-weight: 400;
  font-size: clamp(1.5rem, 3vw, 2rem);
  line-height: 1.15;
  margin-bottom: .7rem;
}

.project h2 a { text-decoration: none; }

.project p { max-width: var(--measure); }

.project-meta {
  margin-top: .8rem;
  font-size: .75rem;
  color: var(--soft);
}

.project-links {
  margin-top: .45rem;
  font-size: .75rem;
}

.project-links a { color: var(--accent); }

.also {
  border-top: 1px solid var(--hair);
  padding-top: 1.75rem;
  color: var(--soft);
  font-style: italic;
  max-width: 44em;
}

.also a { color: var(--ink); font-style: normal; }

/* One line per repo: name, then what it is. Deliberately not a project
   entry — these are for skimming, not reading. */
.index-list {
  list-style: none;
  padding: 0;
  margin-top: 1rem;
  max-width: 52em;
}

.index-list li {
  display: grid;
  grid-template-columns: 15rem minmax(0, 1fr);
  gap: 1rem;
  padding: .55rem 0;
  border-top: 1px solid var(--hair-soft);
  font-size: .8125rem;
}

.index-list a { color: var(--accent); text-decoration: none; }
.index-list a:hover { text-decoration: underline; }
.index-list span { color: var(--soft); }

/* ---- below the stack ------------------------------------------------ */

.below-text {
  font-size: clamp(1.05rem, 1.6vw, 1.2rem);
  line-height: 1.6;
  max-width: 40em;
}

.below-note {
  margin-top: 2rem;
  color: var(--soft);
  font-style: italic;
  max-width: 44em;
}

/* ---- working set --------------------------------------------------- */

.tools-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(1.5rem, 4vw, 4rem);
}

.tool-col h3 { margin-bottom: 1rem; color: var(--accent); }

.tool-col ul { list-style: none; padding: 0; }

.tool-col li {
  padding: .5rem 0;
  border-top: 1px solid var(--hair-soft);
  font-size: 1.0625rem;
}

/* ---- contact ------------------------------------------------------- */

.contact-line {
  font-size: clamp(1.35rem, 3vw, 1.9rem);
  font-weight: 300;
  line-height: 1.45;
  max-width: 30em;
}

/* ---- the terminal moment --------------------------------------------
   The clock is the one place on the page already set in mono, so it is
   the one place a block cursor belongs. */

#local-time::after {
  content: "▋";
  margin-left: .15em;
}

/* ---- reading position ------------------------------------------------ */

.intro-index a[aria-current="true"] {
  color: var(--accent);
  padding-left: .5rem;
}

/* ---- motion ----------------------------------------------------------
   The page sets itself like a printed sheet: each rule draws left to
   right, then the type settles onto it. Everything here is opt-out —
   ask for reduced motion and you get the finished page, immediately.

   The reveal list below is mirrored in index.html (REVEAL); keep them
   in step. Hidden states live under .js so the page is readable with
   scripting off, and .js is set in <head> so nothing flashes first.
   --------------------------------------------------------------------- */

@media (prefers-reduced-motion: no-preference) {

  html { scroll-behavior: smooth; }

  .masthead-status::before { animation: pulse 2.6s ease-in-out infinite; }
  #local-time::after { animation: caret 1.2s step-end infinite; }

  .intro-index a { transition: color .2s ease, padding-left .2s ease; }

  .project-no { transition: transform .3s cubic-bezier(.22,.61,.36,1); }
  .project:hover .project-no { transform: translateX(3px); }

  /* Rules draw. */
  .js .section { position: relative; border-top-color: transparent; }

  .js .section::before {
    content: "";
    position: absolute;
    top: -1px; left: 0;
    width: 100%; height: 1px;
    background: var(--ink);
    transform: scaleX(0);
    transform-origin: left center;
    transition: transform .75s cubic-bezier(.22,.61,.36,1);
  }

  .js .section.is-in::before { transform: scaleX(1); }

  /* Type settles. */
  /* :where() keeps this at .js — one class — so .js .is-in below always
     outranks it. Without that, any selector here carrying an element
     (.intro-index a) would win and the element would never appear. */
  .js :where(
    .h1-line, .intro-lede, .intro-index a, .section-head, .project,
    .also, .index-list, .below-text, .below-note, .tool-col, .contact-line
  ) {
    opacity: 0;
    transform: translateY(8px);
  }

  .js .is-in {
    opacity: 1;
    transform: none;
    transition:
      opacity .6s ease var(--d, 0ms),
      transform .6s cubic-bezier(.22,.61,.36,1) var(--d, 0ms);
  }

  /* The two headline lines land one after the other. */
  .js em.h1-line { --d: 130ms; }

  /* The index writes itself down the column. */
  .js .intro-index a:nth-child(2) { --d: 60ms; }
  .js .intro-index a:nth-child(3) { --d: 120ms; }
  .js .intro-index a:nth-child(4) { --d: 180ms; }
  .js .intro-index a:nth-child(5) { --d: 240ms; }

  /* Stack columns arrive left to right. */
  .js .tool-col:nth-child(2) { --d: 90ms; }
  .js .tool-col:nth-child(3) { --d: 180ms; }
}

@keyframes caret { 0%, 100% { opacity: 1 } 50% { opacity: 0 } }
@keyframes pulse { 0%, 100% { opacity: 1 } 50% { opacity: .35 } }

/* ---- mobile navigation menu --------------------------------------- */

.mobile-nav-btn {
  display: none;
  background: none;
  border: 1px solid var(--hair);
  border-radius: 2px;
  padding: .25rem .5rem;
  line-height: 1.25;
  color: var(--ink);
  font-family: var(--mono);
  font-size: .6875rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: border-color .15s ease, color .15s ease;
}

.mobile-nav-btn .arrow-down {
  font-size: .75em;
  margin-left: .25em;
  color: var(--accent);
  transition: transform .2s ease;
}

.mobile-nav-btn[aria-expanded="true"] {
  border-color: var(--accent);
}

.mobile-nav-btn[aria-expanded="true"] .arrow-down {
  transform: rotate(180deg);
}

.mobile-nav-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--paper);
  border-bottom: 1px solid var(--hair);
  box-shadow: 0 12px 28px rgba(0,0,0,.08);
  flex-direction: column;
}

.mobile-nav-menu.is-open {
  display: flex;
}

.mobile-nav-menu a {
  padding: .85rem clamp(1.25rem, 4vw, 3rem);
  font-size: .8125rem;
  text-decoration: none;
  color: var(--ink);
  border-top: 1px solid var(--hair-soft);
  display: flex;
  align-items: center;
  transition: background-color .15s ease, color .15s ease;
}

.mobile-nav-menu a:first-child { border-top: 0; }

.mobile-nav-menu a span {
  color: var(--accent);
  margin-right: .75em;
  font-weight: 500;
}

.mobile-nav-menu a[aria-current="true"] {
  background: var(--hair-soft);
  color: var(--accent);
}

/* ---- small screens -------------------------------------------------- */

@media (max-width: 960px) {
  .masthead-time,
  .masthead-status { display: none; }
  .masthead-nav { gap: .85rem; }
}

@media (max-width: 720px) {
  .masthead {
    margin-inline: calc(-1 * clamp(1.25rem, 4vw, 3rem));
    padding-inline: clamp(1.25rem, 4vw, 3rem);
    padding-block: 0;
    height: 3.25rem;
    gap: .5rem;
  }

  .masthead-status,
  .masthead-time { display: none; }

  /* On mobile, completely hide desktop nav and rely on the active section pill */
  .masthead-nav { display: none !important; }

  .masthead.is-scrolled .mobile-nav-btn {
    display: inline-flex;
    align-items: center;
  }

  .intro-cols { grid-template-columns: 1fr; }

  .project { grid-template-columns: 1fr; gap: .25rem; }
  .project-no { font-size: 1.15rem; }

  .tools-grid { grid-template-columns: 1fr; gap: 1.5rem; }

  .index-list li { grid-template-columns: 1fr; gap: .15rem; }
}
