/* ============================================================
   Borna Safai — Portfolio
   Multi-file static site · theme-aware · no build step
   ============================================================ */

:root {
  --bg:        #f7f8fb;
  --bg-elev:   #ffffff;
  --bg-sunken: #eef1f6;
  --text:      #1a2230;
  --text-soft: #55607a;
  --text-mute: #8791a6;
  --border:    #e2e6ef;
  --border-strong: #d3d9e6;
  --brand:     #3d5a99;
  --brand-2:   #6a8fd8;
  --accent:    #c76b4a;
  --shadow:    0 1px 2px rgba(20,30,55,.04), 0 12px 30px -12px rgba(20,30,55,.14);
  --shadow-lg: 0 30px 60px -22px rgba(20,30,55,.30);
  --radius:    16px;
  --radius-sm: 9px;
  --maxw:      1080px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, "Georgia", serif;
}

:root[data-theme="dark"] {
  --bg:        #0e1220;
  --bg-elev:   #171d2e;
  --bg-sunken: #101524;
  --text:      #eef1f8;
  --text-soft: #a9b3c9;
  --text-mute: #6f7a92;
  --border:    #263148;
  --border-strong: #33405c;
  --brand:     #7ba0e6;
  --brand-2:   #9db9f0;
  --accent:    #e08a68;
  --shadow:    0 1px 2px rgba(0,0,0,.3), 0 14px 34px -14px rgba(0,0,0,.55);
  --shadow-lg: 0 34px 70px -24px rgba(0,0,0,.7);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:        #0e1220;
    --bg-elev:   #171d2e;
    --bg-sunken: #101524;
    --text:      #eef1f8;
    --text-soft: #a9b3c9;
    --text-mute: #6f7a92;
    --border:    #263148;
    --border-strong: #33405c;
    --brand:     #7ba0e6;
    --brand-2:   #9db9f0;
    --accent:    #e08a68;
    --shadow:    0 1px 2px rgba(0,0,0,.3), 0 14px 34px -14px rgba(0,0,0,.55);
    --shadow-lg: 0 34px 70px -24px rgba(0,0,0,.7);
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
code {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: .86em;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  padding: .08em .4em;
  border-radius: 5px;
}

.skip-link {
  position: absolute; left: -999px; top: 0;
  background: var(--brand); color: #fff; padding: .6rem 1rem; border-radius: 0 0 8px 0; z-index: 100;
}
.skip-link:focus { left: 0; }

/* ---------- NAV ---------- */
.nav {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color .25s, background .25s;
}
.nav.is-scrolled { border-bottom-color: var(--border); }
.nav__inner {
  max-width: var(--maxw); margin: 0 auto; padding: .85rem 1.5rem;
  display: flex; align-items: center; gap: 1rem;
}
.nav__brand { font-weight: 700; letter-spacing: -.01em; color: var(--text); font-size: 1.05rem; }
.nav__brand:hover { text-decoration: none; color: var(--brand); }
.nav__links { margin-left: auto; display: flex; gap: 1.6rem; }
.nav__links a { color: var(--text-soft); font-size: .93rem; font-weight: 500; }
.nav__links a:hover { color: var(--text); text-decoration: none; }
@media (max-width: 560px) { .nav__links { display: none; } }

.theme-toggle {
  width: 38px; height: 38px; border-radius: 50%;
  border: 1px solid var(--border-strong); background: var(--bg-elev);
  cursor: pointer; display: grid; place-items: center; color: var(--text-soft);
  transition: transform .2s, border-color .2s, color .2s;
}
.theme-toggle:hover { transform: rotate(20deg); border-color: var(--brand); color: var(--brand); }
.theme-toggle__icon { width: 18px; height: 18px; display: block; }
.theme-toggle__icon::before { content: "🌙"; font-size: 16px; line-height: 1; }
:root[data-theme="dark"] .theme-toggle__icon::before { content: "☀️"; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle__icon::before { content: "☀️"; }
}

/* ---------- HERO ---------- */
.hero { position: relative; padding: clamp(4rem, 12vw, 8rem) 1.5rem clamp(3rem, 7vw, 5rem); overflow: hidden; }
.hero::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background:
    radial-gradient(60% 55% at 78% 8%, color-mix(in srgb, var(--brand-2) 22%, transparent), transparent 70%),
    radial-gradient(50% 50% at 12% 30%, color-mix(in srgb, var(--accent) 12%, transparent), transparent 70%);
}
.hero__inner { max-width: var(--maxw); margin: 0 auto; }
.hero__eyebrow {
  margin: 0 0 1.1rem; font-size: .82rem; font-weight: 600; letter-spacing: .08em;
  text-transform: uppercase; color: var(--brand);
}
.hero__title {
  font-family: var(--font-display);
  font-size: clamp(2.1rem, 6vw, 4rem); line-height: 1.08; letter-spacing: -.02em;
  margin: 0 0 1.4rem; font-weight: 600;
}
.grad {
  background: linear-gradient(100deg, var(--brand), var(--brand-2) 60%, var(--accent));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero__lead { max-width: 60ch; font-size: clamp(1.05rem, 2.2vw, 1.28rem); color: var(--text-soft); margin: 0 0 2rem; }
.hero__cta { display: flex; flex-wrap: wrap; gap: .8rem; margin-bottom: 1.8rem; }
.hero__meta { display: flex; flex-wrap: wrap; gap: .7rem; align-items: center; color: var(--text-mute); font-size: .92rem; }
.hero__meta a { color: var(--text-soft); font-weight: 500; }

/* ---------- BUTTONS ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: .72rem 1.35rem; border-radius: 999px; font-weight: 600; font-size: .96rem;
  border: 1px solid transparent; cursor: pointer; transition: transform .15s, box-shadow .2s, background .2s, border-color .2s;
}
.btn:hover { text-decoration: none; transform: translateY(-2px); }
.btn--primary { background: var(--brand); color: #fff; box-shadow: 0 10px 24px -10px color-mix(in srgb, var(--brand) 70%, transparent); }
.btn--primary:hover { box-shadow: 0 16px 30px -12px color-mix(in srgb, var(--brand) 75%, transparent); }
.btn--ghost { background: var(--bg-elev); color: var(--text); border-color: var(--border-strong); }
.btn--ghost:hover { border-color: var(--brand); color: var(--brand); }

/* ---------- SECTIONS ---------- */
section { scroll-margin-top: 72px; }
.section__head { max-width: var(--maxw); margin: 0 auto clamp(2rem, 5vw, 3rem); padding: 0 1.5rem; }
.section__kicker {
  display: inline-block; font-size: .78rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--accent); margin-bottom: .6rem;
}
.section__title { font-family: var(--font-display); font-size: clamp(1.7rem, 4vw, 2.6rem); letter-spacing: -.02em; margin: 0; font-weight: 600; }
.section__sub { color: var(--text-soft); margin: .7rem 0 0; font-size: 1.05rem; }

