/* Layout: Apple "guidelines" document — grey hero band, then a sticky
   numbered sidebar beside one reading column. One text style everywhere. */

@font-face { font-family: "SF Pro Display"; src: url("assets/fonts/SFPRODISPLAYREGULAR.OTF") format("opentype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "SF Pro Display"; src: url("assets/fonts/SFPRODISPLAYMEDIUM.OTF") format("opentype"); font-weight: 500; font-display: swap; }
@font-face { font-family: "SF Pro Display"; src: url("assets/fonts/SFPRODISPLAYBOLD.OTF") format("opentype"); font-weight: 600 700; font-display: swap; }

:root {
  --bg: #ffffff;
  --band: #f1f1f1;
  --fg: #000000;
  --line: #d2d2d7;
  --link: #0066cc;
  --pill: #0071e3;
  --pill-fg: #ffffff;
  --side-bg: rgba(255, 255, 255, 0.9);
  --field: #ffffff;
  --mark: rgba(0, 113, 227, 0.08);
  --font: "SF Pro Display", -apple-system, BlinkMacSystemFont, "SF Pro Text", sans-serif;
  --gap: 24px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000000; --band: #141414; --fg: #f5f5f7; --line: #424245; --link: #2997ff;
    --pill: #0071e3; --pill-fg: #ffffff; --side-bg: rgba(0, 0, 0, 0.9); --field: #1d1d1f; --mark: rgba(41, 151, 255, 0.12);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #000000; --band: #141414; --fg: #f5f5f7; --line: #424245; --link: #2997ff;
  --pill: #0071e3; --pill-fg: #ffffff; --side-bg: rgba(0, 0, 0, 0.9); --field: #1d1d1f; --mark: rgba(41, 151, 255, 0.12);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } *, *::before, *::after { transition: none !important; } }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: 18px;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--fg); text-decoration: underline; text-underline-offset: 2px; }
a:hover { color: inherit; text-decoration: underline; }
:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; border-radius: 4px; }

.wrap {
  max-width: calc(990px + 2 * max(16px, env(safe-area-inset-left, 0px)));
  margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}

/* ---------- Hero ---------- */
/* hero stays pinned; the content scrolls up over it */
.hero { background: var(--band); position: sticky; top: 0; z-index: 0; }
.doc, .footer { position: relative; z-index: 1; }
.doc { background: var(--bg); }
.hero .wrap { padding-block: 140px 160px;; display: grid; gap: 30px; }
.hero__title, .hero__lede { margin: 0; font-size: 48px; font-weight: 600; }


/* ---------- Document ---------- */
.doc .wrap { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 48px; padding-block: 75px 120px; }

.sidebar { position: sticky; top: calc(env(safe-area-inset-top, 0px) + 24px); align-self: start; max-height: calc(100vh - 48px); overflow-y: auto; overscroll-behavior: contain; }
.sidebar__toggle { display: none; }
.toc, .toc ul { list-style: none; margin: 0; padding: 0; }
.toc { border-left: 1px solid var(--line); }
.toc a { position: relative; display: block; padding: 3px 0 3px 16px; color: var(--fg); font-size: 16px; font-weight: 400; text-decoration: none; }
.toc a:hover { color: inherit; text-decoration: underline; }
.toc a.is-active::before { content: ""; position: absolute; left: -1px; top: 0; bottom: 0; width: 1px; background: var(--fg); }
.toc__kids { display: grid; grid-template-rows: 0fr; transition: grid-template-rows 0.35s ease; }
.toc__kids > ul { overflow: hidden; min-height: 0; margin-left: -1px; padding-left: 1px; } /* room so the active line on sub-items is not clipped */
.toc li.is-open > .toc__kids { grid-template-rows: 1fr; }
.toc__kids a { padding-left: 16px; }

.hlToggle { display: flex; align-items: center; gap: 15px; margin-top: 28px; font-size: 16px; font-weight: 400; cursor: pointer; }
.hlToggle span { max-width: 200px; }
.hlToggle input {
  appearance: none; -webkit-appearance: none; flex: none;
  width: 16px; height: 16px; margin: 0; border: 0; border-radius: 4px; cursor: pointer;
  background: url("data:image/svg+xml,%3Csvg%20width%3D%2216%22%20height%3D%2216%22%20viewBox%3D%220%200%2016%2016%22%20fill%3D%22none%22%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%3E%3Crect%20x%3D%220.47619%22%20y%3D%220.47619%22%20width%3D%2215.0476%22%20height%3D%2215.0476%22%20rx%3D%223.8676%22%20stroke%3D%22%2391918C%22%20stroke-width%3D%220.952381%22/%3E%3C/svg%3E") center / 16px 16px no-repeat;
}
.hlToggle input:checked { background-image: url("data:image/svg+xml,%3Csvg%20width%3D%2216%22%20height%3D%2216%22%20viewBox%3D%220%200%2016%2016%22%20fill%3D%22none%22%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%3E%3Crect%20x%3D%220.47619%22%20y%3D%220.47619%22%20width%3D%2215.0476%22%20height%3D%2215.0476%22%20rx%3D%223.8676%22%20fill%3D%22%2391918C%22%20stroke%3D%22%2391918C%22%20stroke-width%3D%220.952381%22/%3E%3Cpath%20d%3D%22M7.04036%2012.4501C6.69025%2012.4501%206.4022%2012.318%206.17622%2012.0538L3.71745%209.15582C3.60923%209.03805%203.53443%208.92506%203.49306%208.81684C3.45486%208.70544%203.43576%208.58767%203.43576%208.46354C3.43576%208.18981%203.52807%207.96224%203.71267%207.78082C3.89728%207.59939%204.13122%207.50868%204.4145%207.50868C4.71687%207.50868%204.96832%207.62486%205.16884%207.8572L7.02127%2010.0773L10.7214%204.26693C10.8391%204.0855%2010.9633%203.95819%2011.0938%203.88498C11.2274%203.80859%2011.3898%203.7704%2011.5807%203.7704C11.8576%203.7704%2012.09%203.86111%2012.2778%204.04253C12.4687%204.22078%2012.5642%204.44676%2012.5642%204.72049C12.5642%204.81916%2012.5467%204.9226%2012.5117%205.03082C12.4767%205.13585%2012.4226%205.24248%2012.3494%205.35069L7.94271%2011.9918C7.739%2012.2973%207.43822%2012.4501%207.04036%2012.4501Z%22%20fill%3D%22black%22/%3E%3C/svg%3E"); }
.hlToggle input:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }

/* ---------- Reading column: one text style ---------- */
.content { min-width: 0; max-width: 700px; }
.chapter { padding-bottom: 30px; }
.chapter + .chapter { border-top: 1px solid var(--line); padding-top: 30px; }
.chapter, .sub { scroll-margin-top: calc(env(safe-area-inset-top, 0px) + 24px); }
.content h2 { margin: 0 0 25px; font-size: 32px; font-weight: 600; }
.content h3 { margin: 0; font-size: 18px; font-weight: 600; }
.content h4 { margin: 0 0 12px; font-size: 18px; font-weight: 600; }
.content p,
.content ul { margin: 0 0 0.7em; font-size: 18px; font-weight: 400; }
.content li { margin: 0 0 6px; font-size: 18px; font-weight: 400; }
.content ul { padding-left: 24px; }
.content li:last-child { margin-bottom: 0; }

/* Apple-style numbered sub-sections: 1.1 heading, then 1.1.1 items */
.sub { padding: 8px 0 0 20px; transition: opacity 0.25s ease; }
.sub > ul { list-style: none; padding-left: 20px; }
.sub > ul > li { margin-bottom: 12px; }
.sub > ul > li:last-child { margin-bottom: 0; }
.num { font-weight: 600; }

/* highlight recent work only: only Work and Projects can stay bright */
body.hl-recent .content .chapter:not(#work):not(#projects),
body.hl-recent #work > p,
body.hl-recent #projects > p,
body.hl-recent #work .sub:not([data-recent]),
body.hl-recent #projects .sub:not([data-recent]) { opacity: 0.3; }

/* footer */
.footer { background: var(--band); font-size: 14px; }
.footer .wrap { padding-block: 20px; display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px 24px; }
.footer__controls { display: flex; flex-wrap: wrap; gap: 8px 28px; }
.switch { display: flex; gap: 14px; }
.switch button { font: inherit; font-size: 14px; color: var(--fg); background: none; border: 0; padding: 0; cursor: pointer; opacity: 0.6; }
.switch button:hover { text-decoration: underline; }
.switch button[aria-pressed="true"] { opacity: 1; }

/* ---------- Narrow screens: sidebar becomes an "On this page" bar ---------- */
@media (max-width: 834px) {
  .hero .wrap { padding-block: 64px 80px; gap: 20px; }
    .hero__title, .hero__lede { font-size: clamp(30px, 7.5vw, 48px); }
  .doc .wrap { grid-template-columns: minmax(0, 1fr); gap: 0; padding-block: 0 80px; }
  .sidebar {
    top: env(safe-area-inset-top, 0px); z-index: 40; max-height: none; overflow: visible;
    margin: 0 calc(-1 * max(16px, env(safe-area-inset-left, 0px))) 32px;
    padding: 0 max(16px, env(safe-area-inset-left, 0px));
    background: var(--side-bg); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--line);
  }
  .sidebar__toggle { display: flex; width: 100%; align-items: center; justify-content: space-between; gap: 12px; font: inherit; font-size: 15px; color: var(--fg); background: none; border: 0; padding: 12px 0; cursor: pointer; text-align: left; }
  .sidebar__toggle small { display: block; font-size: 12px; opacity: 0.7; }
  .sidebar__toggle .chev { transition: transform 0.25s ease; flex: none; }
  .sidebar.is-expanded .sidebar__toggle .chev { transform: rotate(180deg); }
  .sidebar__panel { display: none; padding: 4px 0 18px; max-height: 65vh; overflow-y: auto; }
  .sidebar.is-expanded .sidebar__panel { display: block; }
  .chapter, .sub { scroll-margin-top: calc(env(safe-area-inset-top, 0px) + 72px); }
}
@media (max-width: 560px) {
  .sub { padding-left: 12px; }
  .sub > ul { padding-left: 12px; }
  .form { grid-template-columns: 1fr; }
}
.sub > ul + h4 { margin-top: var(--gap); }


/* skills: label on its own line, tools indented below */
#skills ul { list-style: none; padding-left: 0; }
#skills li { display: grid; grid-template-columns: 250px minmax(0, 1fr); column-gap: 24px; margin-bottom: 14px; }
#skills li { font-size: 18px; font-weight: 600; }
#skills li .tools { display: block; font-weight: 400; }
@media (max-width: 560px) {
  #skills li { grid-template-columns: minmax(0, 1fr); row-gap: 2px; }
}

/* smaller bullet dots, like Apple’s lists */
.content li::marker { font-size: 0.7em; }

/* two lines of space before "Last Updated" */
#contact > p:last-child { margin-top: 2em; }

/* apps listed inside 3.5 App Store (not separate sidebar items) */
.app { padding-top: 16px; }
.app h4 { margin: 0 0 8px; }

/* hero: once you start scrolling, the title swaps to "Kenan Musali’s Portfolio" and the lede hides (keeps its space) */
.hero__title { transition: opacity 0.2s ease, transform 0.2s ease; }
.hero__title.is-swapping { opacity: 0; transform: translateY(-10px); }
.hero__lede { transition: opacity 0.35s ease; }
.hero__lede.is-hidden { opacity: 0; }