/* ---------- ABOUT ---------- */
.about { max-width: var(--maxw); margin: 0 auto; padding: clamp(3rem, 7vw, 5rem) 1.5rem; }
.about__grid { display: grid; grid-template-columns: 1.3fr 1fr; gap: clamp(1.5rem, 4vw, 3.5rem); align-items: start; }
.about__lede { font-size: 1.14rem; color: var(--text-soft); margin: 0; }
.stats { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.stats li { background: var(--bg-elev); padding: 1.1rem 1.2rem; display: flex; flex-direction: column; gap: .15rem; }
.stats strong { font-family: var(--font-display); font-size: 1.7rem; color: var(--brand); line-height: 1; }
.stats span { font-size: .84rem; color: var(--text-mute); }
.chips { list-style: none; display: flex; flex-wrap: wrap; gap: .5rem; padding: 0; margin: 2.4rem 0 0; }
.chips li {
  font-size: .85rem; color: var(--text-soft); background: var(--bg-elev);
  border: 1px solid var(--border); padding: .35rem .85rem; border-radius: 999px;
}
@media (max-width: 720px) { .about__grid { grid-template-columns: 1fr; } }

/* ---------- PROJECTS ---------- */
.projects { padding: clamp(2rem, 5vw, 3rem) 0 clamp(3rem, 7vw, 5rem); }
.project {
  max-width: var(--maxw); margin: 0 auto clamp(2.2rem, 5vw, 3.5rem); padding: 0 1.5rem;
  display: grid; grid-template-columns: 1.05fr .95fr; gap: clamp(1.5rem, 4vw, 3rem); align-items: center;
}
.project--reverse .project__media { order: 2; }
@media (max-width: 780px) {
  .project { grid-template-columns: 1fr; gap: 1.4rem; }
  .project--reverse .project__media { order: 0; }
}

.project__media {
  border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border);
  background: var(--bg-sunken); box-shadow: var(--shadow);
  transition: transform .35s cubic-bezier(.2,.7,.2,1), box-shadow .35s;
}
.project__media img { width: 100%; height: auto; }
.project:hover .project__media { transform: translateY(-4px); box-shadow: var(--shadow-lg); }

/* app screenshots: phones on a tinted stage */
.project__media--phones {
  background: linear-gradient(150deg, color-mix(in srgb, var(--brand) 16%, var(--bg-sunken)), var(--bg-sunken));
  display: flex; justify-content: center; align-items: flex-end; gap: 0; padding: 2rem 1.5rem 0; min-height: 260px;
}
.project__media--phones .phone {
  width: 46%; max-width: 210px; border-radius: 18px; border: 3px solid rgba(0,0,0,.25);
  box-shadow: 0 20px 40px -18px rgba(0,0,0,.5); transition: transform .35s;
}
.phone--back { transform: translateX(-12%) translateY(14px) rotate(4deg) scale(.9); opacity: .95; }
.phone { transform: translateX(8%) rotate(-3deg); z-index: 2; }
.project:hover .phone { transform: translateX(4%) rotate(-2deg) translateY(-6px); }
.project:hover .phone--back { transform: translateX(-14%) translateY(8px) rotate(3deg) scale(.9); }

.project__media--small { max-width: 340px; margin: 0 auto; }

.project__body { min-width: 0; }
.project__tagrow { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin-bottom: .9rem; }
.tag {
  font-size: .74rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  padding: .28rem .6rem; border-radius: 6px; border: 1px solid transparent;
}
.tag--web     { background: color-mix(in srgb, var(--brand) 15%, transparent); color: var(--brand); }
.tag--android { background: color-mix(in srgb, #3ddc84 22%, transparent); color: #1a8f52; }
:root[data-theme="dark"] .tag--android { color: #6ee7a8; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .tag--android { color: #6ee7a8; } }
.tag--ext     { background: color-mix(in srgb, var(--accent) 20%, transparent); color: var(--accent); }
.project__year { font-size: .82rem; color: var(--text-mute); font-weight: 500; }

.project__title { font-family: var(--font-display); font-size: clamp(1.4rem, 3vw, 1.9rem); letter-spacing: -.01em; margin: 0 0 .6rem; font-weight: 600; }
.project__desc { color: var(--text-soft); margin: 0 0 1.1rem; }
.project__note {
  position: relative; background: var(--bg-elev); border: 1px solid var(--border);
  border-left: 3px solid var(--accent); border-radius: var(--radius-sm);
  padding: .9rem 1.1rem; margin: 0 0 1.2rem; font-size: .94rem; color: var(--text-soft);
}
.project__note-label { display: block; font-size: .72rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--accent); margin-bottom: .3rem; }
.project__stack { list-style: none; display: flex; flex-wrap: wrap; gap: .45rem; padding: 0; margin: 0 0 1.2rem; }
.project__stack li { font-size: .8rem; color: var(--text-mute); background: var(--bg-sunken); border: 1px solid var(--border); padding: .25rem .6rem; border-radius: 6px; }
.project__links { display: flex; gap: .8rem; flex-wrap: wrap; }
.link-btn {
  font-weight: 600; font-size: .9rem; color: var(--text); background: var(--bg-elev);
  border: 1px solid var(--border-strong); padding: .5rem 1rem; border-radius: 8px; transition: border-color .2s, color .2s, transform .15s;
}
.link-btn:hover { border-color: var(--brand); color: var(--brand); text-decoration: none; transform: translateY(-2px); }

/* ---------- CONTACT ---------- */
.contact { padding: clamp(3rem, 8vw, 6rem) 1.5rem; }
.contact__inner {
  max-width: 760px; margin: 0 auto; text-align: center;
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 6px); padding: clamp(2.2rem, 6vw, 4rem) 1.5rem;
  box-shadow: var(--shadow);
  background-image: radial-gradient(70% 120% at 50% 0%, color-mix(in srgb, var(--brand-2) 12%, transparent), transparent 60%);
}
.contact__lead { color: var(--text-soft); font-size: 1.1rem; max-width: 46ch; margin: .8rem auto 1.8rem; }
.contact__links { display: flex; gap: .8rem; justify-content: center; flex-wrap: wrap; }

/* ---------- FOOTER ---------- */
.footer { text-align: center; padding: 2.5rem 1.5rem; color: var(--text-mute); font-size: .88rem; border-top: 1px solid var(--border); }

/* ---------- REVEAL ANIMATION ---------- */
.reveal { opacity: 0; transform: translateY(22px); transition: opacity .7s ease, transform .7s cubic-bezier(.2,.7,.2,1); }
.reveal.is-visible { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) { .reveal { opacity: 1; transform: none; transition: none; } }
